Index: mollom.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/mollom/Attic/mollom.admin.inc,v retrieving revision 1.1.2.11 diff -u -p -r1.1.2.11 mollom.admin.inc --- mollom.admin.inc 7 Dec 2009 00:09:59 -0000 1.1.2.11 +++ mollom.admin.inc 10 Dec 2009 01:48:18 -0000 @@ -445,4 +445,3 @@ function mollom_reports_page() { } return drupal_render($form); } - Index: mollom.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v retrieving revision 1.2.2.104 diff -u -p -r1.2.2.104 mollom.module --- mollom.module 7 Dec 2009 00:09:59 -0000 1.2.2.104 +++ mollom.module 10 Dec 2009 01:48:21 -0000 @@ -1624,9 +1624,76 @@ function mollom_mail_alter(&$message) { $message['body'] .= "\n\n" . $report_link; } } -} + /** * @} End of "name mollom_contact". */ +/** + * Implementation of hook_action_info(). + */ +function mollom_action_info() { + return array( + // Unpublish Action + 'mollom_unpublish_comment' => array( + 'description' => t('Report to Mollom as spam and unpublish'), + 'type' => 'comment', + 'configuration' => FALSE, + 'hooks' => array( + 'comment' => array('insert', 'update'), + ), + ), + // Delete action + 'mollom_delete_comment' => array( + 'description' => t('Report to Mollom as spam and delete'), + 'type' => 'comment', + 'configuration' => FALSE, + 'hooks' => array( + 'comment' => array('insert', 'update'), + ), + ), + ); +} + +/** + * Action callback to report to mollom and unpublish. + */ +function mollom_unpublish_comment($comment, $context = array()) { + mollom_action_comment($comment, 'unpublish'); +} + +/** + * Action callback to report to mollom and delete. + */ +function mollom_delete_comment($comment, $context = array()) { + mollom_action_comment($comment, 'delete'); +} + +/** + * Preform action and send to Mollom as Spam + */ +function mollom_action_comment($comment, $op) { + + // First, send the proper information to the XML-RPC server: + if ($data = mollom_get_data('comment-'. $comment->cid)) { + mollom('mollom.sendFeedback', array('session_id' => $data->session, 'feedback' => 'spam')); + } + + // Second, perform the proper operation on the comments: + if ($op == 'unpublish') { + db_query("UPDATE {comments} SET status = %d WHERE cid = %d", COMMENT_NOT_PUBLISHED, $cid); + _comment_update_node_statistics($comment->nid); + } + elseif ($op == 'delete') { + _comment_delete_thread($comment); + _comment_update_node_statistics($comment->nid); + } + + if ($operation == 'delete') { + drupal_set_message(t('The selected comments have been reported as inappropriate and are deleted.')); + } + else { + drupal_set_message(t('The selected comments have been reported as inappropriate and are unpublished.')); + } +}