=== modified file 'akismet.module' --- akismet.module 2009-03-28 21:37:30 +0000 +++ akismet.module 2009-03-28 22:25:42 +0000 @@ -111,7 +111,7 @@ function akismet_requirements($phase) { */ function akismet_perm() { $perms = array('administer akismet settings'); - + foreach (node_get_types('names') as $type => $name) { $perms[] = 'moderate spam in nodes of type '. $name; } @@ -269,15 +269,13 @@ function akismet_menu() { 'file' => 'akismet.admin.inc', ); } - } - else { $item = array( 'title' => 'switch content status', 'page callback' => 'akismet_page', 'page arguments' => array(0, 1, 2, 3), 'load arguments' => array('%map', '%index'), 'access callback' => 'akismet_access_callback', - 'access argument' => array(0, 1, 2, 3), + 'access arguments' => array(0, 1, 2, 3), ); foreach (array('publish', 'unpublish', 'submit-spam', 'submit-ham') as $op) { $items['akismet/%akismet/%/'. $op] = $item; @@ -299,11 +297,11 @@ function akismet_load($arg, &$map, $inde } } if ($content_type == 'comment' && module_exists('comment')) { - if (!$map[2] = comment_load($map[2])) { + if (!$map[2] = _comment_load($map[2])) { return FALSE; } } - $op == $map[3]; + $op = $map[3]; if ($op == 'publish' || $op == 'unpublish') { $map[0] = 'akismet_callback_set_published_status'; } @@ -314,7 +312,7 @@ function akismet_load($arg, &$map, $inde } function akismet_access_callback($callback, $content_type, $object, $op) { - if ($content_type == 'node' && !node_access($map[2])) { + if ($content_type == 'node' && !node_access('update', $object)) { return FALSE; } if (function_exists($callback && !akismet_is_spam_moderator(akismet_content_get_moderator_type($content_type, $object)))) { @@ -383,13 +381,15 @@ function akismet_link($type, $content = * @param string Operation; it can be 'publish' or 'unpublish'. */ function akismet_callback_set_published_status($content_type, $object, $op) { - // Load the content (existence has been checked in hook_menu). - $content = akismet_content_load($content_type, $object); - +// TODO: Should we be passing the object around or just the ID, or should we have akismet_content_load at all? if ($content_type == 'node') { + // Load the content (existence has been checked in hook_menu). + $content = akismet_content_load($content_type, $object->nid); $is_published = ($content->status ? TRUE : FALSE); } else { // comment + // Load the content (existence has been checked in hook_menu). + $content = akismet_content_load($content_type, $object->cid); $is_published = ($content->status == COMMENT_PUBLISHED ? TRUE : FALSE); } @@ -418,15 +418,17 @@ function akismet_callback_set_published_ * @param string Operation; it can be 'submit-spam' or 'submit-ham'. */ function akismet_callback_set_spam_status($content_type, $object, $op) { - $is_spam = akismet_content_is_spam($content_type, $object); - - // Load the content (existence has been checked in hook_menu). - $content = akismet_content_load($content_type, $object); - +// TODO: again passing object around and reloading the object with akismet_content_load. if ($content_type == 'node') { + $is_spam = akismet_content_is_spam($content_type, $object->nid); + // Load the content (existence has been checked in hook_menu). + $content = akismet_content_load($content_type, $object->nid); $is_published = ($content->status ? TRUE : FALSE); } else { // comment + $is_spam = akismet_content_is_spam($content_type, $object->cid); + // Load the content (existence has been checked in hook_menu). + $content = akismet_content_load($content_type, $object->cid); $is_published = ($content->status == COMMENT_PUBLISHED ? TRUE : FALSE); } @@ -679,7 +681,7 @@ function _akismet_comment_form_validate( /** * Comment form submit callback; check for spam. */ -function _akismet_comment_form_submit($form, &$form_state, $original_submit_callback = NULL) { +function _akismet_comment_form_submit($form, &$form_state, $original_submit_callback = NULL) { // Our default destination. It doesn't need to override the original. $goto = NULL; @@ -744,10 +746,10 @@ function _akismet_comment_form_submit($f // Record the event to watchdog. if ($akismet_api_result == AKISMET_API_RESULT_ERROR) { - watchdog('content', 'Akismet service seems to be down, comment queued for manual approval: %subject', array('%subject' => $comment->subject), WATCHDOG_WARNING, l(t('view'), 'node/'. $comment->nid, NULL, NULL, 'comment-'. $comment->cid)); + watchdog('content', 'Akismet service seems to be down, comment queued for manual approval: %subject', array('%subject' => $comment->subject), WATCHDOG_WARNING, l(t('view'), 'node/'. $comment->nid, array('fragment' => 'comment-'. $comment->cid))); } else { - watchdog('content', 'Spam detected by Akismet in comment: %subject', array('%subject' => $comment->subject), WATCHDOG_WARNING, l(t('view'), 'node/'. $comment->nid, NULL, NULL, 'comment-'. $comment->cid)); + watchdog('content', 'Spam detected by Akismet in comment: %subject', array('%subject' => $comment->subject), WATCHDOG_WARNING, l(t('view'), 'node/'. $comment->nid, array('fragment' => 'comment-'. $comment->cid))); // If requested to, generate a delay so the spammer has to wait for a while. if (($seconds = variable_get('akismet_antispambot_delay', 60)) > 0) { sleep($seconds); @@ -1017,7 +1019,7 @@ function akismet_notify_moderators($cont $site_name = variable_get('site_name', t('Drupal')); if ($content_type == 'comment') { if (!($node = akismet_content_load('node', $content->nid))) { - watchdog('akismet', 'An error has ocurred while trying to notify moderators about a comment. The associated node could not be loaded.', array(), WATCHDOG_NOTICE, l(t('view'), 'node/'. $content->nid, NULL, NULL, 'comment-'. $content->cid)); + watchdog('akismet', 'An error has ocurred while trying to notify moderators about a comment. The associated node could not be loaded.', array(), WATCHDOG_NOTICE, l(t('view'), 'node/'. $content->nid, array('fragment' => 'comment-'. $content->cid))); return; } $message_args = array( @@ -1438,7 +1440,7 @@ function akismet_content_spam_operation( else { // comment $content_id = $content->cid; $content_title = $content->subject; - $content_link = l(t('view'), 'node/'. $content->nid, NULL, NULL, 'comment-'. $content->cid); + $content_link = l(t('view'), 'node/'. $content->nid, array('fragment' => 'comment-'. $content->cid)); $user_mail = $content->mail; } @@ -1514,7 +1516,7 @@ function akismet_content_publish_operati if ($log_action) { $action = ($op == 'publish' ? t('Comment published') : t('Comment unpublished')); - watchdog('content', '@action: %subject', array('@action' => $action, '%subject' => $content->subject), WATCHDOG_NOTICE, l(t('view'), 'node/'. $content->nid, NULL, NULL, 'comment-'. $content->cid)); + watchdog('content', '@action: %subject', array('@action' => $action, '%subject' => $content->subject), WATCHDOG_NOTICE, l(t('view'), 'node/'. $content->nid, array('fragment' => 'comment-'. $content->cid))); } }