You are here

function _captcha_available_challenge_types in CAPTCHA 6.2

Same name and namespace in other branches
  1. 5.3 captcha.module \_captcha_available_challenge_types()
  2. 6 captcha.admin.inc \_captcha_available_challenge_types()
  3. 7 captcha.admin.inc \_captcha_available_challenge_types()

Return an array with the available CAPTCHA types, for use as options array for a select form elements.

Parameters

$add_special_options if true: also add a 'none' and 'default' option:

Return value

an associative array mapping "$module/$type" to "$type (from module $module)" with $module the module name implementing the CAPTCHA and $type the name of the CAPTCHA type.

2 calls to _captcha_available_challenge_types()
captcha_admin_settings in ./captcha.admin.inc
Form builder function for the general CAPTCHA configuration
captcha_point_admin_form in ./captcha.admin.inc

File

./captcha.admin.inc, line 18
Functionality and helper functions for CAPTCHA administration.

Code

function _captcha_available_challenge_types($add_special_options = TRUE) {
  if ($add_special_options) {
    $captcha_types['none'] = '[' . t('none') . ']';
    $captcha_types['default'] = '[' . t('default challenge type') . ']';
  }

  // We do our own version of Drupal's module_invoke_all() here because
  // we want to build an array with custom keys and values.
  foreach (module_implements('captcha') as $module) {
    $result = call_user_func_array($module . '_captcha', array(
      'list',
    ));
    if (is_array($result)) {
      foreach ($result as $type) {
        $captcha_types["{$module}/{$type}"] = t('@type (from module @module)', array(
          '@type' => $type,
          '@module' => $module,
        ));
      }
    }
  }
  return $captcha_types;
}