Special Ops 2.50
[specialops2.git] / lib / Messagelist_Threaded.php
blobdde06fc09984dd1b8db359f6455e24ca6a67caec
1 <?php
2 /**
3 * Threaded messagelist layout
5 * @author Ant P <p@cpi.merseine.nu>
6 * @license file://../COPYING
7 * @version 2.15
8 */
9 require_once 'lib/iface.Messagelist.php';
11 class Messagelist_Threaded implements Messagelist
13 protected $tree;
14 protected $topicid;
15 protected $mo;
17 function __construct($topicid, Messagestyle $mo, $mpp, $page)
19 $tmp = SO2::$DB->q('SELECT userid, mtime, topicid, replyto, score, marks, messageid, INET_NTOA(origin_ip) AS ip '.
20 'FROM messages WHERE topicid = ?', $topicid, SO2_PDO::QOBJ);
21 while ( $item = $tmp->fetch(PDO::FETCH_ASSOC) ) {
22 $this->tree[$item['replyto']][] = $item;
25 list($this->topicid, $this->mo) = func_get_args();
28 public function display()
30 $this->printtree(NULL);
33 private function printtree($branch)
35 foreach ( $this->tree[$branch] as $m ) {
36 if ( $m['score'] < SO2::$User->cutoff && SO2::$User->userid != $m['userid'] )
37 $m['mtext'] = sprintf(self::MODMSG, SO2::$User->cutoff);
38 $this->mo->display($m);
40 if ( ! empty($this->tree[$m['messageid']]) ) {
41 echo '<div class="thread">',"\n";
42 $this->printtree($m['messageid']);
43 echo "</div>\n";
48 // Not implemented
49 public function pagelist()
51 return null;