From 6ff00c9404cb2b2dddcd12d63c497c85d9d087d8 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 27 Aug 2009 22:55:32 -0400 Subject: Implement the is_member and membership group api's --- actions/api.php | 2 + actions/twitapigroups.php | 95 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 96 insertions(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/api.php b/actions/api.php index 93e33085f..f425a8dcd 100644 --- a/actions/api.php +++ b/actions/api.php @@ -133,6 +133,8 @@ class ApiAction extends Action 'groups/show', 'groups/timeline', 'groups/list_all', + 'groups/membership', + 'groups/is_member', 'groups/timeline'); static $bareauth = array('statuses/user_timeline', diff --git a/actions/twitapigroups.php b/actions/twitapigroups.php index 214fa8214..1740a33b5 100644 --- a/actions/twitapigroups.php +++ b/actions/twitapigroups.php @@ -21,7 +21,7 @@ * * @category Twitter * @package StatusNet - * @author Craig Andrews + * @author Craig Andrews * @author Zach Copley * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 @@ -233,4 +233,97 @@ require_once INSTALLDIR.'/lib/twitterapi.php'; } } + function membership($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; + } + + $sitename = common_config('site', 'name'); + $title = sprintf(_("Members of %s group"), $group->nickname); + $taguribase = common_config('integration', 'taguri'); + $id = "tag:$taguribase:GroupMembership:".$group->id; + $link = common_local_url('showgroup', + array('nickname' => $group->nickname)); + $subtitle = sprintf(_('Members of %1$s on %2$s'), + $group->nickname, $sitename); + + $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'); + + $member = $group->getMembers(($page-1)*$count, + $count, $since_id, $max_id, $since); + + switch($apidata['content-type']) { + case 'xml': + $this->show_twitter_xml_users($member); + break; + //TODO implement the RSS and ATOM content types + /*case 'rss': + $this->show_rss_users($member, $title, $link, $subtitle); + break;*/ + /*case 'atom': + if (isset($apidata['api_arg'])) { + $selfuri = common_root_url() . + 'api/statusnet/groups/membership/' . + $apidata['api_arg'] . '.atom'; + } else { + $selfuri = common_root_url() . + 'api/statusnet/groups/membership.atom'; + } + $this->show_atom_users($member, $title, $id, $link, + $subtitle, null, $selfuri); + break;*/ + case 'json': + $this->show_json_users($member); + break; + default: + $this->clientError(_('API method not found!'), $code = 404); + } + } + + function is_member($args, $apidata) + { + parent::handle($args); + + common_debug("in groups api action"); + + $this->auth_user = $apidata['user']; + $group = User_group::staticGet($args['group_id']); + if(! $group){ + $this->clientError(_('Group not found'), $code = 500); + } + $user = User::staticGet('id', $args['user_id']); + if(! $user){ + $this->clientError(_('User not found'), $code = 500); + } + + $is_member=$user->isMember($group); + + switch($apidata['content-type']) { + case 'xml': + $this->init_document('xml'); + $this->element('is_member', null, $is_member); + $this->end_document('xml'); + break; + case 'json': + $this->init_document('json'); + $this->show_json_objects(array('is_member'=>$is_member)); + $this->end_document('json'); + break; + default: + $this->clientError(_('API method not found!'), $code = 404); + } + } } -- cgit v1.2.3-54-g00ecf From 70fc32c5b93a6cd71cf33212ac792c38632bbdb3 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 27 Aug 2009 22:56:54 -0400 Subject: added my email address next to my name at the top of the files --- actions/twitapigroups.php | 2 +- actions/twitapitags.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'actions') diff --git a/actions/twitapigroups.php b/actions/twitapigroups.php index 1740a33b5..4deb1b764 100644 --- a/actions/twitapigroups.php +++ b/actions/twitapigroups.php @@ -41,7 +41,7 @@ require_once INSTALLDIR.'/lib/twitterapi.php'; * * @category Twitter * @package StatusNet - * @author Craig Andrews + * @author Craig Andrews * @author Zach Copley * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 diff --git a/actions/twitapitags.php b/actions/twitapitags.php index 2bb7ee01a..0bcc55d37 100644 --- a/actions/twitapitags.php +++ b/actions/twitapitags.php @@ -21,7 +21,7 @@ * * @category Twitter * @package StatusNet - * @author Craig Andrews + * @author Craig Andrews * @author Zach Copley * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 @@ -41,7 +41,7 @@ require_once INSTALLDIR.'/lib/twitterapi.php'; * * @category Twitter * @package StatusNet - * @author Craig Andrews + * @author Craig Andrews * @author Zach Copley * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 -- cgit v1.2.3-54-g00ecf From aa7bda4677f1fe7a6168665d4d5e29e8fa2db68c Mon Sep 17 00:00:00 2001 From: Carlos Perilla Date: Tue, 1 Sep 2009 09:19:10 -0500 Subject: Fixes foaf notices, use Profile for information that's missing in Remote_profile --- actions/foaf.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'actions') diff --git a/actions/foaf.php b/actions/foaf.php index 4dae9dfc1..356393304 100644 --- a/actions/foaf.php +++ b/actions/foaf.php @@ -146,8 +146,10 @@ class FoafAction extends Action while ($sub->fetch()) { if ($sub->token) { $other = Remote_profile::staticGet('id', $sub->subscriber); + $profile = Profile::staticGet('id', $sub->subscriber); } else { $other = User::staticGet('id', $sub->subscriber); + $profile = Profile::staticGet('id', $sub->subscriber); } if (!$other) { common_debug('Got a bad subscription: '.print_r($sub,true)); @@ -158,12 +160,15 @@ class FoafAction extends Action } else { $person[$other->uri] = array(LISTENER, $other->id, - $other->nickname, + $profile->nickname, (empty($sub->token)) ? 'User' : 'Remote_profile'); } $other->free(); $other = null; unset($other); + $profile->free(); + $profile = null; + unset($profile); } } @@ -254,8 +259,10 @@ class FoafAction extends Action while ($sub->fetch()) { if (!empty($sub->token)) { $other = Remote_profile::staticGet('id', $sub->subscribed); + $profile = Profile::staticGet('id', $sub->subscribed); } else { $other = User::staticGet('id', $sub->subscribed); + $profile = Profile::staticGet('id', $sub->subscribed); } if (empty($other)) { common_debug('Got a bad subscription: '.print_r($sub,true)); @@ -264,11 +271,14 @@ class FoafAction extends Action $this->element('sioc:follows', array('rdf:resource' => $other->uri.'#acct')); $person[$other->uri] = array(LISTENEE, $other->id, - $other->nickname, + $profile->nickname, (empty($sub->token)) ? 'User' : 'Remote_profile'); $other->free(); $other = null; unset($other); + $profile->free(); + $profile = null; + unset($profile); } } -- cgit v1.2.3-54-g00ecf From 8b040eba4062bcb464f49e3e04d7a172a1d55c1e Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 2 Sep 2009 00:24:30 +0000 Subject: Fixed bug in which you cannot turn off importing friends timelines flag --- actions/twittersettings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/twittersettings.php b/actions/twittersettings.php index 563d867a4..89169941e 100644 --- a/actions/twittersettings.php +++ b/actions/twittersettings.php @@ -165,7 +165,7 @@ class TwittersettingsAction extends ConnectSettingsAction ($flink->noticesync & FOREIGN_NOTICE_RECV) : false); $this->elementEnd('li'); - + } else { // preserve setting even if bidrection bridge toggled off if ($flink && ($flink->noticesync & FOREIGN_NOTICE_RECV)) { -- cgit v1.2.3-54-g00ecf