? blacklist.patch
? blacklistUI.jpg
? blacklistUI.patch
Index: mollom.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.admin.inc,v
retrieving revision 1.1.2.24
diff -u -p -r1.1.2.24 mollom.admin.inc
--- mollom.admin.inc	16 Feb 2010 07:55:12 -0000	1.1.2.24
+++ mollom.admin.inc	27 Feb 2010 09:18:50 -0000
@@ -259,35 +259,36 @@ function mollom_admin_unprotect_form_sub
 
 /**
  * Menu callback; renders the blacklist overview page.
- *
- * @todo Do we want to keep both blacklist on the same page?
  */
 function mollom_admin_blacklist() {
-  $output  = '<h2>' . t('Text blacklist') . '</h2>';
-  $output .= drupal_get_form('mollom_admin_blacklist_text_form');
-  $output .= '<h2>' . t('URL blacklist') . '</h2>';
-  $output .= drupal_get_form('mollom_admin_blacklist_url_form');
+  $output  = '<h2>' . t('Blacklist') . '</h2>';
+  $output .= '<p>' . t("Mollom's filters are trained and shared globally over all participating sites. Due to this, some content might still be accepted to your site which you do not desire, even after giving feedback to Mollom. Using the site-specific blacklist, your are able to customize the filters to your specific needs.");
+  $output .= '<div class="description"><p>'. t("The blacklist can be applied to specific contexts: it can look in all the content, or only in the links. When analysing links, Mollom will both look in the URL and the link text. You can also define if the blacklisted item is see as spam, profanity or unwanted content. We provided a few example blacklist items to demonstrate its usage.");
+  $output .= '<p>' . t("If you specify a blacklisted item as multiple words, Mollom will try to match it to several combinations. When you for example add the blacklist item \"replica watches\" for links, all the following URLs will be blocked:");
+  $output .= '<ul><li>http://replica-watches.com</li><li>http://replicawatches.com</li><li>http://replica-watches.com</li><li><a href=\".\">replica watches</a></li></ul>';
+  $output .= '<p>' . t("It is also possible to block whole URL domains by defining links blacklists as \"http://replicawatches.com\". This will block all possible subdomains and paths of this base URL. <p>Note that Mollom's global filters are also improved when multiple people put items in their blacklist. <em>This way you can help become a better spam and profanity fighter.</em>") . '</div>'; 
+  $output .= drupal_get_form('mollom_admin_blacklist_form');
   return $output;
 }
 
 /**
  * Form builder; declares the text blacklist form.
  */
-function mollom_admin_blacklist_text_form() {
+function mollom_admin_blacklist_form() {
   $form['#tree'] = TRUE;
 
-  $form['entry']['match'] = array(
+  $form['entry']['context'] = array(
     '#type' => 'select',
     '#options' => array(
-      'exact' => t('Exact'),
-      'contains' => t('Contains'),
+      'everything' => t('Everything'),
+      'links' => t('Links'),
     ),
-    '#default_value' => 'exact',
+    '#default_value' => 'everything',
     '#required' => TRUE,
   );
   $form['entry']['text'] = array(
     '#type' => 'textfield',
-    '#size' => 30,
+    '#size' => 40,
     '#required' => TRUE,
     '#maxlength' => 64,
   );
@@ -312,8 +313,8 @@ function mollom_admin_blacklist_text_for
 /**
  * Form submit handler to save a text string to the Mollom blacklist.
  */
-function mollom_admin_blacklist_text_form_submit($form, &$form_state) {
-  $result = mollom('mollom.addBlacklistText', $form_state['values']['entry']);
+function mollom_admin_blacklist_form_submit($form, &$form_state) {
+  $result = mollom('mollom.addBlacklist', $form_state['values']['entry']);
 
   if ($result === TRUE) {
     drupal_set_message(t('The text has been added to the blacklist.'));
@@ -326,30 +327,30 @@ function mollom_admin_blacklist_text_for
 /**
  * Theme function; theme the text blacklist table so we can integrate the form.
  */
-function theme_mollom_admin_blacklist_text_form($form) {
+function theme_mollom_admin_blacklist_form($form) {
   $header = array(
-    t('Match'),
+    t('Context'),
     t('Text'),
     t('Reason'),
     t('Operations'),
   );
 
-  $blacklist = mollom('mollom.listBlacklistText');
+  $blacklist = mollom('mollom.listBlacklist');
 
   $rows = array();
   if (is_array($blacklist)) {
     foreach ($blacklist as $entry) {
       $rows[] = array(
-        check_plain($entry['match']),
+        check_plain($entry['context']),
         check_plain($entry['text']),
         check_plain($entry['reason']),
-        l(t('delete'), 'admin/settings/mollom/blacklist/delete/text/' . base64_encode($entry['text'])),
+        l(t('delete'), 'admin/settings/mollom/blacklist/delete/' . check_plain($entry['context']) . '/' . base64_encode($entry['text']) . '/' . check_plain($entry['reason'])),
       );
     }
   }
 
   $rows[] = array(
-    drupal_render($form['entry']['match']),
+    drupal_render($form['entry']['context']),
     drupal_render($form['entry']['text']),
     drupal_render($form['entry']['reason']),
     drupal_render($form['actions']),
@@ -363,88 +364,19 @@ function theme_mollom_admin_blacklist_te
 }
 
 /**
- * Form builder; declares the URL blacklist form.
- */
-function mollom_admin_blacklist_url_form() {
-  $form['#tree'] = TRUE;
-
-  $form['entry']['url'] = array(
-    '#type' => 'textfield',
-    '#size' => 30,
-    '#required' => TRUE,
-    '#field_prefix' => 'http://',
-    '#maxlength' => 64,
-  );
-  $form['actions']['submit'] = array(
-    '#type' => 'submit',
-    '#value' => t('Add'),
-  );
-
-  return $form;
-}
-
-/**
- * Form submit handler to save a URL to the Mollom blacklist.
- */
-function mollom_admin_blacklist_url_form_submit($form, &$form_state) {
-  $result = mollom('mollom.addBlacklistURL', array(
-    'url' => 'http://' . $form_state['values']['entry']['url'],
-  ));
-
-  if ($result === TRUE) {
-    drupal_set_message(t('The URL has been added to the blacklist.'));
-  }
-  else {
-    drupal_set_message(t('An error occurred upon trying to add the URL to the blacklist.'), 'error');
-  }
-}
-
-/**
- * Theme function; theme the URL blacklist table so we can integrate the form.
- */
-function theme_mollom_admin_blacklist_url_form($form) {
-  $header = array(
-    t('URL'),
-    t('Operations'),
-  );
-
-  $blacklist = mollom('mollom.listBlacklistURL');
-
-  $rows = array();
-  if (is_array($blacklist)) {
-    foreach ($blacklist as $entry) {
-      $rows[] = array(
-        check_plain($entry['url']),
-        l(t('delete'), 'admin/settings/mollom/blacklist/delete/url/' . base64_encode($entry['url'])),
-      );
-    }
-  }
-
-  $rows[] = array(
-    drupal_render($form['entry']['url']),
-    drupal_render($form['actions']),
-  );
-
-  // This table is never empty due to the form.
-  $output  = theme('table', $header, $rows);
-  $output .= drupal_render($form);
-
-  return $output;
-}
-
-/**
  * Form builder; Builds the confirmation form for deleting a blacklist item.
  *
  * @ingroup forms
  * @see mollom_admin_blacklist_delete_submit()
  */
-function mollom_admin_blacklist_delete(&$form_state, $blacklist, $key) {
-  $form['#mollom-blacklist-type'] = $blacklist;
-  $form['#mollom-blacklist-key'] = base64_decode($key);
+function mollom_admin_blacklist_delete(&$form_state, $key) {
+  $form['#mollom-blacklist-context'] = $context;
+  $form['#mollom-blacklist-text'] = base64_decode($text);
+  $form['#mollom-blacklist-reason'] = $reason;
 
   return confirm_form(
     $form,
-    t('Are you sure you want to delete %key from the blacklist?', array('%key' => $form['#mollom-blacklist-key'])),
+    t('Are you sure you want to delete %text from the blacklist?', array('%text' => $form['#mollom-blacklist-text'])),
     'admin/settings/mollom/blacklist',
     t('This action cannot be undone.'),
     t('Delete'), t('Cancel')
@@ -455,12 +387,7 @@ function mollom_admin_blacklist_delete(&
  * Form submit handler to delete an entry from the blacklist.
  */
 function mollom_admin_blacklist_delete_submit($form, &$form_state) {
-  if ($form['#mollom-blacklist-type'] == 'text') {
-    $result = mollom('mollom.removeBlacklistText', array('text' => $form['#mollom-blacklist-key']));
-  }
-  else {
-    $result = mollom('mollom.removeBlacklistURL', array('url' => $form['#mollom-blacklist-key']));
-  }
+  $result = mollom('mollom.removeBlacklist', array('context' => $form['#mollom-blacklist-context'], 'text' => $form['#mollom-blacklist-text'], 'reason' => $form['#mollom-blacklist-reason']));
 
   if ($result === TRUE) {
     drupal_set_message(t('The item has been removed from the blacklist.'));
Index: mollom.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v
retrieving revision 1.2.2.131
diff -u -p -r1.2.2.131 mollom.module
--- mollom.module	20 Feb 2010 21:35:59 -0000	1.2.2.131
+++ mollom.module	27 Feb 2010 09:18:51 -0000
@@ -96,10 +96,6 @@ function mollom_help($path, $arg) {
     ));
   }
 
-  if ($path == 'admin/settings/mollom/blacklist') {
-    return t('Mollom automatically blocks unwanted content, and learns from all participating sites to make its filters better. On top of automatic spam blocking, you can provide custom blacklists.');
-  }
-
   if ($path == 'admin/help#mollom') {
     $output = '<p>';
     $output = t("Allowing users to react, participate and contribute while still keeping your site's content under control can be a huge challenge. Mollom is a web service that helps you identify content quality and, more importantly, helps you stop spam. When content moderation becomes easier, you have more time and energy to interact with your web community. More information about Mollom is available on the <a href=\"@mollom-website\">Mollom website</a> or in the <a href=\"@mollom-faq\">Mollom FAQ</a>.",
@@ -205,7 +201,7 @@ function mollom_menu() {
   );
   $items['admin/settings/mollom/blacklist'] = array(
     'title' => 'Blacklist',
-    'description' => 'Configure word and URL blacklists.',
+    'description' => 'Configure blacklist.',
     'page callback' => 'mollom_admin_blacklist',
     'access arguments' => array('administer mollom'),
     'type' => MENU_LOCAL_TASK,
@@ -214,7 +210,7 @@ function mollom_menu() {
   $items['admin/settings/mollom/blacklist/delete'] = array(
     'title' => 'Delete',
     'page callback' => 'drupal_get_form',
-    'page arguments' => array('mollom_admin_blacklist_delete', 5, 6),
+    'page arguments' => array('mollom_admin_blacklist_delete', 4, 5, 6),
     'access arguments' => array('administer mollom'),
     'type' => MENU_CALLBACK,
     'file' => 'mollom.admin.inc',
@@ -906,14 +902,10 @@ function mollom_theme() {
     'mollom' => array(
       'arguments' => array('element' => NULL),
     ),
-    'mollom_admin_blacklist_text_form' => array(
-      'arguments' => array('form' => NULL),
-      'file' => 'mollom.admin.inc',
-    ),
-    'mollom_admin_blacklist_url_form' => array(
+    'mollom_admin_blacklist_form' => array(
       'arguments' => array('form' => NULL),
       'file' => 'mollom.admin.inc',
-    ),
+    )
   );
 }
 
