Added some class="" to pagelist code
[specialops2.git] / lib / class.Boardlist_SO1.php
blobb40c246480f95dc56bd419686493801e0fded75e
1 <?php
2 /**
3 * Board List layout similar to old Special Ops 1 one
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_SO1 implements Boardlist
13 const ID = 1;
14 const Name = 'SO1';
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 // Really bad multidimensional array hack
25 while ( $tmp = $boards->fetch_assoc() ) {
26 $groups[array_shift($tmp)][array_shift($tmp)] = $tmp;
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(`messageid`) FROM `messages` WHERE `topicid` IN
49 (SELECT `topicid` FROM `topics` WHERE `boardid` = @boardid)')->fetch_row();
50 list($topiccount) = $DB->query('SELECT COUNT(*) FROM `topics` WHERE `boardid` = @boardid')->fetch_row();
52 if ( $lastpost ) {
53 $postinfo = $DB->query('SELECT `messages`.`userid`, `alias`, `mtime`, `topics`.`topicid`, `topic_title`
54 FROM `messages`
55 LEFT JOIN `topics` USING(`topicid`)
56 LEFT JOIN `users` ON `messages`.`userid` = `users`.`userid`
57 WHERE `messageid` = '.$lastpost)->fetch_assoc();
58 } else {
59 $postinfo = null;
62 echo '<tr class="content">',"\n",
63 ' <td>'.(
64 $user->has_priv('viewboard', $board['view_restrict']) ?
65 '<a href="topiclist?'.$boardid.'">'.$board['name'].'</a>' : $board['name']
66 )."<br/>\n",
67 ' <small style="margin-left:1em">',$board['caption'],"</small></td>\n",
68 ' <td>',$postcount,"</td>\n",
69 ' <td>',$topiccount,"</td>\n";
71 if ( $postinfo && $user->has_priv('viewboard', $board['view_restrict']) ) {
72 printf(
73 " <td><small>\n".
74 " <strong>From:</strong> %s\n".
75 " <strong>at</strong> %s<br/>\n".
76 ' <strong>in topic:</strong> <a class="topic" href="messagelist?%d">%s</a></small></td>'."\n".
77 "</tr>\n",
78 $user->namelink($postinfo['userid'],
79 $postinfo['alias']),
80 $user->fdate($postinfo['mtime']),
81 $postinfo['topicid'],
82 $postinfo['topic_title']
84 } else {
85 echo "\t<td>N/A</td>\n</tr>\n";
88 echo "</tbody>\n";
90 echo "</table>\n";