Index: modules/book.module =================================================================== RCS file: /cvs/drupal/drupal/modules/book.module,v retrieving revision 1.251 diff -u -F^f -r1.251 book.module --- modules/book.module 8 Sep 2004 15:38:25 -0000 1.251 +++ modules/book.module 13 Sep 2004 02:23:44 -0000 @@ -51,6 +51,12 @@ function book_access($op, $node) { return (user_access('maintain books') && !$node->moderate && $node->revision) || ($node->uid == $user->uid && user_access('edit own book pages')); } + + if ($op == 'comment') { + if (user_access('post comments') && $node->comment == 2) { + return TRUE; + } + } } /** Index: modules/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment.module,v retrieving revision 1.279 diff -u -F^f -r1.279 comment.module --- modules/comment.module 11 Sep 2004 13:45:23 -0000 1.279 +++ modules/comment.module 13 Sep 2004 02:23:44 -0000 @@ -192,7 +192,7 @@ function comment_link($type, $node = 0, } else { if ($node->comment == 2) { - if (user_access('post comments')) { + if (node_access('comment', $node)) { $links[] = l(t('add new comment'), "comment/reply/$node->nid", array('title' => t('Add a new comment to this page.'))); } else { @@ -207,7 +207,7 @@ function comment_link($type, $node = 0, // post comments, if this node is not read-only, and if the comment form isn't already shown if ($node->comment == 2 && variable_get('comment_form_location', 0) == 0) { - if (user_access('post comments')) { + if (node_access('comment', $node)) { $links[] = l(t('add new comment'), "comment/reply/$node->nid", array('title' => t('Share your thoughts and opinions related to this posting.')), NULL, 'comment'); } else { @@ -393,6 +393,8 @@ function comment_edit($cid) { function comment_reply($nid, $pid = NULL) { + $node = node_load(array('nid' => $nid)); + $output = ''; // are we posting or previewing a reply? @@ -426,10 +428,10 @@ function comment_reply($nid, $pid = NULL } // should we show the reply box? - if (node_comment_mode($nid) != 2) { + if ($node->comment != 2) { $output .= theme('box', t('Reply'), t("This discussion is closed: you can't post new comments.")); } - else if (user_access('post comments')) { + else if (node_access('comment', $node)) { $output .= theme('comment_form', array('pid' => $pid, 'nid' => $nid), t('Reply')); } else { @@ -533,7 +535,9 @@ function comment_preview($edit) { function comment_post($edit) { global $user; - if (user_access('post comments') && node_comment_mode($edit['nid']) == 2) { + $node = node_load(array('nid' => $edit['nid'])); + + if (node_access('comment', $node) && $node->comment == 2) { // Validate the comment's subject. If not specified, extract // one from the comment's body. @@ -706,13 +710,15 @@ function comment_links($comment, $return $links[] = l(t('parent'), comment_node_url(), NULL, NULL, "comment-$comment->cid"); } - if (node_comment_mode($comment->nid) == 2) { + $node = node_load(array('nid' => $comment->nid)); + + if ($node->comment == 2) { if (user_access('administer comments') && user_access('access administration pages')) { $links[] = l(t('delete'), "admin/comment/delete/$comment->cid"); $links[] = l(t('edit'), "admin/comment/edit/$comment->cid"); $links[] = l(t('reply'), "comment/reply/$comment->nid/$comment->cid"); } - else if (user_access('post comments')) { + else if (node_access('comment', $node)) { if (comment_access('edit', $comment)) { $links[] = l(t('edit'), "comment/edit/$comment->cid"); } @@ -932,7 +938,7 @@ function comment_render($node, $cid = 0) } // If enabled, show new comment form. - if (user_access('post comments') && node_comment_mode($nid) == 2 && variable_get('comment_form_location', 0)) { + if (node_access('comment', $node) && $node->comment == 2 && variable_get('comment_form_location', 0)) { $output .= theme('comment_form', array('nid' => $nid), t('Post new comment')); } } Index: modules/forum.module =================================================================== RCS file: /cvs/drupal/drupal/modules/forum.module,v retrieving revision 1.197 diff -u -F^f -r1.197 forum.module --- modules/forum.module 9 Sep 2004 05:51:08 -0000 1.197 +++ modules/forum.module 13 Sep 2004 02:23:44 -0000 @@ -44,6 +44,11 @@ function forum_access($op, $node) { if ($op == 'create') { return user_access('create forum topics'); } + if ($op == 'comment') { + if (user_access('post comments') && $node->comment == 2) { + return TRUE; + } + } } /** Index: modules/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node.module,v retrieving revision 1.397 diff -u -F^f -r1.397 node.module --- modules/node.module 9 Sep 2004 13:36:00 -0000 1.397 +++ modules/node.module 13 Sep 2004 02:23:45 -0000 @@ -594,17 +594,6 @@ function node_configure() { } /** - * Retrieve the comment mode for the given node ID (none, read, or read/write). - */ -function node_comment_mode($nid) { - static $comment_mode; - if (!isset($comment_mode[$nid])) { - $comment_mode[$nid] = db_result(db_query('SELECT comment FROM {node} WHERE nid = %d', $nid)); - } - return $comment_mode[$nid]; -} - -/** * Implementation of hook_link(). */ function node_link($type, $node = 0, $main = 0) { @@ -1587,6 +1576,7 @@ function node_nodeapi(&$node, $op, $arg * - "view" * - "update" * - "delete" + * - "comment" * @param $node * The node object (or node array) on which the operation is to be performed. * @return @@ -1630,6 +1620,11 @@ function node_access($op, $node = NULL) $result = db_query($sql, $node->nid); return (db_result($result)); } + + if ($op == 'comment' && $node->comment == 2 && user_access('post comments')) { + return TRUE; + } + return FALSE; } Index: modules/page.module =================================================================== RCS file: /cvs/drupal/drupal/modules/page.module,v retrieving revision 1.124 diff -u -F^f -r1.124 page.module --- modules/page.module 21 Aug 2004 06:42:36 -0000 1.124 +++ modules/page.module 13 Sep 2004 02:23:45 -0000 @@ -54,6 +54,12 @@ function page_access($op, $node) { return TRUE; } } + + if ($op == 'comment') { + if (user_access('post comments') && $node->comment == 2) { + return TRUE; + } + } } /** Index: modules/story.module =================================================================== RCS file: /cvs/drupal/drupal/modules/story.module,v retrieving revision 1.156 diff -u -F^f -r1.156 story.module --- modules/story.module 21 Aug 2004 06:42:37 -0000 1.156 +++ modules/story.module 13 Sep 2004 02:23:45 -0000 @@ -69,6 +69,12 @@ function story_access($op, $node) { return TRUE; } } + + if ($op == 'comment') { + if (user_access('post comments') && $node->comment == 2) { + return TRUE; + } + } } /**