summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2006-04-27 22:03:20 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2006-04-27 22:03:20 +0000
commit546f5930a471af31b7c50a52e0a5a6088acb9b0e (patch)
tree95906a950f8590928c23c4b688c6bd5d8b4477f5
parentca9293b3ee13390349521c83e9bb175d4c95009a (diff)
downloadbrdo-546f5930a471af31b7c50a52e0a5a6088acb9b0e.tar.gz
brdo-546f5930a471af31b7c50a52e0a5a6088acb9b0e.tar.bz2
#58953: Flat collapsed mode and newest first order broken
-rw-r--r--database/updates.inc10
-rw-r--r--modules/comment.module78
-rw-r--r--modules/comment/comment.module78
3 files changed, 107 insertions, 59 deletions
diff --git a/database/updates.inc b/database/updates.inc
index f3b3eb863..5d65503cd 100644
--- a/database/updates.inc
+++ b/database/updates.inc
@@ -1689,15 +1689,7 @@ function system_update_173() {
}
function system_update_174() {
- // update comments system variables on upgrade.
- $mode = variable_get('comment_default_mode', 4);
- if ($mode > 0) {
- variable_set('comment_default_mode', $mode - 1);
- }
- $order = variable_get('comment_default_order', 1);
- if ($order > 0) {
- variable_set('comment_default_order', $order - 1);
- }
+ // This update (update comments system variables on upgrade) has been removed.
return array();
}
diff --git a/modules/comment.module b/modules/comment.module
index afaf5492f..83fae38b7 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -19,16 +19,16 @@ define('COMMENT_NOT_PUBLISHED', 1);
/**
* Constants to define the viewing modes for comment listings
*/
-define('COMMENT_MODE_FLAT_COLLAPSED', 0);
-define('COMMENT_MODE_FLAT_EXPANDED', 1);
-define('COMMENT_MODE_THREADED_COLLAPSED', 2);
-define('COMMENT_MODE_THREADED_EXPANDED', 3);
+define('COMMENT_MODE_FLAT_COLLAPSED', 1);
+define('COMMENT_MODE_FLAT_EXPANDED', 2);
+define('COMMENT_MODE_THREADED_COLLAPSED', 3);
+define('COMMENT_MODE_THREADED_EXPANDED', 4);
/**
* Constants to define the viewing orders for comment listings
*/
-define('COMMENT_ORDER_NEWEST_FIRST', 0);
-define('COMMENT_ORDER_OLDEST_FIRST', 1);
+define('COMMENT_ORDER_NEWEST_FIRST', 1);
+define('COMMENT_ORDER_OLDEST_FIRST', 2);
/**
* Constants to define the position of the comment controls
@@ -696,11 +696,6 @@ function comment_links($comment, $return = 1) {
function comment_render($node, $cid = 0) {
global $user;
- $mode = $_GET['mode'];
- $order = $_GET['order'];
- $comments_per_page = $_GET['comments_per_page'];
- $comment_page = $_GET['comment_page'];
-
$output = '';
if (user_access('access comments')) {
@@ -710,17 +705,9 @@ function comment_render($node, $cid = 0) {
$nid = 0;
}
- if (!isset($mode)) {
- $mode = isset($user->mode) ? $user->mode : (isset($_SESSION['comment_mode']) ? $_SESSION['comment_mode'] : variable_get('comment_default_mode', COMMENT_MODE_THREADED_EXPANDED));
- }
-
- if (!isset($order)) {
- $order = isset($user->sort) ? $user->sort : (isset($_SESSION['comment_sort']) ? $_SESSION['comment_sort'] : variable_get('comment_default_order', COMMENT_ORDER_NEWEST_FIRST));
- }
-
- if (empty($comments_per_page)) {
- $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'));
- }
+ $mode = _comment_get_display_setting('mode');
+ $order = _comment_get_display_setting('sort');
+ $comments_per_page = _comment_get_display_setting('comments_per_page');
$output .= "<a id=\"comment\"></a>\n";
@@ -866,9 +853,7 @@ function comment_render($node, $cid = 0) {
}
}
- // Use the standard pager; $pager_total is the number of returned rows,
- // is global and defined in pager.inc.
- $output .= theme('pager', NULL, $comments_per_page, 0, array('comments_per_page' => $comments_per_page));
+ $output .= theme('pager', NULL, $comments_per_page, 0);
if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_BELOW || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
$output .= comment_controls($mode, $order, $comments_per_page);
@@ -1673,6 +1658,49 @@ function _comment_per_page() {
}
/**
+ * Return a current comment display setting
+ *
+ * $setting can be one of these: 'mode', 'sort', 'comments_per_page'
+ */
+function _comment_get_display_setting($setting) {
+ global $user;
+
+ if ($_GET[$setting]) {
+ $value = $_GET[$setting];
+ }
+ else {
+ // get the setting's site default
+ switch ($setting) {
+ case 'mode':
+ $default = variable_get('comment_default_mode', COMMENT_MODE_THREADED_EXPANDED);
+ break;
+ case 'sort':
+ $default = variable_get('comment_default_order', COMMENT_ORDER_NEWEST_FIRST);
+ break;
+ case 'comments_per_page':
+ $default = variable_get('comment_default_per_page', '50');
+ }
+ if (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_HIDDEN) {
+ // if comment controls are disabled use site default
+ $value = $default;
+ }
+ else {
+ // otherwise use the user's setting if set
+ if ($user->$setting) {
+ $value = $user->$setting;
+ }
+ else if ($_SESSION['comment_'. $setting]) {
+ $value = $_SESSION['comment_'. $setting];
+ }
+ else {
+ $value = $default;
+ }
+ }
+ }
+ return $value;
+}
+
+/**
* Updates the comment statistics for a given node. This should be called any
* time a comment is added, deleted, or updated.
*
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index afaf5492f..83fae38b7 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -19,16 +19,16 @@ define('COMMENT_NOT_PUBLISHED', 1);
/**
* Constants to define the viewing modes for comment listings
*/
-define('COMMENT_MODE_FLAT_COLLAPSED', 0);
-define('COMMENT_MODE_FLAT_EXPANDED', 1);
-define('COMMENT_MODE_THREADED_COLLAPSED', 2);
-define('COMMENT_MODE_THREADED_EXPANDED', 3);
+define('COMMENT_MODE_FLAT_COLLAPSED', 1);
+define('COMMENT_MODE_FLAT_EXPANDED', 2);
+define('COMMENT_MODE_THREADED_COLLAPSED', 3);
+define('COMMENT_MODE_THREADED_EXPANDED', 4);
/**
* Constants to define the viewing orders for comment listings
*/
-define('COMMENT_ORDER_NEWEST_FIRST', 0);
-define('COMMENT_ORDER_OLDEST_FIRST', 1);
+define('COMMENT_ORDER_NEWEST_FIRST', 1);
+define('COMMENT_ORDER_OLDEST_FIRST', 2);
/**
* Constants to define the position of the comment controls
@@ -696,11 +696,6 @@ function comment_links($comment, $return = 1) {
function comment_render($node, $cid = 0) {
global $user;
- $mode = $_GET['mode'];
- $order = $_GET['order'];
- $comments_per_page = $_GET['comments_per_page'];
- $comment_page = $_GET['comment_page'];
-
$output = '';
if (user_access('access comments')) {
@@ -710,17 +705,9 @@ function comment_render($node, $cid = 0) {
$nid = 0;
}
- if (!isset($mode)) {
- $mode = isset($user->mode) ? $user->mode : (isset($_SESSION['comment_mode']) ? $_SESSION['comment_mode'] : variable_get('comment_default_mode', COMMENT_MODE_THREADED_EXPANDED));
- }
-
- if (!isset($order)) {
- $order = isset($user->sort) ? $user->sort : (isset($_SESSION['comment_sort']) ? $_SESSION['comment_sort'] : variable_get('comment_default_order', COMMENT_ORDER_NEWEST_FIRST));
- }
-
- if (empty($comments_per_page)) {
- $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'));
- }
+ $mode = _comment_get_display_setting('mode');
+ $order = _comment_get_display_setting('sort');
+ $comments_per_page = _comment_get_display_setting('comments_per_page');
$output .= "<a id=\"comment\"></a>\n";
@@ -866,9 +853,7 @@ function comment_render($node, $cid = 0) {
}
}
- // Use the standard pager; $pager_total is the number of returned rows,
- // is global and defined in pager.inc.
- $output .= theme('pager', NULL, $comments_per_page, 0, array('comments_per_page' => $comments_per_page));
+ $output .= theme('pager', NULL, $comments_per_page, 0);
if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_BELOW || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
$output .= comment_controls($mode, $order, $comments_per_page);
@@ -1673,6 +1658,49 @@ function _comment_per_page() {
}
/**
+ * Return a current comment display setting
+ *
+ * $setting can be one of these: 'mode', 'sort', 'comments_per_page'
+ */
+function _comment_get_display_setting($setting) {
+ global $user;
+
+ if ($_GET[$setting]) {
+ $value = $_GET[$setting];
+ }
+ else {
+ // get the setting's site default
+ switch ($setting) {
+ case 'mode':
+ $default = variable_get('comment_default_mode', COMMENT_MODE_THREADED_EXPANDED);
+ break;
+ case 'sort':
+ $default = variable_get('comment_default_order', COMMENT_ORDER_NEWEST_FIRST);
+ break;
+ case 'comments_per_page':
+ $default = variable_get('comment_default_per_page', '50');
+ }
+ if (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_HIDDEN) {
+ // if comment controls are disabled use site default
+ $value = $default;
+ }
+ else {
+ // otherwise use the user's setting if set
+ if ($user->$setting) {
+ $value = $user->$setting;
+ }
+ else if ($_SESSION['comment_'. $setting]) {
+ $value = $_SESSION['comment_'. $setting];
+ }
+ else {
+ $value = $default;
+ }
+ }
+ }
+ return $value;
+}
+
+/**
* Updates the comment statistics for a given node. This should be called any
* time a comment is added, deleted, or updated.
*