summaryrefslogtreecommitdiff
path: root/forum/utils
diff options
context:
space:
mode:
Diffstat (limited to 'forum/utils')
-rw-r--r--forum/utils/threads.php71
1 files changed, 70 insertions, 1 deletions
diff --git a/forum/utils/threads.php b/forum/utils/threads.php
index 258f97c..52dda06 100644
--- a/forum/utils/threads.php
+++ b/forum/utils/threads.php
@@ -17,9 +17,23 @@ class Thread {
public $lastseen = array();
public $lastpost;
+ public $first_pid;
+ public $first_title;
+ public $first_user;
+ public $first_date;
+
+ public $last_pid;
+ public $last_title;
+ public $last_user;
+ public $last_date;
+
+ public $numposts;
+ public $numunread;
+
public function show()
{
global $fid, $current_user;
+ global $users;
$jumptonew = "";
$newcls = " thread_nonew";
@@ -32,12 +46,44 @@ class Thread {
echo " <span class=\"thread_icon".$newcls."\">&nbsp;</span>\n";
echo " <a class=\"thread_title\" href=\"?fid=" . $fid .
"&amp;tid=" . $this->tid . $jumptonew."\">" . $this->name . "</a>\n";
+ echo " <span class=\"thread_numposts\">".$this->numposts." posts";
+ if($this->numunread != 0) {
+ echo " <strong>(".$this->numunread." unread)</strong>";
+ }
+ echo "</span>\n";
echo " <span class=\"thread_lastpost\">Last post: ".
date("j. M Y - G:i", $this->lastpost)."</span>\n";
- // echo " <span class=\"thread_numposts\">".$this->numposts." posts</span>\n";
+ $user = $users->getUser($this->first_user);
+ echo " <span class=\"thread_createdby\">By ".$user->name;
+ echo " at ". date("j. M Y - G:i", $this->first_date)."</span>\n";
echo " </div>\n";
}
+ public function processPost($pid, $title, $user, $date)
+ {
+ global $current_user;
+
+ $this->numposts++;
+
+ if($this->lastseen[$current_user->uid] < $date) {
+ $this->numunread++;
+ }
+
+ if($date < $this->first_date || $this->first_date == -1) {
+ $this->first_pid = $pid;
+ $this->first_title = $title;
+ $this->first_user = $user;
+ $this->first_date = $date;
+ }
+
+ if($date > $this->last_date || $this->last_date == -1) {
+ $this->last_pid = $pid;
+ $this->last_title = $title;
+ $this->last_user = $user;
+ $this->last_date = $date;
+ }
+ }
+
private function loadLastSeen($lastseen)
{
if($lastseen == "") return;
@@ -52,6 +98,10 @@ class Thread {
public function Thread($tid, $name, $lastpost, $lastseen)
{
+ $this->numunread = 0;
+ $this->numposts = 0;
+ $this->first_date = -1;
+ $this->last_date = -1;
$this->tid = $tid;
$this->name = $name;
$this->lastpost = $lastpost;
@@ -156,6 +206,21 @@ class Threads {
return false;
}
+ private function recurser($parentpost, $element, $thread)
+ {
+ if($element->tagName != "post") return;
+
+ $thread->processPost($element->getAttribute('pid'),
+ $element->getAttribute('title'),
+ $element->getAttribute('user'),
+ $element->getAttribute('date'));
+
+ foreach($element->childNodes as $child) {
+ if($child->tagName == "post")
+ $this->recurser($post, $child, $thread);
+ }
+ }
+
private function read()
{
$dh = opendir($this->dir);
@@ -172,6 +237,10 @@ class Threads {
$f->getAttribute('lastpost'),
$f->getAttribute('lastseen'));
+ foreach($f->childNodes as $child) {
+ $this->recurser(false, $child, $thread);
+ }
+
$this->add($thread);
}
}