From 3534e8bc62a0f775a25a1d710f75be5035a80207 Mon Sep 17 00:00:00 2001 From: Gordon Heydon Date: Fri, 17 Feb 2012 11:17:13 +1100 Subject: [PATCH] Issue #655846 by gordon, indytechcook: Added Mollom Actions. --- mollom.module | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 78 insertions(+), 0 deletions(-) diff --git a/mollom.module b/mollom.module index c3bbc4f..8ed4ed1 100644 --- a/mollom.module +++ b/mollom.module @@ -3381,3 +3381,81 @@ function profile_mollom_form_info_alter(&$form_info, $form_id) { /** * @} End of "name mollom_profile". */ + + /** + * @name mollom_action Actions module integration for Mollom. + * @{ + */ + + /** + * 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', + 'configurable' => FALSE, + 'hooks' => array( + 'comment' => array('insert', 'update'), + ), + ), + // Delete action + 'mollom_delete_comment' => array( + 'description' => t('Report to Mollom as spam and delete'), + 'type' => 'comment', + 'configurable' => 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) { + module_load_include('inc', 'comment', 'comment.admin'); + + // First, send the proper information to the XML-RPC server: + if ($data = mollom_data_load('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.')); + } +} + +/** + * @} End of "name mollom_action". + */ \ No newline at end of file -- 1.7.5.4