4 $prefetch = array('`points`', '`msglist_layout`', '`msgs_page`');
7 $page->title
= 'Message List';
9 if ( is_numeric($_SERVER['QUERY_STRING']) )
10 $topicid = intval($_SERVER['QUERY_STRING']);
11 elseif ( isset($_GET['topic']) )
12 $topicid = intval($_GET['topic']);
14 if ( isset($topicid) ) {
15 $topic = $DB->query('SELECT `board_name`, `boards`.`boardid`,
16 `view_level`, `post_level`, `topic_level`, `topic_title`
18 NATURAL LEFT JOIN `topics`
19 WHERE `topicid` = '.$topicid)->fetch_row();
21 $page->errorfooter('topicid');
23 // Check for valid topic ID
24 if ( !is_array($topic) )
25 $page->errorfooter('topicid');
28 if ( $topic[2] > $user->level
)
29 $page->errorfooter('level', $topic[2]);
31 $page->title
.= ': '.$topic[5];
33 $page->nav
['Topic List: '.$topic[0]] = 'topiclist?'.$topic[1];
34 if ( $user instanceof authuser
&& $user->level
>= $topic[3] )
35 $user->userlinks
['Post Message'] = 'post?topic='.$topicid;
39 if ( $user instanceof authuser
) {
40 $start = isset($_GET['page']) ?
intval($_GET['page']) : 0;
41 $posts = isset($_GET['length']) && ($_GET['length'] <= 100) ?
intval($_GET['length']) : $user->msgs_page
;
44 $posts = $user->msgs_page
;
47 switch ( $user->msglist_layout
) {
49 $mlist = new messagelist_flat($topicid, $posts, $start); break;
51 $mlist = new messagelist_threaded($topicid, $posts, $start); break;
53 $mlist = new messagelist_irc($topicid, $posts, $start); break;
55 throw new OutOfBoundsException('user->msglist_layout is out of valid range');
58 $l = $mlist->pagelist();
60 if ( $user instanceof authuser
&& $l )
61 echo '<dl id="pagelist-head" class="nl"><dt>Pages:</dt> '.$l."</dl>\n";
63 echo '<div id="',get_class($mlist),"\">\n";
67 if ( $user instanceof authuser
&& $l )
68 echo '<dl id="pagelist-foot" class="nl"><dt>Pages:</dt> '.$l."</dl>\n";