Index: mollom.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.admin.inc,v
retrieving revision 1.1.2.47
diff -u -p -r1.1.2.47 mollom.admin.inc
--- mollom.admin.inc	25 Oct 2010 20:34:55 -0000	1.1.2.47
+++ mollom.admin.inc	29 Oct 2010 13:52:18 -0000
@@ -12,6 +12,9 @@
 function mollom_admin_form_list() {
   _mollom_testing_mode_warning();
 
+  // Reset the cached list of protected forms.
+  mollom_form_cache(TRUE);
+
   $modes = array(
     MOLLOM_MODE_ANALYSIS => t('Text analysis'),
     MOLLOM_MODE_CAPTCHA => t('CAPTCHA'),
@@ -131,7 +134,6 @@ function mollom_admin_configure_form(&$f
       drupal_set_title(t('Configure %form-title protection', array('%form-title' => $mollom_form['title'])));
       $form['#after_build'][] = 'mollom_admin_configure_form_after_build';
 
-      // Display a list of fields for textual analysis (last step).
       $form['mollom']['form_id'] = array(
         '#type' => 'value',
         '#value' => $mollom_form['form_id'],
@@ -152,6 +154,30 @@ function mollom_admin_configure_form(&$f
         '#default_value' => isset($mollom_form['mode']) ? $mollom_form['mode'] : key($modes),
       );
 
+      $all_permissions = array();
+      foreach (module_implements('perm') as $module) {
+        // Transpose permissions into D7 format.
+        $module_permissions = array_flip(module_invoke($module, 'perm'));
+        foreach ($module_permissions as $permission => $key) {
+          $module_permissions[$permission] = array(
+            'title' => $permission,
+            'module' => $module,
+          );
+        }
+        $all_permissions += $module_permissions;
+      }
+      // Prepend Mollom's global permission to the list.
+      array_unshift($mollom_form['bypass access'], 'bypass mollom protection');
+      $permissions = array();
+      foreach ($mollom_form['bypass access'] as $permission) {
+        $permissions[] = l($all_permissions[$permission]['title'], 'admin/user/permissions', array(
+          'fragment' => 'module-' . $all_permissions[$permission]['module'],
+        ));
+      }
+      $form['mollom']['mode']['#description'] = t('The protection is not enabled for the following user permissions: !permission-list', array(
+        '!permission-list' => theme('item_list', $permissions),
+      ));
+
       if (!empty($mollom_form['elements'])) {
         // If not re-configuring an existing protection, make it the default.
         if (!isset($mollom_form['mode'])) {
@@ -171,18 +197,6 @@ function mollom_admin_configure_form(&$f
           '#access' => FALSE,
         );
 
-        $form['mollom']['discard'] = array(
-          '#type' => 'radios',
-          '#title' => t('When a post is blocked'),
-          '#default_value' => $mollom_form['discard'],
-          '#options' => array(
-            1 => t('Automatically discard'),
-            0 => t('Retain for manual moderation'),
-          ),
-          // Only possible for forms supporting moderation of unpublished posts.
-          '#access' => !empty($mollom_form['moderation callback']),
-        );
-
         // Form elements defined by hook_mollom_form_info() use the
         // 'parent][child' syntax, which Form API also uses internally for
         // form_set_error(), and which allows us to recurse into nested fields
@@ -209,6 +223,18 @@ function mollom_admin_configure_form(&$f
           '#default_value' => $enabled_fields,
           '#required' => $mollom_form['mode'] == MOLLOM_MODE_ANALYSIS,
         );
+
+        $form['mollom']['discard'] = array(
+          '#type' => 'radios',
+          '#title' => t('When a bad post is identified'),
+          '#default_value' => $mollom_form['discard'],
+          '#options' => array(
+            1 => t('Automatically discard the post'),
+            0 => t('Retain the post for manual moderation'),
+          ),
+          // Only possible for forms supporting moderation of unpublished posts.
+          '#access' => !empty($mollom_form['moderation callback']),
+        );
       }
 
       $form['actions']['submit'] = array(
Index: tests/mollom.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/tests/mollom.test,v
retrieving revision 1.1.2.72
diff -u -p -r1.1.2.72 mollom.test
--- tests/mollom.test	28 Oct 2010 02:04:52 -0000	1.1.2.72
+++ tests/mollom.test	29 Oct 2010 13:37:47 -0000
@@ -1723,6 +1723,20 @@ class MollomFormConfigurationTestCase ex
     $this->assertText($form_info['user_register']['title']);
     $this->assertTrue(mollom_form_load('user_register'), t('Form configuration exists.'));
 
+    // Retrieve a list of all permissions to verify them below.
+    $all_permissions = array();
+    foreach (module_implements('perm') as $module) {
+      // Transpose permissions into D7 format.
+      $module_permissions = array_flip(module_invoke($module, 'perm'));
+      foreach ($module_permissions as $permission => $key) {
+        $module_permissions[$permission] = array(
+          'title' => $permission,
+          'module' => $module,
+        );
+      }
+      $all_permissions += $module_permissions;
+    }
+
     // Iterate over all unconfigured forms and protect them.
     foreach ($form_info as $form_id => $info) {
       if (!mollom_form_load($form_id)) {
@@ -1745,6 +1759,11 @@ class MollomFormConfigurationTestCase ex
           $this->assertNoText(t('Analyze text for'));
           $this->assertNoText(t('Text fields to analyze'));
         }
+        // Verify that bypass permissions are output.
+        $this->assertText($all_permissions['bypass mollom protection']['title']);
+        foreach ($info['bypass access'] as $permission) {
+          $this->assertText($all_permissions[$permission]['title']);
+        }
         $this->drupalPost(NULL, $edit, t('Save'));
         $this->assertText(t('The form protection has been added.'));
       }
