Projet

Général

Profil

Paste
Télécharger (1,99 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / imce_mkdir / imce_mkdir.module @ 87dbc3bf

1
<?php
2

    
3
/**
4
 * Implements hook_form_formID_alter().
5
 */
6
function imce_mkdir_form_imce_profile_form_alter(&$form, &$form_state) {
7
  include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'imce_mkdir') . '/imce_mkdir.inc';
8
  return _imce_mkdir_form_imce_profile_form_alter($form, $form_state);
9
}
10

    
11
/**
12
 * Custom profile process. Redefines mkdir permission based on some other parameters.
13
 */
14
function imce_mkdir_process_profile(&$imce) {
15
  if (!$imce['error']) {
16
    $imce['mkdirnum'] = (int) $imce['mkdirnum'];
17
    $imce['perm']['mkdir'] = $imce['perm']['mkdir'] && (!$imce['mkdirnum'] || ($imce['direct'] && $imce['mkdirnum'] > count($imce['subdirectories'])));
18
    $imce['perm']['rmdir'] = $imce['perm']['rmdir'] && (!$imce['mkdirnum'] || $imce['direct']);
19
  }
20
}
21

    
22
/**
23
 * Custom content. Returns directory creation form
24
 */
25
function imce_mkdir_content(&$imce) {
26
  if (!$imce['error'] && (imce_perm_exists($imce, 'mkdir') || imce_perm_exists($imce, 'rmdir'))) {
27
    $path = drupal_get_path('module', 'imce_mkdir');
28
    drupal_add_js($path . '/imce_mkdir.js');
29
    drupal_add_css($path . '/imce_mkdir.css');
30
    $form = drupal_get_form('imce_mkdir_form', array('imce' => &$imce));
31
    return drupal_render($form);
32
  }
33
}
34

    
35
/**
36
 * Mkdir form.
37
 */
38
function imce_mkdir_form($form, &$form_state, $ref) {
39
  $imce =& $ref['imce'];
40
  include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'imce_mkdir') . '/imce_mkdir.inc';
41
  return _imce_mkdir_form($form, $form_state, $imce);
42
}
43

    
44
/**
45
 * Ajax operation: mkdir
46
 */
47
function imce_js_mkdir(&$imce) {
48
  if ($imce['perm']['mkdir']) {
49
    $_POST['op'] = t('Add');
50
    drupal_get_form('imce_mkdir_form', array('imce' => &$imce));
51
    return array('diradded' => array_map('rawurlencode', $imce['diradded']));
52
  }
53
}
54

    
55
/**
56
 * Ajax operation: rmdir
57
 */
58
function imce_js_rmdir(&$imce) {
59
  if ($imce['perm']['rmdir']) {
60
    $_POST['op'] = t('Remove');
61
    drupal_get_form('imce_mkdir_form', array('imce' => &$imce));
62
    return array('dirremoved' => array_map('rawurlencode', $imce['dirremoved']));
63
  }
64
}