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 @ b42754b9

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

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

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

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

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

    
60

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

    
71

    
72
  return $items;
73
}
74

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

    
100

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

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

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

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

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

    
135
}