]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/showgroup.php
Resolve Group Aliases in showgroup.php
[quix0rs-gnu-social.git] / actions / showgroup.php
index 357f579d8f1c3d060b778ac19a3cd1ebad23624b..b0cc1dbc7df61ab4d720f49debc39c4a83fdc119 100644 (file)
@@ -47,10 +47,9 @@ define('MEMBERS_PER_SECTION', 27);
  * @link     http://laconi.ca/
  */
 
-class ShowgroupAction extends Action
+class ShowgroupAction extends GroupDesignAction
 {
-    /** group we're viewing. */
-    var $group = null;
+
     /** page we're viewing. */
     var $page = null;
 
@@ -131,8 +130,18 @@ class ShowgroupAction extends Action
         $this->group = User_group::staticGet('nickname', $nickname);
 
         if (!$this->group) {
-            $this->clientError(_('No such group'), 404);
-            return false;
+            $alias = Group_alias::staticGet('alias', $nickname);
+            if ($alias) {
+                $args = array('id' => $alias->group_id);
+                if ($this->page != 1) {
+                    $args['page'] = $this->page;
+                }
+                common_redirect(common_local_url('groupbyid', $args), 301);
+                return false;
+            } else {
+                $this->clientError(_('No such group'), 404);
+                return false;
+            }
         }
 
         common_set_returnto($this->selfUrl());
@@ -318,8 +327,25 @@ class ShowgroupAction extends Action
           common_local_url('grouprss',
                            array('nickname' => $this->group->nickname));
 
-        return array(new Feed(Feed::RSS1, $url, sprintf(_('Notice feed for %s group'),
-                                                        $this->group->nickname)));
+        return array(new Feed(Feed::RSS1,
+                              common_local_url('grouprss',
+                                               array('nickname' => $this->group->nickname)),
+                              sprintf(_('Notice feed for %s group (RSS 1.0)'),
+                                      $this->group->nickname)),
+                     new Feed(Feed::RSS2,
+                              common_local_url('api',
+                                               array('apiaction' => 'groups',
+                                                     'method' => 'timeline',
+                                                     'argument' => $this->group->nickname.'.rss')),
+                              sprintf(_('Notice feed for %s group (RSS 2.0)'),
+                                      $this->group->nickname)),
+                     new Feed(Feed::ATOM,
+                              common_local_url('api',
+                                               array('apiaction' => 'groups',
+                                                     'method' => 'timeline',
+                                                     'argument' => $this->group->nickname.'.atom')),
+                              sprintf(_('Notice feed for %s group (Atom)'),
+                                      $this->group->nickname)));
     }
 
     /**
@@ -332,6 +358,7 @@ class ShowgroupAction extends Action
     {
         $this->showMembers();
         $this->showStatistics();
+        $this->showAdmins();
         $cloud = new GroupTagCloudSection($this, $this->group);
         $cloud->show();
     }
@@ -370,6 +397,18 @@ class ShowgroupAction extends Action
         $this->elementEnd('div');
     }
 
+    /**
+     * Show list of admins
+     *
+     * @return void
+     */
+
+    function showAdmins()
+    {
+        $adminSection = new GroupAdminSection($this, $this->group);
+        $adminSection->show();
+    }
+
     /**
      * Show some statistics
      *
@@ -411,8 +450,9 @@ class ShowgroupAction extends Action
             $m = sprintf(_('**%s** is a user group on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
                 'based on the Free Software [Laconica](http://laconi.ca/) tool. Its members share ' .
                 'short messages about their life and interests. '.
-                '[Join now](%%%%action.register%%%%) to become part of this group and many more! ([Read more](%%%%doc.help%%%%))'),
-                     $this->group->nickname);
+                '[Join now](%%%%action.%s%%%%) to become part of this group and many more! ([Read more](%%%%doc.help%%%%))'),
+                     $this->group->nickname,
+                     (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
         } else {
             $m = sprintf(_('**%s** is a user group on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
                 'based on the Free Software [Laconica](http://laconi.ca/) tool. Its members share ' .
@@ -424,3 +464,34 @@ class ShowgroupAction extends Action
         $this->elementEnd('div');
     }
 }
+
+class GroupAdminSection extends ProfileSection
+{
+    var $group;
+
+    function __construct($out, $group)
+    {
+        parent::__construct($out);
+        $this->group = $group;
+    }
+
+    function getProfiles()
+    {
+        return $this->group->getAdmins();
+    }
+
+    function title()
+    {
+        return _('Admins');
+    }
+
+    function divId()
+    {
+        return 'group_admins';
+    }
+
+    function moreUrl()
+    {
+        return null;
+    }
+}