Made the caching stuff in Page class better
[specialops2.git] / lib / class.Boardlist_SO2.php
blob17b298d410dcb8ac7bef2d7ee387d185e0d1fed4
1 <?php
2 /**
3 * Special Ops 2 board list layout
5 * @author Anthony Parsons (xmpp:ant@specialops.ath.cx)
6 * @license file://../COPYING
7 * @version $Id$
8 */
9 require_once 'iface.Boardlist.php';
11 class Boardlist_SO2 implements Boardlist
13 const ID = 2;
14 const Name = 'SO2';
16 function display()
18 global $DB, $user;
20 $boards = $DB->query('SELECT `group_name`, `boardid`, `board_name` AS `name`, `caption`, `view_restrict`
21 FROM `boards` LEFT JOIN `board-groups` USING(`groupid`)
22 ORDER BY `groupid` ASC, `boardid` ASC', MYSQLI_USE_RESULT);
24 // See class.boardlist_so1
25 while ( $tmp = $boards->fetch_assoc() ) {
26 $groups[array_shift($tmp)][array_shift($tmp)] = $tmp;
29 // Nothing wrong with a bit of outdenting ?>
30 <table>
31 <col/><col/><col/><col/>
32 <thead>
33 <tr>
34 <th scope="col">Board</th>
35 <th scope="col">Posts</th>
36 <th scope="col">Topics</th>
37 <th scope="col">Last Post</th>
38 </tr>
39 </thead>
40 <?php
41 foreach ( $groups as $groupname => $boards ) {
42 echo '<tbody class="boardgroup">',"\n",
43 '<tr><th scope="rowgroup" colspan="4">',$groupname,"</th></tr>\n";
45 foreach ( $boards as $boardid => $board ) {
46 $DB->query('SET @boardid = '.$boardid);
48 list($postcount, $lastpost) = $DB->query('SELECT COUNT(*), MAX(`mtime`) FROM `messages` WHERE `topicid` IN
49 (SELECT `topicid` FROM `topics` WHERE `boardid` = @boardid)')->fetch_row();
50 list($topiccount) = $DB->query('SELECT COUNT(*) AS `c` FROM `topics` WHERE `boardid` = @boardid')->fetch_row();
52 echo
53 '<tr class="content">',"\n",
54 ' <td>'.(
55 $user->has_priv('viewboard', $board['view_restrict']) ?
56 '<a href="topiclist?'.$boardid.'">'.$board['name'].'</a>' : $board['name']
57 )."<br/>\n",
58 ' <small style="margin-left:1em">',$board['caption'],"</small></td>\n",
59 ' <td>',$postcount,"</td>\n",
60 ' <td>',$topiccount,"</td>\n",
61 ' <td>',$user->fdate($lastpost),"</td>\n",
62 "</tr>\n";
64 echo "</tbody>\n";
66 echo "</table>\n";