]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/public.php
Revert "Added configuration option to only allow OpenID logins."
[quix0rs-gnu-social.git] / actions / public.php
index 961606908db126c3977a35d4eac1ddc2ca2eeb49..15bedb7119b6f24cde6b29f8a9e2bb3d85bd69d3 100644 (file)
@@ -35,6 +35,10 @@ require_once INSTALLDIR.'/lib/publicgroupnav.php';
 require_once INSTALLDIR.'/lib/noticelist.php';
 require_once INSTALLDIR.'/lib/feedlist.php';
 
+// Farther than any human will go
+
+define('MAX_PUBLIC_PAGE', 100);
+
 /**
  * Action for displaying the public stream
  *
@@ -55,20 +59,9 @@ class PublicAction extends Action
      */
 
     var $page = null;
+    var $notice;
 
-    /**
-     * Number of notices being shown on this page.
-     */
-    //    Does this need to be here? Should it be?
-    //    If it does, this property needs to be
-    //    added to other actions as well, like $page.
-    //    I'm trying to find a way to capture the
-    //    output of the $cnt variable from this
-    //    action's showContent() method but need
-    //    to do so earlier, I think...?
-    var $count = null;
-
-    function isReadOnly()
+    function isReadOnly($args)
     {
         return true;
     }
@@ -86,8 +79,24 @@ class PublicAction extends Action
         parent::prepare($args);
         $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
 
+        if ($this->page > MAX_PUBLIC_PAGE) {
+            $this->clientError(sprintf(_("Beyond the page limit (%s)"), MAX_PUBLIC_PAGE));
+        }
+
         common_set_returnto($this->selfUrl());
 
+        $this->notice = Notice::publicStream(($this->page-1)*NOTICES_PER_PAGE,
+                                       NOTICES_PER_PAGE + 1);
+
+        if (!$this->notice) {
+            $this->serverError(_('Could not retrieve public stream.'));
+            return;
+        }
+
+        if($this->page > 1 && $this->notice->N == 0){
+            $this->serverError(_('No such page'),$code=404);
+        }
+
         return true;
     }
 
@@ -105,8 +114,6 @@ class PublicAction extends Action
     {
         parent::handle($args);
 
-        header('X-XRDS-Location: '. common_local_url('publicxrds'));
-
         $this->showPage();
     }
 
@@ -147,33 +154,6 @@ class PublicAction extends Action
                               _('Public Stream Feed (Atom)')));
     }
 
-    /**
-     * Output document relationship links
-     *
-     * @return void
-     */
-    function showRelationshipLinks()
-    {
-        $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
-                                     $this->page, 'public');
-    }
-
-    /**
-     * Extra head elements
-     *
-     * We include a <meta> element linking to the publicxrds page, for OpenID
-     * client-side authentication.
-     *
-     * @return void
-     */
-
-    function extraHead()
-    {
-        // for client side of OpenID authentication
-        $this->element('meta', array('http-equiv' => 'X-XRDS-Location',
-                                     'content' => common_local_url('publicxrds')));
-    }
-
     /**
      * Show tabset for this page
      *
@@ -197,8 +177,10 @@ class PublicAction extends Action
             $message .= _('Be the first to post!');
         }
         else {
-            $message .= _('Why not [register an account](%%action.register%%) and be the first to post!');
-        }
+            if (! (common_config('site','closed') || common_config('site','inviteonly'))) {
+                $message .= _('Why not [register an account](%%action.register%%) and be the first to post!');
+            }
+       }
 
         $this->elementStart('div', 'guide');
         $this->raw(common_markup_to_html($message));
@@ -216,15 +198,7 @@ class PublicAction extends Action
 
     function showContent()
     {
-        $notice = Notice::publicStream(($this->page-1)*NOTICES_PER_PAGE,
-                                       NOTICES_PER_PAGE + 1);
-
-        if (!$notice) {
-            $this->serverError(_('Could not retrieve public stream.'));
-            return;
-        }
-
-        $nl = new NoticeList($notice, $this);
+        $nl = new NoticeList($this->notice, $this);
 
         $cnt = $nl->show();
 
@@ -242,7 +216,7 @@ class PublicAction extends Action
         // $top->show();
         $pop = new PopularNoticeSection($this);
         $pop->show();
-        $gbp = new GroupsByPostsSection($this);
+        $gbp = new GroupsByMembersSection($this);
         $gbp->show();
         $feat = new FeaturedUsersSection($this);
         $feat->show();