Shitload of stuff and quickpost
[specialops2.git] / topiclist.php
blobed52c6afac4e9d9e0369729dfc5fc7873417c119
1 <?php
2 /**
3 * Topic List
5 * @author Anthony Parsons (xmpp:ant@specialops.ath.cx)
6 * @license file://COPYING
7 * @version $Id$
8 */
10 $prefetch = array('`topiclist_layout`', '`topics_page`');
11 require 'con.php';
13 $page->title = 'Topic List';
14 $page->cacheable = true;
16 $boardid = isset($_GET['board']) ? intval($_GET['board']) : intval($_SERVER['QUERY_STRING']);
18 $board = $DB->query('SELECT `board_name`, `view_restrict`, `post_restrict` FROM `boards` WHERE `boardid` = '.$boardid)->fetch_row();
20 if ( !is_array($board) ) {
21 $page->errorfooter('boardid');
24 $page->title .= ': '.$board[0];
27 if ( ! $user->has_priv('viewboard', $board[1]) ) { // View restriction
28 $page->errorfooter('level');
30 if ( $user->has_priv('posttopic', $board[2]) ) { // Add topic post link if they're allowed to post one
31 $user->userlinks['Post Topic'] = 'post?board='.$boardid;
34 list($page->mtime) = $DB->query('SELECT MAX(`mtime`) FROM `messages` NATURAL LEFT JOIN `topics` WHERE `boardid` = '.$boardid)->fetch_row();
36 $user->userheader();
38 $start = isset($_GET['page']) ? intval($_GET['page']) : 0;
40 $DB->query('SET @boardid = '.$boardid);
42 switch ( $user->topiclist_layout ) {
43 case 1:
44 $tlist = new Topiclist_TL($user->topics_page, $start); break;
45 default:
46 $tlist = new Topiclist_Default($user->topics_page, $start);
49 $l = $tlist->pagelist();
51 echo '<div id="topiclist" class="',get_class($tlist),"\">\n";
52 if ( $l ) {
53 echo '<dl id="pagelist-head" class="nl"><dt>Pages:</dt> '.$l."</dl>\n";
56 $tlist->display();
58 if ( $l ) {
59 echo '<dl id="pagelist-foot" class="nl"><dt>Pages:</dt> '.$l."</dl>\n";
61 echo "</div>\n";
63 $page->pagefooter();