You are here

function math_captcha_captcha in CAPTCHA Pack 7

Same name and namespace in other branches
  1. 8 math_captcha/math_captcha.module \math_captcha_captcha()
  2. 5 math_captcha/math_captcha.module \math_captcha_captcha()
  3. 6 math_captcha/math_captcha.module \math_captcha_captcha()

Implements hook_captcha().

File

math_captcha/math_captcha.module, line 34

Code

function math_captcha_captcha($op, $captcha_type = '') {
  switch ($op) {
    case 'list':
      return array(
        'Math CAPTCHA',
      );
    case 'generate':
      if ($captcha_type == 'Math CAPTCHA') {
        require_once 'math_captcha.challenge.inc';

        // Get the available challenges
        $enabled_challenges = _math_captcha_enabled_challenges();
        $challenges = array_filter($enabled_challenges);
        $challenge = $challenges[array_rand($challenges)];
        $form_item = call_user_func("_math_captcha_{$challenge}_challenge");
        return $form_item;
      }
  }
}