Readme update
[specialops2.git] / messagelist.php
blobc6d1baf273355e985cdb0af2bf9d9df3fa450cb0
1 <?php
2 /**
3 * Message List
5 * @author Anthony Parsons (xmpp:ant@specialops.ath.cx)
6 * @license file://COPYING
7 * @version $Id$
8 */
10 $prefetch = array('`points`', '`msglist_layout`', '`msglist_style`', '`msgs_page`');
11 require 'con.php';
13 $page->title = 'Message List';
15 if ( is_numeric($_SERVER['QUERY_STRING']) ) {
16 $topicid = intval($_SERVER['QUERY_STRING']);
17 } elseif ( isset($_GET['topic']) ) {
18 $topicid = intval($_GET['topic']);
22 if ( isset($topicid) ) {
23 $topic = $DB->query('SELECT `board_name`, `boards`.`boardid`, `topic_title`, `view_restrict`, `post_restrict`
24 FROM `boards` NATURAL LEFT JOIN `topics` WHERE `topicid` = '.$topicid)->fetch_row();
25 list($firstmsg) = $DB->query('SELECT MIN(`messageid`) FROM `messages` WHERE `topicid` = '.$topicid)->fetch_row();
26 } else {
27 $page->errorfooter('topicid');
31 /* Error checks */
32 if ( !is_array($topic) ) { // Check for valid topic ID
33 $page->errorfooter('topicid');
35 if ( ! $user->has_priv('viewboard', $topic[3]) ) { // Check whether or not they can view this board
36 $page->errorfooter('level', $topic[3]);
39 $page->title .= ': '.$topic[2];
40 $page->nav['Topic List: '.$topic[0]] = 'topiclist?'.$topic[1];
41 $page->nav['Post Reply'] = 'post?message='.$firstmsg;
43 $mpp = isset($_GET['length']) && ($_GET['length'] <= 100) ? intval($_GET['length']) : $user->msgs_page;
44 $pagenum = isset($_GET['page']) ? intval($_GET['page']) : 0;
46 define('HERE', 'messagelist?topic='.$topicid.';page='.$pagenum.';length='.$mpp);
48 switch ( $user->msglist_style ) {
49 case Messagestyle_Frozenoven::ID:
50 $style = 'Messagestyle_Frozenoven'; break;
51 case Messagestyle_IRC::ID:
52 $style = 'Messagestyle_IRC'; break;
53 case Messagestyle_Plain::ID:
54 default:
55 $style = 'Messagestyle_Plain'; break;
58 switch ( $user->msglist_layout ) {
59 case Messagelist_Threaded::ID:
60 $mlist = new Messagelist_Threaded($topicid, new $style, $mpp, $pagenum); break;
61 case Messagelist_Flat::ID:
62 default:
63 $mlist = new Messagelist_Flat($topicid, new $style, $mpp, $pagenum); break;
66 $user->userheader();
68 $l = $mlist->pagelist();
70 if ( $l ) {
71 echo '<dl id="pagelist-head" class="nl"><dt>Pages:</dt> ',$l,"</dl>\n";
74 echo '<div id="messagelist" class="',get_class($mlist)," $style\">\n";
75 $mlist->display();
76 echo "</div>\n";
78 if ( $l ) {
79 echo '<dl id="pagelist-foot" class="nl"><dt>Pages:</dt> '.$l."</dl>\n";
82 $page->pagefooter();