Index: captcha.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/captcha/captcha.module,v
retrieving revision 1.42.2.24
diff -u -r1.42.2.24 captcha.module
--- captcha.module	24 Aug 2007 03:16:29 -0000	1.42.2.24
+++ captcha.module	27 Aug 2007 20:36:40 -0000
@@ -23,7 +23,7 @@
 function captcha_help($section = 'admin/help#captcha') {
   switch ($section) {
     case 'admin/help#captcha':
-      return '<p>' . t('A captcha is a tool to fight automated spam submission of forms (e.g. user registration forms, comment forms, guestbook forms, etc.) by malicious users. A captcha is an extra field (or several fields) on a form presented to the user. It represents a challenge, which should be easy for a normal human to solve (e.g. a simple math problem), but hard enough to keep automated scripts and spam bots out.') . '</p>';
+      return '<p>'. t('A captcha is a tool to fight automated spam submission of forms (e.g. user registration forms, comment forms, guestbook forms, etc.) by malicious users. A captcha is an extra field (or several fields) on a form presented to the user. It represents a challenge, which should be easy for a normal human to solve (e.g. a simple math problem), but hard enough to keep automated scripts and spam bots out.') .'</p>';
     case 'admin/user/captcha':
     case 'admin/user/captcha/captcha':
     case 'admin/user/captcha/captcha/settings':
@@ -93,12 +93,12 @@
  * challenge and $challenge the name of the challenge type.
  * (It also includes a 'none' => 'none' option)
  */
-function _captcha_available_challenge_types(){
+function _captcha_available_challenge_types() {
   $captcha_challenges['none'] = 'none';
-  foreach(module_implements('captcha') as $module) {
+  foreach (module_implements('captcha') as $module) {
     $result = call_user_func_array($module .'_captcha', 'list');
     if (is_array($result)) {
-      foreach($result as $challenge) {
+      foreach ($result as $challenge) {
         $captcha_challenges["$module/$challenge"] = "$challenge ($module)";
       }
     }
@@ -139,13 +139,13 @@
       case 'disable':
         // disable the captcha for the form: set the module and type to NULL
         db_query("UPDATE {captcha_points} SET module = NULL, type = NULL WHERE form_id = '%s'", $form_id);
-        drupal_set_message(t('Disabled captcha for form %form_id.', array('%form_id'=>$form_id)));
+        drupal_set_message(t('Disabled captcha for form %form_id.', array('%form_id' => $form_id)));
         // goto the captcha adminstration or alternative destination if present in URI
         drupal_goto('admin/user/captcha');
         break;
       case 'delete':
         db_query("DELETE FROM {captcha_points} WHERE form_id = '%s'", $form_id);
-        drupal_set_message(t('Deleted captcha for form %form_id.', array('%form_id'=>$form_id)));
+        drupal_set_message(t('Deleted captcha for form %form_id.', array('%form_id' => $form_id)));
         // goto the captcha adminstration or alternative destination if present in URI
         drupal_goto('admin/user/captcha');
         break;
@@ -200,7 +200,7 @@
     );
     // if a form_id was given as argument of this form builder, highlight the captcha type select widget
     if ($form_id == $captcha_point->form_id) {
-      $form['captcha_types'][$captcha_point->form_id]['captcha_type']['#attributes'] = array('class'=>'error');
+      $form['captcha_types'][$captcha_point->form_id]['captcha_type']['#attributes'] = array('class' => 'error');
     }
     // additional operations
     $form['captcha_types'][$captcha_point->form_id]['operations'] = array(
@@ -221,7 +221,7 @@
     foreach ($langs['name'] as $lang_code => $lang_name) {
       $form['captcha_descriptions']["captcha_description_$lang_code"] = array(
         '#type' => 'textfield',
-        '#title' => t('Captcha description for %lang_name (locale %lang_code)', array('%lang_name'=>$lang_name, '%lang_code'=>$lang_code)),
+        '#title' => t('Captcha description for %lang_name (locale %lang_code)', array('%lang_name' => $lang_name, '%lang_code' => $lang_code)),
         '#default_value' => _captcha_get_description($lang_code),
       );
     }
@@ -308,7 +308,7 @@
     // Visitor does not have permission to skip the captcha challenge
 
     // Do not present captcha if not captcha-persistent and user has already solved a captcha for this form
-    if(!variable_get('captcha_persistence', TRUE) && ($_SESSION['captcha'][$form_id]['success'] === TRUE)) {
+    if (!variable_get('captcha_persistence', TRUE) && ($_SESSION['captcha'][$form_id]['success'] === TRUE)) {
       return;
     }
 
@@ -328,7 +328,7 @@
       //The selected module returned nothing, maybe it is disabled or it's wrong, we should watchdog that and then quit.
       watchdog('captcha',
         t('Captcha problem: hook_captcha() of module %module returned nothing when trying to retrieve captcha type %type for form %form_id.',
-          array('%type' => $captcha_point->type, '%module' => $captcha_point->module, '%form_id'=> $form_id)),
+          array('%type' => $captcha_point->type, '%module' => $captcha_point->module, '%form_id' => $form_id)),
         WATCHDOG_ERROR);
       return;
     }
@@ -358,7 +358,7 @@
     // in a new (POST) request. Consequently the right captcha solution would be
     // overwritten just before validation. The pre_render functions are not run
     // before validation and are the right place to store the solution in $_SESSION.
-    $form['captcha']['captcha_solution'] = array (
+    $form['captcha']['captcha_solution'] = array(
       '#type' => 'value',
       '#value' => $captcha['solution'],
     );
@@ -368,7 +368,7 @@
     // couple of times before submitting them. The solution of the captcha of
     // each of these form instances will be stored at the pre_render phase in
     // $_SESSION['captcha'][$form_id][$captcha_token]
-    $form['captcha']['captcha_token'] = array (
+    $form['captcha']['captcha_token'] = array(
       '#type' => 'hidden',
       '#value' => md5(mt_rand()),
     );
@@ -503,7 +503,7 @@
 function captcha_pre_render_place_captcha($form_id, &$form) {
   // search the weights of the buttons in the form
   $button_weights = array();
-  foreach(element_children($form) as $key) {
+  foreach (element_children($form) as $key) {
     if ($form[$key]['#type'] == 'submit' || $form[$key]['#type'] == 'button') {
       $button_weights[] = $form[$key]['#weight'];
     }
@@ -541,10 +541,10 @@
   else {
     // generate a list with examples of the available challenges
     $output = t('This page gives an overview of all available captcha types, generated with their current settings.');
-    foreach(module_implements('captcha') as $module) {
+    foreach (module_implements('captcha') as $module) {
       $challenges = call_user_func_array($module .'_captcha', 'list');
       if ($challenges) {
-        foreach($challenges as $challenge) {
+        foreach ($challenges as $challenge) {
           // generate captcha challenge
           $captcha = call_user_func_array($module .'_captcha', array('generate', $challenge));
           // build form
@@ -573,7 +573,7 @@
  * Default implementation of hook_captcha
  */
 function captcha_captcha($op, $captcha_type='') {
-  switch($op) {
+  switch ($op) {
     case 'list':
       return array('Math');
     case 'generate':
@@ -583,7 +583,7 @@
         $x = mt_rand(1, $answer);
         $y = $answer - $x;
         $result['solution'] = "$answer";
-        $result['form']['captcha_response'] = array (
+        $result['form']['captcha_response'] = array(
           '#type' => 'textfield',
           '#title' => t('Math Question'),
           '#description' => t('Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.'),

