Index: mollom.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.admin.inc,v
retrieving revision 1.9
diff -u -r1.9 mollom.admin.inc
--- mollom.admin.inc	29 Jan 2010 22:06:15 -0000	1.9
+++ mollom.admin.inc	30 Jan 2010 19:04:29 -0000
@@ -267,6 +267,232 @@
 }
 
 /**
+ * Menu callback that 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_render(drupal_get_form('mollom_admin_blacklist_text_form'));
+  $output .= '<h2>'. t('URL blacklist') .'</h2>';
+  $output .= drupal_render(drupal_get_form('mollom_admin_blacklist_url_form'));
+  
+  return $output;
+}
+
+/**
+ * Form builder; declare the text blacklist form.
+ */
+function mollom_admin_blacklist_text_form() {
+
+  $form['match'] = array(
+    '#type' => 'select',
+    '#options' => array(
+      'exact' => t('Exact'),
+      'contains' => t('Contains'),
+    ),
+    '#default_value' => 'exact',
+    '#required' => TRUE,
+  );
+
+  $form['text'] = array(
+    '#type' => 'textfield',
+    '#size' => 30,
+    '#required' => TRUE,
+    '#maxlength' => 64,
+  );
+
+  $form['reason'] = array(
+    '#type' => 'select',
+    '#options' => array(
+      'spam' => t('Spam'),
+      'profanity' => t('Profanity'),
+      'unwanted' => t('Unwanted'),
+    ),
+    '#default_value' => 'spam',
+    '#required' => TRUE,
+  );
+
+  include_once DRUPAL_ROOT . '/includes/locale.inc';
+  $predefined = _locale_prepare_predefined_list();
+
+  $form['language'] = array(
+    '#type' => 'select',
+    '#options' => $predefined,
+    '#default_value' => 'en',
+    '#required' => TRUE,
+  );
+      
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Save'),
+  );
+    
+  return $form;
+}
+
+/**
+ * Form submit handler for saving a text string to the Mollom blacklist.
+ */
+function mollom_admin_blacklist_text_form_submit($form, &$form_state) {
+  
+  $result = mollom('mollom.addBlacklistText', array(
+    'text' => $form_state['values']['text'],
+    'match' => $form_state['values']['match'],
+    'reason' => $form_state['values']['reason'],
+    'language' => $form_state['values']['language'],
+  ));
+
+  // @todo: verify that the call was successful.
+  drupal_set_message(t('The word has been added to the blacklist.'));
+}
+
+/**
+ * Theme function; theme the text blacklist table so we can integrate the form.
+ */
+function theme_mollom_admin_blacklist_text_form($variables) {
+  
+  $form = $variables['form'];
+
+  $header = array(
+    t('Match'),    
+    t('Text'),
+    t('Reason'),
+    t('Language'),
+    t('Operations')
+  );
+  
+  $blacklist = mollom('mollom.listBlacklistText');
+
+  $rows = array();
+  foreach ($blacklist as $entry) {
+    $rows[] = array(
+      check_plain($entry['match']),
+      check_plain($entry['text']),
+      check_plain($entry['reason']),
+      check_plain($entry['language']),
+      l(t('delete'), 'admin/config/content/mollom/blacklist/delete/text/' . $entry['text'])
+    );  
+  }
+  
+  $rows[] = array(
+    drupal_render($form['match']),
+    drupal_render($form['text']),
+    drupal_render($form['reason']),
+    drupal_render($form['language']),
+    drupal_render($form['submit'])
+  );
+  
+  $output  = theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No words have been added to the blacklist.')));
+  $output .= drupal_render_children($form);
+  
+  return $output;
+}
+
+/**
+ * Form builder; declare the URL blacklist form.
+ */
+function mollom_admin_blacklist_url_form() {
+
+  $form['url'] = array(
+    '#type' => 'textfield',
+    '#size' => 30,
+    '#required' => TRUE,
+    '#prefix' => 'http://',
+    '#maxlength' => 64,
+  );
+      
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Save'),
+  );
+
+  return $form;
+}
+
+/**
+ * Form submit handler for saving an 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']['url'],
+  ));
+  
+  // @todo: verify that the call was successful.
+  drupal_set_message(t('The URL has been added to the blacklist.'));
+}
+
+/**
+ * Theme function; theme the URL blacklist table so we can integrate the form.
+ */
+function theme_mollom_admin_blacklist_url_form($variables) {
+  
+  $form = $variables['form'];
+
+  $header = array(t('URL'),
+    t('Operations')
+  );
+  
+  $blacklist = mollom('mollom.listBlacklistURL');
+
+  $rows = array();
+  foreach ($blacklist as $entry) {
+    $rows[] = array(
+      check_plain($entry['url']),
+      // @todo the URL should be encoded, or we should pass in an ID ...
+      l(t('delete'), 'admin/config/content/mollom/blacklist/delete/url/' . $entry['url'])
+    );  
+  }
+  
+  $rows[] = array(
+    drupal_render($form['url']),
+    drupal_render($form['submit'])
+  );
+  
+  $output  = theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No URLs have been added to the blacklist.')));
+  $output .= drupal_render_children($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, &$form_state, $blacklist, $key) {
+  
+  $form['#mollom-blacklist-type'] = $blacklist;
+  $form['#mollom-blacklist-key'] = $key;
+
+  return confirm_form(
+    $form,
+    t('Are you sure you want to delete %key from the blacklist?', array('%key' => $key)),
+    'admin/config/content/mollom/blacklist',
+    t('This action cannot be undone.'),
+    t('Delete'), t('Cancel'),
+    'mollom_admin_blacklist_delete_submit');
+}
+
+/**
+ * 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') {
+    mollom('mollom.removeBlacklistText', array('text' => $form['#mollom-blacklist-key']));
+  }
+  else {
+    mollom('mollom.removeBlacklistURL', array('url' => $form['#mollom-blacklist-key']));
+  }
+  
+  // @todo: verify that the item was actually deleted.
+  drupal_set_message(t('The item has been removed from the blacklist.'));
+
+  $form_state['redirect'] = "admin/config/content/mollom/blacklist";
+}
+
+/**
  * Form builder; Global Mollom settings form.
  */
 function mollom_admin_settings($form, &$form_state) {
Index: mollom.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v
retrieving revision 1.18
diff -u -r1.18 mollom.module
--- mollom.module	30 Jan 2010 14:35:08 -0000	1.18
+++ mollom.module	30 Jan 2010 19:04:29 -0000
@@ -143,8 +143,8 @@
     'access arguments' => array('administer mollom'),
     'file' => 'mollom.admin.inc',
   );
-  $items['admin/config/content/mollom/list'] = array(
-    'title' => 'List',
+  $items['admin/config/content/mollom/forms'] = array(
+    'title' => 'Forms',
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'weight' => -10,
   );
@@ -171,6 +171,24 @@
     'type' => MENU_CALLBACK,
     'file' => 'mollom.admin.inc',
   );
+  $items['admin/config/content/mollom/blacklist'] = array(
+    'title' => 'Blacklist',
+    'description' => 'Configure word and URL blacklists.',
+    'page callback' => 'mollom_admin_blacklist',
+    'access arguments' => array('administer mollom'),
+    'type' => MENU_LOCAL_TASK,
+    'file' => 'mollom.admin.inc',
+  );
+  $items['admin/config/content/mollom/blacklist/delete'] = array(
+    'title' => 'Delete',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('mollom_admin_blacklist_delete', 6, 7),
+    'access arguments' => array('administer mollom'),
+    'type' => MENU_LOCAL_TASK,
+    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
+    'file' => 'mollom.admin.inc',
+    'weight' => 2,
+  );
   $items['admin/config/content/mollom/settings'] = array(
     'title' => 'Settings',
     'description' => 'Configure Mollom keys and global settings.',
@@ -204,6 +222,22 @@
 }
 
 /**
+ * Implements hook_theme().
+ */
+function mollom_theme() {
+  return array(
+    'mollom_admin_blacklist_text_form' => array(
+      'render element' => 'form',
+      'file' => 'mollom.admin.inc',
+    ),
+    'mollom_admin_blacklist_url_form' => array(
+      'render element' => 'form',
+      'file' => 'mollom.admin.inc',
+    ),
+  );
+}
+
+/**
  * Access callback; check if the module is configured.
  *
  * This function does not actually check whether Mollom keys are valid for the
