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 17 Jan 2011 11:21:42 -0000 @@ -409,6 +409,9 @@ // 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); + } } /** @@ -429,4 +432,27 @@ // 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 17 Jan 2011 11:21:42 -0000 @@ -218,6 +218,9 @@ // 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); + } } /** @@ -238,4 +241,28 @@ // 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 17 Jan 2011 11:21:42 -0000 @@ -272,6 +272,9 @@ // 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); + } } /** @@ -292,4 +295,28 @@ // 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 17 Jan 2011 11:21:42 -0000 @@ -84,6 +84,9 @@ /** * 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.) + * TODO: ref #1021696 */ function spam_content_is_spam($content, $type, $extra = array(), $filter_test = FALSE) { if (user_access('bypass filters')) { @@ -945,8 +948,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'; @@ -2099,14 +2102,20 @@ $spam_types = array( 'node', 'comment', 'user' ); foreach ($spam_types as $type) { if (module_exists($type)) { - $spam_actions['spam_mark_'.$type.'_as_spam_action'] = array( - 'description' => t('Mark '.$type.' as spam'), + $spam_actions['spam_mark_' . $type . '_as_spam_action'] = array( + 'description' => t('Mark ' . $type . ' as spam'), 'type' => $type, 'configurable' => FALSE, 'hooks' => array( 'any' => TRUE ) ); - $spam_actions['spam_mark_'.$type.'_as_not_spam_action'] = array( - 'description' => t('Mark '.$type.' as not spam'), + $spam_actions['spam_mark_' . $type . '_as_not_spam_action'] = array( + 'description' => t('Mark ' . $type . ' as not spam'), + 'type' => $type, + '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 )