5 * @author Ant P <p@cpi.merseine.nu>
6 * @license file://COPYING
12 SO2
::$Page->title
= 'Message List';
13 SO2
::$Page->cacheable
= true;
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
);
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
;
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);
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";
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">
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
);
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
>