You are here

ldap_help.module in Lightweight Directory Access Protocol (LDAP) 8.2

The ldaphelp module is a module to help admins debug ldap_integration modules.

File

ldap_help/ldap_help.module
View source
<?php

/**
 * @file
 * The ldaphelp module is a module to help admins debug ldap_integration modules.
 *
 */

/**
 * Implements hook_menu().
 */
function ldap_help_menu() {
  $items = array();
  $items['admin/config/people/ldap/help'] = array(
    'title' => 'Help',
    'type' => MENU_LOCAL_TASK,
    'weight' => 9,
    'description' => 'Debugging and Configuration Help with LDAP',
    'file' => 'ldap_help.resources.inc',
    'page callback' => 'ldap_help_main',
    'access arguments' => array(
      'administer site configuration',
    ),
  );
  $items['admin/config/people/ldap/help/intro'] = array(
    'title' => 'Resources',
    'type' => MENU_DEFAULT_LOCAL_TASK,
  );
  $items['admin/config/people/ldap/help/status'] = array(
    'title' => 'Status',
    'description' => 'LDAP status page',
    'page callback' => 'ldap_help_status',
    'access arguments' => array(
      'administer site configuration',
    ),
    'file' => 'ldap_help.status.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => 4,
  );
  $items['admin/config/people/ldap/help/watchdog'] = array(
    'title' => 'Watchdog',
    'description' => 'LDAP watchdog logs',
    'page callback' => 'ldap_help_watchdog',
    'access arguments' => array(
      'administer site configuration',
    ),
    'file' => 'ldap_help.watchdog.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => 5,
  );
  $items['admin/config/people/ldap/help/issues'] = array(
    'title' => 'Issue Reporting',
    'description' => 'Creating LDAP Issue Queue Items',
    'page callback' => 'ldap_help_issues',
    'access arguments' => array(
      'administer site configuration',
    ),
    'file' => 'ldap_help.issues.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => 7,
  );
  $items['admin/config/people/ldap/help/examples'] = array(
    'title' => 'Sample LDAPs',
    'description' => 'Sample LDAPs from Documentation',
    'page callback' => 'ldap_help_examples',
    'access arguments' => array(
      'administer site configuration',
    ),
    'file' => 'ldap_help.examples.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => 7,
  );
  return $items;
}
function ldap_help_form_ldap_servers_settings_alter(&$form, &$form_state) {
  $form['watchdog_detail'] = array(
    '#type' => 'fieldset',
    '#title' => t('Development'),
  );
  $form['watchdog_detail']['watchdog_detail'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enabled Detailed LDAP Watchdog logging.  This is generally for
       debugging and reporting issues with the ldap modules and should not be left
       on.'),
    '#default_value' => config('ldap_help.settings')
      ->get('watchdog_detail'),
  );
  $date = config('ldap_help.settings')
    ->get('user_data_clear_set_date');
  $form['watchdog_detail']['user_data_clear'] = array(
    '#type' => 'checkbox',
    '#title' => t('Discard and ignore user authorization data stored by ldap module in user records data before %date.
      This is useful for implementers of development versions of the module
      that may have corrupt user data from the past.', array(
      '%date' => date('Y-m-d H:i:s', $date),
    )),
    '#default_value' => config('ldap_help.settings')
      ->get('user_data_clear'),
  );

  //array('%date' => date('Y-m-d H:i:s', $date))
  $form['watchdog_detail']['user_data_clear_date'] = array(
    '#type' => 'checkbox',
    '#title' => t('Reset the clear date to the current date %date', array(
      '%date' => date('Y-m-d H:i:s'),
    )),
    '#default_value' => config('ldap_help.settings')
      ->get('user_data_clear_set_date'),
  );
  $form['#submit'][] = 'ldap_help_watchdog_detail_submit';
}
function ldap_help_watchdog_detail_submit($form, &$form_state) {
  if ($form_state['submitted']) {
    $watchdog_detail = $form_state['values']['watchdog_detail'];
    if ($watchdog_detail != config('ldap_help.settings')
      ->get('watchdog_detail')) {
      variable_set('ldap_help_watchdog_detail', $watchdog_detail);
    }
    if ($form_state['values']['user_data_clear'] != config('ldap_help.settings')
      ->get('user_data_clear')) {
      variable_set('ldap_help_user_data_clear', $form_state['values']['user_data_clear']);
    }
    if ($form_state['values']['user_data_clear_date'] != 0) {
      variable_set('ldap_help_user_data_clear_set_date', time());
    }
  }
}
function ldap_help_help($path, $arg) {
  $help = '<h3>' . t('LDAP Help Module') . '</h3><p>' . t('This module assists Drupal admins in configuring, debugging, sharing, and submitting
  support and bug request related to LDAP modules.') . '<strong><em> ' . t('LDAP Help Module should be disabled unless you are debugging or configuring
    LDAP problems.') . ' </em></strong>' . t('It adds no functionality to the LDAP modules.') . '</p>';
  switch ($path) {
    case 'admin/config/people/ldap/help':
      $output = '<p>' . $help . '</p>';
      return $output;
    case 'admin/help#ldap_help':
      $output = '<p>' . $help . '</p>';
      return $output;
  }
}