. * * @category API * @package StatusNet * @author Craig Andrews * @author Evan Prodromou * @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/ */ if (!defined('STATUSNET')) { exit(1); } /** * Outputs detailed information about the group specified by ID * * @category API * @package StatusNet * @author Craig Andrews * @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; /** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ 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; } /** * Handle the request * * Check the format and show the user info * * @return void */ protected function handle() { parent::handle(); switch($this->format) { case 'xml': $this->showSingleXmlGroup($this->group); break; case 'json': $this->showSingleJsonGroup($this->group); break; default: // TRANS: Client error displayed when coming across a non-supported API method. $this->clientError(_('API method not found.'), 404); } } /** * When was this group last modified? * * @return string datestamp of the latest notice in the stream */ function lastModified() { if (!empty($this->group)) { return strtotime($this->group->modified); } return null; } /** * An entity tag for this group * * Returns an Etag based on the action name, language, and * timestamps of the notice * * @return string etag */ function etag() { if (!empty($this->group)) { return '"' . implode( ':', array($this->arg('action'), common_user_cache_hash($this->auth_user), common_language(), $this->group->id, strtotime($this->group->modified)) ) . '"'; } return null; } /** * Return true if read only. * * MAY override * * @param array $args other arguments * * @return boolean is read only action? */ function isReadOnly(array $args=array()) { return true; } }