Index: comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment.module,v retrieving revision 1.277 diff -u -F^f -r1.277 comment.module --- comment.module 22 Aug 2004 17:03:41 -0000 1.277 +++ comment.module 29 Aug 2004 06:56: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? @@ -406,7 +408,6 @@ function comment_reply($nid, $pid = NULL $edit = $_POST['edit']; comment_validate_form($edit); print theme('page', comment_preview($edit), t('Preview comment')); - } // or are we merely showing the form? @@ -426,10 +427,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 +534,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 +709,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 +937,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: node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node.module,v retrieving revision 1.393 diff -u -F^f -r1.393 node.module --- node.module 25 Aug 2004 16:41:30 -0000 1.393 +++ node.module 29 Aug 2004 06:56:46 -0000 @@ -595,17 +595,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) { @@ -1586,6 +1575,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 @@ -1629,6 +1619,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; }