]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/threadednoticelist.php
better output for registration confirmation
[quix0rs-gnu-social.git] / lib / threadednoticelist.php
index c5cd2d308156034005a1e90fad6a6c03165717af..96be0df0c58d037eb2eb988665c077b84a0739f4 100644 (file)
@@ -50,6 +50,17 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
  */
 class ThreadedNoticeList extends NoticeList
 {
+    protected $userProfile;
+
+    function __construct($notice, $out=null, $profile=-1)
+    {
+        parent::__construct($notice, $out);
+        if (is_int($profile) && $profile == -1) {
+            $profile = Profile::current();
+        }
+        $this->userProfile = $profile;
+    }
+
     /**
      * show the list of notices
      *
@@ -90,7 +101,7 @@ class ThreadedNoticeList extends NoticeList
             $conversations[$convo] = true;
 
             // Get the convo's root notice
-            $root = $notice->conversationRoot();
+            $root = $notice->conversationRoot($this->userProfile);
             if ($root) {
                 $notice = $root;
             }
@@ -123,7 +134,7 @@ class ThreadedNoticeList extends NoticeList
      */
     function newListItem($notice)
     {
-        return new ThreadedNoticeListItem($notice, $this->out);
+        return new ThreadedNoticeListItem($notice, $this->out, $this->userProfile);
     }
 }
 
@@ -146,6 +157,14 @@ class ThreadedNoticeList extends NoticeList
  */
 class ThreadedNoticeListItem extends NoticeListItem
 {
+    protected $userProfile = null;
+
+    function __construct($notice, $out=null, $profile=null)
+    {
+        parent::__construct($notice, $out);
+        $this->userProfile = $profile;
+    }
+
     function initialItems()
     {
         return 3;
@@ -167,7 +186,8 @@ class ThreadedNoticeListItem extends NoticeListItem
     {
         $max = $this->initialItems();
         if (!$this->repeat) {
-            $notice = Notice::conversationStream($this->notice->conversation, 0, $max + 2);
+            $stream = new ConversationNoticeStream($this->notice->conversation, $this->userProfile);
+            $notice = $stream->getNotices(0, $max + 2);
             $notices = array();
             $cnt = 0;
             $moreCutoff = null;
@@ -201,7 +221,7 @@ class ThreadedNoticeListItem extends NoticeListItem
                     }
                     foreach (array_reverse($notices) as $notice) {
                         if (Event::handle('StartShowThreadedNoticeSub', array($this, $this->notice, $notice))) {
-                            $item = new ThreadedNoticeListSubItem($notice, $this->out);
+                            $item = new ThreadedNoticeListSubItem($notice, $this->notice, $this->out);
                             $item->show();
                             Event::handle('StartShowThreadedNoticeSub', array($this, $this->notice, $notice));
                         }
@@ -228,6 +248,14 @@ class ThreadedNoticeListItem extends NoticeListItem
 // @todo FIXME: needs documentation.
 class ThreadedNoticeListSubItem extends NoticeListItem
 {
+    protected $root = null;
+
+    function __construct($notice, $root, $out)
+    {
+        $this->root = $root;
+        parent::__construct($notice, $out);
+    }
+
     function avatarSize()
     {
         return AVATAR_STREAM_SIZE; // @fixme would like something in between
@@ -248,6 +276,23 @@ class ThreadedNoticeListSubItem extends NoticeListItem
         //
     }
 
+    function getReplyProfiles()
+    {
+        $all = parent::getReplyProfiles();
+
+        $profiles = array();
+
+        $rootAuthor = $this->root->getProfile();
+
+        foreach ($all as $profile) {
+            if ($profile->id != $rootAuthor->id) {
+                $profiles[] = $profile;
+            }
+        }
+
+        return $profiles;
+    }
+
     function showEnd()
     {
         $item = new ThreadedNoticeListInlineFavesItem($this->notice, $this->out);