### Eclipse Workspace Patch 1.0 #P drupal-contrib-cvs Index: modules/captcha/captcha.module =================================================================== RCS file: captcha.module,v retrieving revision 1.29 diff -u -r1.29 captcha.module --- modules/captcha/captcha.module 23 Dec 2006 14:22:09 -0000 1.29 +++ modules/captcha/captcha.module 27 Dec 2006 18:48:31 -0000 @@ -9,17 +9,28 @@ $output .= "
Adds a Captcha to the registration form.
"; $output .= "More help needed here.
"; break; - case 'admin/modules#description': - case 'admin/modules/captcha': - case 'admin/captcha': - $output = t("Adds a Captcha to the registration form."); - break; } return $output; } -function captcha_settings() { +function captcha_menu($may_cache) { + $items = array(); + if ($may_cache) { + $items[] = array( + 'path' => 'admin/settings/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 site configuration'), + 'type' => MENU_NORMAL_ITEM, + ); + } + return $items; +} + +function captcha_admin_settings() { //this is where you can add more captcha points $captcha_points = array( @@ -42,10 +53,10 @@ foreach($captcha_points as $captcha_point=>$captcha_point_description) { $varname = $captcha_point .'_'. $varsuffix; $form[$varsuffix][$varname] = array( - '#type' => 'checkbox', - '#title' => $captcha_point_description, - '#default_value' => variable_get($varname, NULL) - ); + '#type' => 'checkbox', + '#title' => $captcha_point_description, + '#default_value' => variable_get($varname, NULL) + ); } } @@ -55,29 +66,14 @@ } $form['captcha_type'] = array( - '#type' => 'select', - '#title' => t('Type of captcha to use'), - '#default_value' => variable_get('captcha_type','captcha'), - '#options' => $captchamodules, - '#description' => t('Select what kind of challenge you want to pose to the user') - ); - - $form['captcha_description'] = array( - '#type' => 'textfield', - '#title' => t('Additional response description text'), - '#default_value' => variable_get('captcha_description', ''), - '#description' => t('This text will be added below the captcha response field.'), - ); + '#type' => 'select', + '#title' => t('Type of captcha to use'), + '#default_value' => variable_get('captcha_type','captcha'), + '#options' => $captchamodules, + '#description' => t('Select what kind of challenge you want to pose to the user') + ); - $form['captcha_override_module_description'] = array( - '#type' => 'checkbox', - '#title' => t('Override module's form item description?'), - '#default_value' => variable_get('captcha_override_module_description', 0), - '#description' => t('Override the captcha module's form item description to the one set above.'), - ); - - - return $form; + return system_settings_form($form); } @@ -101,10 +97,10 @@ $flag = false; break; } - } + } if ($flag && isset($trigger)) { $form['#submit'] = array('captcha_submit' => array()) + $form['#submit']; - if (!_captcha_validate($_POST['edit']['captcha_response'])) { + if (!_captcha_validate($_POST['captcha_response'])) { //use call_func because module_invoke does not allow call by reference. if (module_hook($captcha_type, 'captchachallenge')) { call_user_func_array($captcha_type.'_captchachallenge', array(&$form, &$_SESSION['captcha'])); @@ -136,6 +132,11 @@ } +function captcha_validate($formid, $form_values) { + echo "1:".$form_values['captcha_response']; + form_set_error('', 'this blows'); +} + function _captcha_validate($captcha_response) { if ($_SESSION['captcha_correct']) return TRUE;