summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorCraig Andrews <candrews@integralblue.com>2009-08-07 18:00:04 -0400
committerCraig Andrews <candrews@integralblue.com>2009-08-07 18:00:04 -0400
commit11086c78239a30dc47622837a2800d899ebf9b0f (patch)
tree94e5f2a8bff5d20008731aa293753cc24a6dcc7d /actions
parent63cedb7c31078d018069640a1a4b00d9de45e89c (diff)
Implemented the list_all and list groups API methods as defined at http://laconi.ca/trac/wiki/ProposedGroupsAPI
Made the Autocomplete plugin also autocomplete groups
Diffstat (limited to 'actions')
-rw-r--r--actions/api.php5
-rw-r--r--actions/twitapigroups.php97
2 files changed, 101 insertions, 1 deletions
diff --git a/actions/api.php b/actions/api.php
index 99ab262ad..6d226af7e 100644
--- a/actions/api.php
+++ b/actions/api.php
@@ -131,6 +131,8 @@ class ApiAction extends Action
'tags/timeline',
'oembed/oembed',
'groups/show',
+ 'groups/timeline',
+ 'groups/list_all',
'groups/timeline');
static $bareauth = array('statuses/user_timeline',
@@ -140,7 +142,8 @@ class ApiAction extends Action
'statuses/mentions',
'statuses/followers',
'favorites/favorites',
- 'friendships/show');
+ 'friendships/show',
+ 'groups/list_groups');
$fullname = "$this->api_action/$this->api_method";
diff --git a/actions/twitapigroups.php b/actions/twitapigroups.php
index 82604ebff..bebc07fa1 100644
--- a/actions/twitapigroups.php
+++ b/actions/twitapigroups.php
@@ -51,6 +51,103 @@ require_once INSTALLDIR.'/lib/twitterapi.php';
class TwitapigroupsAction extends TwitterapiAction
{
+ function list_groups($args, $apidata)
+ {
+ parent::handle($args);
+
+ common_debug("in groups api action");
+
+ $this->auth_user = $apidata['user'];
+ $user = $this->get_user($apidata['api_arg'], $apidata);
+
+ if (empty($user)) {
+ $this->clientError('Not Found', 404, $apidata['content-type']);
+ return;
+ }
+
+ $page = (int)$this->arg('page', 1);
+ $count = (int)$this->arg('count', 20);
+ $max_id = (int)$this->arg('max_id', 0);
+ $since_id = (int)$this->arg('since_id', 0);
+ $since = $this->arg('since');
+ $group = $user->getGroups(($page-1)*$count,
+ $count, $since_id, $max_id, $since);
+
+ $sitename = common_config('site', 'name');
+ $title = sprintf(_("%s's groups"), $user->nickname);
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:Groups";
+ $link = common_root_url();
+ $subtitle = sprintf(_("groups %s is a member of on %s"), $user->nickname, $sitename);
+
+ switch($apidata['content-type']) {
+ case 'xml':
+ $this->show_xml_groups($group);
+ break;
+ case 'rss':
+ $this->show_rss_groups($group, $title, $link, $subtitle);
+ break;
+ case 'atom':
+ $selfuri = common_root_url() . 'api/laconica/groups/list/' . $user->id . '.atom';
+ $this->show_atom_groups($group, $title, $id, $link,
+ $subtitle, $selfuri);
+ break;
+ case 'json':
+ $this->show_json_groups($group);
+ break;
+ default:
+ $this->clientError(_('API method not found!'), $code = 404);
+ break;
+ }
+ }
+
+ function list_all($args, $apidata)
+ {
+ parent::handle($args);
+
+ common_debug("in groups api action");
+
+ $page = (int)$this->arg('page', 1);
+ $count = (int)$this->arg('count', 20);
+ $max_id = (int)$this->arg('max_id', 0);
+ $since_id = (int)$this->arg('since_id', 0);
+ $since = $this->arg('since');
+
+ /* TODO:
+ Use the $page, $count, $max_id, $since_id, and $since parameters
+ */
+ $group = new User_group();
+ $group->orderBy('created DESC');
+ $group->find();
+
+ $sitename = common_config('site', 'name');
+ $title = sprintf(_("%s groups"), $sitename);
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:Groups";
+ $link = common_root_url();
+ $subtitle = sprintf(_("groups on %s"), $sitename);
+
+ switch($apidata['content-type']) {
+ case 'xml':
+ $this->show_xml_groups($group);
+ break;
+ case 'rss':
+ $this->show_rss_groups($group, $title, $link, $subtitle);
+ break;
+ case 'atom':
+ $selfuri = common_root_url() . 'api/laconica/groups/list_all.atom';
+ $this->show_atom_groups($group, $title, $id, $link,
+ $subtitle, $selfuri);
+ break;
+ case 'json':
+ $this->show_json_groups($group);
+ break;
+ default:
+ $this->clientError(_('API method not found!'), $code = 404);
+ break;
+ }
+ }
+
function show($args, $apidata)
{
parent::handle($args);