Index: modules/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment.module,v retrieving revision 1.369 diff -u -F^f -r1.369 comment.module --- modules/comment.module 7 Sep 2005 20:45:53 -0000 1.369 +++ modules/comment.module 12 Sep 2005 22:22:18 -0000 @@ -144,6 +144,18 @@ function comment_menu($may_cache) { 'callback' => 'node_page', 'type' => MENU_CALLBACK); } + if (((arg(0) == 'node') || (arg(0) == 'comment')) && is_numeric(arg(1)) && variable_get('comment_task', FALSE)) { + $node = node_load(array('nid' => arg(1))); + $title = t('discuss'); + $num = comment_num_all(arg(1)); + $title .= " ($num)"; + $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' => user_access('access '. node_invoke($node, 'node_name') .' comments') ); + } + if (arg(0) == 'comment' && is_numeric(arg(1))) { + $_GET['q'] = variable_get('comment_task', FALSE) ? 'node/'. arg(1) .'/discuss': 'node/'. arg(1); + } } return $items; @@ -312,6 +324,7 @@ function comment_configure() { } $group = form_radios(t('Default display mode'), 'comment_default_mode', variable_get('comment_default_mode', 4), _comment_get_modes(), t('The default view for comments. Expanded views display the body of the comment. Threaded views keep replies together.')); + $group .= form_checkbox(t('Show comments on own tab when viewing a post.'), 'comment_task', 1, variable_get('comment_task', FALSE)); $group .= form_radios(t('Default display order'), 'comment_default_order', variable_get('comment_default_order', 1), _comment_get_orders(), t('The default sorting for new users and anonymous users while viewing comments. These users may change their view using the comment control panel. For registered users, this change is remembered as a persistent user preference.')); $group .= form_select(t('Default comments per page'), 'comment_default_per_page', variable_get('comment_default_per_page', '50'), _comment_per_page(), t('Default number of comments for each page: more comments are distributed in several pages.')); $group .= form_radios(t('Comment controls'), 'comment_controls', variable_get('comment_controls', 3), array(t('Display above the comments'), t('Display below the comments'), t('Display above and below the comments'), t('Do not display')), t('Position of the comment controls box. The comment controls let the user change the default display mode and display order of comments.')); @@ -388,7 +401,7 @@ function comment_reply($nid, $pid = NULL 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 +764,16 @@ function comment_links($comment, $return return $links; } +function comment_task($nid, $cid = 0) { + $node = node_load(array('nid' => $nid)); + $output = comment_render($node, $cid); + // if (!$output) { + // drupal_set_message(t('there are no comments for this post.')); + // } + drupal_set_title($node->title); + print theme('page', $output); +} + function comment_render($node, $cid = 0) { global $user; @@ -761,13 +784,13 @@ function comment_render($node, $cid = 0) $comment_page = $_GET['comment_page']; $output = ''; - + $nid = $node->nid; + if (empty($nid)) { + $nid = 0; + } if (user_access('access comments')) { + && (!variable_get('comment_task', FALSE) || arg(2) == 'discuss')) { // 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 +973,10 @@ 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)) { - $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 +1042,7 @@ function comment_admin_overview($type = 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 +1552,7 @@ function comment_moderation_form($commen function theme_comment($comment, $links = 0) { $output = "