Projet

Général

Profil

Paste
Télécharger (4,68 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ldap / ldap_help / ldap_help.module @ bc175c27

1
<?php
2

    
3
/**
4
 * @file
5
 * The ldaphelp module is a module to help admins debug ldap_integration modules.
6
 *
7
 */
8

    
9
/**
10
 * Implements hook_menu().
11
 */
12
function ldap_help_menu() {
13
  $items = array();
14
  $items['admin/config/people/ldap/help'] = array(
15
    'title' => 'Help',
16
    'type' => MENU_LOCAL_TASK,
17
    'weight' => 9,
18
    'description' => 'Debugging and Configuration Help with LDAP',
19
    'file' => 'ldap_help.resources.inc',
20
    'page callback' => 'ldap_help_main',
21
    'access arguments' => array('administer site configuration'),
22
  );
23

    
24
  $items['admin/config/people/ldap/help/intro'] = array(
25
    'title' => 'Resources',
26
    'type' => MENU_DEFAULT_LOCAL_TASK,
27
  );
28

    
29
  $items['admin/config/people/ldap/help/status'] = array(
30
    'title' => 'Status',
31
    'description' => 'LDAP status page',
32
    'page callback' => 'ldap_help_status',
33
    'access arguments' => array('administer site configuration'),
34
    'file' => 'ldap_help.status.inc',
35
    'type' => MENU_LOCAL_TASK,
36
    'weight' => 4,
37
  );
38

    
39
  $items['admin/config/people/ldap/help/watchdog'] = array(
40
    'title' => 'Watchdog',
41
    'description' => 'LDAP watchdog logs',
42
    'page callback' => 'ldap_help_watchdog',
43
    'access arguments' => array('administer site configuration'),
44
    'file' => 'ldap_help.watchdog.inc',
45
    'type' => MENU_LOCAL_TASK,
46
    'weight' => 5,
47
  );
48

    
49
  $items['admin/config/people/ldap/help/issues'] = array(
50
    'title' => 'Issue Reporting',
51
    'description' => 'Creating LDAP Issue Queue Items',
52
    'page callback' => 'ldap_help_issues',
53
    'access arguments' => array('administer site configuration'),
54
    'file' => 'ldap_help.issues.inc',
55
    'type' => MENU_LOCAL_TASK,
56
    'weight' => 7,
57
  );
58

    
59

    
60
  $items['admin/config/people/ldap/help/examples'] = array(
61
    'title' => 'Sample LDAPs',
62
    'description' => 'Sample LDAPs from Documentation',
63
    'page callback' => 'ldap_help_examples',
64
    'access arguments' => array('administer site configuration'),
65
    'file' => 'ldap_help.examples.inc',
66
    'type' => MENU_LOCAL_TASK,
67
    'weight' => 7,
68
  );
69

    
70

    
71
  return $items;
72
}
73

    
74
function ldap_help_form_ldap_servers_settings_alter(&$form, &$form_state) {
75
  $form['watchdog_detail'] = array('#type' => 'fieldset', '#title' => t('Development'));
76
  $form['watchdog_detail']['watchdog_detail'] = array(
77
    '#type' => 'checkbox',
78
    '#title' => t('Enabled Detailed LDAP Watchdog logging.  This is generally for
79
       debugging and reporting issues with the ldap modules and should not be left
80
       on.'),
81
    '#default_value' => variable_get('ldap_help_watchdog_detail', 0),
82
  );
83
 $date = variable_get('ldap_help_user_data_clear_set_date', time());
84
 $form['watchdog_detail']['user_data_clear'] = array(
85
    '#type' => 'checkbox',
86
    '#title' => t('Discard and ignore user authorization data stored by ldap module in user records data before %date.
87
      This is useful for implementers of development versions of the module
88
      that may have corrupt user data from the past.', array('%date' => date('Y-m-d H:i:s', $date))),
89
    '#default_value' => variable_get('ldap_help_user_data_clear', 0),
90
  );  //array('%date' => date('Y-m-d H:i:s', $date))
91
 $form['watchdog_detail']['user_data_clear_date'] = array(
92
    '#type' => 'checkbox',
93
    '#title' => t('Reset the clear date to the current date %date', array('%date' => date('Y-m-d H:i:s'))),
94
    '#default_value' => variable_get('ldap_help_user_data_clear_set_date', 0),
95
  );
96
  $form['#submit'][] = 'ldap_help_watchdog_detail_submit';
97
}
98

    
99

    
100
function ldap_help_watchdog_detail_submit($form, &$form_state) {
101
  if ($form_state['submitted']) {
102
    $watchdog_detail = $form_state['values']['watchdog_detail'];
103
    if ($watchdog_detail != variable_get('ldap_help_watchdog_detail', 0)) {
104
      variable_set('ldap_help_watchdog_detail', $watchdog_detail);
105
    }
106
    if ($form_state['values']['user_data_clear'] != variable_get('ldap_help_user_data_clear', 0)) {
107
      variable_set('ldap_help_user_data_clear', $form_state['values']['user_data_clear']);
108
    }
109
    if ($form_state['values']['user_data_clear_date'] != 0) {
110
      variable_set('ldap_help_user_data_clear_set_date', time());
111
    }
112
  }
113
}
114

    
115
function ldap_help_help($path, $arg) {
116

    
117
  $help = '<h3>' . t('LDAP Help Module') . '</h3><p>' .
118
  t('This module assists Drupal admins in configuring, debugging, sharing, and submitting
119
  support and bug request related to LDAP modules.') . '<strong><em> ' .
120
  t('LDAP Help Module should be disabled unless you are debugging or configuring
121
    LDAP problems.') . ' </em></strong>' .
122
  t('It adds no functionality to the LDAP modules.') . '</p>';
123

    
124
  switch ($path) {
125
    case 'admin/config/people/ldap/help':
126
      $output = '<p>' . $help . '</p>';
127
      return $output;
128

    
129
    case 'admin/help#ldap_help':
130
      $output = '<p>' . $help . '</p>';
131
      return $output;
132
  }
133

    
134
}