]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Revert "Revert "Return a 404 when a page is request that has no notices""
authorEvan Prodromou <evan@controlyourself.ca>
Sun, 16 Aug 2009 14:37:15 +0000 (10:37 -0400)
committerEvan Prodromou <evan@controlyourself.ca>
Sun, 16 Aug 2009 14:37:15 +0000 (10:37 -0400)
This reverts commit 1b204fde39271acd38bb8f9dd16734f15c68138a.

actions/all.php
actions/public.php
actions/replies.php
actions/showfavorites.php
actions/tag.php

index 5db09a0e619a12885c0a074c6d9a38d009b255b6..38aee65b64c0c7c85148cdd3dba243ebde124334 100644 (file)
@@ -25,11 +25,31 @@ require_once INSTALLDIR.'/lib/feedlist.php';
 
 class AllAction extends ProfileAction
 {
+    var $notice;
+
     function isReadOnly($args)
     {
         return true;
     }
 
+    function prepare($args)
+    {
+        parent::prepare($args);
+        $cur = common_current_user();
+
+        if (!empty($cur) && $cur->id == $this->user->id) {
+            $this->notice = $this->user->noticeInbox(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
+        } else {
+            $this->notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
+        }
+
+        if($this->page > 1 && $this->notice->N == 0){
+            $this->serverError(_('No such page'),$code=404);
+        }
+
+        return true;
+    }
+
     function handle($args)
     {
         parent::handle($args);
@@ -100,15 +120,7 @@ class AllAction extends ProfileAction
 
     function showContent()
     {
-        $cur = common_current_user();
-
-        if (!empty($cur) && $cur->id == $this->user->id) {
-            $notice = $this->user->noticeInbox(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
-        } else {
-            $notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
-        }
-
-        $nl = new NoticeList($notice, $this);
+        $nl = new NoticeList($this->notice, $this);
 
         $cnt = $nl->show();
 
index ca352faf85a068ea20d79db458248f9348e381c2..2cf2e96e685c606f5214f9b57a17be80d67be9da 100644 (file)
@@ -93,7 +93,7 @@ class PublicAction extends Action
             return;
         }
 
-        if($this->page > 0 && $this->notice->N == 0){
+        if($this->page > 1 && $this->notice->N == 0){
             $this->serverError(_('No such page'),$code=404);
         }
 
index f14383d33b8fed5d5d9e240d4ad4080bbc548113..fcfc3a272514c343fddcb2746e01b57d76204332 100644 (file)
@@ -48,6 +48,7 @@ require_once INSTALLDIR.'/lib/feedlist.php';
 class RepliesAction extends OwnerDesignAction
 {
     var $page = null;
+    var $notice;
 
     /**
      * Prepare the object
@@ -84,6 +85,13 @@ class RepliesAction extends OwnerDesignAction
 
         common_set_returnto($this->selfUrl());
 
+        $this->notice = $this->user->getReplies(($this->page-1) * NOTICES_PER_PAGE,
+             NOTICES_PER_PAGE + 1);
+
+        if($this->page > 1 && $this->notice->N == 0){
+            $this->serverError(_('No such page'),$code=404);
+        }
+
         return true;
     }
 
@@ -159,10 +167,7 @@ class RepliesAction extends OwnerDesignAction
 
     function showContent()
     {
-        $notice = $this->user->getReplies(($this->page-1) * NOTICES_PER_PAGE,
-                                          NOTICES_PER_PAGE + 1);
-
-        $nl = new NoticeList($notice, $this);
+        $nl = new NoticeList($this->notice, $this);
 
         $cnt = $nl->show();
         if (0 === $cnt) {
index 9f549baf246f6c64672e9356d32f2443521e6983..91287cc9630b802a4b1887abb0a11b4343bcd994 100644 (file)
@@ -114,6 +114,29 @@ class ShowfavoritesAction extends OwnerDesignAction
 
         common_set_returnto($this->selfUrl());
 
+        $cur = common_current_user();
+
+        if (!empty($cur) && $cur->id == $this->user->id) {
+
+            // Show imported/gateway notices as well as local if
+            // the user is looking at his own favorites
+
+            $this->notice = $this->user->favoriteNotices(($this->page-1)*NOTICES_PER_PAGE,
+                                                   NOTICES_PER_PAGE + 1, true);
+        } else {
+            $this->notice = $this->user->favoriteNotices(($this->page-1)*NOTICES_PER_PAGE,
+                                                   NOTICES_PER_PAGE + 1, false);
+        }
+
+        if (empty($this->notice)) {
+            $this->serverError(_('Could not retrieve favorite notices.'));
+            return;
+        }
+
+        if($this->page > 1 && $this->notice->N == 0){
+            $this->serverError(_('No such page'),$code=404);
+        }
+
         return true;
     }
 
@@ -193,26 +216,7 @@ class ShowfavoritesAction extends OwnerDesignAction
 
     function showContent()
     {
-        $cur = common_current_user();
-
-        if (!empty($cur) && $cur->id == $this->user->id) {
-
-            // Show imported/gateway notices as well as local if
-            // the user is looking at his own favorites
-
-            $notice = $this->user->favoriteNotices(($this->page-1)*NOTICES_PER_PAGE,
-                                                   NOTICES_PER_PAGE + 1, true);
-        } else {
-            $notice = $this->user->favoriteNotices(($this->page-1)*NOTICES_PER_PAGE,
-                                                   NOTICES_PER_PAGE + 1, false);
-        }
-
-        if (empty($notice)) {
-            $this->serverError(_('Could not retrieve favorite notices.'));
-            return;
-        }
-
-        $nl = new NoticeList($notice, $this);
+        $nl = new NoticeList($this->notice, $this);
 
         $cnt = $nl->show();
         if (0 == $cnt) {
index 020399d9eeddc2b1d6476f4460fcefc117c26646..771eb2861eec50e7f9bcb6da2fee507fd7d6aa0f 100644 (file)
@@ -21,6 +21,9 @@ if (!defined('LACONICA')) { exit(1); }
 
 class TagAction extends Action
 {
+
+    var $notice;
+
     function prepare($args)
     {
         parent::prepare($args);
@@ -42,6 +45,12 @@ class TagAction extends Action
 
         common_set_returnto($this->selfUrl());
 
+        $this->notice = Notice_tag::getStream($this->tag, (($this->page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
+
+        if($this->page > 1 && $this->notice->N == 0){
+            $this->serverError(_('No such page'),$code=404);
+        }
+
         return true;
     }
 
@@ -94,9 +103,7 @@ class TagAction extends Action
 
     function showContent()
     {
-        $notice = Notice_tag::getStream($this->tag, (($this->page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
-
-        $nl = new NoticeList($notice, $this);
+        $nl = new NoticeList($this->notice, $this);
 
         $cnt = $nl->show();