]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
threadednoticelist takes a profile param
authorEvan Prodromou <evan@status.net>
Mon, 11 Apr 2011 00:16:51 +0000 (20:16 -0400)
committerEvan Prodromou <evan@status.net>
Mon, 11 Apr 2011 00:16:51 +0000 (20:16 -0400)
actions/all.php
actions/conversation.php
actions/conversationreplies.php
actions/public.php
actions/showgroup.php
lib/threadednoticelist.php

index 74a0059346b57d497867bb00e98a7037fa398b1f..5fd2475e4911f3b467a8836cfba87b92a63cdc36 100644 (file)
@@ -157,7 +157,16 @@ class AllAction extends ProfileAction
     function showContent()
     {
         if (Event::handle('StartShowAllContent', array($this))) {
-            $nl = new ThreadedNoticeList($this->notice, $this);
+
+            $profile = null;
+
+            $current_user = common_current_user();
+
+            if (!empty($current_user)) {
+                $profile = $current_user->getProfile();
+            }
+
+            $nl = new ThreadedNoticeList($this->notice, $this, $profile);
 
             $cnt = $nl->show();
 
index cfe4e47fe607607eab22d7e896d69b2cfde8e699..123965afa2340aa524f94775cb4829693124a9d7 100644 (file)
@@ -47,9 +47,10 @@ require_once INSTALLDIR.'/lib/noticelist.php';
  */
 class ConversationAction extends Action
 {
-    var $id      = null;
-    var $page    = null;
-    var $notices = null;
+    var $id          = null;
+    var $page        = null;
+    var $notices     = null;
+    var $userProfile = null;
 
     const MAX_NOTICES = 500;
 
@@ -76,14 +77,14 @@ class ConversationAction extends Action
         $cur = common_current_user();
 
         if (empty($cur)) {
-            $profile = null;
+            $this->userProfile = null;
         } else {
-            $profile = $cur->getProfile();
+            $this->userProfile = $cur->getProfile();
         }
 
-        $stream = new ConversationNoticeStream($this->id, $profile);
+        $stream = new ConversationNoticeStream($this->id, $this->userProfile);
 
-        $this->notices = $stream->getNotices(0, self::MAX_NOTICES, null, null);
+        $this->notices = $stream->getNotices(0, self::MAX_NOTICES);
 
         return true;
     }
@@ -122,7 +123,7 @@ class ConversationAction extends Action
      */
     function showContent()
     {
-        $tnl = new ThreadedNoticeList($this->notices, $this);
+        $tnl = new ThreadedNoticeList($this->notices, $this, $this->userProfile);
 
         $cnt = $tnl->show();
     }
index 51bc97f1fceaafb6594b28ade68bed45ab93cdab..450a3d68282136b75fa8e8c574ac586fe150dd6d 100644 (file)
@@ -66,7 +66,7 @@ class ConversationRepliesAction extends ConversationAction
      */
     function showContent()
     {
-        $ct = new FullThreadedNoticeList($this->notices, $this);
+        $ct = new FullThreadedNoticeList($this->notices, $this, $this->userProfile);
 
         $cnt = $ct->show();
     }
@@ -91,7 +91,7 @@ class FullThreadedNoticeList extends ThreadedNoticeList
 {
     function newListItem($notice)
     {
-        return new FullThreadedNoticeListItem($notice, $this->out);
+        return new FullThreadedNoticeListItem($notice, $this->out, $this->userProfile);
     }
 }
 
index d2b0373dc69382aad8951b88cc9f664117e90164..84306e1fccf23418da9ad97d450821b659d0471f 100644 (file)
@@ -85,8 +85,18 @@ class PublicAction extends Action
 
         common_set_returnto($this->selfUrl());
 
-        $this->notice = Notice::publicStream(($this->page-1)*NOTICES_PER_PAGE,
-                                       NOTICES_PER_PAGE + 1);
+        $profile = null;
+        
+        $user = common_current_user();
+
+        if (!empty($user)) {
+            $profile = $user->getProfile();
+        }
+
+        $stream = new PublicNoticeStream($profile);
+
+        $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
+                                            NOTICES_PER_PAGE + 1);
 
         if (!$this->notice) {
             // TRANS: Server error displayed when a public timeline cannot be retrieved.
index 512ca6a0ee262d71d89d49c1899164d0ce84bf8a..49c8e04dcdec462dfbbf448916c32bb74ebb971f 100644 (file)
@@ -50,6 +50,8 @@ class ShowgroupAction extends GroupDesignAction
 {
     /** page we're viewing. */
     var $page = null;
+    var $userProfile = null;
+    var $notice = null;
 
     /**
      * Is this page read-only?
@@ -144,6 +146,15 @@ class ShowgroupAction extends GroupDesignAction
             return false;
         }
 
+        $cur = common_current_user();
+
+        $this->userProfile = (empty($cur)) ? null : $cur->getProfile();
+
+        $stream = new GroupNoticeStream($this->group, $this->userProfile);
+
+        $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
+                                            NOTICES_PER_PAGE + 1);
+
         common_set_returnto($this->selfUrl());
 
         return true;
@@ -190,10 +201,7 @@ class ShowgroupAction extends GroupDesignAction
      */
     function showGroupNotices()
     {
-        $notice = $this->group->getNotices(($this->page-1)*NOTICES_PER_PAGE,
-                                           NOTICES_PER_PAGE + 1);
-
-        $nl = new ThreadedNoticeList($notice, $this);
+        $nl = new ThreadedNoticeList($notice, $this, $this->userProfile);
         $cnt = $nl->show();
 
         $this->pagination($this->page > 1,
index c5cd2d308156034005a1e90fad6a6c03165717af..372791c3e5492da532796cf75b3221eb81de10bd 100644 (file)
@@ -50,6 +50,14 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
  */
 class ThreadedNoticeList extends NoticeList
 {
+    protected $userProfile;
+
+    function __construct($notice, $out=null, $profile=null)
+    {
+        parent::__construct($notice, $out);
+        $this->userProfile = $profile;
+    }
+
     /**
      * show the list of notices
      *
@@ -123,7 +131,7 @@ class ThreadedNoticeList extends NoticeList
      */
     function newListItem($notice)
     {
-        return new ThreadedNoticeListItem($notice, $this->out);
+        return new ThreadedNoticeListItem($notice, $this->out, $this->userProfile);
     }
 }
 
@@ -146,6 +154,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 +183,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;