Index: database/database.mysql =================================================================== RCS file: /cvs/drupal/drupal/database/database.mysql,v retrieving revision 1.180 diff -u -F^f -r1.180 database.mysql --- database/database.mysql 24 Apr 2005 13:49:58 -0000 1.180 +++ database/database.mysql 27 Apr 2005 15:32:33 -0000 @@ -438,6 +438,7 @@ grant_view tinyint(1) unsigned NOT NULL default '0', grant_update tinyint(1) unsigned NOT NULL default '0', grant_delete tinyint(1) unsigned NOT NULL default '0', + grant_comment tinyint(1) unsigned NOT NULL default '0', PRIMARY KEY (nid,gid,realm) ) TYPE=MyISAM; Index: database/database.pgsql =================================================================== RCS file: /cvs/drupal/drupal/database/database.pgsql,v retrieving revision 1.117 diff -u -F^f -r1.117 database.pgsql --- database/database.pgsql 24 Apr 2005 13:49:58 -0000 1.117 +++ database/database.pgsql 27 Apr 2005 15:32:33 -0000 @@ -440,6 +440,7 @@ grant_view smallint NOT NULL default '0', grant_update smallint NOT NULL default '0', grant_delete smallint NOT NULL default '0', + grant_comment smallint NOT NULL default '0', PRIMARY KEY (nid,gid,realm) ); Index: modules/blog.module =================================================================== RCS file: /cvs/drupal/drupal/modules/blog.module,v retrieving revision 1.215 diff -u -F^f -r1.215 blog.module --- modules/blog.module 24 Apr 2005 16:34:32 -0000 1.215 +++ modules/blog.module 27 Apr 2005 15:32:33 -0000 @@ -35,6 +35,12 @@ function blog_access($op, $node) { return TRUE; } } + + if ($op == 'comment') { + if (user_access('post comments') && $node->comment == 2) { + return TRUE; + } + } } /** Index: modules/book.module =================================================================== RCS file: /cvs/drupal/drupal/modules/book.module,v retrieving revision 1.293 diff -u -F^f -r1.293 book.module --- modules/book.module 24 Apr 2005 20:57:38 -0000 1.293 +++ modules/book.module 27 Apr 2005 15:32:33 -0000 @@ -46,6 +46,12 @@ function book_access($op, $node) { // do nothing. node-access() will determine further access } } + + 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.350 diff -u -F^f -r1.350 comment.module --- modules/comment.module 24 Apr 2005 16:34:33 -0000 1.350 +++ modules/comment.module 27 Apr 2005 15:32:33 -0000 @@ -200,7 +200,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 { @@ -215,7 +215,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 { @@ -373,6 +373,8 @@ function comment_reply($nid, $pid = NULL $node = node_load(array('nid' => $nid)); menu_set_location(array(array('path' => "node/$nid", 'title' => $node->title), array('path' => "comment/reply/$nid"))); + $node = node_load(array('nid' => $nid)); + $output = ''; // are we posting or previewing a reply? @@ -406,10 +408,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 { @@ -518,7 +520,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) { if (!form_get_errors()) { // Check for duplicate comments. Note that we have to use the // validated/filtered data to perform such check. @@ -677,13 +681,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"); } @@ -901,7 +907,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.248 diff -u -F^f -r1.248 forum.module --- modules/forum.module 24 Apr 2005 16:34:33 -0000 1.248 +++ modules/forum.module 27 Apr 2005 15:32:33 -0000 @@ -48,6 +48,11 @@ function forum_access($op, $node) { return TRUE; } } + 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.487 diff -u -F^f -r1.487 node.module --- modules/node.module 24 Apr 2005 16:34:34 -0000 1.487 +++ modules/node.module 27 Apr 2005 15:32:33 -0000 @@ -618,17 +618,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) { @@ -1829,6 +1818,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. * @param $uid @@ -1874,6 +1864,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.132 diff -u -F^f -r1.132 page.module --- modules/page.module 8 Feb 2005 19:44:39 -0000 1.132 +++ modules/page.module 27 Apr 2005 15:32:33 -0000 @@ -47,6 +47,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.167 diff -u -F^f -r1.167 story.module --- modules/story.module 1 Apr 2005 15:55:01 -0000 1.167 +++ modules/story.module 27 Apr 2005 15:32:33 -0000 @@ -47,6 +47,12 @@ function story_access($op, $node) { return TRUE; } } + + if ($op == 'comment') { + if (user_access('post comments') && $node->comment == 2) { + return TRUE; + } + } } /**