Projet

Général

Profil

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

root / drupal7 / sites / all / modules / ldap / ldap_help / ldap_help.module @ 91af538d

1
<?php
2

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

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

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

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

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

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

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

    
68
  return $items;
69
}
70

    
71
/**
72
 *
73
 */
74
function ldap_help_form_ldap_servers_settings_alter(&$form, &$form_state) {
75
  $form['watchdog_detail'] = ['#type' => 'fieldset', '#title' => t('Development')];
76
  $form['watchdog_detail']['watchdog_detail'] = [
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'] = [
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.', ['%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
  ];
92
  $form['watchdog_detail']['user_data_clear_date'] = [
93
    '#type' => 'checkbox',
94
    '#title' => t('Reset the clear date to the current date %date', ['%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
 *
102
 */
103
function ldap_help_watchdog_detail_submit($form, &$form_state) {
104
  if ($form_state['submitted']) {
105
    $watchdog_detail = $form_state['values']['watchdog_detail'];
106
    if ($watchdog_detail != variable_get('ldap_help_watchdog_detail', 0)) {
107
      variable_set('ldap_help_watchdog_detail', $watchdog_detail);
108
    }
109
    if ($form_state['values']['user_data_clear'] != variable_get('ldap_help_user_data_clear', 0)) {
110
      variable_set('ldap_help_user_data_clear', $form_state['values']['user_data_clear']);
111
    }
112
    if ($form_state['values']['user_data_clear_date'] != 0) {
113
      variable_set('ldap_help_user_data_clear_set_date', time());
114
    }
115
  }
116
}
117

    
118
/**
119
 *
120
 */
121
function ldap_help_help($path, $arg) {
122

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

    
130
  switch ($path) {
131
    case 'admin/config/people/ldap/help':
132
      $output = '<p>' . $help . '</p>';
133
      return $output;
134

    
135
    case 'admin/help#ldap_help':
136
      $output = '<p>' . $help . '</p>';
137
      return $output;
138
  }
139

    
140
}