Index: modules/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment.module,v retrieving revision 1.369 diff -u -r1.369 comment.module --- modules/comment.module 7 Sep 2005 20:45:53 -0000 1.369 +++ modules/comment.module 13 Sep 2005 18:36:14 -0000 @@ -144,6 +144,20 @@ 'callback' => 'node_page', 'type' => MENU_CALLBACK); } + if (((arg(0) == 'node') || (arg(0) == 'comment')) && is_numeric(arg(1))) { + $node = node_load(array('nid' => arg(1))); + if (variable_get('comment_task_'. $node->type, FALSE)) { + $title = t('discuss'); + $title .= " ($node->comment_count)"; + $items[] = array('path' => ('node/'. arg(1) .'/discuss'), 'title' => $title, 'weight' => 2, + 'callback' => 'comment_task', 'callback arguments' => array(arg(1), arg(3)), 'type' => MENU_LOCAL_TASK, + 'access' => node_access('view', $node) ); + } + } + if (arg(0) == 'comment' && is_numeric(arg(1))) { + $node = node_load(array('nid' => arg(1))); + $_GET['q'] = variable_get('comment_task_'. $node->type, FALSE) ? 'node/'. arg(1) .'/discuss': 'node/'. arg(1); + } } return $items; @@ -242,8 +256,10 @@ function comment_nodeapi(&$node, $op, $arg = 0) { switch ($op) { case 'settings': - return form_radios(t('Default comment setting'), 'comment_'. $node->type, variable_get('comment_'. $node->type, 2), array(t('Disabled'), t('Read only'), t('Read/Write')), t('Users with the administer comments permission will be able to override this setting.')); - + $output = form_radios(t('Default comment setting'), 'comment_'. $node->type, variable_get('comment_'. $node->type, 2), array(t('Disabled'), t('Read only'), t('Read/Write')), t('Users with the administer comments permission will be able to override this setting.')); + $output .= form_checkbox(t('Show comments on own tab'), 'comment_task_'. $node->type, 1, variable_get('comment_task_'. $node->type, FALSE), t('If unchecked, comments will be shown directly beneath the corresponding post, instead of in a tab called %discuss', array('%discuss' => theme('placeholder', t('discuss'))))); + return $output; + case 'fields': return array('comment'); @@ -388,7 +404,7 @@ return comment_preview($edit); } else { - drupal_goto("node/$nid#comment-$cid"); + drupal_goto("comment/$nid#comment-$cid"); } } else if ($_POST['op'] == t('Preview comment')) { @@ -751,6 +767,21 @@ return $links; } +function comment_task($nid, $cid = 0) { + $node = node_load(array('nid' => $nid)); + $links[] = l(t('add new comment'), "comment/reply/$nid#comment-form"); + $links[] = l(t('view post'), "node/$nid"); + $output = theme('item_list', $links); + if ($node->comment_count) { + $output .= comment_render($node, $cid); + } + else { + drupal_set_message(t('there are no comments for this post.')); + } + drupal_set_title($node->title); + return $output; +} + function comment_render($node, $cid = 0) { global $user; @@ -761,13 +792,12 @@ $comment_page = $_GET['comment_page']; $output = ''; - + $nid = $node->nid; + if (empty($nid)) { + $nid = 0; + } if (user_access('access comments')) { // Pre-process variables. - $nid = $node->nid; - if (empty($nid)) { - $nid = 0; - } if (empty($mode)) { $mode = $user->mode ? $user->mode : ($_SESSION['comment_mode'] ? $_SESSION['comment_mode'] : variable_get('comment_default_mode', 4)); @@ -950,10 +980,10 @@ } } - // If enabled, show new comment form. - if (user_access('post comments') && node_comment_mode($nid) == 2 && variable_get('comment_form_location', 0)) { - $output .= theme('comment_form', array('nid' => $nid), t('Post new comment')); - } + } + // If enabled, show new comment form. + if (user_access('post comments') && node_comment_mode($nid) == 2 && variable_get('comment_form_location', 0)) { + $output .= theme('comment_form', array('nid' => $nid), t('Post new comment')); } return $output; } @@ -1019,7 +1049,7 @@ while ($comment = db_fetch_object($result)) { $comment->name = $comment->uid ? $comment->registered_name : $comment->name; $rows[] = array( - l($comment->subject, "node/$comment->nid", array('title' => truncate_utf8($comment->comment, 128)), NULL, "comment-$comment->cid") ." ". theme('mark', node_mark($comment->nid, $comment->timestamp)), + l($comment->subject, "comment/$comment->nid", array('title' => truncate_utf8($comment->comment, 128)), NULL, "comment-$comment->cid") ." ". theme('mark', node_mark($comment->nid, $comment->timestamp)), theme('username', $comment), ($comment->status == COMMENT_PUBLISHED ? t('Published') : t('Not published')), format_date($comment->timestamp, 'small'), @@ -1529,7 +1559,7 @@ function theme_comment($comment, $links = 0) { $output = "
\n"; - $output .= '
'. l($comment->subject, $_GET['q'], NULL, NULL, "comment-$comment->cid") . ' ' . theme('mark', $comment->new) ."
\n"; + $output .= '
'. l($comment->subject, "comment/$comment->nid", NULL, NULL, "comment-$comment->cid") . ' ' . theme('mark', $comment->new) ."
\n"; $output .= '
'. $comment->moderation ."
\n"; $output .= '
'. t('by %a on %b', array('%a' => theme('username', $comment), '%b' => format_date($comment->timestamp))) ."
\n"; $output .= "
$comment->comment
\n"; Index: modules/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node.module,v retrieving revision 1.527 diff -u -r1.527 node.module --- modules/node.module 2 Sep 2005 02:11:41 -0000 1.527 +++ modules/node.module 13 Sep 2005 18:36:14 -0000 @@ -573,7 +573,7 @@ function node_show($node, $cid) { $output = node_view($node, FALSE, TRUE); - if (function_exists('comment_render') && $node->comment) { + if (function_exists('comment_render') && $node->comment && !variable_get('comment_task_'. $node->type, FALSE)) { $output .= comment_render($node, $cid); }