Closed (won't fix)
Project:
Advanced Forum
Version:
6.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
18 Jun 2008 at 13:23 UTC
Updated:
31 Jul 2008 at 21:32 UTC
with a postgresql database, there is an error syntax : "AS" keyword is forgotten is the two "select" requests, causing errors.
Good function is as follow:
/*****************************************************************************/
/*** LAST UPDATED TOPIC ******************************************************/
/*****************************************************************************/
function _advanced_forum_get_last_topic($tid) {
// Get the most recently created node, in the given forum, that the user has access to
$query = "SELECT n.nid AS topic_id,
n.title AS topic_title,
n.created AS topic_timestamp,
n.type AS topic_type,
n.uid AS topic_author_id,
u.name AS topic_author_name
FROM {node} n
INNER JOIN {term_node} tn on n.nid = tn.nid
INNER JOIN {users} u on n.uid = u.uid
WHERE tn.tid = $tid AND n.status = 1
ORDER BY n.created DESC";
$node = db_fetch_object(db_query_range(db_rewrite_sql($query), array(), 0, 1));
// If there is at least one node, then we need to look for the most recent comment
if ($node) {
$query = "SELECT c.nid AS topic_id,
c.cid AS reply_id,
c.timestamp AS reply_timestamp,
c.subject AS reply_title,
c.uid AS topic_author_id,
n.title AS topic_title,
n.created AS topic_timestamp,
n.type AS topic_type,
c.name AS reply_author_name
FROM {comments} c
INNER JOIN {term_node} tn ON c.nid = tn.nid
INNER JOIN {node} n ON c.nid = n.nid
WHERE tn.tid = $tid AND n.status = 1 AND c.status = 0
ORDER BY c.timestamp DESC";
$comment = db_fetch_object(db_query_range(db_rewrite_sql($query,'c','cid'), array(), 0, 1));
if ($node->topic_timestamp >= $comment->reply_timestamp) {
$node->tid = $tid;
$node->reply_id = 0;
return $node;
}
else {
$comment->tid = $tid;
return $comment;
}
}
}
Comments
Comment #1
michelleWill be moot soon. http://drupal.org/node/268273
Michelle