* Minor TOS change
[specialops2.git] / lib / class.Boardlist_SO1.php
blob271edaf850dcbc719cb90f9020d344933561ce33
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 WHERE `hidden` = 0
23 ORDER BY `groupid` ASC, `boardid` ASC', MYSQLI_USE_RESULT);
25 // Really bad multidimensional array hack
26 while ( $tmp = $boards->fetch_assoc() ) {
27 $groups[array_shift($tmp)][array_shift($tmp)] = $tmp;
31 <table>
32 <col/><col class="num"/><col class="num"/><col/>
33 <thead>
34 <tr>
35 <th scope="col">Board</th>
36 <th scope="col">Posts</th>
37 <th scope="col">Topics</th>
38 <th scope="col">Last Post</th>
39 </tr>
40 </thead>
41 <?php
42 foreach ( $groups as $groupname => $boards ) {
43 echo '<tbody class="boardgroup">',"\n",
44 '<tr><th scope="rowgroup" colspan="4">',$groupname,"</th></tr>\n";
46 foreach ( $boards as $boardid => $board ) {
47 $DB->query('SET @boardid = '.$boardid);
49 list($postcount, $lastpost) = $DB->query('SELECT COUNT(*), MAX(`messageid`) FROM `messages` WHERE `topicid` IN
50 (SELECT `topicid` FROM `topics` WHERE `boardid` = @boardid)')->fetch_row();
51 list($topiccount) = $DB->query('SELECT COUNT(*) FROM `topics` WHERE `boardid` = @boardid')->fetch_row();
53 if ( $lastpost ) {
54 $postinfo = $DB->query('SELECT `messages`.`userid`, `alias`, `mtime`, `topics`.`topicid`, `topic_title`
55 FROM `messages`
56 LEFT JOIN `topics` USING(`topicid`)
57 LEFT JOIN `users` ON `messages`.`userid` = `users`.`userid`
58 WHERE `messageid` = '.$lastpost)->fetch_assoc();
59 } else {
60 $postinfo = null;
63 echo '<tr class="content">',"\n",
64 ' <td><a href="topiclist?',$boardid,'">',$board['name'],"</a><br/>\n",
65 ' <small style="margin-left:1em">',$board['caption'],"</small></td>\n",
66 ' <td>',$postcount,"</td>\n",
67 ' <td>',$topiccount,"</td>\n";
69 if ( $postinfo ) {
70 printf(
71 " <td><small>\n".
72 " <strong>From:</strong> %s\n".
73 " <strong>at</strong> %s<br/>\n".
74 ' <strong>in topic:</strong> %s</small></td>'."\n".
75 "</tr>\n",
76 $user->namelink($postinfo['userid'],
77 $postinfo['alias']),
78 $user->fdate($postinfo['mtime']),
79 $user->has_priv('viewboard', $board['view_restrict'])
80 ? '<a class="topic" href="messagelist?'.$postinfo['topicid'].'">'.$postinfo['topic_title'].'</a>'
81 : $postinfo['topic_title']
83 } else {
84 echo "\t<td>N/A</td>\n</tr>\n";
87 echo "</tbody>\n";
89 echo "</table>\n";