]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apigroupshow.php
Match parent class definition of clientError
[quix0rs-gnu-social.git] / actions / apigroupshow.php
index 8969ae194b83df1ebc660cb63365d13cc8da8d53..a1643302e1cab8b8ed11b51a484d403671efdf09 100644 (file)
  *
  * @category  API
  * @package   StatusNet
+ * @author    Craig Andrews <candrews@integralblue.com>
+ * @author    Evan Prodromou <evan@status.net>
+ * @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/
  */
@@ -31,19 +35,20 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR.'/lib/api.php';
-
 /**
  * Outputs detailed information about the group specified by ID
  *
  * @category API
  * @package  StatusNet
+ * @author   Craig Andrews <candrews@integralblue.com>
+ * @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/
  */
-
-class ApiGroupShowAction extends ApiAction
+class ApiGroupShowAction extends ApiPrivateAuthAction
 {
     var $group = null;
 
@@ -53,15 +58,28 @@ class ApiGroupShowAction extends ApiAction
      * @param array $args $_REQUEST args
      *
      * @return boolean success flag
-     *
      */
-
-    function prepare($args)
+    protected function prepare(array $args=array())
     {
         parent::prepare($args);
 
         $this->group = $this->getTargetGroup($this->arg('id'));
 
+        if (empty($this->group)) {
+            $alias = Group_alias::getKV(
+                '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 {
+                // TRANS: Client error displayed when trying to show a group that could not be found.
+                $this->clientError(_('Group not found.'), 404);
+            }
+            return;
+        }
+
         return true;
     }
 
@@ -70,36 +88,23 @@ class ApiGroupShowAction extends ApiAction
      *
      * Check the format and show the user info
      *
-     * @param array $args $_REQUEST data (unused)
-     *
      * @return void
      */
-
-    function handle($args)
+    protected function handle()
     {
-        parent::handle($args);
-
-        if (empty($this->group)) {
-            $this->clientError(
-                'Group not found!',
-                404,
-                $this->format
-            );
-            return;
-        }
+        parent::handle();
 
         switch($this->format) {
         case 'xml':
-            $this->show_single_xml_group($this->group);
+            $this->showSingleXmlGroup($this->group);
             break;
         case 'json':
             $this->showSingleJsonGroup($this->group);
             break;
         default:
-            $this->clientError(_('API method not found!'), 404, $this->format);
-            break;
+            // TRANS: Client error displayed when coming across a non-supported API method.
+            $this->clientError(_('API method not found.'), 404);
         }
-
     }
 
     /**
@@ -107,7 +112,6 @@ class ApiGroupShowAction extends ApiAction
      *
      * @return string datestamp of the latest notice in the stream
      */
-
     function lastModified()
     {
         if (!empty($this->group)) {
@@ -125,7 +129,6 @@ class ApiGroupShowAction extends ApiAction
      *
      * @return string etag
      */
-
     function etag()
     {
         if (!empty($this->group)) {
@@ -133,6 +136,7 @@ class ApiGroupShowAction extends ApiAction
             return '"' . implode(
                 ':',
                 array($this->arg('action'),
+                      common_user_cache_hash($this->auth_user),
                       common_language(),
                       $this->group->id,
                       strtotime($this->group->modified))
@@ -143,4 +147,17 @@ class ApiGroupShowAction extends ApiAction
         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;
+    }
 }