X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapigroupshow.php;h=a1643302e1cab8b8ed11b51a484d403671efdf09;hb=0a20abf1d8a9a068df9310d6903cc303f39b25ed;hp=b745ff92f6aff0223f63115b4141d3ff9b78a307;hpb=d9cde0ef80ee838a99035d44f0286b3cc902e332;p=quix0rs-gnu-social.git diff --git a/actions/apigroupshow.php b/actions/apigroupshow.php index b745ff92f6..a1643302e1 100644 --- a/actions/apigroupshow.php +++ b/actions/apigroupshow.php @@ -26,6 +26,7 @@ * @author Jeffery To * @author Zach Copley * @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/ */ @@ -34,8 +35,6 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR . '/lib/apiprivateauth.php'; - /** * Outputs detailed information about the group specified by ID * @@ -45,10 +44,10 @@ require_once INSTALLDIR . '/lib/apiprivateauth.php'; * @author Evan Prodromou * @author Jeffery To * @author Zach Copley + * @author Michele * @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 ApiPrivateAuthAction { var $group = null; @@ -59,15 +58,28 @@ class ApiGroupShowAction extends ApiPrivateAuthAction * @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; } @@ -76,36 +88,23 @@ class ApiGroupShowAction extends ApiPrivateAuthAction * * 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); } - } /** @@ -113,7 +112,6 @@ class ApiGroupShowAction extends ApiPrivateAuthAction * * @return string datestamp of the latest notice in the stream */ - function lastModified() { if (!empty($this->group)) { @@ -131,7 +129,6 @@ class ApiGroupShowAction extends ApiPrivateAuthAction * * @return string etag */ - function etag() { if (!empty($this->group)) { @@ -139,6 +136,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 +147,17 @@ 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; + } }