You are here

function captcha_menu in CAPTCHA 5.3

Same name and namespace in other branches
  1. 6.2 captcha.module \captcha_menu()
  2. 6 captcha.module \captcha_menu()
  3. 7 captcha.module \captcha_menu()

Implementation of hook_menu().

File

./captcha.module, line 50
This module enables basic CAPTCHA functionality: administrators can add a CAPTCHA to desired forms that users without the 'skip CAPTCHA' permission (typically anonymous visitors) have to solve.

Code

function captcha_menu($may_cache) {
  $items = array();
  if ($may_cache) {

    // main configuration page of the basic CAPTCHA module
    $items[] = array(
      'path' => 'admin/user/captcha',
      'title' => t('CAPTCHA'),
      'description' => t('Administer how and where CAPTCHAs are used.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'captcha_admin_settings',
      ),
      'access' => user_access('administer CAPTCHA settings'),
      'type' => MENU_NORMAL_ITEM,
    );

    // the default local task (needed when other modules want to offer
    // alternative CAPTCHA types and their own configuration page as local task)
    $items[] = array(
      'path' => 'admin/user/captcha/captcha',
      'title' => t('CAPTCHA'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -20,
    );
    $items[] = array(
      'path' => 'admin/user/captcha/captcha/settings',
      'title' => t('General settings'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => 0,
    );
    $items[] = array(
      'path' => 'admin/user/captcha/captcha/examples',
      'title' => t('Examples'),
      'description' => t('An overview of the available challenge types with examples.'),
      'callback' => 'captcha_examples',
      'type' => MENU_LOCAL_TASK,
      'weight' => 5,
    );

    // form for adding/editing CAPTCHA points
    $items[] = array(
      'path' => 'admin/user/captcha/captcha/captcha_point',
      'title' => t('Set CAPTCHA point'),
      'description' => t('Add or edit form_id\'s to protect with a CAPTCHA.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'captcha_point_admin_form',
      ),
      'type' => MENU_LOCAL_TASK,
      'weight' => 2,
    );
  }
  else {

    // Some non cachable menu items for disabling/deleting CAPTCHA points
    // start with arg(4) == 'captcha_point' for faster short circuit
    if (arg(4) == 'captcha_point' && arg(0) == 'admin' && arg(1) == 'user' && arg(2) == 'captcha' && arg(3) == 'captcha' && !is_null(arg(5))) {
      $items[] = array(
        'path' => 'admin/user/captcha/captcha/captcha_point/' . arg(5) . '/disable',
        'title' => t('Disable'),
        'callback' => 'drupal_get_form',
        'callback arguments' => array(
          'captcha_point_disable_confirm',
          arg(5),
          FALSE,
        ),
        'type' => MENU_CALLBACK,
      );
      $items[] = array(
        'path' => 'admin/user/captcha/captcha/captcha_point/' . arg(5) . '/delete',
        'title' => t('Delete'),
        'callback' => 'drupal_get_form',
        'callback arguments' => array(
          'captcha_point_disable_confirm',
          arg(5),
          TRUE,
        ),
        'type' => MENU_CALLBACK,
      );
    }
  }
  return $items;
}