X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapigroupmembership.php;h=99ac965fa18d2c5aa9de82cf91ef317a3be8e025;hb=cff14c7e10b5125874438215fb799bccaa9337ea;hp=0cd3ed2906f9ae783d38c6c445d9b079ebd59707;hpb=08de0f1ebdabdce561ce863bdec219a913e61d26;p=quix0rs-gnu-social.git diff --git a/actions/apigroupmembership.php b/actions/apigroupmembership.php index 0cd3ed2906..99ac965fa1 100644 --- a/actions/apigroupmembership.php +++ b/actions/apigroupmembership.php @@ -21,8 +21,12 @@ * * @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/ */ @@ -31,26 +35,22 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR . '/lib/twitterapi.php'; +require_once INSTALLDIR . '/lib/apiprivateauth.php'; /** - * List 20 newest members of the group specified by name or ID. + * List 20 newest members of the group specified by name or ID. * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - -class ApiGroupMembershipAction extends TwitterApiAction +class ApiGroupMembershipAction extends ApiPrivateAuthAction { - var $format = null; - var $page = null; - var $count = null; - var $max_id = null; - var $since_id = null; - var $since = null; var $group = null; var $profiles = null; @@ -60,22 +60,12 @@ class ApiGroupMembershipAction extends TwitterApiAction * @param array $args $_REQUEST args * * @return boolean success flag - * */ - function prepare($args) { parent::prepare($args); - $this->page = (int)$this->arg('page', 1); - $this->count = (int)$this->arg('count', 20); - $this->max_id = (int)$this->arg('max_id', 0); - $this->since_id = (int)$this->arg('since_id', 0); - $this->since = $this->arg('since'); - - $this->format = $this->arg('format'); - $this->group = $this->getTargetGroup($this->arg('id')); - + $this->group = $this->getTargetGroup($this->arg('id')); $this->profiles = $this->getProfiles(); return true; @@ -90,23 +80,29 @@ class ApiGroupMembershipAction extends TwitterApiAction * * @return void */ - function handle($args) { parent::handle($args); + if (empty($this->group)) { + // TRANS: Client error displayed trying to show group membership on a non-existing group. + $this->clientError(_('Group not found.'), 404, $this->format); + return false; + } + // XXX: RSS and Atom switch($this->format) { case 'xml': - $this->show_twitter_xml_users($this->profiles); + $this->showTwitterXmlUsers($this->profiles); break; case 'json': - $this->show_json_users($this->profiles); + $this->showJsonUsers($this->profiles); break; default: $this->clientError( - _('API method not found!'), + // TRANS: Client error displayed trying to execute an unknown API method showing group membership. + _('API method not found.'), 404, $this->format ); @@ -117,19 +113,17 @@ class ApiGroupMembershipAction extends TwitterApiAction /** * Fetch the members of a group * - * @return array $profiles list of profiles + * @return array $profiles list of profiles */ - function getProfiles() { $profiles = array(); $profile = $this->group->getMembers( ($this->page - 1) * $this->count, - $this->count, - $this->since_id, - $this->max_id, - $this->since + $this->count, + $this->since_id, + $this->max_id ); while ($profile->fetch()) { @@ -146,7 +140,6 @@ class ApiGroupMembershipAction extends TwitterApiAction * * @return boolean true */ - function isReadOnly($args) { return true; @@ -157,7 +150,6 @@ class ApiGroupMembershipAction extends TwitterApiAction * * @return string datestamp of the lastest profile in the group */ - function lastModified() { if (!empty($this->profiles) && (count($this->profiles) > 0)) { @@ -171,12 +163,11 @@ class ApiGroupMembershipAction extends TwitterApiAction * An entity tag for this list of groups * * Returns an Etag based on the action name, language - * the group id, and timestamps of the first and last + * the group id, and timestamps of the first and last * user who has joined the group * * @return string etag */ - function etag() { if (!empty($this->profiles) && (count($this->profiles) > 0)) { @@ -186,6 +177,7 @@ class ApiGroupMembershipAction extends TwitterApiAction return '"' . implode( ':', array($this->arg('action'), + common_user_cache_hash($this->auth_user), common_language(), $this->group->id, strtotime($this->profiles[0]->created), @@ -196,5 +188,4 @@ class ApiGroupMembershipAction extends TwitterApiAction return null; } - }