From 5d684e108eae96336f4e37b7648eadbf3bacf5a6 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 14 Oct 2003 18:08:33 +0000 Subject: - Bugfix: stopped the menu system from generating empty lists (). Patch by Nick (CodeMonkeyX). - Bugfix: anonymous users could not change comment settings. Patch by Bart. - Bugfix: the comment control form always showed "order by date - newest first", no matter what order you selected. Patch by Bart. - Small usability improvement: only display comment controls when there are comments to show. Patch by Bart. --- modules/comment.module | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'modules/comment.module') diff --git a/modules/comment.module b/modules/comment.module index 3d5f2b6f2..4b700fd05 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -578,20 +578,20 @@ function comment_render($node, $cid = 0) { } if (empty($mode)) { - $mode = $user->mode ? $user->mode : variable_get("comment_default_mode", 4); + $mode = $user->mode ? $user->mode : ($_SESSION["comment_mode"] ? $_SESSION["comment_mode"] : variable_get("comment_default_mode", 4)); } if (empty($order)) { - $order = $user->sort ? $user->sort : variable_get("comment_default_order", 1); + $order = $user->sort ? $user->sort : ($_SESSION["comment_sort"] ? $_SESSION["comment_sort"] : variable_get("comment_default_order", 1)); } if (empty($threshold)) { - $threshold = $user->uid ? $user->threshold : variable_get("comment_default_threshold", 0); + $threshold = $user->threshold ? $user->threshold : ($_SESSION["comment_threshold"] ? $_SESSION["comment_threshold"] : variable_get("comment_default_threshold", 0)); } $threshold_min = db_result(db_query("SELECT minimum FROM {moderation_filters} WHERE fid = %d", $threshold)); if (empty($comments_per_page)) { - $comments_per_page = $user->comments_per_page ? $user->comments_per_page : variable_get("comment_default_per_page", "50"); + $comments_per_page = $user->comments_per_page ? $user->comments_per_page : ($_SESSION["comment_comments_per_page"] ? $_SESSION["comment_comments_per_page"] : variable_get("comment_default_per_page", "50")); } print "\n"; @@ -720,7 +720,7 @@ function comment_render($node, $cid = 0) { $result = pager_query($query, $comments_per_page, 0, "SELECT COUNT(*) FROM {comments} WHERE nid = '". check_query($nid) ."'"); - if ((variable_get("comment_controls", 0) == 0) || (variable_get("comment_controls", 0) == 2)) { + if (db_num_rows($result) && (variable_get("comment_controls", 0) == 0 || variable_get("comment_controls", 0) == 2)) { print "
\n"; theme("comment_controls", $threshold, $mode, $order, $comments_per_page); print form_hidden("nid", $nid); @@ -755,13 +755,13 @@ function comment_render($node, $cid = 0) { print $pager; } - if (comment_user_can_moderate($node)) { + if (db_num_rows($result) && comment_user_can_moderate($node)) { print "
". form_submit(t("Moderate comments")) ."

"; } print "
"; - if ((variable_get("comment_controls", 0) == 1) || (variable_get("comment_controls", 0) == 2)) { + if (db_num_rows($result) && (variable_get("comment_controls", 0) == 1 || variable_get("comment_controls", 0) == 2)) { print "
\n"; theme("comment_controls", $threshold, $mode, $order, $comments_per_page); print form_hidden("nid", $nid); @@ -1276,8 +1276,8 @@ function comment_mode_form($mode) { function comment_order_form($order) { - $order = _comment_get_orders(); - foreach ($order as $key=>$value) { + $orders = _comment_get_orders(); + foreach ($orders as $key=>$value) { $options .= " \n"; } @@ -1490,6 +1490,12 @@ function comment_save_settings($mode, $order, $threshold, $comments_per_page) { if ($user->uid) { $user = user_save($user, array("mode" => $mode, "sort" => $order, "threshold" => $threshold, "comments_per_page" => $comments_per_page)); } + else { + $_SESSION["comment_mode"] = $mode; + $_SESSION["comment_sort"] = $order; + $_SESSION["comment_threshold"] = $threshold; + $_SESSION["comment_comments_per_page"] = $comments_per_page; + } } function comment_num_all($nid) { -- cgit v1.2.3