Changed database a bit to store more useful message marks info
[specialops2.git] / lib / class.messagelist_flat.php
blobc4afd60b15dd1b283021c01d3fd0acdf3877bd88
1 <?php
2 /**
3 * Plain messagelist like GF uses
5 * @author Anthony Parsons (xmpp:ant@specialops.ath.cx)
6 * @license file://../COPYING
7 * @version $Id$
8 */
9 require_once 'lib/iface.messagedisplay.php';
11 class messagelist_flat implements messagedisplay
13 const ID = 0;
14 const Name = 'Flat';
16 public function display(mysqli_result $rows)
18 global $user;
20 while ( $m = $rows->fetch_assoc() ) {
21 $params = array(
22 'From: '.$user->namelink($m['userid'], $m['alias']),
23 'At: '.$user->fdate($m['mtime']),
24 sprintf('<a href="%s#m%d">#%2$d</a>', HERE, $m['messageid']),
25 'Score: '.$m['score'],
26 '<a href="post?message='.$m['messageid'].'">Reply</a>');
28 if ( $user instanceof authuser ) {
29 if ( $user->has_priv('moderate') && $user->userid != $m['userid'] ) {
30 $params[3] .= sprintf(self::MD_LINKS, $m['messageid']);
32 if ( $m['marks'] ) {
33 $params[3] .= sprintf(self::MD_VIEW, $m['messageid']);
37 if ( $m['replyto'] ) {
38 $params[] = sprintf('Reply to <a href="#m%d">#%1$d</a>', $m['replyto']);
40 if ( $user->has_priv('admin') ) {
41 $params[] = $m['ip'];
44 echo '<div class="info u',$m['userid'],'" id="m',$m['messageid'],'">',implode(' | ', $params),"</div>\n",
45 '<div class="content">',$m['mtext'],"</div>\n";
49 public function pagelist($posts, $page, $topicid, $totalposts)
51 if ( $totalposts < $posts ) {
52 return null;
55 $tmp = '';
56 for ( $i = 0; $i < $totalposts; $i += $posts ) {
57 if ( $i/$posts == $page ) {
58 $tmp .= '<dd>['.($i/$posts+1).']</dd> ';
59 } else {
60 $tmp .= sprintf('<dd><a href="messagelist?topic=%d;page=%d;length=%d">%d</a></dd> ',
61 $topicid, ($i/$posts), $posts, ($i/$posts+1));
65 return $tmp;