]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apigrouplist.php
Merge branch '1.0.x' of gitorious.org:statusnet/mainline into 1.0.x
[quix0rs-gnu-social.git] / actions / apigrouplist.php
index 605b3823261338bcf750b5c1a74ad9c5fae28983..c7518ca129fb39dfc314fed08a00fc7382bdd6e0 100644 (file)
@@ -26,6 +26,7 @@
  * @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/
  */
@@ -48,7 +49,6 @@ require_once INSTALLDIR . '/lib/apibareauth.php';
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link     http://status.net/
  */
-
 class ApiGroupListAction extends ApiBareAuthAction
 {
     var $groups   = null;
@@ -59,14 +59,19 @@ class ApiGroupListAction extends ApiBareAuthAction
      * @param array $args $_REQUEST args
      *
      * @return boolean success flag
-     *
      */
-
     function prepare($args)
     {
         parent::prepare($args);
 
-        $this->user   = $this->getTargetUser($id);
+        $this->user   = $this->getTargetUser(null);
+
+        if (empty($this->user)) {
+            // TRANS: Client error displayed when user not found for an action.
+            $this->clientError(_('No such user.'), 404, $this->format);
+            return false;
+        }
+
         $this->groups = $this->getGroups();
 
         return true;
@@ -81,17 +86,12 @@ class ApiGroupListAction extends ApiBareAuthAction
      *
      * @return void
      */
-
     function handle($args)
     {
         parent::handle($args);
 
-        if (empty($this->user)) {
-            $this->clientError(_('No such user.'), 404, $this->format);
-            return;
-        }
-
         $sitename   = common_config('site', 'name');
+        // TRANS: Used as title in check for group membership. %s is a user name.
         $title      = sprintf(_("%s's groups"), $this->user->nickname);
         $taguribase = TagURI::base();
         $id         = "tag:$taguribase:Groups";
@@ -99,10 +99,12 @@ class ApiGroupListAction extends ApiBareAuthAction
             'usergroups',
             array('nickname' => $this->user->nickname)
         );
+
         $subtitle   = sprintf(
-            _("Groups %1$s is a member of on %2$s."),
-            $this->user->nickname,
-            $sitename
+            // TRANS: Used as subtitle in check for group membership. %1$s is the site name, %2$s is a user name.
+            _('%1$s groups %2$s is a member of.'),
+            $sitename,
+            $this->user->nickname
         );
 
         switch($this->format) {
@@ -129,13 +131,13 @@ class ApiGroupListAction extends ApiBareAuthAction
             break;
         default:
             $this->clientError(
+                // TRANS: Client error displayed when coming across a non-supported API method.
                 _('API method not found.'),
                 404,
                 $this->format
             );
             break;
         }
-
     }
 
     /**
@@ -143,7 +145,6 @@ class ApiGroupListAction extends ApiBareAuthAction
      *
      * @return array groups
      */
-
     function getGroups()
     {
         $groups = array();
@@ -152,8 +153,7 @@ class ApiGroupListAction extends ApiBareAuthAction
             ($this->page - 1) * $this->count,
             $this->count,
             $this->since_id,
-            $this->max_id,
-            $this->since
+            $this->max_id
         );
 
         while ($group->fetch()) {
@@ -170,7 +170,6 @@ class ApiGroupListAction extends ApiBareAuthAction
      *
      * @return boolean true
      */
-
     function isReadOnly($args)
     {
         return true;
@@ -199,7 +198,6 @@ class ApiGroupListAction extends ApiBareAuthAction
      *
      * @return string etag
      */
-
     function etag()
     {
         if (!empty($this->groups) && (count($this->groups) > 0)) {
@@ -209,6 +207,7 @@ class ApiGroupListAction extends ApiBareAuthAction
             return '"' . implode(
                 ':',
                 array($this->arg('action'),
+                      common_user_cache_hash($this->auth_user),
                       common_language(),
                       $this->user->id,
                       strtotime($this->groups[0]->created),
@@ -219,5 +218,4 @@ class ApiGroupListAction extends ApiBareAuthAction
 
         return null;
     }
-
 }