From 9dc1e9870418a54f834c2e546e1c549c3662c4e8 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Tue, 12 Apr 2011 18:02:20 +1000 Subject: PM inbox --- mod.php | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'mod.php') diff --git a/mod.php b/mod.php index 06331a2a..6414ce9a 100644 --- a/mod.php +++ b/mod.php @@ -122,6 +122,19 @@ } $fieldset['Noticeboard'] .= 'View all entires'; + + $query = prepare("SELECT COUNT(*) AS `count` FROM `pms` WHERE `to` = :id AND `unread` = 1"); + $query->bindValue(':id', $mod['id']); + $query->execute() or error(db_error($query)); + $count = $query->fetch(); + $count = $count['count']; + + $fieldset['Noticeboard'] .= '
  • PM inbox' . + ($count > 0 + ? + ' (' . $count . ' unread)' + : '') . + '
  • '; } if($mod['type'] >= $config['mod']['reports']) { @@ -311,6 +324,39 @@ 'mod'=>true ) ); + } elseif(preg_match('/^\/inbox$/', $query, $match)) { + $query = prepare("SELECT `unread`,`pms`.`id`, `time`, `sender`, `to`, `message`, `username` FROM `pms` LEFT JOIN `mods` ON `mods`.`id` = `sender` WHERE `to` = :mod ORDER BY `unread` DESC, `time` DESC"); + $query->bindValue(':mod', $mod['id'], PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + + if($query->rowCount() == 0) { + $body = '

    (No private messages for you.)

    '; + } else { + $unread_pms = 0; + + $body = ''; + while($pm = $query->fetch()) { + $body .= '' . + '' . + '' . + '' . + '' . + ''; + + if($pm['unread']) + $unread_pms++; + } + $body .= '
    IDFromDateMessage snippet
    ' . $pm['id'] . '' . $pm['username'] . '' . date($config['post_date'], $pm['time']) . '' . pm_snippet($pm['message']) . '
    '; + } + + + echo Element('page.html', Array( + 'config'=>$config, + 'title'=>'PM Inbox (' . ($query->rowCount() == 0 ? 'empty' : $unread_pms . ' unread') . ')', + 'body'=>$body, + 'mod'=>true + ) + ); } elseif(preg_match('/^\/PM\/(\d+)$/', $query, $match)) { $id = $match[1]; -- cgit v1.3