summaryrefslogtreecommitdiff
path: root/actions/twitapigroups.php
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2009-09-24 18:18:26 -0700
committerZach Copley <zach@status.net>2009-09-24 18:18:26 -0700
commit150cf8c045e8e091a70440d1b833fa19aaf31419 (patch)
tree26aa6f09e89cf1176785f6bcb9b38b4c61d4a7cd /actions/twitapigroups.php
parented9ba9d945e4f50812022a7489fc8135f4e49846 (diff)
parentb617c608ea0d66451eb2dcd75e1e1c58c179d8e6 (diff)
Merge branch '0.9.x' into refactor-api
* 0.9.x: (88 commits) Left a couple debugging statements in (removed) Output If-Modified-Since header for all RSS 1.0 feeds (again) Revert "move scripts to just before </body>, add event for scripts that need to be in <head>" Implemented join and leave groups api methods implemented etag and last modified Fixed broken Piwik plugin - was not using the supplied site code move scripts to just before </body>, add event for scripts that need to be in <head> some UI fixes Using timeline string instead of title for WindowName because IE doesn't Added JavaScript to initialize the poped Window Some layout and rendering adjustment for Realtime plugin Created addPop() for Realtime plugin and added param to include iconurl move some stuff around for realtime hack around address hack in util.js Add some more realtime feeds Do realtime popup with PHP instead of Javascript JavaScript fixes for IE Revert "Added realtime streams for all and showstream timelines" Revert "Fixed indenting" Revert "Made it slighly more compact with less jQuery selection" ...
Diffstat (limited to 'actions/twitapigroups.php')
-rw-r--r--actions/twitapigroups.php124
1 files changed, 124 insertions, 0 deletions
diff --git a/actions/twitapigroups.php b/actions/twitapigroups.php
index 4deb1b764..493144e77 100644
--- a/actions/twitapigroups.php
+++ b/actions/twitapigroups.php
@@ -293,6 +293,105 @@ require_once INSTALLDIR.'/lib/twitterapi.php';
}
}
+ function join($args, $apidata)
+ {
+ parent::handle($args);
+
+ common_debug("in groups api action");
+
+ $this->auth_user = $apidata['user'];
+ $group = $this->get_group($apidata['api_arg'], $apidata);
+
+ if (empty($group)) {
+ $this->clientError('Not Found', 404, $apidata['content-type']);
+ return false;
+ }
+
+ if($this->auth_user->isMember($group)){
+ $this->clientError(_('You are already a member of that group'), $code = 403);
+ return false;
+ }
+
+ if (Group_block::isBlocked($group, $this->auth_user->getProfile())) {
+ $this->clientError(_('You have been blocked from that group by the admin.'), 403);
+ return false;
+ }
+
+ $member = new Group_member();
+
+ $member->group_id = $group->id;
+ $member->profile_id = $this->auth_user->id;
+ $member->created = common_sql_now();
+
+ $result = $member->insert();
+
+ if (!$result) {
+ common_log_db_error($member, 'INSERT', __FILE__);
+ $this->serverError(sprintf(_('Could not join user %s to group %s'),
+ $this->auth_user->nickname, $group->nickname));
+ }
+
+ switch($apidata['content-type']) {
+ case 'xml':
+ $this->show_single_xml_group($group);
+ break;
+ case 'json':
+ $this->show_single_json_group($group);
+ break;
+ default:
+ $this->clientError(_('API method not found!'), $code = 404);
+ }
+ }
+
+ function leave($args, $apidata)
+ {
+ parent::handle($args);
+
+ common_debug("in groups api action");
+
+ $this->auth_user = $apidata['user'];
+ $group = $this->get_group($apidata['api_arg'], $apidata);
+
+ if (empty($group)) {
+ $this->clientError('Not Found', 404, $apidata['content-type']);
+ return false;
+ }
+
+ if(! $this->auth_user->isMember($group)){
+ $this->clientError(_('You are not a member of that group'), $code = 403);
+ return false;
+ }
+
+ $member = new Group_member();
+
+ $member->group_id = $group->id;
+ $member->profile_id = $this->auth_user->id;
+
+ if (!$member->find(true)) {
+ $this->serverError(_('Could not find membership record.'));
+ return;
+ }
+
+ $result = $member->delete();
+
+ if (!$result) {
+ common_log_db_error($member, 'INSERT', __FILE__);
+ $this->serverError(sprintf(_('Could not remove user %s to group %s'),
+ $this->auth_user->nickname, $group->nickname));
+ }
+
+ switch($apidata['content-type']) {
+ case 'xml':
+ $this->show_single_xml_group($group);
+ break;
+ case 'json':
+ $this->show_single_json_group($group);
+ break;
+ default:
+ $this->clientError(_('API method not found!'), $code = 404);
+ }
+ }
+
function is_member($args, $apidata)
{
parent::handle($args);
@@ -326,4 +425,29 @@ require_once INSTALLDIR.'/lib/twitterapi.php';
$this->clientError(_('API method not found!'), $code = 404);
}
}
+
+ function create($args, $apidata)
+ {
+ die("todo");
+ }
+
+ function update($args, $apidata)
+ {
+ die("todo");
+ }
+
+ function update_group_logo($args, $apidata)
+ {
+ die("todo");
+ }
+
+ function destroy($args, $apidata)
+ {
+ die("todo");
+ }
+
+ function tag($args, $apidata)
+ {
+ die("todo");
+ }
}