Rewrote every file for readability,
[specialops2.git] / messagelist.php
blob69a0f61fd59687e6cd0d1fb107f6dbfa64b962a0
1 <?php
2 // $Id$
4 $prefetch = array('`points`', '`msglist_layout`', '`msgs_page`');
5 require 'con.php';
7 $page->title = 'Message List';
9 if ( isset($_GET['topic']) ) {
10 $topicid = intval($_GET['topic']);
11 $topic = $DB->query('SELECT `board_name`, `boards`.`boardid`,
12 `view_level`, `post_level`, `topic_level`, `topic_title`
13 FROM `boards`
14 NATURAL LEFT JOIN `topics`
15 WHERE `topicid` = '.$topicid)->fetch_row();
18 // Check for valid topic ID
19 if ( !is_array($topic) )
20 $page->errorfooter('topicid');
22 // Access control
23 if ( $topic[2] > $user->level )
24 $page->errorfooter('level', $topic[2]);
26 $page->title .= ': '.$topic[5];
28 $page->nav['Topic List: '.$topic[0]] = 'topiclist?board='.$topic[1];
29 if ( $user instanceof authuser && $user->level >= $topic[3] )
30 $user->userlinks['Post Message'] = 'post?topic='.$topicid;
32 $user->userheader();
34 if ( $user instanceof authuser ) {
35 $start = isset($_GET['page']) ? intval($_GET['page']) : 0;
36 $posts = isset($_GET['length']) && ($_GET['length'] <= 100) ? intval($_GET['length']) : $user->msgs_page;
37 } else {
38 $start = 0;
39 $posts = $user->msgs_page;
42 switch ( $user->msglist_layout ) {
43 case 0:
44 $mlist = new messagelist_flat($topicid, $posts, $start); break;
45 case 1:
46 $mlist = new messagelist_threaded($topicid, $posts, $start); break;
47 case 2:
48 $mlist = new messagelist_irc($topicid, $posts, $start); break;
51 $l = $mlist->pagelist();
53 if ( $user instanceof authuser && $l )
54 echo '<div id="pagelist-head" class="nl">Pages: <ul>',"\n$l</ul></div>\n";
56 echo '<div id="',get_class($mlist),"\">\n";
57 $mlist->display();
58 echo "</div>\n";
60 if ( $user instanceof authuser && $l )
61 echo '<div id="pagelist-foot" class="nl">Pages: <ul>',"\n$l</ul></div>\n";
63 $page->pagefooter();