Apparently not.
[specialops2.git] / messagelist.php
blob1f5ab7c3b8df54397cd0f90f0f7d778704f51e4f
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`', '`msgs_page`');
11 require 'conf.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 } else {
26 $page->errorfooter('topicid');
30 /* Error checks */
31 if ( !is_array($topic) ) { // Check for valid topic ID
32 $page->errorfooter('topicid');
34 if ( ! $user->has_priv('viewboard', $topic[3]) ) { // Check whether or not they can view this board
35 $page->errorfooter('level', $topic[3]);
38 $page->title .= ': '.$topic[2];
39 $page->nav['Topic List: '.$topic[0]] = 'topiclist?'.$topic[1];
40 if ( $user->has_priv('postmessage', $topic[4]) ) {
41 $user->userlinks['Post Message'] = 'post?topic='.$topicid;
44 $user->userheader();
46 $start = isset($_GET['page']) ? intval($_GET['page']) : 0;
47 $posts = isset($_GET['length']) && ($_GET['length'] <= 100) ? intval($_GET['length']) : $user->msgs_page;
49 define('HERE', 'messagelist?topic='.$topicid.';page='.$start.';length='.$posts);
51 list($postcount) = $DB->query('SELECT COUNT(*) FROM `messages` WHERE `topicid` = '.$topicid)->fetch_row();
52 $tmpquery = 'SELECT `messages`.`userid`, `alias`, `mtime`, `mtext`, `replyto`,
53 `score`, `marks`, `messages`.`messageid`, INET_NTOA(`origin_ip`) AS `ip`
54 FROM `message-data`
55 NATURAL LEFT JOIN `messages`
56 NATURAL LEFT JOIN `users`
57 WHERE `topicid` = '.$topicid.'
58 ORDER BY `mtime` ASC';
60 if ( messagelist_threaded::ID == $user->msglist_layout ) {
61 $msgs = $DB->query($tmpquery, MYSQLI_USE_RESULT);
62 } else {
63 $msgs = $DB->query($tmpquery.' LIMIT '.($posts*$start).', '.$posts);
66 switch ( $user->msglist_layout ) {
67 case messagelist_flat::ID:
68 $mlist = new messagelist_flat; break;
69 case messagelist_irc::ID:
70 $mlist = new messagelist_irc; break;
71 case messagelist_frozenoven::ID:
72 $mlist = new messagelist_frozenoven; break;
73 case messagelist_threaded::ID:
74 $mlist = new messagelist_threaded; break;
77 $l = $mlist->pagelist($posts, $start, $topicid, $postcount);
79 if ( $l ) {
80 echo '<dl id="pagelist-head" class="nl"><dt>Pages:</dt> '.$l."</dl>\n";
83 echo '<div id="messagelist" class="',get_class($mlist),"\">\n";
84 $mlist->display($msgs);
85 echo "</div>\n";
87 if ( $l ) {
88 echo '<dl id="pagelist-foot" class="nl"><dt>Pages:</dt> '.$l."</dl>\n";
91 $page->pagefooter();