]> ruin.nu Git - ndwebbie.git/commitdiff
order by last post
authorMichael Andreen <harv@ruin.nu>
Sun, 7 Jan 2007 13:15:47 +0000 (13:15 +0000)
committerMichael Andreen <harv@ruin.nu>
Sun, 7 Jan 2007 13:15:47 +0000 (13:15 +0000)
forum.pl
templates/forum.tmpl

index cdd51fec478d0ac40bb4047a133da8bb831b483e..e006b201cfc39418eb4c0b8793273e2fb4496c16 100644 (file)
--- a/forum.pl
+++ b/forum.pl
@@ -61,11 +61,12 @@ if (defined param('cmd') && param('cmd') eq 'forumpost'){
 }
 
 my $categories = $DBH->prepare(q{SELECT fcid AS id,category FROM forum_categories ORDER BY fcid});
-my $threads = $DBH->prepare(q{SELECT ft.ftid AS id,ft.subject,count(NULLIF(COALESCE(fp.time > ftv.time,TRUE),FALSE)) AS unread,count(fp.fpid) AS posts
+my $threads = $DBH->prepare(q{SELECT ft.ftid AS id,ft.subject,count(NULLIF(COALESCE(fp.time > ftv.time,TRUE),FALSE)) AS unread,count(fp.fpid) AS posts, max(fp.time)::timestamp as last_post
 FROM forum_threads ft JOIN forum_posts fp USING (ftid) LEFT OUTER JOIN (SELECT * FROM forum_thread_visits WHERE uid = $2) ftv ON ftv.ftid = ft.ftid
 WHERE ft.fbid = $1
 GROUP BY ft.ftid, ft.subject
-HAVING count(NULLIF(COALESCE(fp.time > ftv.time,TRUE),FALSE)) >= $3});
+HAVING count(NULLIF(COALESCE(fp.time > ftv.time,TRUE),FALSE)) >= $3
+ORDER BY last_post DESC});
 
 if ($thread){ #Display the thread
        $BODY->param(Thread => viewForumThread $thread);
@@ -94,6 +95,7 @@ FROM forum_boards fb NATURAL JOIN forum_access fa
 WHERE fb.fcid = $1 AND (gid = -1 OR gid IN (SELECT gid FROM groupmembers
        WHERE uid = $2))
 GROUP BY fb.fbid,fb.board
+ORDER BY fb.fbid
 });
        while (my $category = $categories->fetchrow_hashref){
                $boards->execute($category->{id},$ND::UID) or $ERROR .= p($DBH->errstr);
index 925e40bed48e018d2669ec96379e8f0c1bb84aba..8081a48b77ea1dc628833d508d4c992b1a71526a 100644 (file)
@@ -6,12 +6,14 @@
        <th>Unread</th>
        <th>Total</th>
        <th>Subject</th>
+       <th>Last post</th>
 </tr>
 <TMPL_LOOP Threads>
        <tr class="<TMPL_IF ODD>odd<TMPL_ELSE>even</TMPL_IF>">
                <td align="center"><TMPL_VAR NAME=Unread></td>
                <td align="center"><TMPL_VAR NAME=Posts></td>
                <td><a href="<TMPL_VAR NAME=PAGE>?t=<TMPL_VAR NAME=Id>#NewPosts">&nbsp;<TMPL_VAR NAME=Subject>&nbsp;</a></td>
+               <td align="center"><TMPL_VAR NAME=Last_post></td>
        </tr>
 </TMPL_LOOP>
 </table>
@@ -51,6 +53,7 @@
        <th>Unread</th>
        <th>Total</th>
        <th>Subject</th>
+       <th>Last post</th>
 </tr>
 <TMPL_LOOP Categories>
        <tr><th colspan="2"><TMPL_VAR NAME=Category></th></tr>
@@ -64,6 +67,7 @@
                <td align="center"><TMPL_VAR NAME=Unread></td>
                <td align="center"><TMPL_VAR NAME=Posts></td>
                <td><a href="<TMPL_VAR NAME=PAGE>?t=<TMPL_VAR NAME=Id>#NewPosts">&nbsp;<TMPL_VAR NAME=Subject>&nbsp;</a></td>
+               <td align="center"><TMPL_VAR NAME=Last_post></td>
        </tr>
                </TMPL_LOOP>
        </TMPL_LOOP>