diff options
author | Dries Buytaert <dries@buytaert.net> | 2005-01-29 22:02:37 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2005-01-29 22:02:37 +0000 |
commit | 993ea0c6c5a07cf9c2edadf2c0f6a378cde56acb (patch) | |
tree | 3a0999b14fee17844a3318ee2f564191a83e31f3 /modules/forum/forum.module | |
parent | e6d36892abca87d1c668d6294106a154c219cee4 (diff) | |
download | brdo-993ea0c6c5a07cf9c2edadf2c0f6a378cde56acb.tar.gz brdo-993ea0c6c5a07cf9c2edadf2c0f6a378cde56acb.tar.bz2 |
- Patch #16111 by chx: generalized node_rewrite_query to db_rewrite_query.
Diffstat (limited to 'modules/forum/forum.module')
-rw-r--r-- | modules/forum/forum.module | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 40824117c..6f1292c23 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -315,11 +315,11 @@ function forum_block($op = 'list', $delta = 0, $edit = array()) { case 'view': if (user_access('access content')) { $sql = "SELECT n.nid, n.title, l.last_comment_timestamp, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND n.type='forum' ORDER BY l.last_comment_timestamp DESC"; - $sql = node_rewrite_sql($sql); + $sql = db_rewrite_sql($sql); $content = node_title_list(db_query_range($sql, 0, variable_get('forum_block_num', '5')), t('Active forum topics:')); $sql = "SELECT n.nid, n.title, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.type = 'forum' AND n.status = 1 ORDER BY n.nid DESC"; - $sql = node_rewrite_sql($sql); + $sql = db_rewrite_sql($sql); $content .= node_title_list(db_query_range($sql, 0, variable_get('forum_block_num', '5')), t('New forum topics:')); if ($content) { @@ -346,7 +346,7 @@ function forum_link($type, $node = 0, $main = 0) { // get previous and next topic $sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum' ORDER BY n.sticky DESC, ". _forum_get_topic_order_sql(variable_get('forum_order', 1)); - $sql = node_rewrite_sql($sql); + $sql = db_rewrite_sql($sql); $result = db_query($sql, $node->tid); while ($topic = db_fetch_object($result)) { @@ -559,7 +559,7 @@ function forum_get_forums($tid = 0) { $counts = array(); $sql = "SELECT r.tid, COUNT(n.nid) AS topic_count, SUM(l.comment_count) AS comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid WHERE n.status = 1 AND n.type = 'forum' GROUP BY r.tid"; - $sql = node_rewrite_sql($sql); + $sql = db_rewrite_sql($sql); $_counts = db_query($sql, $forum->tid); while ($count = db_fetch_object($_counts)) { $counts[$count->tid] = $count; @@ -584,7 +584,7 @@ function forum_get_forums($tid = 0) { // table1 INNER JOIN table2 INNER JOIN table3 ON table2_criteria ON table3_criteria // used to join node_comment_statistics to users. $sql = "SELECT n.nid, l.last_comment_timestamp, IF(l.last_comment_uid, cu.name, l.last_comment_name) as last_comment_name, l.last_comment_uid FROM {node} n, {node_comment_statistics} l /*! USE INDEX (node_comment_timestamp) */, {users} cu, {term_node} r WHERE n.nid = r.nid AND r.tid = %d AND n.status = 1 AND n.type = 'forum' AND l.last_comment_uid = cu.uid AND n.nid = l.nid ORDER BY l.last_comment_timestamp DESC"; - $sql = node_rewrite_sql($sql); + $sql = db_rewrite_sql($sql); $topic = db_fetch_object(db_query_range($sql, $forum->tid, 0, 1)); $last_post = new StdClass(); @@ -604,10 +604,10 @@ function _forum_topics_read($term, $uid) { // than NODE_NEW_LIMIT are read, and include the recent posts that user has // read. $sql = "SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.created <= %d AND n.status = 1 AND n.type = 'forum'"; - $sql = node_rewrite_sql($sql); + $sql = db_rewrite_sql($sql); $ancient = db_result(db_query($sql, $term, NODE_NEW_LIMIT)); $sql = "SELECT COUNT(n.nid) FROM {node} n INNER JOIN {history} h ON n.nid = h.nid AND h.uid = %d INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum' AND n.created > %d"; - $sql = node_rewrite_sql($sql); + $sql = db_rewrite_sql($sql); $recent = db_result(db_query($sql, $uid, $term, NODE_NEW_LIMIT)); return $ancient + $recent; @@ -633,10 +633,10 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { $term = taxonomy_get_term($tid); - $sql = node_rewrite_sql("SELECT n.nid, f.tid, n.title, n.sticky, u.name, u.uid, n.created AS timestamp, n.comment AS comment_mode, l.last_comment_timestamp, IF(l.last_comment_uid, cu.name, l.last_comment_name) AS last_comment_name, l.last_comment_uid, l.comment_count AS num_comments FROM {node} n, {node_comment_statistics} l, {users} cu, {term_node} r, {users} u, {forum} f WHERE n.status = 1 AND l.last_comment_uid = cu.uid AND n.nid = l.nid AND n.nid = r.nid AND r.tid = %d AND n.uid = u.uid AND n.nid = f.nid"); + $sql = db_rewrite_sql("SELECT n.nid, f.tid, n.title, n.sticky, u.name, u.uid, n.created AS timestamp, n.comment AS comment_mode, l.last_comment_timestamp, IF(l.last_comment_uid, cu.name, l.last_comment_name) AS last_comment_name, l.last_comment_uid, l.comment_count AS num_comments FROM {node} n, {node_comment_statistics} l, {users} cu, {term_node} r, {users} u, {forum} f WHERE n.status = 1 AND l.last_comment_uid = cu.uid AND n.nid = l.nid AND n.nid = r.nid AND r.tid = %d AND n.uid = u.uid AND n.nid = f.nid"); $sql .= tablesort_sql($forum_topic_list_header, 'n.sticky DESC,'); - $sql_count = node_rewrite_sql("SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum'"); + $sql_count = db_rewrite_sql("SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum'"); $result = pager_query($sql, $forum_per_page, 0, $sql_count, $tid); @@ -678,7 +678,7 @@ function _forum_new($tid) { global $user; $sql = "SELECT n.nid FROM {node} n LEFT JOIN {history} h ON n.nid = h.nid AND h.uid = %d INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum' AND h.nid IS NULL AND n.created > %d ORDER BY created"; - $sql = node_rewrite_sql($sql); + $sql = db_rewrite_sql($sql); $nid = db_result(db_query_range($sql, $user->uid, $tid, NODE_NEW_LIMIT, 0, 1)); return $nid ? $nid : 0; |