2 // This file has terrible indenting
3 require_once 'iface.Boardlist.php';
6 * SO2 Default Boardlist Module
8 * @author Ant P <p@cpi.merseine.nu>
9 * @licence file://../COPYING
12 class Boardlist_Default
implements Boardlist
16 $q = SO2
::$DB->query('SELECT group_name, boardid, board_name AS name, caption, view_lvl, points '.
17 'FROM boards LEFT JOIN board_groups USING(groupid) '.
18 'WHERE hidden = 0 ORDER BY groupid ASC, boardid ASC')->fetchAll(PDO
::FETCH_ASSOC
);
20 // Really bad multidimensional array hack
21 foreach ( $q as $board ) {
22 $groups[array_shift($board)][array_shift($board)] = $board;
26 <col
/><col
class="num"/><col
class="num"/><col
/>
29 <th scope
="col">Board
</th
>
30 <th scope
="col">Posts
</th
>
31 <th scope
="col">Topics
</th
>
32 <th scope
="col">Last Post
</th
>
36 foreach ( $groups as $groupname => $boards ) {
37 echo '<tbody class="boardgroup">',"\n",
38 '<tr><th scope="rowgroup" colspan="4">',$groupname,"</th></tr>\n";
40 foreach ( $boards as $boardid => $board ) {
41 SO2
::$DB->exec('SET @boardid = '.$boardid);
43 $counts = SO2
::$DB->query('SELECT boards.posts, boards.topics, MAX(lastpost) AS lastpost '.
44 'FROM boards LEFT JOIN topics USING(boardid) '.
45 'WHERE boardid = @boardid GROUP BY boardid')->fetch(PDO
::FETCH_ASSOC
);
47 echo '<tr class="content">',"\n",
48 ' <td>'.( SO2
::$User->has_access('viewboard', $board)
49 ?
'<a href="topiclist?'.$boardid.'">'.$board['name'].'</a>'
52 '<br/><small>',$board['caption'],"</small></td>\n";
54 // If no posts then skip the last three columns completely
55 if ( $counts['posts'] ) {
56 $p = SO2
::$DB->q('SELECT messages.userid, mtime, topics.topicid, topic_title, topics.userid AS tposter '.
57 'FROM messages LEFT JOIN topics USING(topicid) '.
58 'WHERE messageid = ?', $counts['lastpost']);
60 echo ' <td>',$counts['posts'],"</td>\n",
61 ' <td>',$counts['topics'],"</td>\n";
63 if ( SO2
::$User->has_access('viewboard', $board) ) {
64 echo " <td><small>\n",
65 ' From: ',SO2
::$Page->namelink($p['userid']),
66 ' at ',SO2
::$Page->fdate($p['mtime']),"<br/>\n",
67 ' in: <a class="topic u',$p['tposter'],'" href="messagelist?',$p['topicid'],'#m',$counts['lastpost'],'">',
68 $p['topic_title'],"</a></small></td>\n";
70 echo " <td>N/A</td>\n";
73 echo " <td colspan=\"3\">No Posts</td>\n";