diff options
-rw-r--r-- | includes/tablesort.inc | 4 | ||||
-rw-r--r-- | modules/blog.module | 2 | ||||
-rw-r--r-- | modules/blog/blog.module | 2 | ||||
-rw-r--r-- | modules/forum.module | 16 | ||||
-rw-r--r-- | modules/forum/forum.module | 16 |
5 files changed, 24 insertions, 16 deletions
diff --git a/includes/tablesort.inc b/includes/tablesort.inc index 2a6fc04c2..e72e078f5 100644 --- a/includes/tablesort.inc +++ b/includes/tablesort.inc @@ -14,12 +14,12 @@ function tablesort_pager() { return $cgi; } -function tablesort_sql($header) { +function tablesort_sql($header, $before = "") { $ts = tablesort_init($header); if ($ts['sql']) { $sql = check_query($ts['sql']); $sort = strtoupper(check_query($ts['sort'])); - return " ORDER BY $sql $sort"; + return " ORDER BY $before $sql $sort"; } } diff --git a/modules/blog.module b/modules/blog.module index 7e7eca288..12efee5e4 100644 --- a/modules/blog.module +++ b/modules/blog.module @@ -143,7 +143,7 @@ function blog_page_user($uid) { $title = t("%name's blog", array('%name' => $account->name)); $output = ''; - $result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY nid DESC", variable_get('default_nodes_main', 10)); + $result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY sticky DESC, nid DESC", variable_get('default_nodes_main', 10)); while ($node = db_fetch_object($result)) { $output .= node_view(node_load(array('nid' => $node->nid)), 1); } diff --git a/modules/blog/blog.module b/modules/blog/blog.module index 7e7eca288..12efee5e4 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -143,7 +143,7 @@ function blog_page_user($uid) { $title = t("%name's blog", array('%name' => $account->name)); $output = ''; - $result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY nid DESC", variable_get('default_nodes_main', 10)); + $result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY sticky DESC, nid DESC", variable_get('default_nodes_main', 10)); while ($node = db_fetch_object($result)) { $output .= node_view(node_load(array('nid' => $node->nid)), 1); } diff --git a/modules/forum.module b/modules/forum.module index cd145ee56..f10a17a1b 100644 --- a/modules/forum.module +++ b/modules/forum.module @@ -152,7 +152,7 @@ function forum_link($type, $node = 0, $main = 0) { if (!$main && $type == 'node' && $node->type == 'forum') { // get previous and next topic - $result = db_query('SELECT n.nid, n.title, GREATEST(n.created, MAX(c.timestamp)) AS date_sort, COUNT(c.nid) AS num_comments FROM {node} n INNER JOIN {forum} f ON n.nid = f.nid INNER JOIN {comments} c ON n.nid = c.nid WHERE n.nid = f.nid AND f.tid = %d AND n.status = 1 GROUP BY n.nid, n.title, n.created ORDER BY '. _forum_get_topic_order(isset($user->sortby) ? $user->sortby : variable_get('forum_order', 1)), $node->tid); + $result = db_query('SELECT n.nid, n.title, GREATEST(n.created, MAX(c.timestamp)) AS date_sort, COUNT(c.nid) AS num_comments FROM {node} n INNER JOIN {forum} f ON n.nid = f.nid INNER JOIN {comments} c ON n.nid = c.nid WHERE n.nid = f.nid AND f.tid = %d AND n.status = 1 GROUP BY n.nid, n.title, n.created ORDER BY n.sticky DESC, '. _forum_get_topic_order(isset($user->sortby) ? $user->sortby : variable_get('forum_order', 1)), $node->tid); while ($topic = db_fetch_object($result)) { if ($stop == 1) { @@ -411,8 +411,8 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { // show topics with the correct tid, or in the forum but with shadow = 1 // @TODO: this is not ANSI SQL! ("user error: 'n.created' isn't in GROUP BY") // @TODO: timestamp is a sql reserved word. are there more? - $sql = "SELECT n.nid, n.title, u.name AS name, u.uid AS uid, n.created AS timestamp, GREATEST(n.created, MAX(c.timestamp)) AS date_sort, COUNT(c.nid) AS num_comments, n.comment AS comment_mode, f.tid FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid INNER JOIN {forum} f ON n.nid = f.nid WHERE n.nid = r.nid AND ((r.tid = $check_tid AND f.shadow = 1) OR f.tid = $check_tid) AND n.status = 1 AND n.type = 'forum' GROUP BY n.nid, n.title, u.name, u.uid, n.created, n.comment, f.tid"; - $sql .= tablesort_sql($forum_topic_list_header); + $sql = "SELECT n.nid, n.title, n.sticky, u.name AS name, u.uid AS uid, n.created AS timestamp, GREATEST(n.created, MAX(c.timestamp)) AS date_sort, COUNT(c.nid) AS num_comments, n.comment AS comment_mode, f.tid FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid INNER JOIN {forum} f ON n.nid = f.nid WHERE n.nid = r.nid AND ((r.tid = $check_tid AND f.shadow = 1) OR f.tid = $check_tid) AND n.status = 1 AND n.type = 'forum' GROUP BY n.nid, n.title, u.name, u.uid, n.created, n.comment, f.tid"; + $sql .= tablesort_sql($forum_topic_list_header, 'n.sticky DESC,'); $sql_count = "SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {forum} f ON n.nid = f.nid INNER JOIN {term_node} r ON n.nid = r.nid WHERE n.nid = r.nid AND ( (r.tid = $check_tid AND f.shadow = 1) OR f.tid = $check_tid) AND n.status = 1 AND n.type = 'forum'"; @@ -661,14 +661,14 @@ function theme_forum_topic_list($tid, $topics, $sortby, $forum_per_page, $offset // folder is new if topic is new or there are new comments since last visit if ($topic->tid != $tid) { $rows[] = array( - array('data' => _forum_icon($topic->new, $topic->num_comments, $topic->comment_mode), 'class' => 'icon'), + array('data' => _forum_icon($topic->new, $topic->num_comments, $topic->comment_mode, $topic->sticky), 'class' => 'icon'), array('data' => $topic->title, 'class' => 'title'), array('data' => l(t('This topic has been moved'), "forum/$topic->tid"), 'colspan' => '3') ); } else { $rows[] = array( - array('data' => _forum_icon($topic->new, $topic->num_comments, $topic->comment_mode), 'class' => 'icon'), + array('data' => _forum_icon($topic->new, $topic->num_comments, $topic->comment_mode, $topic->sticky), 'class' => 'icon'), array('data' => l($topic->title, "node/$topic->nid"), 'class' => 'topic'), array('data' => $topic->num_comments . ($topic->new_replies ? '<br />'. l(t('%a new', array('%a' => $topic->new_replies)), "node/$topic->nid", NULL, NULL, 'new') : ''), 'class' => 'replies'), array('data' => _forum_format($topic), 'class' => 'created'), @@ -689,7 +689,7 @@ function theme_forum_topic_list($tid, $topics, $sortby, $forum_per_page, $offset /** @} End of addtogroup themeable */ -function _forum_icon($new_posts, $num_posts = 0, $comment_mode = 0) { +function _forum_icon($new_posts, $num_posts = 0, $comment_mode = 0, $sticky = 0) { $base_path = variable_get('forum_icon_path', ''); if ($base_path) { @@ -704,6 +704,10 @@ function _forum_icon($new_posts, $num_posts = 0, $comment_mode = 0) { $icon = 'closed'; } + if ($sticky == 1) { + $icon = 'sticky'; + } + // default $file = $base_path ."/forum-$icon.png"; diff --git a/modules/forum/forum.module b/modules/forum/forum.module index cd145ee56..f10a17a1b 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -152,7 +152,7 @@ function forum_link($type, $node = 0, $main = 0) { if (!$main && $type == 'node' && $node->type == 'forum') { // get previous and next topic - $result = db_query('SELECT n.nid, n.title, GREATEST(n.created, MAX(c.timestamp)) AS date_sort, COUNT(c.nid) AS num_comments FROM {node} n INNER JOIN {forum} f ON n.nid = f.nid INNER JOIN {comments} c ON n.nid = c.nid WHERE n.nid = f.nid AND f.tid = %d AND n.status = 1 GROUP BY n.nid, n.title, n.created ORDER BY '. _forum_get_topic_order(isset($user->sortby) ? $user->sortby : variable_get('forum_order', 1)), $node->tid); + $result = db_query('SELECT n.nid, n.title, GREATEST(n.created, MAX(c.timestamp)) AS date_sort, COUNT(c.nid) AS num_comments FROM {node} n INNER JOIN {forum} f ON n.nid = f.nid INNER JOIN {comments} c ON n.nid = c.nid WHERE n.nid = f.nid AND f.tid = %d AND n.status = 1 GROUP BY n.nid, n.title, n.created ORDER BY n.sticky DESC, '. _forum_get_topic_order(isset($user->sortby) ? $user->sortby : variable_get('forum_order', 1)), $node->tid); while ($topic = db_fetch_object($result)) { if ($stop == 1) { @@ -411,8 +411,8 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { // show topics with the correct tid, or in the forum but with shadow = 1 // @TODO: this is not ANSI SQL! ("user error: 'n.created' isn't in GROUP BY") // @TODO: timestamp is a sql reserved word. are there more? - $sql = "SELECT n.nid, n.title, u.name AS name, u.uid AS uid, n.created AS timestamp, GREATEST(n.created, MAX(c.timestamp)) AS date_sort, COUNT(c.nid) AS num_comments, n.comment AS comment_mode, f.tid FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid INNER JOIN {forum} f ON n.nid = f.nid WHERE n.nid = r.nid AND ((r.tid = $check_tid AND f.shadow = 1) OR f.tid = $check_tid) AND n.status = 1 AND n.type = 'forum' GROUP BY n.nid, n.title, u.name, u.uid, n.created, n.comment, f.tid"; - $sql .= tablesort_sql($forum_topic_list_header); + $sql = "SELECT n.nid, n.title, n.sticky, u.name AS name, u.uid AS uid, n.created AS timestamp, GREATEST(n.created, MAX(c.timestamp)) AS date_sort, COUNT(c.nid) AS num_comments, n.comment AS comment_mode, f.tid FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid INNER JOIN {forum} f ON n.nid = f.nid WHERE n.nid = r.nid AND ((r.tid = $check_tid AND f.shadow = 1) OR f.tid = $check_tid) AND n.status = 1 AND n.type = 'forum' GROUP BY n.nid, n.title, u.name, u.uid, n.created, n.comment, f.tid"; + $sql .= tablesort_sql($forum_topic_list_header, 'n.sticky DESC,'); $sql_count = "SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {forum} f ON n.nid = f.nid INNER JOIN {term_node} r ON n.nid = r.nid WHERE n.nid = r.nid AND ( (r.tid = $check_tid AND f.shadow = 1) OR f.tid = $check_tid) AND n.status = 1 AND n.type = 'forum'"; @@ -661,14 +661,14 @@ function theme_forum_topic_list($tid, $topics, $sortby, $forum_per_page, $offset // folder is new if topic is new or there are new comments since last visit if ($topic->tid != $tid) { $rows[] = array( - array('data' => _forum_icon($topic->new, $topic->num_comments, $topic->comment_mode), 'class' => 'icon'), + array('data' => _forum_icon($topic->new, $topic->num_comments, $topic->comment_mode, $topic->sticky), 'class' => 'icon'), array('data' => $topic->title, 'class' => 'title'), array('data' => l(t('This topic has been moved'), "forum/$topic->tid"), 'colspan' => '3') ); } else { $rows[] = array( - array('data' => _forum_icon($topic->new, $topic->num_comments, $topic->comment_mode), 'class' => 'icon'), + array('data' => _forum_icon($topic->new, $topic->num_comments, $topic->comment_mode, $topic->sticky), 'class' => 'icon'), array('data' => l($topic->title, "node/$topic->nid"), 'class' => 'topic'), array('data' => $topic->num_comments . ($topic->new_replies ? '<br />'. l(t('%a new', array('%a' => $topic->new_replies)), "node/$topic->nid", NULL, NULL, 'new') : ''), 'class' => 'replies'), array('data' => _forum_format($topic), 'class' => 'created'), @@ -689,7 +689,7 @@ function theme_forum_topic_list($tid, $topics, $sortby, $forum_per_page, $offset /** @} End of addtogroup themeable */ -function _forum_icon($new_posts, $num_posts = 0, $comment_mode = 0) { +function _forum_icon($new_posts, $num_posts = 0, $comment_mode = 0, $sticky = 0) { $base_path = variable_get('forum_icon_path', ''); if ($base_path) { @@ -704,6 +704,10 @@ function _forum_icon($new_posts, $num_posts = 0, $comment_mode = 0) { $icon = 'closed'; } + if ($sticky == 1) { + $icon = 'sticky'; + } + // default $file = $base_path ."/forum-$icon.png"; |