]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apigroupmembership.php
* i18n/L10n fixes.
[quix0rs-gnu-social.git] / actions / apigroupmembership.php
index 27f77029eb62b154fdc49c2cde0f06ed7fd4fc73..99ac965fa18d2c5aa9de82cf91ef317a3be8e025 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,21 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/api.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 <candrews@integralblue.com>
+ * @author   Evan Prodromou <evan@status.net>
+ * @author   Jeffery To <jeffery.to@gmail.com>
  * @author   Zach Copley <zach@status.net>
  * @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 ApiAction
+class ApiGroupMembershipAction extends ApiPrivateAuthAction
 {
     var $group    = null;
     var $profiles = null;
@@ -54,9 +60,7 @@ class ApiGroupMembershipAction extends ApiAction
      * @param array $args $_REQUEST args
      *
      * @return boolean success flag
-     *
      */
-
     function prepare($args)
     {
         parent::prepare($args);
@@ -76,11 +80,16 @@ class ApiGroupMembershipAction extends ApiAction
      *
      * @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) {
@@ -92,7 +101,8 @@ class ApiGroupMembershipAction extends ApiAction
             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
             );
@@ -103,19 +113,17 @@ class ApiGroupMembershipAction extends ApiAction
     /**
      * 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()) {
@@ -132,7 +140,6 @@ class ApiGroupMembershipAction extends ApiAction
      *
      * @return boolean true
      */
-
     function isReadOnly($args)
     {
         return true;
@@ -143,7 +150,6 @@ class ApiGroupMembershipAction extends ApiAction
      *
      * @return string datestamp of the lastest profile in the group
      */
-
     function lastModified()
     {
         if (!empty($this->profiles) && (count($this->profiles) > 0)) {
@@ -157,12 +163,11 @@ class ApiGroupMembershipAction extends ApiAction
      * 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)) {
@@ -172,6 +177,7 @@ class ApiGroupMembershipAction extends ApiAction
             return '"' . implode(
                 ':',
                 array($this->arg('action'),
+                      common_user_cache_hash($this->auth_user),
                       common_language(),
                       $this->group->id,
                       strtotime($this->profiles[0]->created),
@@ -182,5 +188,4 @@ class ApiGroupMembershipAction extends ApiAction
 
         return null;
     }
-
 }