Special Ops 2.50
[specialops2.git] / messagelist.php
blobf4cb097d393b63ff71d035a426bd4bf611544f4b
1 <?php
2 /**
3 * Message List
5 * @author Ant P <p@cpi.merseine.nu>
6 * @license file://COPYING
7 * @version 2.15
8 */
10 require 'con.php';
12 SO2::$Page->title = 'Message List';
13 SO2::$Page->cacheable = true;
15 // Get the topic ID
16 if ( is_numeric($_SERVER['QUERY_STRING']) ) {
17 $topicid = $_SERVER['QUERY_STRING'];
18 } elseif ( isset($_GET['topic']) ) {
19 $topicid = $_GET['topic'];
22 // Get topic/board metadata
23 if ( isset($topicid) && is_numeric($topicid) ) {
24 $topic = SO2::$DB->q('SELECT board_name, boards.boardid AS boardid, topic_title, view_lvl, post_lvl, points '.
25 'FROM boards LEFT JOIN topics USING(boardid) WHERE topicid = ?', $topicid);
28 // Check whether the topic exists
29 if ( empty($topic) ) {
30 SO2::$Page->message(Page::ERR_NOTOPIC);
31 } else {
32 // first message in topic is the reply-to message ID for the quickpost and post page link in the navbar
33 list($firstmsg, SO2::$Page->mtime) = SO2::$DB->q('SELECT MIN(messageid), MAX(mtime) FROM messages WHERE topicid = ?',
34 $topicid, SO2_PDO::QROW);
37 if ( ! SO2::$User->has_access('viewboard', $topic) ) { // Check whether or not they can view this board
38 SO2::$Page->message(Page::ERR_ULEVEL);
41 // Only add these links after it's known they can access them
42 SO2::$Page->title .= ': '.$topic['topic_title'];
43 SO2::$Page->nav['Topic List: '.$topic['board_name']] = 'topiclist?'.$topic['boardid'];
44 SO2::$Page->nav['Reply'] = 'post?message='.$firstmsg;
45 SO2::$Page->pageheader();
47 // Calculate number of messages and starting offset for the message list
48 $mpp = isset($_GET['length']) ? min(100, $_GET['length']) : SO2::$User->msgs_page;
49 $currentpage = isset($_GET['page']) ? intval($_GET['page']) : 0;
51 // Required for message permalinks to work
52 define('HERE', 'messagelist?topic='.$topicid.';page='.$currentpage.';length='.$mpp);
54 // Load the message list
55 if ( file_exists('lib/Messagestyle_'.SO2::$User->msglist_style.'.php') ) {
56 $style = 'Messagestyle_'.SO2::$User->msglist_style;
57 } else {
58 $style = 'Messagestyle_Default';
61 if ( file_exists('lib/Messagelist_'.SO2::$User->msglist_layout.'.php') ) {
62 $tmp = 'Messagelist_'.SO2::$User->msglist_layout;
63 $mlist = new $tmp($topicid, new $style, $mpp, $currentpage);
64 } else {
65 SO2::$User->msglist_layout = 'Flat';
66 $mlist = new Messagelist_Flat($topicid, new $style, $mpp, $currentpage);
69 // Display the message list
70 if ( $l = $mlist->pagelist() ) {
71 echo '<dl id="pagelist-head" class="nl"><dt>Pages:</dt> ',$l,"</dl>\n";
73 echo '<div id="messagelist" class="',get_class($mlist)," $style\">\n";
74 $mlist->display();
75 echo "</div>\n";
76 if ( $l ) {
77 echo '<dl id="pagelist-foot" class="nl"><dt>Pages:</dt> '.$l."</dl>\n";
80 // Display the quickpost box if enabled
81 if ( SO2::$User->getopt('quickpost') ) {
83 <form action="post?message=<?php echo $firstmsg ?>" method="post" id="quickpost">
84 <fieldset>
85 <legend>Quick Reply</legend>
86 <textarea rows="5" cols="60" name="message_text" tabindex="1"><?php
87 if ( SO2::$User->sig ) {
88 echo ( strpos($_SERVER['HTTP_USER_AGENT'], 'KHTML') ? "\n\n" : "\n" ),htmlspecialchars(SO2::$User->sig);
90 ?></textarea>
91 <button type="submit" accesskey="p" name="post" tabindex="1">Post (P)</button>
92 <button type="submit" accesskey="r" name="preview" tabindex="1">Preview (R)</button>
93 </fieldset>
94 </form>
95 <?php