]> 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 b6a0f4844e78a69752cd6c690203b54d869ede07..b0cc1dbc7df61ab4d720f49debc39c4a83fdc119 100644 (file)
@@ -130,8 +130,18 @@ class ShowgroupAction extends GroupDesignAction
         $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());
@@ -317,8 +327,25 @@ class ShowgroupAction extends GroupDesignAction
           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)));
     }
 
     /**
@@ -331,6 +358,7 @@ class ShowgroupAction extends GroupDesignAction
     {
         $this->showMembers();
         $this->showStatistics();
+        $this->showAdmins();
         $cloud = new GroupTagCloudSection($this, $this->group);
         $cloud->show();
     }
@@ -369,6 +397,18 @@ class ShowgroupAction extends GroupDesignAction
         $this->elementEnd('div');
     }
 
+    /**
+     * Show list of admins
+     *
+     * @return void
+     */
+
+    function showAdmins()
+    {
+        $adminSection = new GroupAdminSection($this, $this->group);
+        $adminSection->show();
+    }
+
     /**
      * Show some statistics
      *
@@ -410,8 +450,9 @@ class ShowgroupAction extends GroupDesignAction
             $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 ' .
@@ -423,3 +464,34 @@ class ShowgroupAction extends GroupDesignAction
         $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;
+    }
+}