diff options
-rw-r--r-- | includes/menu.inc | 8 | ||||
-rw-r--r-- | modules/comment.module | 24 | ||||
-rw-r--r-- | modules/comment/comment.module | 24 |
3 files changed, 36 insertions, 20 deletions
diff --git a/includes/menu.inc b/includes/menu.inc index ca2088fef..7cb17459a 100644 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -135,7 +135,8 @@ function menu_tree($parent = "") { } if ($_list[$parent]["children"]) { - $output = "\n<ul>\n"; + $output = ""; + usort($_list[$parent]["children"], "_menu_sort"); foreach ($_list[$parent]["children"] as $item) { /* @@ -153,7 +154,10 @@ function menu_tree($parent = "") { $output .= "</li>\n"; } } - $output .= "</ul>\n"; + + if ($output != '') { + $output = "\n<ul>\n$output\n</ul>\n"; + } } return $output; 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 "<a id=\"comment\"></a>\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 "<form method=\"post\" action=\"". url("comment") ."\"><div>\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 "<div align=\"center\">". form_submit(t("Moderate comments")) ."</div><br />"; } print "</div></form>"; - 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 "<form method=\"post\" action=\"". url("comment") ."\"><div>\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 .= " <option value=\"$key\"". ($order == $key ? " selected=\"selected\"" : "") .">$value</option>\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) { diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 3d5f2b6f2..4b700fd05 100644 --- a/modules/comment/comment.module +++ b/modules/comment/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 "<a id=\"comment\"></a>\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 "<form method=\"post\" action=\"". url("comment") ."\"><div>\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 "<div align=\"center\">". form_submit(t("Moderate comments")) ."</div><br />"; } print "</div></form>"; - 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 "<form method=\"post\" action=\"". url("comment") ."\"><div>\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 .= " <option value=\"$key\"". ($order == $key ? " selected=\"selected\"" : "") .">$value</option>\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) { |