]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/profileaction.php
Merge branch 'master' of https://git.gnu.io/gnu/gnu-social into social-master
[quix0rs-gnu-social.git] / lib / profileaction.php
index 08e03bac5a62625888a4357346b90109b6bfddde..1cda2b509422f451db256b7d2adf97da25c8adcc 100644 (file)
@@ -41,7 +41,7 @@ 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/
  */
-abstract class ProfileAction extends ManagedAction
+abstract class ProfileAction extends ManagedAction implements NoticestreamAction
 {
     var $page    = null;
     var $tag     = null;
@@ -50,7 +50,7 @@ abstract class ProfileAction extends ManagedAction
 
     protected function prepare(array $args=array())
     {
-        // this will call ->doPreparation() which lower classes can use
+        // this will call ->doPreparation() which child classes use to set $this->target
         parent::prepare($args);
 
         if ($this->target->hasRole(Profile_role::SILENCED)
@@ -66,7 +66,14 @@ abstract class ProfileAction extends ManagedAction
         common_set_returnto($this->selfUrl());
 
         // fetch the actual stream stuff
-        $this->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);
+        }
+
 
         return true;
     }
@@ -81,7 +88,7 @@ abstract class ProfileAction extends ManagedAction
         return $this->target;
     }
 
-    function isReadOnly($args)
+    function isReadOnly(array $args=array())
     {
         return true;
     }
@@ -181,20 +188,19 @@ abstract class ProfileAction extends ManagedAction
         // TRANS: H2 text for user statistics.
         $this->element('h2', null, _('Statistics'));
 
-        $profile = $this->target;
-        $actionParams = array('nickname' => $profile->nickname);
+        $actionParams = array('nickname' => $this->target->nickname);
         $stats = array(
             array(
                 'id' => 'user-id',
                 // TRANS: Label for user statistics.
                 'label' => _('User ID'),
-                'value' => $profile->id,
+                'value' => $this->target->id,
             ),
             array(
                 'id' => 'member-since',
                 // TRANS: Label for user statistics.
                 'label' => _('Member since'),
-                'value' => date('j M Y', strtotime($profile->created))
+                'value' => date('j M Y', strtotime($this->target->created))
             ),
             array(
                 'id' => 'notices',
@@ -212,7 +218,7 @@ abstract class ProfileAction extends ManagedAction
         );
 
         // Give plugins a chance to add stats entries
-        Event::handle('ProfileStats', array($profile, &$stats));
+        Event::handle('ProfileStats', array($this->target, &$stats));
 
         foreach ($stats as $row) {
             $this->showStatsRow($row);
@@ -317,7 +323,7 @@ abstract class ProfileAction extends ManagedAction
 
 class SubscribersMiniList extends ProfileMiniList
 {
-    function newListItem($profile)
+    function newListItem(Profile $profile)
     {
         return new SubscribersMiniListItem($profile, $this->action);
     }