]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Quick fixes for grouplistall:
authorBrion Vibber <brion@pobox.com>
Tue, 30 Mar 2010 18:07:01 +0000 (11:07 -0700)
committerBrion Vibber <brion@pobox.com>
Tue, 30 Mar 2010 18:10:29 +0000 (11:10 -0700)
* respect count instead of listing all groups
* respect page parameter
* don't spew notice on undefined $id
* don't spew notice on undefined $group->homepage_url (dropped the element since there's nothing to go in it)

actions/apigrouplistall.php
lib/apiaction.php

index e1b54a83229ae1bcf985444d8ceebde0b572ace1..f7677970f8e387442c49569c57e07c1ddbd318a2 100644 (file)
@@ -66,7 +66,7 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
     {
         parent::prepare($args);
 
-        $this->user   = $this->getTargetUser($id);
+        $this->user   = $this->getTargetUser(null);
         $this->groups = $this->getGroups();
 
         return true;
@@ -137,11 +137,18 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
         $qry = 'SELECT user_group.* '.
           'from user_group join local_group on user_group.id = local_group.group_id '.
           'order by created desc ';
-
+        $offset = intval($this->page - 1) * intval($this->count);
+        $limit = intval($this->count);
+        if (common_config('db', 'type') == 'pgsql') {
+            $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
+        } else {
+            $qry .= ' LIMIT ' . $offset . ', ' . $limit;
+        }
         $group = new User_group();
 
         $group->query($qry);
 
+        $groups = array();
         while ($group->fetch()) {
             $groups[] = clone($group);
         }
index 9fc1a0779916d38722c65fee087998b5aff070d1..59dc47c23beee0daa678b1a2fec3d89fe5ed1339 100644 (file)
@@ -318,7 +318,6 @@ class ApiAction extends Action
         $twitter_group['url']=$group->permalink();
         $twitter_group['nickname']=$group->nickname;
         $twitter_group['fullname']=$group->fullname;
-        $twitter_group['homepage_url']=$group->homepage_url;
         $twitter_group['original_logo']=$group->original_logo;
         $twitter_group['homepage_logo']=$group->homepage_logo;
         $twitter_group['stream_logo']=$group->stream_logo;