]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Make Group actions ManagedAction so groupbyid works
authorMikael Nordfeldth <mmn@hethane.se>
Sun, 28 Aug 2016 07:34:31 +0000 (09:34 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Sun, 28 Aug 2016 07:34:31 +0000 (09:34 +0200)
actions/groupbyid.php
actions/groupmembers.php
actions/showgroup.php
lib/groupaction.php
lib/profileaction.php

index de87ec5c672e20da7632ef8f29e99c9411e4a91a..ed4ec979a9c7cccdfdd0acb63579e6ce38943132 100644 (file)
@@ -42,7 +42,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/
  */
-class GroupbyidAction extends ManagedAction
+class GroupbyidAction extends ShowgroupAction
 {
     /** group we're viewing. */
     protected $group = null;
@@ -55,10 +55,10 @@ class GroupbyidAction extends ManagedAction
     protected function doPreparation()
     {
         $this->group = User_group::getByID($this->arg('id'));
-    }
+        $this->target = $this->group->getProfile();
 
-    public function showPage()
-    {
-        common_redirect($this->group->homeUrl(), 303);
+        if ($this->target->isLocal()) {
+            common_redirect($this->target->getUrl());
+        }
     }
 }
index 44c4dd6f9963d27dbda9bbcf1a8be576f03e306b..1d2171b27f30c19afec99820bb1e7c0cdd6c80f4 100644 (file)
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) {
-    exit(1);
-}
-
-require_once(INSTALLDIR.'/lib/profilelist.php');
-require_once INSTALLDIR.'/lib/publicgroupnav.php';
+if (!defined('GNUSOCIAL)') { exit(1); }
 
 /**
  * List of group members
@@ -52,15 +47,6 @@ class GroupmembersAction extends GroupAction
         return true;
     }
 
-    protected function prepare(array $args=array())
-    {
-        parent::prepare($args);
-
-        $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
-
-        return true;
-    }
-
     function title()
     {
         if ($this->page == 1) {
index 8770e6cc8b5061735295ad7787c4f47eab035a39..8cc65aa9061f6a487ca738621a6666242a4d5934 100644 (file)
@@ -76,79 +76,15 @@ class ShowgroupAction extends GroupAction
         }
     }
 
-    /**
-     * Prepare the action
-     *
-     * Reads and validates arguments and instantiates the attributes.
-     *
-     * @param array $args $_REQUEST args
-     *
-     * @return boolean success flag
-     */
-    protected function prepare(array $args=array())
+    public function getStream()
     {
-        parent::prepare($args);
-
-        $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
-
         if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
             $stream = new GroupNoticeStream($this->group, $this->scoped);
         } else {
             $stream = new ThreadingGroupNoticeStream($this->group, $this->scoped);
         }
 
-        $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
-                                            NOTICES_PER_PAGE + 1);
-
-        common_set_returnto($this->selfUrl());
-
-        return true;
-    }
-
-    /**
-     * Handle the request
-     *
-     * Shows a profile for the group, some controls, and a list of
-     * group notices.
-     *
-     * @return void
-     */
-    protected function handle()
-    {
-        parent::handle();
-        $this->showPage();
-    }
-
-    /**
-     * Show the page content
-     *
-     * Shows a group profile and a list of group notices
-     */
-    function showContent()
-    {
-        $this->showGroupNotices();
-    }
-
-    /**
-     * Show the group notices
-     *
-     * @return void
-     */
-    function showGroupNotices()
-    {
-        if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
-            $nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
-        } else {
-            $nl = new ThreadedNoticeList($this->notice, $this, $this->scoped);
-        } 
-
-        $cnt = $nl->show();
-
-        $this->pagination($this->page > 1,
-                          $cnt > NOTICES_PER_PAGE,
-                          $this->page,
-                          'showgroup',
-                          array('nickname' => $this->group->nickname));
+        return $stream;
     }
 
     /**
index 31a0b8bc345fcfe0c9c3be3a905be6f1b862dcd2..2fcec360bcd6f8af0ad1c60422436919e843b9d9 100644 (file)
@@ -40,25 +40,23 @@ define('MEMBERS_PER_SECTION', 27);
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link     http://status.net/
  */
-class GroupAction extends Action
+class GroupAction extends ShowstreamAction
 {
     protected $group;
 
-    protected function prepare(array $args=array())
+    protected function doPreparation()
     {
-        parent::prepare($args);
-
         $nickname_arg = $this->arg('nickname');
         $nickname = common_canonical_nickname($nickname_arg);
 
         // Permanent redirect on non-canonical nickname
 
-        if ($nickname_arg != $nickname) {
+        if ($nickname_arg !== $nickname) {
             $args = array('nickname' => $nickname);
             if ($this->page != 1) {
                 $args['page'] = $this->page;
             }
-            common_redirect(common_local_url('showgroup', $args), 301);
+            common_redirect(common_local_url($this->getActionName(), $args), 301);
         }
 
         if (!$nickname) {
@@ -79,15 +77,16 @@ class GroupAction extends Action
             } else {
                 common_log(LOG_NOTICE, "Couldn't find local group for nickname '$nickname'");
                 // TRANS: Client error displayed if no remote group with a given name was found requesting group page.
-                $this->clientError(_('No such group.'), 404);
+                throw new ClientException(_('No such group.'), 404);
             }
         }
 
         $this->group = User_group::getKV('id', $local->group_id);
+        $this->target = $this->group->getProfile();
 
         if (!$this->group instanceof User_group) {
             // TRANS: Client error displayed if no local group with a given name was found requesting group page.
-            $this->clientError(_('No such group.'), 404);
+            throw new ClientException(_('No such group.'), 404);
         }
     }
 
@@ -105,8 +104,7 @@ class GroupAction extends Action
     function showSections()
     {
         $this->showMembers();
-        $cur = common_current_user();
-        if ($cur && $cur->isAdmin($this->group)) {
+        if ($this->scoped instanceof Profile && $this->scoped->isAdmin($this->group)) {
             $this->showPending();
             $this->showBlocked();
         }
index 22c960406a49d1fec4c31be0cd7c4e925759eb4d..64087cf3126a60efc6c0f3050217020e192f94c7 100644 (file)
@@ -55,7 +55,7 @@ abstract class ProfileAction extends ManagedAction
         $nickname     = common_canonical_nickname($nickname_arg);
 
         // Permanent redirect on non-canonical nickname
-        if ($nickname_arg != $nickname) {
+        if ($nickname_arg !== $nickname) {
             $args = array('nickname' => $nickname);
             if ($this->arg('page') && $this->arg('page') != 1) {
                 $args['page'] = $this->arg['page'];
@@ -83,7 +83,7 @@ abstract class ProfileAction extends ManagedAction
         // this will call ->doPreparation() which child classes use to set $this->target
         parent::prepare($args);
 
-        if ($this->target->hasRole(Profile_role::SILENCED)
+        if ($this->target->isPerson() && $this->target->hasRole(Profile_role::SILENCED)
                 && (!$this->scoped instanceof Profile || !$this->scoped->hasRight(Right::SILENCEUSER))) {
             throw new ClientException(_('This profile has been silenced by site moderators'), 403);
         }