X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapigrouplistall.php;h=f7677970f8e387442c49569c57e07c1ddbd318a2;hb=a21a17263956808e074fb62551300c5d6297387b;hp=89469f36f4a180cfa08f525f85ddd7de0a1bc9e0;hpb=870b091693531ba9aca20a0b0fa64ec326d72725;p=quix0rs-gnu-social.git diff --git a/actions/apigrouplistall.php b/actions/apigrouplistall.php index 89469f36f4..f7677970f8 100644 --- a/actions/apigrouplistall.php +++ b/actions/apigrouplistall.php @@ -34,7 +34,7 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR . '/lib/api.php'; +require_once INSTALLDIR . '/lib/apiprivateauth.php'; /** * Returns of the lastest 20 groups for the site @@ -49,7 +49,7 @@ require_once INSTALLDIR . '/lib/api.php'; * @link http://status.net/ */ -class ApiGroupListAllAction extends ApiAction +class ApiGroupListAllAction extends ApiPrivateAuthAction { var $groups = null; @@ -66,7 +66,7 @@ class ApiGroupListAllAction extends ApiAction { parent::prepare($args); - $this->user = $this->getTargetUser($id); + $this->user = $this->getTargetUser(null); $this->groups = $this->getGroups(); return true; @@ -88,7 +88,7 @@ class ApiGroupListAllAction extends ApiAction $sitename = common_config('site', 'name'); $title = sprintf(_("%s groups"), $sitename); - $taguribase = common_config('integration', 'taguri'); + $taguribase = TagURI::base(); $id = "tag:$taguribase:Groups"; $link = common_local_url('groups'); $subtitle = sprintf(_("groups on %s"), $sitename); @@ -117,7 +117,7 @@ class ApiGroupListAllAction extends ApiAction break; default: $this->clientError( - _('API method not found!'), + _('API method not found.'), 404, $this->format ); @@ -134,14 +134,21 @@ class ApiGroupListAllAction extends ApiAction function getGroups() { - $groups = array(); - - // XXX: Use the $page, $count, $max_id, $since_id, and $since parameters - + $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->orderBy('created DESC'); - $group->find(); + $group->query($qry); + + $groups = array(); while ($group->fetch()) { $groups[] = clone($group); }