changed optional arg order in classes
[specialops2.git] / lib / class.messagelist_threaded.php
blobc88afad4611c8c7ffb99c999b831f8ddcf19519a
1 <?php
2 // $Id$
4 $classes['messagelist']['threaded'] = array('name' => _('Threaded'), 'ID' => 1);
6 class messagelist_threaded
8 private $tree;
10 function __construct($topicid, $mpp = 35, $page = 0)
12 global $DB;
13 $q = $DB->query('SELECT `m_poster`, `m_time`, `m_text`, `m_id`, `m_replyto`, INET_NTOA(`m_ip`) AS `m_ip`
14 FROM `messages`, `message-data`
15 WHERE `m_topic` = '.$topicid.'
16 AND `messageid` = `m_id`
17 ORDER BY `m_time` ASC');
18 while ( $item = $q->fetch_assoc() )
19 $this->tree[$item['m_replyto']][] = $item;
21 $this->printtree(NULL);
24 function printtree($branch)
26 global $user;
27 foreach ( $this->tree[$branch] as $msg ) {
28 echo '<div class="info" id="m',$msg['m_id'],'">',
30 sprintf(_('From: %s | At: %s | '), $user->namelink($msg['m_poster']), $user->fdate($msg['m_time'])),
31 '<a href="#m',$msg['m_id'],'">#',$msg['m_id'],'</a>',
32 ( $user instanceof authuser ? ' | <a href="post?message='.$msg['m_id'].'">'._('Reply').'</a>' : '' ),
33 ( $user->u_level >= LVL_ADMIN ? ' | '.$msg['m_ip'] : '' ),
35 "</div>\n",
36 '<div class="content">',$msg['m_text'],"</div>\n";
38 if ( !empty($this->tree[$msg['m_id']]) ) {
39 echo '<div class="thread">',"\n";
40 $this->printtree($msg['m_id']);
41 echo "</div>\n";