]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apigroupshow.php
Merge branch '0.9.x' into activityexport
[quix0rs-gnu-social.git] / actions / apigroupshow.php
index 7aa49b1bf37c71c77763ea781b199814eca6ed76..9b90e6b3832df6717c2ef7165f778defa9a55f9a 100644 (file)
@@ -26,6 +26,7 @@
  * @author    Jeffery To <jeffery.to@gmail.com>
  * @author    Zach Copley <zach@status.net>
  * @copyright 2009 StatusNet, Inc.
+ * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link      http://status.net/
  */
@@ -45,6 +46,7 @@ require_once INSTALLDIR . '/lib/apiprivateauth.php';
  * @author   Evan Prodromou <evan@status.net>
  * @author   Jeffery To <jeffery.to@gmail.com>
  * @author   Zach Copley <zach@status.net>
+ * @author   Michele <macno@macno.org>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link     http://status.net/
  */
@@ -68,6 +70,24 @@ class ApiGroupShowAction extends ApiPrivateAuthAction
 
         $this->group = $this->getTargetGroup($this->arg('id'));
 
+        if (empty($this->group)) {
+            $alias = Group_alias::staticGet(
+                'alias',
+                common_canonical_nickname($this->arg('id'))
+            );
+            if (!empty($alias)) {
+                $args = array('id' => $alias->group_id, 'format' => $this->format);
+                common_redirect(common_local_url('ApiGroupShow', $args), 301);
+            } else {
+                $this->clientError(
+                    _('Group not found.'),
+                    404,
+                    $this->format
+                );
+            }
+            return;
+        }
+
         return true;
     }
 
@@ -85,15 +105,6 @@ class ApiGroupShowAction extends ApiPrivateAuthAction
     {
         parent::handle($args);
 
-        if (empty($this->group)) {
-            $this->clientError(
-                _('Group not found!'),
-                404,
-                $this->format
-            );
-            return;
-        }
-
         switch($this->format) {
         case 'xml':
             $this->showSingleXmlGroup($this->group);
@@ -105,7 +116,6 @@ class ApiGroupShowAction extends ApiPrivateAuthAction
             $this->clientError(_('API method not found.'), 404, $this->format);
             break;
         }
-
     }
 
     /**
@@ -139,6 +149,7 @@ class ApiGroupShowAction extends ApiPrivateAuthAction
             return '"' . implode(
                 ':',
                 array($this->arg('action'),
+                      common_user_cache_hash($this->auth_user),
                       common_language(),
                       $this->group->id,
                       strtotime($this->group->modified))
@@ -149,4 +160,19 @@ class ApiGroupShowAction extends ApiPrivateAuthAction
         return null;
     }
 
+    /**
+     * Return true if read only.
+     *
+     * MAY override
+     *
+     * @param array $args other arguments
+     *
+     * @return boolean is read only action?
+     */
+
+    function isReadOnly($args)
+    {
+        return true;
+    }
+
 }