]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
some more extensions of ShowstreamAction broke in last commit
authorMikael Nordfeldth <mmn@hethane.se>
Fri, 5 Jun 2015 19:49:34 +0000 (21:49 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Fri, 5 Jun 2015 19:49:34 +0000 (21:49 +0200)
actions/all.php
actions/replies.php
actions/showstream.php
lib/profileaction.php

index 9cab91264f00bd2337127dbaba6cdb27f3116db3..886117e6a46096eebe99695e076179f9297b7b30 100644 (file)
  * @link     http://status.net
  */
 
-if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
+if (!defined('GNUSOCIAL')) { exit(1); }
 
-class AllAction extends ProfileAction
+class AllAction extends ShowstreamAction
 {
     var $notice;
 
-    protected function profileActionPreparation()
+    protected function getStream()
     {
         if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
             $stream = new InboxNoticeStream($this->target, $this->scoped);
@@ -49,13 +49,7 @@ class AllAction extends ProfileAction
             $stream = new ThreadingInboxNoticeStream($this->target, $this->scoped);
         }
 
-        $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
-                                            NOTICES_PER_PAGE + 1);
-
-        if ($this->page > 1 && $this->notice->N == 0) {
-            // TRANS: Client error when page not found (404).
-            $this->clientError(_('No such page.'), 404);
-        }
+        return $stream;
     }
 
     function title()
index 49098d0950781f62942b29dc0fb131089e70e0fc..3c7e950d012e1a8d9c518f3b2e4ee28d790ace93 100644 (file)
@@ -38,42 +38,14 @@ if (!defined('GNUSOCIAL')) { exit(1); }
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link     http://status.net/
  */
-class RepliesAction extends ManagedAction
+class RepliesAction extends ShowstreamAction
 {
     var $page = null;
     var $notice;
 
-    protected function doPreparation()
+    protected function getStream()
     {
-        $nickname = common_canonical_nickname($this->arg('nickname'));
-
-        $this->user = User::getKV('nickname', $nickname);
-
-        if (!$this->user instanceof User) {
-            // TRANS: Client error displayed when trying to reply to a non-exsting user.
-            $this->clientError(_('No such user.'));
-        }
-
-        $this->target = $this->user->getProfile();
-
-        if (!$this->target instanceof Profile) {
-            // TRANS: Error message displayed when referring to a user without a profile.
-            $this->serverError(_('User has no profile.'));
-        }
-
-        $this->page = $this->int('page') ?: 1;
-
-        common_set_returnto($this->selfUrl());
-
-        $stream = new ReplyNoticeStream($this->target->getID(), $this->scoped);
-
-        $this->notice = $stream->getNotices(($this->page-1) * NOTICES_PER_PAGE,
-                                            NOTICES_PER_PAGE + 1);
-
-        if ($this->page > 1 && $this->notice->N == 0) {
-            // TRANS: Client error when page not found (404)
-            $this->clientError(_('No such page.'), 404);
-        }
+        return new ReplyNoticeStream($this->target->getID(), $this->scoped);
     }
 
     /**
index ee9891092c15223427c6fc5599c3306285984834..8e8b055b4b4749b3a51ad7248963386bb4aecccc 100644 (file)
@@ -79,6 +79,17 @@ class ShowstreamAction extends ProfileAction
     }
 
     protected function profileActionPreparation()
+    {
+        $stream = $this->getStream();
+        $this->notice = $stream->getNotices(($this->page-1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
+
+        if ($this->page > 1 && $this->notice->N == 0) {
+            // TRANS: Client error when page not found (404).
+            $this->clientError(_('No such page.'), 404);
+        }
+    }
+
+    protected function getStream()
     {
         if (empty($this->tag)) {
             $stream = new ProfileNoticeStream($this->target, $this->scoped);
@@ -86,7 +97,7 @@ class ShowstreamAction extends ProfileAction
             $stream = new TaggedProfileNoticeStream($this->target, $this->tag, $this->scoped);
         }
 
-        $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
+        return $stream;
     }
 
 
index b1a3b72a447e142d50b7c9dd0f2a9f08dbd85fef..08e03bac5a62625888a4357346b90109b6bfddde 100644 (file)
@@ -71,6 +71,11 @@ abstract class ProfileAction extends ManagedAction
         return true;
     }
 
+    protected function profileActionPreparation()
+    {
+        // Nothing to do by default.
+    }
+
     public function getTarget()
     {
         return $this->target;