Index: mollom.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.install,v
retrieving revision 1.2.2.31
diff -u -p -r1.2.2.31 mollom.install
--- mollom.install	6 Apr 2010 22:17:51 -0000	1.2.2.31
+++ mollom.install	16 Aug 2010 16:37:19 -0000
@@ -8,11 +8,22 @@
 
 /**
  * Implements hook_requirements().
+ *
+ * @param $check
+ *   (optional) Boolean whether to re-check the module's installation and
+ *   configuration status. Defaults to TRUE, as this argument is not passed for
+ *   hook_requirements() by default. Passing FALSE allows other run-time code
+ *   to re-generate requirements error messages to be displayed on other pages
+ *   than the site's system status report page.
+ *
+ * @see mollom_init()
+ * @see mollom_admin_settings()
+ * @see _mollom_status()
  */
-function mollom_requirements($phase = 'runtime') {
+function mollom_requirements($phase = 'runtime', $check = TRUE) {
   $requirements = array();
   if ($phase == 'runtime') {
-    $status = _mollom_status(TRUE);
+    $status = _mollom_status($check);
     // Immediately return if everything is in order.
     if ($status === TRUE) {
       return $requirements;
@@ -24,19 +35,35 @@ function mollom_requirements($phase = 'r
       'value' => '',
       'severity' => REQUIREMENT_ERROR,
     );
+    // Append a link to the settings page to the error message on all pages,
+    // except on the settings page itself. These error messages also need to be
+    // shown on the settings page, since Mollom API keys can be entered later.
+    $admin_message = '';
+    if ($_GET['q'] != 'admin/settings/mollom/settings') {
+      $admin_message = t('Visit the <a href="@settings-url">Mollom settings page</a> to configure your keys.', array(
+        '@settings-url' => url('admin/settings/mollom/settings'),
+      ));
+    }
+    // Generate an appropriate error message:
     // Missing API keys.
     if (!$status['keys']) {
       $requirements['mollom']['value'] = t('Not configured');
-      $requirements['mollom']['description'] = t('Mollom API keys are not <a href="@settings-url">configured</a> yet.', array('@settings-url' => url('admin/settings/mollom/settings')));
+      $requirements['mollom']['description'] = t('The Mollom API keys are not configured yet. !admin-message', array(
+        '!admin-message' => $admin_message,
+      ));
     }
+    // Invalid API keys.
+    elseif ($status['keys valid'] === MOLLOM_ERROR) {
+      $requirements['mollom']['value'] = t('Invalid');
+      $requirements['mollom']['description'] = t('The configured Mollom API keys are invalid. !admin-message', array(
+        '!admin-message' => $admin_message,
+      ));
+    }
+    // Communication error.
     elseif ($status['keys valid'] === NETWORK_ERROR) {
       $requirements['mollom']['value'] = t('Network error');
       $requirements['mollom']['description'] = t('The Mollom servers could not be contacted. Please make sure that your web server can make outgoing HTTP requests.');
     }
-    elseif ($status['keys valid'] === MOLLOM_ERROR) {
-      $requirements['mollom']['value'] = t('Invalid');
-      $requirements['mollom']['description'] = t('The <a href="@settings-url">configured</a> Mollom API keys are invalid.', array('@settings-url' => url('admin/settings/mollom/settings')));
-    }
   }
   return $requirements;
 }
Index: mollom.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v
retrieving revision 1.2.2.156
diff -u -p -r1.2.2.156 mollom.module
--- mollom.module	7 Aug 2010 02:49:44 -0000	1.2.2.156
+++ mollom.module	16 Aug 2010 16:37:05 -0000
@@ -154,6 +154,24 @@ function mollom_help($path, $arg) {
 }
 
 /**
+ * Implements hook_init().
+ */
+function mollom_init() {
+  // On all Mollom administration pages, check the module configuration and
+  // display the corresponding requirements error, if invalid.
+  if (empty($_POST) && strpos($_GET['q'], 'admin/settings/mollom') === 0 && user_access('administer mollom')) {
+    // Re-check the status on the settings form only.
+    $status = _mollom_status($_GET['q'] == 'admin/settings/mollom/settings');
+    if ($status !== TRUE) {
+      // Fetch and display requirements error message, without re-checking.
+      module_load_install('mollom');
+      $requirements = mollom_requirements('runtime', FALSE);
+      drupal_set_message($requirements['mollom']['description'], 'error');
+    }
+  }
+}
+
+/**
  * Implements hook_link().
  */
 function mollom_link($type, $object, $teaser = FALSE) {
@@ -341,18 +359,6 @@ function mollom_report_access($entity, $
 }
 
 /**
- * Implements hook_init().
- */
-function mollom_init() {
-  if (empty($_POST) && variable_get('mollom_testing_mode', 0) && user_access('administer mollom')) {
-    $message = t('Mollom testing mode is still enabled. Visit the <a href="@settings-url">Mollom settings page</a> to disable developer mode.', array(
-      '@settings-url' => url('admin/settings/mollom/settings'),
-    ));
-    drupal_set_message($message, 'warning');
-  }
-}
-
-/**
  * Implements hook_perm().
  */
 function mollom_perm() {
@@ -573,6 +579,20 @@ function mollom_form_alter(&$form, &$for
     return;
   }
 
+  // @todo Show this message on all protected forms, regardless of permissions.
+  if (empty($_POST) && variable_get('mollom_testing_mode', 0)) {
+    $admin_message = '';
+    if (user_access('administer mollom') && $_GET['q'] != 'admin/settings/mollom/settings') {
+      $admin_message = t('Visit the <a href="@settings-url">Mollom settings page</a> to disable it.', array(
+        '@settings-url' => url('admin/settings/mollom/settings'),
+      ));
+    }
+    $message = t('Mollom testing mode is still enabled. !admin-message', array(
+      '!admin-message' => $admin_message,
+    ));
+    drupal_set_message($message, 'warning');
+  }
+
   // Site administrators don't have their content checked with Mollom.
   if (!user_access('bypass mollom protection')) {
     // Retrieve a list of all protected forms once.
@@ -1071,6 +1091,7 @@ function _mollom_get_openid($account) {
 function _mollom_status($reset = FALSE) {
   // Load stored status.
   $status = variable_get('mollom_status', array(
+    'keys' => FALSE,
     'keys valid' => FALSE,
   ));
 
@@ -1082,18 +1103,20 @@ function _mollom_status($reset = FALSE) 
   // If we have keys and are asked to reset, check whether keys are valid.
   if ($status['keys'] && $reset) {
     $status['keys valid'] = mollom('mollom.verifyKey');
-    variable_set('mollom_status', $status);
   }
 
-  if ($status['keys valid'] === TRUE) {
-    return TRUE;
+  // In case of an error, indicate whether we have a non-empty server list.
+  if ($status['keys valid'] !== TRUE) {
+    $servers = variable_get('mollom_servers', array());
+    $status['servers'] = !empty($servers);
   }
 
-  // In case of an error, also indicate whether we have a non-empty server list.
-  $servers = variable_get('mollom_servers', array());
-  $status['servers'] = !empty($servers);
+  // Update stored status upon reset.
+  if ($reset) {
+    variable_set('mollom_status', $status);
+  }
 
-  return $status;
+  return ($status['keys valid'] === TRUE ? TRUE : $status);
 }
 
 /**
@@ -1101,6 +1124,10 @@ function _mollom_status($reset = FALSE) 
  */
 function _mollom_fallback() {
   $fallback = variable_get('mollom_fallback', MOLLOM_FALLBACK_BLOCK);
+  // @todo Prevents mollom_admin_settings() from implementing a proper form
+  //   validation. Add !empty($_POST) to this condition + manually invoke from
+  //   mollom_process_form() on GET requests? Or don't call it from mollom()?
+  //   Anything, but just don't mix FAPI logic into XML-RPC logic.
   if ($fallback == MOLLOM_FALLBACK_BLOCK) {
     form_set_error('mollom', t("The spam filter installed on this site is currently unavailable. Per site policy, we are unable to accept new submissions until that problem is resolved. Please try resubmitting the form in a couple of minutes."));
   }
