You are here

function captcha_captcha_default_points_alter in CAPTCHA 6.2

Same name and namespace in other branches
  1. 7 captcha.module \captcha_captcha_default_points_alter()

Implementation of hook_captcha_default_points_alter().

Provide some default captchas only if defaults are not already provided by other modules.

File

./captcha.module, line 292
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_captcha_default_points_alter(&$items) {
  $modules = array(
    'comment' => array(
      'comment_form',
    ),
    'contact' => array(
      'contact_mail_user',
      'contact_mail_page',
    ),
    'forum' => array(
      'forum_node_form',
    ),
    'user' => array(
      'user_register',
      'user_pass',
      'user_login',
      'user_login_block',
    ),
  );
  foreach ($modules as $module => $form_ids) {

    // Only give defaults if the module exists.
    if (module_exists($module)) {
      foreach ($form_ids as $form_id) {

        // Ensure a default has not been provided already.
        if (!isset($items[$form_id])) {
          $captcha = new stdClass();
          $captcha->disabled = FALSE;
          $captcha->api_version = 1;
          $captcha->form_id = $form_id;
          $captcha->module = NULL;
          $captcha->captcha_type = NULL;
          $items[$form_id] = $captcha;
        }
      }
    }
  }
}