Index: content/spam_content_comment.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/spam/content/Attic/spam_content_comment.inc,v retrieving revision 1.1.2.8 diff -u -r1.1.2.8 spam_content_comment.inc --- content/spam_content_comment.inc 10 Jan 2011 09:48:23 -0000 1.1.2.8 +++ content/spam_content_comment.inc 11 Jan 2011 07:09:37 -0000 @@ -408,6 +408,8 @@ spam_mark_as_not_spam('comment', $cid); // record a message noting the action taken watchdog('action', 'Marked comment %cid as spam.', array('%cid' => $cid) ); + } else { + watchdog('action', '"Mark comment as spam" action called without valid cid', array(), WATCHDOG_WARNING); } } @@ -428,5 +430,26 @@ spam_mark_as_not_spam('comment', $cid); // record a message noting the action taken watchdog('action', 'Marked comment %cid as not spam.', array('%cid' => $cid) ); + } else { + watchdog('action', '"Mark comment as not spam" action called without valid cid', array(), WATCHDOG_WARNING); + } +} + +/** +* Implementation of a Drupal action. +* Check comment for spam; mark accordingly. +*/ +function spam_check_comment_for_spam_action(&$object, $context = array()) { + // get the object if we don't have it for whatever reason + if (!($object) && isset($context['cid'])) { + $object = db_fetch_object(db_query('SELECT * FROM {comments} WHERE cid = %d', $context['cid']));; + } + // make sure we have an object + if ($object) { + spam_scan($object, 'comment'); + // record a message noting the action taken + watchdog('action', 'Checked comment %cid for spam.', array('%cid' => $object->cid)); + } else { + watchdog('action', '"Check comment for spam" action called without valid comment object', array(), WATCHDOG_WARNING); } } Index: content/spam_content_node.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/spam/content/Attic/spam_content_node.inc,v retrieving revision 1.1.2.5 diff -u -r1.1.2.5 spam_content_node.inc --- content/spam_content_node.inc 10 Jan 2011 09:48:23 -0000 1.1.2.5 +++ content/spam_content_node.inc 11 Jan 2011 07:09:30 -0000 @@ -217,6 +217,8 @@ spam_mark_as_not_spam('node', $nid); // record a message noting the action taken watchdog('action', 'Marked node %nid as spam.', array('%nid' => $nid) ); + } else { + watchdog('action', '"Mark node as spam" action called without valid nid', array(), WATCHDOG_WARNING); } } @@ -237,5 +239,27 @@ spam_mark_as_not_spam('node', $nid); // record a message noting the action taken watchdog('action', 'Marked node %nid as not spam.', array('%nid' => $nid) ); + } else { + watchdog('action', '"Mark node as not spam" action called without valid nid', array(), WATCHDOG_WARNING); } } + +/** +* Implementation of a Drupal action. +* Check node for spam; mark accordingly. +*/ +function spam_check_node_for_spam_action(&$object, $context = array()) { + // get the object if we don't have it for whatever reason + if (!($object) && isset($context['nid'])) { + $object = node_load($context['nid']); + } + // make sure we have an object + if ($object) { + spam_scan($object, 'node'); + // record a message noting the action taken + watchdog('action', 'Checked node %nid for spam.', array('%nid' => $object->nid)); + } else { + watchdog('action', '"Check node for spam" action called without valid node object', array(), WATCHDOG_WARNING); + } +} + Index: content/spam_content_user.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/spam/content/Attic/spam_content_user.inc,v retrieving revision 1.1.2.5 diff -u -r1.1.2.5 spam_content_user.inc --- content/spam_content_user.inc 10 Jan 2011 09:48:23 -0000 1.1.2.5 +++ content/spam_content_user.inc 11 Jan 2011 07:09:34 -0000 @@ -271,6 +271,8 @@ spam_mark_as_not_spam('user', $uid); // record a message noting the action taken watchdog('action', 'Marked user %uid as not spam.', array('%uid' => $uid) ); + } else { + watchdog('action', '"Mark user as spam" action called without valid uid', array(), WATCHDOG_WARNING); } } @@ -291,5 +293,27 @@ spam_mark_as_not_spam('user', $uid); // record a message noting the action taken watchdog('action', 'Marked user %uid as not spam.', array('%uid' => $uid) ); + } else { + watchdog('action', '"Mark user as not spam" action called without valid uid', array(), WATCHDOG_WARNING); } } + +/** +* Implementation of a Drupal action. +* Check user for spam; mark accordingly. +*/ +function spam_check_user_for_spam_action(&$object, $context = array()) { + // get the object if we don't have it for whatever reason + if (!($object) && isset($context['uid'])) { + $object = user_load($context['uid']); + } + // make sure we have an object + if ($object) { + spam_scan($object, 'user'); + // record a message noting the action taken + watchdog('action', 'Checked user %uid for spam.', array('%uid' => $object->uid)); + } else { + watchdog('action', '"Check user for spam" action called without valid user object', array(), WATCHDOG_WARNING); + } +} + Index: spam.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/spam/spam.module,v retrieving revision 1.51.4.1.2.41.2.30.2.36 diff -u -r1.51.4.1.2.41.2.30.2.36 spam.module --- spam.module 10 Jan 2011 09:48:23 -0000 1.51.4.1.2.41.2.30.2.36 +++ spam.module 11 Jan 2011 00:13:08 -0000 @@ -84,6 +84,8 @@ /** * API call to simply test if content is spam or not. No action is taken. + * (incorrect? spam_mark_as_spam is called, meaning the content is marked as + * spam if the threshold is exceeded.) */ function spam_content_is_spam($content, $type, $extra = array(), $filter_test = FALSE) { if (user_access('bypass filters')) { @@ -945,8 +947,8 @@ /** * As the spam module isn't a core Drupal module, many important modules won't * utilize its API. We define the appropriate hooks for these modules in the - * modules/ subdirectory. For example, we define the spam api hooks for the - * node module in modules/spam_node.inc. + * content/ subdirectory. For example, we define the spam api hooks for the + * node module in content/spam_content_node.inc. */ function spam_init() { $path = drupal_get_path('module', 'spam') .'/content'; @@ -2111,6 +2113,12 @@ 'configurable' => FALSE, 'hooks' => array( 'any' => TRUE ) ); + $spam_actions['spam_check_'.$type.'_for_spam_action'] = array( + 'description' => t('Check '.$type.' for spam, mark accordingly'), + 'type' => $type, + 'configurable' => FALSE, + 'hooks' => array( 'any' => TRUE ) + ); } } return $spam_actions;