From 1e0c36afb5c265eff1d72331b44239e35f5226ed Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 1 Oct 2009 18:19:59 -0700 Subject: Renamed and moved stuff around to better match Twitter's API organization --- actions/apistatusesupdate.php | 240 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100644 actions/apistatusesupdate.php (limited to 'actions/apistatusesupdate.php') diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php new file mode 100644 index 000000000..fb1278559 --- /dev/null +++ b/actions/apistatusesupdate.php @@ -0,0 +1,240 @@ +. + * + * @category API + * @package StatusNet + * @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 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/apiauth.php'; + +/** + * Updates the authenticating user's status (posts a notice). + * + * @category API + * @package StatusNet + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class ApiStatusesUpdateAction extends ApiAuthAction +{ + + var $user = null; + var $source = null; + var $status = null; + var $in_reply_to_status_id = null; + var $format = null; + + static $reserved_sources = array('web', 'omb', 'mail', 'xmpp', 'api'); + + /** + * Take arguments for running + * + * @param array $args $_REQUEST args + * + * @return boolean success flag + * + */ + + function prepare($args) + { + parent::prepare($args); + + if ($this->requiresAuth()) { + if ($this->checkBasicAuthUser() == false) { + return false; + } + } + + $this->user = $this->auth_user; + + if (empty($this->user)) { + $this->clientError(_('No such user!'), 404, $this->format); + return false; + } + + $this->status = $this->trimmed('status'); + + if (empty($this->status)) { + $this->clientError( + 'Client must provide a \'status\' parameter with a value.', + 400, + $this->format + ); + + return false; + } + + $this->source = $this->trimmed('source'); + + if (empty($this->source) || in_array($source, $this->reserved_sources)) { + $this->source = 'api'; + } + + $this->format = $this->arg('format'); + + $this->in_reply_to_status_id + = intval($this->trimmed('in_reply_to_status_id')); + + return true; + } + + /** + * Handle the request + * + * Make a new notice for the update, save it, and show it + * + * @param array $args $_REQUEST data (unused) + * + * @return void + */ + + function handle($args) + { + parent::handle($args); + + if ($_SERVER['REQUEST_METHOD'] != 'POST') { + $this->clientError( + _('This method requires a POST.'), + 400, $this->format + ); + return; + } + + $status_shortened = common_shorten_links($this->status); + + if (Notice::contentTooLong($status_shortened)) { + + // Note: Twitter truncates anything over 140, flags the status + // as "truncated." + + $this->clientError( + sprintf( + _('That\'s too long. Max notice size is %d chars.'), + Notice::maxContent() + ), + 406, + $this->format + ); + + return; + } + + // Check for commands + + $inter = new CommandInterpreter(); + $cmd = $inter->handle_command($this->user, $status_shortened); + + if ($cmd) { + + if ($this->supported($cmd)) { + $cmd->execute(new Channel()); + } + + // Cmd not supported? Twitter just returns your latest status. + // And, it returns your last status whether the cmd was successful + // or not! + + $this->notice = $this->user->getCurrentNotice(); + + } else { + + $reply_to = null; + + if (!empty($this->in_reply_to_status_id)) { + + // Check whether notice actually exists + + $reply = Notice::staticGet($this->in_reply_to_status_id); + + if ($reply) { + $reply_to = $this->in_reply_to_status_id; + } else { + $this->clientError( + _('Not found'), + $code = 404, + $this->format + ); + return; + } + } + + $this->notice = Notice::saveNew( + $this->user->id, + html_entity_decode($this->status, ENT_NOQUOTES, 'UTF-8'), + $this->source, + 1, + $reply_to + ); + + common_broadcast_notice($this->notice); + } + + $this->showNotice(); + } + + /** + * Show the resulting notice + * + * @return void + */ + + function showNotice() + { + if (!empty($this->notice)) { + if ($this->format == 'xml') { + $this->show_single_xml_status($this->notice); + } elseif ($this->format == 'json') { + $this->show_single_json_status($this->notice); + } + } + } + + /** + * Is this command supported when doing an update from the API? + * + * @param string $cmd the command to check for + * + * @return boolean true or false + */ + + function supported($cmd) + { + static $cmdlist = array('MessageCommand', 'SubCommand', 'UnsubCommand', + 'FavCommand', 'OnCommand', 'OffCommand'); + + if (in_array(get_class($cmd), $cmdlist)) { + return true; + } + + return false; + } + +} -- cgit v1.2.3-54-g00ecf From 743c844084bae75db02570d76694f4e9b79a9aa9 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 9 Oct 2009 16:57:22 -0700 Subject: Move all basic auth output and processing to base classes --- actions/apiaccountratelimitstatus.php | 21 --------------------- actions/apiaccountverifycredentials.php | 21 --------------------- actions/apiblockcreate.php | 6 ------ actions/apiblockdestroy.php | 6 ------ actions/apidirectmessage.php | 6 ------ actions/apidirectmessagenew.php | 6 ------ actions/apifavoritecreate.php | 6 ------ actions/apifavoritedestroy.php | 6 ------ actions/apifriendshipscreate.php | 6 ------ actions/apifriendshipsdestroy.php | 6 ------ actions/apifriendshipsshow.php | 6 ------ actions/apigroupismember.php | 6 ------ actions/apigroupjoin.php | 6 ------ actions/apigroupleave.php | 6 ------ actions/apigrouplist.php | 6 ------ actions/apistatusesdestroy.php | 6 ------ actions/apistatusesupdate.php | 6 ------ actions/apisubscriptions.php | 6 ------ actions/apitimelinefavorites.php | 6 ------ actions/apitimelinefriends.php | 6 ------ actions/apitimelinementions.php | 6 ------ actions/apitimelineuser.php | 6 ------ lib/apiauth.php | 24 ++++++++++++++++++++++-- lib/apibareauth.php | 16 ++++++++++++++++ 24 files changed, 38 insertions(+), 164 deletions(-) (limited to 'actions/apistatusesupdate.php') diff --git a/actions/apiaccountratelimitstatus.php b/actions/apiaccountratelimitstatus.php index 9eba5c55d..b823e1cd2 100644 --- a/actions/apiaccountratelimitstatus.php +++ b/actions/apiaccountratelimitstatus.php @@ -46,27 +46,6 @@ require_once INSTALLDIR.'/lib/apibareauth.php'; class ApiAccountRateLimitStatusAction extends ApiBareAuthAction { - /** - * Take arguments for running - * - * @param array $args $_REQUEST args - * - * @return boolean success flag - * - */ - - function prepare($args) - { - parent::prepare($args); - - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return false; - } - } - - return true; - } /** * Handle the request diff --git a/actions/apiaccountverifycredentials.php b/actions/apiaccountverifycredentials.php index 0d4928f6c..104b9867f 100644 --- a/actions/apiaccountverifycredentials.php +++ b/actions/apiaccountverifycredentials.php @@ -47,27 +47,6 @@ require_once INSTALLDIR.'/lib/apiauth.php'; class ApiAccountVerifyCredentialsAction extends ApiAuthAction { - /** - * Take arguments for running - * - * @param array $args $_REQUEST args - * - * @return boolean success flag - * - */ - - function prepare($args) - { - parent::prepare($args); - - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return false; - } - } - - return true; - } /** * Handle the request diff --git a/actions/apiblockcreate.php b/actions/apiblockcreate.php index 642171271..6dd28dd5e 100644 --- a/actions/apiblockcreate.php +++ b/actions/apiblockcreate.php @@ -63,12 +63,6 @@ class ApiBlockCreateAction extends ApiAuthAction { parent::prepare($args); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return; - } - } - $this->user = $this->auth_user; $this->other = $this->getTargetUser($this->arg('id')); diff --git a/actions/apiblockdestroy.php b/actions/apiblockdestroy.php index 109e66ac4..a869dfe46 100644 --- a/actions/apiblockdestroy.php +++ b/actions/apiblockdestroy.php @@ -62,12 +62,6 @@ class ApiBlockDestroyAction extends ApiAuthAction { parent::prepare($args); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return; - } - } - $this->user = $this->auth_user; $this->other = $this->getTargetUser($this->arg('id')); diff --git a/actions/apidirectmessage.php b/actions/apidirectmessage.php index fa6883311..cede4c072 100644 --- a/actions/apidirectmessage.php +++ b/actions/apidirectmessage.php @@ -70,12 +70,6 @@ class ApiDirectMessageAction extends ApiAuthAction { parent::prepare($args); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return; - } - } - $this->user = $this->auth_user; if (empty($this->user)) { diff --git a/actions/apidirectmessagenew.php b/actions/apidirectmessagenew.php index b531d7c5c..6984c8d10 100644 --- a/actions/apidirectmessagenew.php +++ b/actions/apidirectmessagenew.php @@ -64,12 +64,6 @@ class ApiDirectMessageNewAction extends ApiAuthAction { parent::prepare($args); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return; - } - } - $this->user = $this->auth_user; if (empty($this->user)) { diff --git a/actions/apifavoritecreate.php b/actions/apifavoritecreate.php index 6ee6960ba..db001561e 100644 --- a/actions/apifavoritecreate.php +++ b/actions/apifavoritecreate.php @@ -62,12 +62,6 @@ class ApiFavoriteCreateAction extends ApiAuthAction { parent::prepare($args); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return; - } - } - $this->user = $this->auth_user; $this->notice = Notice::staticGet($this->arg('id')); diff --git a/actions/apifavoritedestroy.php b/actions/apifavoritedestroy.php index 36946fbfb..3640459f9 100644 --- a/actions/apifavoritedestroy.php +++ b/actions/apifavoritedestroy.php @@ -63,12 +63,6 @@ class ApiFavoriteDestroyAction extends ApiAuthAction { parent::prepare($args); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return; - } - } - $this->user = $this->auth_user; $this->notice = Notice::staticGet($this->arg('id')); diff --git a/actions/apifriendshipscreate.php b/actions/apifriendshipscreate.php index 27bdbe062..85eaf3a29 100644 --- a/actions/apifriendshipscreate.php +++ b/actions/apifriendshipscreate.php @@ -63,12 +63,6 @@ class ApiFriendshipsCreateAction extends ApiAuthAction { parent::prepare($args); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return; - } - } - $this->user = $this->auth_user; $this->other = $this->getTargetUser($id); diff --git a/actions/apifriendshipsdestroy.php b/actions/apifriendshipsdestroy.php index 3ad12156d..274378051 100644 --- a/actions/apifriendshipsdestroy.php +++ b/actions/apifriendshipsdestroy.php @@ -63,12 +63,6 @@ class ApiFriendshipsDestroyAction extends ApiAuthAction { parent::prepare($args); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return; - } - } - $this->user = $this->auth_user; $this->other = $this->getTargetUser($id); diff --git a/actions/apifriendshipsshow.php b/actions/apifriendshipsshow.php index 2f975b121..0ae6a7b82 100644 --- a/actions/apifriendshipsshow.php +++ b/actions/apifriendshipsshow.php @@ -62,12 +62,6 @@ class ApiFriendshipsShowAction extends ApiBareAuthAction { parent::prepare($args); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return; - } - } - $source_id = (int)$this->trimmed('source_id'); $source_screen_name = $this->trimmed('source_screen_name'); $target_id = (int)$this->trimmed('target_id'); diff --git a/actions/apigroupismember.php b/actions/apigroupismember.php index facc58174..02079b6ff 100644 --- a/actions/apigroupismember.php +++ b/actions/apigroupismember.php @@ -62,12 +62,6 @@ class ApiGroupIsMemberAction extends ApiBareAuthAction { parent::prepare($args); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return; - } - } - $this->user = $this->getTargetUser(null); $this->group = $this->getTargetGroup(null); $this->format = $this->arg('format'); diff --git a/actions/apigroupjoin.php b/actions/apigroupjoin.php index c00d59463..7ab1b7272 100644 --- a/actions/apigroupjoin.php +++ b/actions/apigroupjoin.php @@ -62,12 +62,6 @@ class ApiGroupJoinAction extends ApiAuthAction { parent::prepare($args); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return; - } - } - $this->user = $this->auth_user; $this->group = $this->getTargetGroup($this->arg('id')); diff --git a/actions/apigroupleave.php b/actions/apigroupleave.php index 568b04b7c..86b56f5af 100644 --- a/actions/apigroupleave.php +++ b/actions/apigroupleave.php @@ -62,12 +62,6 @@ class ApiGroupLeaveAction extends ApiAuthAction { parent::prepare($args); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return; - } - } - $this->user = $this->auth_user; $this->group = $this->getTargetGroup($this->arg('id')); diff --git a/actions/apigrouplist.php b/actions/apigrouplist.php index 84b7fc1c8..69c347de1 100644 --- a/actions/apigrouplist.php +++ b/actions/apigrouplist.php @@ -67,12 +67,6 @@ class ApiGroupListAction extends ApiBareAuthAction { parent::prepare($args); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return; - } - } - $this->page = (int)$this->arg('page', 1); $this->count = (int)$this->arg('count', 20); $this->max_id = (int)$this->arg('max_id', 0); diff --git a/actions/apistatusesdestroy.php b/actions/apistatusesdestroy.php index ae0f4c453..16a7cc376 100644 --- a/actions/apistatusesdestroy.php +++ b/actions/apistatusesdestroy.php @@ -63,12 +63,6 @@ class ApiStatusesDestroyAction extends ApiAuthAction { parent::prepare($args); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return false; - } - } - $this->user = $this->auth_user; $this->notice_id = (int)$this->trimmed('id'); diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php index fb1278559..ab33d8a3e 100644 --- a/actions/apistatusesupdate.php +++ b/actions/apistatusesupdate.php @@ -67,12 +67,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction { parent::prepare($args); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return false; - } - } - $this->user = $this->auth_user; if (empty($this->user)) { diff --git a/actions/apisubscriptions.php b/actions/apisubscriptions.php index 78dcd722d..bdaa0ea39 100644 --- a/actions/apisubscriptions.php +++ b/actions/apisubscriptions.php @@ -84,12 +84,6 @@ class ApiSubscriptionsAction extends ApiBareAuthAction $this->count = isset($this->ids_only) ? 5000 : (int)$this->arg('count', 100); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return false; - } - } - $this->user = $this->getTargetUser($this->arg('id')); if (empty($this->user)) { diff --git a/actions/apitimelinefavorites.php b/actions/apitimelinefavorites.php index 9ccee5cfa..35a996c9c 100644 --- a/actions/apitimelinefavorites.php +++ b/actions/apitimelinefavorites.php @@ -69,12 +69,6 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction { parent::prepare($args); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return; - } - } - $this->page = (int)$this->arg('page', 1); $this->count = (int)$this->arg('count', 20); $this->max_id = (int)$this->arg('max_id', 0); diff --git a/actions/apitimelinefriends.php b/actions/apitimelinefriends.php index 65bbb5a74..92a885293 100644 --- a/actions/apitimelinefriends.php +++ b/actions/apitimelinefriends.php @@ -75,12 +75,6 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction $this->since = $this->arg('since'); $this->format = $this->arg('format'); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return; - } - } - $this->user = $this->getTargetUser($this->arg('id')); if (empty($this->user)) { diff --git a/actions/apitimelinementions.php b/actions/apitimelinementions.php index 93c6da307..ecead98cc 100644 --- a/actions/apitimelinementions.php +++ b/actions/apitimelinementions.php @@ -68,12 +68,6 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction $this->since_id = (int)$this->arg('since_id', 0); $this->since = $this->arg('since'); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return; - } - } - $this->user = $this->getTargetUser($this->arg('id')); if (empty($this->user)) { diff --git a/actions/apitimelineuser.php b/actions/apitimelineuser.php index c4d02bc62..d50648d7c 100644 --- a/actions/apitimelineuser.php +++ b/actions/apitimelineuser.php @@ -70,12 +70,6 @@ class ApiTimelineUserAction extends ApiBareAuthAction $this->since_id = (int)$this->arg('since_id', 0); $this->since = $this->arg('since'); - if ($this->requiresAuth()) { - if ($this->checkBasicAuthUser() == false) { - return; - } - } - $this->user = $this->getTargetUser($this->arg('id')); if (empty($this->user)) { diff --git a/lib/apiauth.php b/lib/apiauth.php index d7f8017eb..9fc0e5712 100644 --- a/lib/apiauth.php +++ b/lib/apiauth.php @@ -48,6 +48,26 @@ class ApiAuthAction extends ApiAction var $auth_user = null; + /** + * Take arguments for running, and output basic auth header if needed + * + * @param array $args $_REQUEST args + * + * @return boolean success flag + * + */ + + function prepare($args) + { + parent::prepare($args); + + if ($this->requiresAuth()) { + $this->checkBasicAuthUser(); + } + + return true; + } + /** * Does this API resource require authentication? * @@ -76,7 +96,7 @@ class ApiAuthAction extends ApiAction // show error if the user clicks 'cancel' $this->showBasicAuthError(); - return false; + exit; } else { $nickname = $this->auth_user; @@ -94,7 +114,7 @@ class ApiAuthAction extends ApiAction "$nickname, proxy = $proxy, ip = $ip." ); $this->showBasicAuthError(); - return false; + exit; } } return true; diff --git a/lib/apibareauth.php b/lib/apibareauth.php index a99d450ec..0ae477f46 100644 --- a/lib/apibareauth.php +++ b/lib/apibareauth.php @@ -48,6 +48,22 @@ require_once INSTALLDIR.'/lib/apiauth.php'; class ApiBareAuthAction extends ApiAuthAction { + + /** + * Take arguments for running + * + * @param array $args $_REQUEST args + * + * @return boolean success flag + * + */ + + function prepare($args) + { + parent::prepare($args); + return true; + } + /** * Does this API resource require authentication? * -- cgit v1.2.3-54-g00ecf From 559918826a714c1ee2ecdc49dcfc2b67451a9864 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 9 Oct 2009 17:11:40 -0700 Subject: Remove more redundant $formats --- actions/apigroupismember.php | 2 -- actions/apigroupjoin.php | 3 --- actions/apigroupleave.php | 3 --- actions/apigrouplist.php | 2 -- actions/apigrouplistall.php | 2 -- actions/apigroupmembership.php | 2 -- actions/apistatusesdestroy.php | 2 -- actions/apistatusesshow.php | 2 -- actions/apistatusesupdate.php | 3 --- actions/apisubscriptions.php | 2 -- actions/apitimelinefavorites.php | 2 -- actions/apitimelinefriends.php | 2 -- actions/apitimelinegroup.php | 1 - actions/apitimelinementions.php | 4 ++-- actions/apitimelinepublic.php | 2 +- actions/apitimelinetag.php | 1 - actions/apitimelineuser.php | 4 ++-- lib/apiauth.php | 4 ++-- 18 files changed, 7 insertions(+), 36 deletions(-) (limited to 'actions/apistatusesupdate.php') diff --git a/actions/apigroupismember.php b/actions/apigroupismember.php index 02079b6ff..359b7ca4f 100644 --- a/actions/apigroupismember.php +++ b/actions/apigroupismember.php @@ -45,7 +45,6 @@ require_once INSTALLDIR . '/lib/apibareauth.php'; class ApiGroupIsMemberAction extends ApiBareAuthAction { - var $format = null; var $user = null; var $group = null; @@ -64,7 +63,6 @@ class ApiGroupIsMemberAction extends ApiBareAuthAction $this->user = $this->getTargetUser(null); $this->group = $this->getTargetGroup(null); - $this->format = $this->arg('format'); return true; } diff --git a/actions/apigroupjoin.php b/actions/apigroupjoin.php index 7ab1b7272..e51842bcb 100644 --- a/actions/apigroupjoin.php +++ b/actions/apigroupjoin.php @@ -45,7 +45,6 @@ require_once INSTALLDIR . '/lib/apiauth.php'; class ApiGroupJoinAction extends ApiAuthAction { - var $format = null; var $user = null; var $group = null; @@ -65,8 +64,6 @@ class ApiGroupJoinAction extends ApiAuthAction $this->user = $this->auth_user; $this->group = $this->getTargetGroup($this->arg('id')); - $this->format = $this->arg('format'); - return true; } diff --git a/actions/apigroupleave.php b/actions/apigroupleave.php index 86b56f5af..332bd7b7b 100644 --- a/actions/apigroupleave.php +++ b/actions/apigroupleave.php @@ -45,7 +45,6 @@ require_once INSTALLDIR . '/lib/apiauth.php'; class ApiGroupLeaveAction extends ApiAuthAction { - var $format = null; var $user = null; var $group = null; @@ -65,8 +64,6 @@ class ApiGroupLeaveAction extends ApiAuthAction $this->user = $this->auth_user; $this->group = $this->getTargetGroup($this->arg('id')); - $this->format = $this->arg('format'); - return true; } diff --git a/actions/apigrouplist.php b/actions/apigrouplist.php index 69c347de1..00ceeed76 100644 --- a/actions/apigrouplist.php +++ b/actions/apigrouplist.php @@ -45,7 +45,6 @@ require_once INSTALLDIR . '/lib/apibareauth.php'; class ApiGroupListAction extends ApiBareAuthAction { - var $format = null; var $user = null; var $page = null; var $count = null; @@ -74,7 +73,6 @@ class ApiGroupListAction extends ApiBareAuthAction $this->since = $this->arg('since'); $this->user = $this->getTargetUser($id); - $this->format = $this->arg('format'); $this->groups = $this->getGroups(); return true; diff --git a/actions/apigrouplistall.php b/actions/apigrouplistall.php index 80dcad9dc..a0f04ed76 100644 --- a/actions/apigrouplistall.php +++ b/actions/apigrouplistall.php @@ -45,7 +45,6 @@ require_once INSTALLDIR . '/lib/api.php'; class ApiGroupListAllAction extends TwitterApiAction { - var $format = null; var $page = null; var $count = null; var $max_id = null; @@ -73,7 +72,6 @@ class ApiGroupListAllAction extends TwitterApiAction $this->since = $this->arg('since'); $this->user = $this->getTargetUser($id); - $this->format = $this->arg('format'); $this->groups = $this->getGroups(); return true; diff --git a/actions/apigroupmembership.php b/actions/apigroupmembership.php index 872ee45ee..da510ff26 100644 --- a/actions/apigroupmembership.php +++ b/actions/apigroupmembership.php @@ -45,7 +45,6 @@ require_once INSTALLDIR . '/lib/api.php'; class ApiGroupMembershipAction extends TwitterApiAction { - var $format = null; var $page = null; var $count = null; var $max_id = null; @@ -73,7 +72,6 @@ class ApiGroupMembershipAction extends TwitterApiAction $this->since_id = (int)$this->arg('since_id', 0); $this->since = $this->arg('since'); - $this->format = $this->arg('format'); $this->group = $this->getTargetGroup($this->arg('id')); $this->profiles = $this->getProfiles(); diff --git a/actions/apistatusesdestroy.php b/actions/apistatusesdestroy.php index 16a7cc376..7680f96dc 100644 --- a/actions/apistatusesdestroy.php +++ b/actions/apistatusesdestroy.php @@ -48,7 +48,6 @@ class ApiStatusesDestroyAction extends ApiAuthAction var $user = null; var $status = null; - var $format = null; /** * Take arguments for running @@ -70,7 +69,6 @@ class ApiStatusesDestroyAction extends ApiAuthAction $this->notice_id = (int)$this->arg('id'); } - $this->format = $this->arg('format'); $this->notice = Notice::staticGet((int)$this->notice_id); return true; diff --git a/actions/apistatusesshow.php b/actions/apistatusesshow.php index 9e28fe2ab..0096cfe6b 100644 --- a/actions/apistatusesshow.php +++ b/actions/apistatusesshow.php @@ -48,7 +48,6 @@ class ApiStatusesShowAction extends ApiAction var $notice_id = null; var $notice = null; - var $format = null; /** * Take arguments for running @@ -74,7 +73,6 @@ class ApiStatusesShowAction extends ApiAction $this->notice_id = (int)$this->arg('id'); } - $this->format = $this->arg('format'); $this->notice = Notice::staticGet((int)$this->notice_id); return true; diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php index ab33d8a3e..7d6a574ef 100644 --- a/actions/apistatusesupdate.php +++ b/actions/apistatusesupdate.php @@ -50,7 +50,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction var $source = null; var $status = null; var $in_reply_to_status_id = null; - var $format = null; static $reserved_sources = array('web', 'omb', 'mail', 'xmpp', 'api'); @@ -92,8 +91,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction $this->source = 'api'; } - $this->format = $this->arg('format'); - $this->in_reply_to_status_id = intval($this->trimmed('in_reply_to_status_id')); diff --git a/actions/apisubscriptions.php b/actions/apisubscriptions.php index bdaa0ea39..9dbddbd9b 100644 --- a/actions/apisubscriptions.php +++ b/actions/apisubscriptions.php @@ -52,7 +52,6 @@ class ApiSubscriptionsAction extends ApiBareAuthAction var $count = null; var $user = null; var $profiles = null; - var $format = null; var $tag = null; var $lite = null; var $ids_only = null; @@ -72,7 +71,6 @@ class ApiSubscriptionsAction extends ApiBareAuthAction $this->page = (int)$this->arg('page', 1); $this->tag = $this->arg('tag'); - $this->format = $this->arg('format'); // Note: Twitter no longer supports 'lite' $this->lite = $this->arg('lite'); diff --git a/actions/apitimelinefavorites.php b/actions/apitimelinefavorites.php index 35a996c9c..231f2ae49 100644 --- a/actions/apitimelinefavorites.php +++ b/actions/apitimelinefavorites.php @@ -49,7 +49,6 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction var $user = null; var $notices = null; - var $format = null; var $page = null; var $count = null; var $max_id = null; @@ -74,7 +73,6 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction $this->max_id = (int)$this->arg('max_id', 0); $this->since_id = (int)$this->arg('since_id', 0); $this->since = $this->arg('since'); - $this->format = $this->arg('format'); $this->user = $this->getTargetUser($this->arg('id')); diff --git a/actions/apitimelinefriends.php b/actions/apitimelinefriends.php index 92a885293..02e352569 100644 --- a/actions/apitimelinefriends.php +++ b/actions/apitimelinefriends.php @@ -53,7 +53,6 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction var $max_id = null; var $since_id = null; var $since = null; - var $format = null; /** * Take arguments for running @@ -73,7 +72,6 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction $this->max_id = (int)$this->arg('max_id', 0); $this->since_id = (int)$this->arg('since_id', 0); $this->since = $this->arg('since'); - $this->format = $this->arg('format'); $this->user = $this->getTargetUser($this->arg('id')); diff --git a/actions/apitimelinegroup.php b/actions/apitimelinegroup.php index 9d6ac6ad1..abe7f0c5d 100644 --- a/actions/apitimelinegroup.php +++ b/actions/apitimelinegroup.php @@ -70,7 +70,6 @@ class ApiTimelineGroupAction extends ApiAction $this->group = $this->getTargetGroup($this->arg('id')); - $this->format = $this->arg('format'); $this->notices = $this->getNotices(); return true; diff --git a/actions/apitimelinementions.php b/actions/apitimelinementions.php index ecead98cc..7549b4722 100644 --- a/actions/apitimelinementions.php +++ b/actions/apitimelinementions.php @@ -71,7 +71,7 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction $this->user = $this->getTargetUser($this->arg('id')); if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->arg('format')); + $this->clientError(_('No such user!'), 404, $this->format); return; } @@ -122,7 +122,7 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction $sitename, $this->user->nickname, $profile->getBestName() ); - switch($this->arg('format')) { + switch($this->format) { case 'xml': $this->show_xml_timeline($this->notices); break; diff --git a/actions/apitimelinepublic.php b/actions/apitimelinepublic.php index 2638dd292..a635ddc91 100644 --- a/actions/apitimelinepublic.php +++ b/actions/apitimelinepublic.php @@ -103,7 +103,7 @@ class ApiTimelinePublicAction extends ApiAction $link = common_root_url(); $subtitle = sprintf(_("%s updates from everyone!"), $sitename); - switch($this->arg('format')) { + switch($this->format) { case 'xml': $this->show_xml_timeline($this->notices); break; diff --git a/actions/apitimelinetag.php b/actions/apitimelinetag.php index 0efe8d244..8211b0122 100644 --- a/actions/apitimelinetag.php +++ b/actions/apitimelinetag.php @@ -64,7 +64,6 @@ class ApiTimelineTagAction extends ApiAction $this->page = (int)$this->arg('page', 1); $this->count = (int)$this->arg('count', 20); $this->tag = $this->arg('tag'); - $this->format = $this->arg('format'); $this->notices = $this->getNotices(); diff --git a/actions/apitimelineuser.php b/actions/apitimelineuser.php index d50648d7c..81e23116b 100644 --- a/actions/apitimelineuser.php +++ b/actions/apitimelineuser.php @@ -73,7 +73,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction $this->user = $this->getTargetUser($this->arg('id')); if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->arg('format')); + $this->clientError(_('No such user!'), 404, $this->format); return; } @@ -127,7 +127,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction $suplink = common_local_url('sup', null, null, $this->user->id); header('X-SUP-ID: ' . $suplink); - switch($this->arg('format')) { + switch($this->format) { case 'xml': $this->show_xml_timeline($this->notices); break; diff --git a/lib/apiauth.php b/lib/apiauth.php index 9fc0e5712..25bbae24e 100644 --- a/lib/apiauth.php +++ b/lib/apiauth.php @@ -172,7 +172,7 @@ class ApiAuthAction extends ApiAction header('HTTP/1.1 401 Unauthorized'); $msg = 'Could not authenticate you.'; - if ($this->arg('format') == 'xml') { + if ($this->format == 'xml') { header('Content-Type: application/xml; charset=utf-8'); $this->startXML(); $this->elementStart('hash'); @@ -180,7 +180,7 @@ class ApiAuthAction extends ApiAction $this->element('request', null, $_SERVER['REQUEST_URI']); $this->elementEnd('hash'); $this->endXML(); - } elseif ($this->arg('format') == 'json') { + } elseif ($this->format == 'json') { header('Content-Type: application/json; charset=utf-8'); $error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']); -- cgit v1.2.3-54-g00ecf From 061af8fa06ccb98f667d1ee670da2dbb179d8b0e Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 9 Oct 2009 17:53:35 -0700 Subject: CamelCase all function names in the API code --- actions/apiaccountratelimitstatus.php | 4 +- actions/apiblockcreate.php | 6 +- actions/apiblockdestroy.php | 6 +- actions/apidirectmessage.php | 20 +-- actions/apifavoritecreate.php | 2 +- actions/apifavoritedestroy.php | 2 +- actions/apifriendshipscreate.php | 6 +- actions/apifriendshipsdestroy.php | 6 +- actions/apifriendshipsexists.php | 8 +- actions/apifriendshipsshow.php | 12 +- actions/apigroupismember.php | 10 +- actions/apigroupjoin.php | 2 +- actions/apigroupleave.php | 2 +- actions/apigrouplist.php | 8 +- actions/apigrouplistall.php | 8 +- actions/apigroupmembership.php | 4 +- actions/apigroupshow.php | 2 +- actions/apihelptest.php | 8 +- actions/apistatusesdestroy.php | 4 +- actions/apistatusesshow.php | 2 +- actions/apistatusesupdate.php | 2 +- actions/apistatusnetconfig.php | 10 +- actions/apistatusnetversion.php | 8 +- actions/apisubscriptions.php | 8 +- actions/apitimelinefavorites.php | 8 +- actions/apitimelinefriends.php | 8 +- actions/apitimelinegroup.php | 8 +- actions/apitimelinementions.php | 8 +- actions/apitimelinepublic.php | 8 +- actions/apitimelinetag.php | 8 +- actions/apitimelineuser.php | 8 +- actions/apiusershow.php | 14 +- actions/twitapisearchatom.php | 2 +- actions/twitapisearchjson.php | 4 +- lib/api.php | 295 ++++++++++++++++------------------ lib/twitter.php | 4 +- plugins/Realtime/RealtimePlugin.php | 2 +- 37 files changed, 255 insertions(+), 272 deletions(-) (limited to 'actions/apistatusesupdate.php') diff --git a/actions/apiaccountratelimitstatus.php b/actions/apiaccountratelimitstatus.php index b823e1cd2..af86dae6a 100644 --- a/actions/apiaccountratelimitstatus.php +++ b/actions/apiaccountratelimitstatus.php @@ -73,7 +73,7 @@ class ApiAccountRateLimitStatusAction extends ApiBareAuthAction $reset = new DateTime(); $reset->modify('+1 hour'); - $this->init_document($this->format); + $this->initDocument($this->format); if ($this->format == 'xml') { $this->elementStart('hash'); @@ -101,7 +101,7 @@ class ApiAccountRateLimitStatusAction extends ApiBareAuthAction print json_encode($out); } - $this->end_document($this->format); + $this->endDocument($this->format); } } diff --git a/actions/apiblockcreate.php b/actions/apiblockcreate.php index 6dd28dd5e..e003e5ee9 100644 --- a/actions/apiblockcreate.php +++ b/actions/apiblockcreate.php @@ -100,9 +100,9 @@ class ApiBlockCreateAction extends ApiAuthAction if ($this->user->hasBlocked($this->other) || $this->user->block($this->other) ) { - $this->init_document($this->format); - $this->show_profile($this->other, $this->format); - $this->end_document($this->format); + $this->initDocument($this->format); + $this->showProfile($this->other, $this->format); + $this->endDocument($this->format); } else { $this->serverError(_('Block user failed.'), 500, $this->format); } diff --git a/actions/apiblockdestroy.php b/actions/apiblockdestroy.php index a869dfe46..470b60ea5 100644 --- a/actions/apiblockdestroy.php +++ b/actions/apiblockdestroy.php @@ -99,9 +99,9 @@ class ApiBlockDestroyAction extends ApiAuthAction if (!$this->user->hasBlocked($this->other) || $this->user->unblock($this->other) ) { - $this->init_document($this->format); - $this->show_profile($this->other, $this->format); - $this->end_document($this->format); + $this->initDocument($this->format); + $this->showProfile($this->other, $this->format); + $this->endDocument($this->format); } else { $this->serverError(_('Unblock user failed.')); } diff --git a/actions/apidirectmessage.php b/actions/apidirectmessage.php index f0013c54c..4e55886d9 100644 --- a/actions/apidirectmessage.php +++ b/actions/apidirectmessage.php @@ -230,7 +230,7 @@ class ApiDirectMessageAction extends ApiAuthAction function showXmlDirectMessages() { - $this->init_document('xml'); + $this->initDocument('xml'); $this->elementStart('direct-messages', array('type' => 'array')); foreach ($this->messages as $m) { @@ -239,7 +239,7 @@ class ApiDirectMessageAction extends ApiAuthAction } $this->elementEnd('direct-messages'); - $this->end_document('xml'); + $this->endDocument('xml'); } /** @@ -250,7 +250,7 @@ class ApiDirectMessageAction extends ApiAuthAction function showJsonDirectMessages() { - $this->init_document('json'); + $this->initDocument('json'); $dmsgs = array(); @@ -259,8 +259,8 @@ class ApiDirectMessageAction extends ApiAuthAction array_push($dmsgs, $dm_array); } - $this->show_json_objects($dmsgs); - $this->end_document('json'); + $this->showJsonObjects($dmsgs); + $this->endDocument('json'); } /** @@ -271,7 +271,7 @@ class ApiDirectMessageAction extends ApiAuthAction function showRssDirectMessages() { - $this->init_document('rss'); + $this->initDocument('rss'); $this->element('title', null, $this->title); @@ -292,10 +292,10 @@ class ApiDirectMessageAction extends ApiAuthAction foreach ($this->messages as $m) { $entry = $this->rssDirectMessageArray($m); - $this->show_twitter_rss_item($entry); + $this->showTwitterRssItem($entry); } - $this->end_twitter_rss(); + $this->endTwitterRss(); } /** @@ -306,7 +306,7 @@ class ApiDirectMessageAction extends ApiAuthAction function showAtomDirectMessages() { - $this->init_document('atom'); + $this->initDocument('atom'); $this->element('title', null, $this->title); $this->element('id', null, $this->id); @@ -334,7 +334,7 @@ class ApiDirectMessageAction extends ApiAuthAction $this->showTwitterAtomEntry($entry); } - $this->end_document('atom'); + $this->endDocument('atom'); } /** diff --git a/actions/apifavoritecreate.php b/actions/apifavoritecreate.php index db001561e..1b05eb95c 100644 --- a/actions/apifavoritecreate.php +++ b/actions/apifavoritecreate.php @@ -135,7 +135,7 @@ class ApiFavoriteCreateAction extends ApiAuthAction $this->user->blowFavesCache(); if ($this->format == 'xml') { - $this->show_single_xml_status($this->notice); + $this->showSingleXmlStatus($this->notice); } elseif ($this->format == 'json') { $this->show_single_json_status($this->notice); } diff --git a/actions/apifavoritedestroy.php b/actions/apifavoritedestroy.php index 3640459f9..aac866d7e 100644 --- a/actions/apifavoritedestroy.php +++ b/actions/apifavoritedestroy.php @@ -138,7 +138,7 @@ class ApiFavoriteDestroyAction extends ApiAuthAction $this->user->blowFavesCache(); if ($this->format == 'xml') { - $this->show_single_xml_status($this->notice); + $this->showSingleXmlStatus($this->notice); } elseif ($this->format == 'json') { $this->show_single_json_status($this->notice); } diff --git a/actions/apifriendshipscreate.php b/actions/apifriendshipscreate.php index 85eaf3a29..6c44d7961 100644 --- a/actions/apifriendshipscreate.php +++ b/actions/apifriendshipscreate.php @@ -126,9 +126,9 @@ class ApiFriendshipsCreateAction extends ApiAuthAction return; } - $this->init_document($this->format); - $this->show_profile($this->other, $this->format); - $this->end_document($this->format); + $this->initDocument($this->format); + $this->showProfile($this->other, $this->format); + $this->endDocument($this->format); } } diff --git a/actions/apifriendshipsdestroy.php b/actions/apifriendshipsdestroy.php index 274378051..a15f202aa 100644 --- a/actions/apifriendshipsdestroy.php +++ b/actions/apifriendshipsdestroy.php @@ -128,9 +128,9 @@ class ApiFriendshipsDestroyAction extends ApiAuthAction return; } - $this->init_document($this->format); - $this->show_profile($this->other, $this->format); - $this->end_document($this->format); + $this->initDocument($this->format); + $this->showProfile($this->other, $this->format); + $this->endDocument($this->format); } } diff --git a/actions/apifriendshipsexists.php b/actions/apifriendshipsexists.php index df9f0c949..93be5f84e 100644 --- a/actions/apifriendshipsexists.php +++ b/actions/apifriendshipsexists.php @@ -107,14 +107,14 @@ class ApiFriendshipsExistsAction extends ApiAction switch ($this->format) { case 'xml': - $this->init_document('xml'); + $this->initDocument('xml'); $this->element('friends', null, $result); - $this->end_document('xml'); + $this->endDocument('xml'); break; case 'json': - $this->init_document('json'); + $this->initDocument('json'); print json_encode($result); - $this->end_document('json'); + $this->endDocument('json'); break; default: break; diff --git a/actions/apifriendshipsshow.php b/actions/apifriendshipsshow.php index 0ae6a7b82..8850496c7 100644 --- a/actions/apifriendshipsshow.php +++ b/actions/apifriendshipsshow.php @@ -143,18 +143,18 @@ class ApiFriendshipsShowAction extends ApiBareAuthAction return; } - $result = $this->twitter_relationship_array($this->source, $this->target); + $result = $this->twitterRelationshipArray($this->source, $this->target); switch ($this->format) { case 'xml': - $this->init_document('xml'); - $this->show_twitter_xml_relationship($result[relationship]); - $this->end_document('xml'); + $this->initDocument('xml'); + $this->showTwitterXmlRelationship($result[relationship]); + $this->endDocument('xml'); break; case 'json': - $this->init_document('json'); + $this->initDocument('json'); print json_encode($result); - $this->end_document('json'); + $this->endDocument('json'); break; default: break; diff --git a/actions/apigroupismember.php b/actions/apigroupismember.php index 359b7ca4f..6cf327012 100644 --- a/actions/apigroupismember.php +++ b/actions/apigroupismember.php @@ -95,14 +95,14 @@ class ApiGroupIsMemberAction extends ApiBareAuthAction switch($this->format) { case 'xml': - $this->init_document('xml'); + $this->initDocument('xml'); $this->element('is_member', null, $is_member); - $this->end_document('xml'); + $this->endDocument('xml'); break; case 'json': - $this->init_document('json'); - $this->show_json_objects(array('is_member' => $is_member)); - $this->end_document('json'); + $this->initDocument('json'); + $this->showJsonObjects(array('is_member' => $is_member)); + $this->endDocument('json'); break; default: $this->clientError( diff --git a/actions/apigroupjoin.php b/actions/apigroupjoin.php index e51842bcb..f930aa519 100644 --- a/actions/apigroupjoin.php +++ b/actions/apigroupjoin.php @@ -143,7 +143,7 @@ class ApiGroupJoinAction extends ApiAuthAction $this->show_single_xml_group($this->group); break; case 'json': - $this->show_single_json_group($this->group); + $this->showSingleJsonGroup($this->group); break; default: $this->clientError( diff --git a/actions/apigroupleave.php b/actions/apigroupleave.php index 332bd7b7b..4e3192ac0 100644 --- a/actions/apigroupleave.php +++ b/actions/apigroupleave.php @@ -129,7 +129,7 @@ class ApiGroupLeaveAction extends ApiAuthAction $this->show_single_xml_group($this->group); break; case 'json': - $this->show_single_json_group($this->group); + $this->showSingleJsonGroup($this->group); break; default: $this->clientError( diff --git a/actions/apigrouplist.php b/actions/apigrouplist.php index 7a5aab72e..1fc31831a 100644 --- a/actions/apigrouplist.php +++ b/actions/apigrouplist.php @@ -101,15 +101,15 @@ class ApiGroupListAction extends ApiBareAuthAction switch($this->format) { case 'xml': - $this->show_xml_groups($this->groups); + $this->showXmlGroups($this->groups); break; case 'rss': - $this->show_rss_groups($this->groups, $title, $link, $subtitle); + $this->showRssGroups($this->groups, $title, $link, $subtitle); break; case 'atom': $selfuri = common_root_url() . 'api/statusnet/groups/list/' . $this->user->id . '.atom'; - $this->show_atom_groups( + $this->showAtomGroups( $this->groups, $title, $id, @@ -119,7 +119,7 @@ class ApiGroupListAction extends ApiBareAuthAction ); break; case 'json': - $this->show_json_groups($this->groups); + $this->showJsonGroups($this->groups); break; default: $this->clientError( diff --git a/actions/apigrouplistall.php b/actions/apigrouplistall.php index 3e236816a..ef96a08bd 100644 --- a/actions/apigrouplistall.php +++ b/actions/apigrouplistall.php @@ -89,15 +89,15 @@ class ApiGroupListAllAction extends ApiAction switch($this->format) { case 'xml': - $this->show_xml_groups($this->groups); + $this->showXmlGroups($this->groups); break; case 'rss': - $this->show_rss_groups($this->groups, $title, $link, $subtitle); + $this->showRssGroups($this->groups, $title, $link, $subtitle); break; case 'atom': $selfuri = common_root_url() . 'api/statusnet/groups/list_all.atom'; - $this->show_atom_groups( + $this->showAtomGroups( $this->groups, $title, $id, @@ -107,7 +107,7 @@ class ApiGroupListAllAction extends ApiAction ); break; case 'json': - $this->show_json_groups($this->groups); + $this->showJsonGroups($this->groups); break; default: $this->clientError( diff --git a/actions/apigroupmembership.php b/actions/apigroupmembership.php index 0bc846d60..27f77029e 100644 --- a/actions/apigroupmembership.php +++ b/actions/apigroupmembership.php @@ -85,10 +85,10 @@ class ApiGroupMembershipAction extends ApiAction switch($this->format) { case 'xml': - $this->show_twitter_xml_users($this->profiles); + $this->showTwitterXmlUsers($this->profiles); break; case 'json': - $this->show_json_users($this->profiles); + $this->showJsonUsers($this->profiles); break; default: $this->clientError( diff --git a/actions/apigroupshow.php b/actions/apigroupshow.php index 262fe6718..8969ae194 100644 --- a/actions/apigroupshow.php +++ b/actions/apigroupshow.php @@ -93,7 +93,7 @@ class ApiGroupShowAction extends ApiAction $this->show_single_xml_group($this->group); break; case 'json': - $this->show_single_json_group($this->group); + $this->showSingleJsonGroup($this->group); break; default: $this->clientError(_('API method not found!'), 404, $this->format); diff --git a/actions/apihelptest.php b/actions/apihelptest.php index cd5b86cf9..4691cbf99 100644 --- a/actions/apihelptest.php +++ b/actions/apihelptest.php @@ -74,13 +74,13 @@ class ApiHelpTestAction extends ApiAction parent::handle($args); if ($this->format == 'xml') { - $this->init_document('xml'); + $this->initDocument('xml'); $this->element('ok', null, 'true'); - $this->end_document('xml'); + $this->endDocument('xml'); } elseif ($this->format == 'json') { - $this->init_document('json'); + $this->initDocument('json'); print '"ok"'; - $this->end_document('json'); + $this->endDocument('json'); } else { $this->clientError( _('API method not found!'), diff --git a/actions/apistatusesdestroy.php b/actions/apistatusesdestroy.php index 7680f96dc..74a1310a2 100644 --- a/actions/apistatusesdestroy.php +++ b/actions/apistatusesdestroy.php @@ -112,7 +112,7 @@ class ApiStatusesDestroyAction extends ApiAuthAction $this->notice->delete(); if ($this->format == 'xml') { - $this->show_single_xml_status($this->notice); + $this->showSingleXmlStatus($this->notice); } elseif ($this->format == 'json') { $this->show_single_json_status($this->notice); } @@ -134,7 +134,7 @@ class ApiStatusesDestroyAction extends ApiAuthAction { if (!empty($this->notice)) { if ($this->format == 'xml') { - $this->show_single_xml_status($this->notice); + $this->showSingleXmlStatus($this->notice); } elseif ($this->format == 'json') { $this->show_single_json_status($this->notice); } diff --git a/actions/apistatusesshow.php b/actions/apistatusesshow.php index 0096cfe6b..5d32a0bfc 100644 --- a/actions/apistatusesshow.php +++ b/actions/apistatusesshow.php @@ -110,7 +110,7 @@ class ApiStatusesShowAction extends ApiAction { if (!empty($this->notice)) { if ($this->format == 'xml') { - $this->show_single_xml_status($this->notice); + $this->showSingleXmlStatus($this->notice); } elseif ($this->format == 'json') { $this->show_single_json_status($this->notice); } diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php index 7d6a574ef..479654be8 100644 --- a/actions/apistatusesupdate.php +++ b/actions/apistatusesupdate.php @@ -201,7 +201,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction { if (!empty($this->notice)) { if ($this->format == 'xml') { - $this->show_single_xml_status($this->notice); + $this->showSingleXmlStatus($this->notice); } elseif ($this->format == 'json') { $this->show_single_json_status($this->notice); } diff --git a/actions/apistatusnetconfig.php b/actions/apistatusnetconfig.php index 356942a85..a93570698 100644 --- a/actions/apistatusnetconfig.php +++ b/actions/apistatusnetconfig.php @@ -88,7 +88,7 @@ class ApiStatusnetConfigAction extends ApiAction switch ($this->format) { case 'xml': - $this->init_document('xml'); + $this->initDocument('xml'); $this->elementStart('config'); // XXX: check that all sections and settings are legal XML elements @@ -111,7 +111,7 @@ class ApiStatusnetConfigAction extends ApiAction $this->elementEnd($section); } $this->elementEnd('config'); - $this->end_document('xml'); + $this->endDocument('xml'); break; case 'json': $result = array(); @@ -122,9 +122,9 @@ class ApiStatusnetConfigAction extends ApiAction = common_config($section, $setting); } } - $this->init_document('json'); - $this->show_json_objects($result); - $this->end_document('json'); + $this->initDocument('json'); + $this->showJsonObjects($result); + $this->endDocument('json'); break; default: $this->clientError( diff --git a/actions/apistatusnetversion.php b/actions/apistatusnetversion.php index fb632fd93..6af9bdd1a 100644 --- a/actions/apistatusnetversion.php +++ b/actions/apistatusnetversion.php @@ -77,14 +77,14 @@ class ApiStatusnetVersionAction extends ApiAction switch ($this->format) { case 'xml': - $this->init_document('xml'); + $this->initDocument('xml'); $this->element('version', null, STATUSNET_VERSION); - $this->end_document('xml'); + $this->endDocument('xml'); break; case 'json': - $this->init_document('json'); + $this->initDocument('json'); print '"'.STATUSNET_VERSION.'"'; - $this->end_document('json'); + $this->endDocument('json'); break; default: $this->clientError( diff --git a/actions/apisubscriptions.php b/actions/apisubscriptions.php index 1332fd71c..a952e20b8 100644 --- a/actions/apisubscriptions.php +++ b/actions/apisubscriptions.php @@ -108,7 +108,7 @@ class ApiSubscriptionsAction extends ApiBareAuthAction return; } - $this->init_document($this->format); + $this->initDocument($this->format); if (isset($this->ids_only)) { $this->showIds(); @@ -116,7 +116,7 @@ class ApiSubscriptionsAction extends ApiBareAuthAction $this->showProfiles(isset($this->lite) ? false : true); } - $this->end_document($this->format); + $this->endDocument($this->format); } /** @@ -204,7 +204,7 @@ class ApiSubscriptionsAction extends ApiBareAuthAction case 'xml': $this->elementStart('users', array('type' => 'array')); foreach ($this->profiles as $profile) { - $this->show_profile( + $this->showProfile( $profile, $this->format, null, @@ -216,7 +216,7 @@ class ApiSubscriptionsAction extends ApiBareAuthAction case 'json': $arrays = array(); foreach ($this->profiles as $profile) { - $arrays[] = $this->twitter_user_array( + $arrays[] = $this->twitterUserArray( $profile, $include_statuses ); diff --git a/actions/apitimelinefavorites.php b/actions/apitimelinefavorites.php index d35e05183..c85e56264 100644 --- a/actions/apitimelinefavorites.php +++ b/actions/apitimelinefavorites.php @@ -121,21 +121,21 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction switch($this->format) { case 'xml': - $this->show_xml_timeline($this->notices); + $this->showXmlTimeline($this->notices); break; case 'rss': - $this->show_rss_timeline($this->notices, $title, $link, $subtitle); + $this->showRssTimeline($this->notices, $title, $link, $subtitle); break; case 'atom': $selfuri = common_root_url() . ltrim($_SERVER['QUERY_STRING'], 'p='); - $this->show_atom_timeline( + $this->showAtomTimeline( $this->notices, $title, $id, $link, $subtitle, null, $selfuri ); break; case 'json': - $this->show_json_timeline($this->notices); + $this->showJsonTimeline($this->notices); break; default: $this->clientError(_('API method not found!'), $code = 404); diff --git a/actions/apitimelinefriends.php b/actions/apitimelinefriends.php index 544824078..90f3b3c06 100644 --- a/actions/apitimelinefriends.php +++ b/actions/apitimelinefriends.php @@ -112,10 +112,10 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction switch($this->format) { case 'xml': - $this->show_xml_timeline($this->notices); + $this->showXmlTimeline($this->notices); break; case 'rss': - $this->show_rss_timeline($this->notices, $title, $link, $subtitle); + $this->showRssTimeline($this->notices, $title, $link, $subtitle); break; case 'atom': @@ -130,13 +130,13 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction 'api/statuses/friends_timeline.atom'; } - $this->show_atom_timeline( + $this->showAtomTimeline( $this->notices, $title, $id, $link, $subtitle, null, $selfuri ); break; case 'json': - $this->show_json_timeline($this->notices); + $this->showJsonTimeline($this->notices); break; default: $this->clientError(_('API method not found!'), $code = 404); diff --git a/actions/apitimelinegroup.php b/actions/apitimelinegroup.php index 6f2043fb6..2a6f35d72 100644 --- a/actions/apitimelinegroup.php +++ b/actions/apitimelinegroup.php @@ -108,16 +108,16 @@ class ApiTimelineGroupAction extends ApiAction switch($this->format) { case 'xml': - $this->show_xml_timeline($this->notices); + $this->showXmlTimeline($this->notices); break; case 'rss': - $this->show_rss_timeline($this->notices, $title, $link, $subtitle); + $this->showRssTimeline($this->notices, $title, $link, $subtitle); break; case 'atom': $selfuri = common_root_url() . 'api/statusnet/groups/timeline/' . $this->group->nickname . '.atom'; - $this->show_atom_timeline( + $this->showAtomTimeline( $this->notices, $title, $id, @@ -128,7 +128,7 @@ class ApiTimelineGroupAction extends ApiAction ); break; case 'json': - $this->show_json_timeline($this->notices); + $this->showJsonTimeline($this->notices); break; default: $this->clientError( diff --git a/actions/apitimelinementions.php b/actions/apitimelinementions.php index 60669d9ba..c25fb0a0e 100644 --- a/actions/apitimelinementions.php +++ b/actions/apitimelinementions.php @@ -118,21 +118,21 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction switch($this->format) { case 'xml': - $this->show_xml_timeline($this->notices); + $this->showXmlTimeline($this->notices); break; case 'rss': - $this->show_rss_timeline($this->notices, $title, $link, $subtitle); + $this->showRssTimeline($this->notices, $title, $link, $subtitle); break; case 'atom': $selfuri = common_root_url() . ltrim($_SERVER['QUERY_STRING'], 'p='); - $this->show_atom_timeline( + $this->showAtomTimeline( $this->notices, $title, $id, $link, $subtitle, null, $selfuri ); break; case 'json': - $this->show_json_timeline($this->notices); + $this->showJsonTimeline($this->notices); break; default: $this->clientError(_('API method not found!'), $code = 404); diff --git a/actions/apitimelinepublic.php b/actions/apitimelinepublic.php index b992136d1..4bff4adb6 100644 --- a/actions/apitimelinepublic.php +++ b/actions/apitimelinepublic.php @@ -99,20 +99,20 @@ class ApiTimelinePublicAction extends ApiAction switch($this->format) { case 'xml': - $this->show_xml_timeline($this->notices); + $this->showXmlTimeline($this->notices); break; case 'rss': - $this->show_rss_timeline($this->notices, $title, $link, $subtitle); + $this->showRssTimeline($this->notices, $title, $link, $subtitle); break; case 'atom': $selfuri = common_root_url() . 'api/statuses/public_timeline.atom'; - $this->show_atom_timeline( + $this->showAtomTimeline( $this->notices, $title, $id, $link, $subtitle, null, $selfuri ); break; case 'json': - $this->show_json_timeline($this->notices); + $this->showJsonTimeline($this->notices); break; default: $this->clientError(_('API method not found!'), $code = 404); diff --git a/actions/apitimelinetag.php b/actions/apitimelinetag.php index 53e79e4b9..cf211b173 100644 --- a/actions/apitimelinetag.php +++ b/actions/apitimelinetag.php @@ -107,16 +107,16 @@ class ApiTimelineTagAction extends ApiAction switch($this->format) { case 'xml': - $this->show_xml_timeline($this->notices); + $this->showXmlTimeline($this->notices); break; case 'rss': - $this->show_rss_timeline($this->notices, $title, $link, $subtitle); + $this->showRssTimeline($this->notices, $title, $link, $subtitle); break; case 'atom': $selfuri = common_root_url() . 'api/statusnet/tags/timeline/' . $this->tag . '.atom'; - $this->show_atom_timeline( + $this->showAtomTimeline( $this->notices, $title, $id, @@ -127,7 +127,7 @@ class ApiTimelineTagAction extends ApiAction ); break; case 'json': - $this->show_json_timeline($this->notices); + $this->showJsonTimeline($this->notices); break; default: $this->clientError(_('API method not found!'), $code = 404); diff --git a/actions/apitimelineuser.php b/actions/apitimelineuser.php index 652a1b0d9..e7fac3e7a 100644 --- a/actions/apitimelineuser.php +++ b/actions/apitimelineuser.php @@ -123,10 +123,10 @@ class ApiTimelineUserAction extends ApiBareAuthAction switch($this->format) { case 'xml': - $this->show_xml_timeline($this->notices); + $this->showXmlTimeline($this->notices); break; case 'rss': - $this->show_rss_timeline( + $this->showRssTimeline( $this->notices, $title, $link, $subtitle, $suplink ); @@ -140,13 +140,13 @@ class ApiTimelineUserAction extends ApiBareAuthAction $selfuri = common_root_url() . 'api/statuses/user_timeline.atom'; } - $this->show_atom_timeline( + $this->showAtomTimeline( $this->notices, $title, $id, $link, $subtitle, $suplink, $selfuri ); break; case 'json': - $this->show_json_timeline($this->notices); + $this->showJsonTimeline($this->notices); break; default: $this->clientError(_('API method not found!'), $code = 404); diff --git a/actions/apiusershow.php b/actions/apiusershow.php index 442efc194..d07040a43 100644 --- a/actions/apiusershow.php +++ b/actions/apiusershow.php @@ -105,16 +105,16 @@ class ApiUserShowAction extends ApiAction return; } - $twitter_user = $this->twitter_user_array($this->user->getProfile(), true); + $twitter_user = $this->twitterUserArray($this->user->getProfile(), true); if ($this->format == 'xml') { - $this->init_document('xml'); - $this->show_twitter_xml_user($twitter_user); - $this->end_document('xml'); + $this->initDocument('xml'); + $this->showTwitterXmlUser($twitter_user); + $this->endDocument('xml'); } elseif ($this->format == 'json') { - $this->init_document('json'); - $this->show_json_objects($twitter_user); - $this->end_document('json'); + $this->initDocument('json'); + $this->showJsonObjects($twitter_user); + $this->endDocument('json'); } } diff --git a/actions/twitapisearchatom.php b/actions/twitapisearchatom.php index 0ef9d2826..7d618c471 100644 --- a/actions/twitapisearchatom.php +++ b/actions/twitapisearchatom.php @@ -340,7 +340,7 @@ class TwitapisearchatomAction extends ApiAction // TODO: Here is where we'd put in a link to an atom feed for threads $this->element("twitter:source", null, - htmlentities($this->source_link($notice->source))); + htmlentities($this->sourceLink($notice->source))); $this->elementStart('author'); diff --git a/actions/twitapisearchjson.php b/actions/twitapisearchjson.php index 5abff6496..c7fa741a0 100644 --- a/actions/twitapisearchjson.php +++ b/actions/twitapisearchjson.php @@ -134,9 +134,9 @@ class TwitapisearchjsonAction extends ApiAction $results = new JSONSearchResultsList($notice, $q, $this->rpp, $this->page); - $this->init_document('json'); + $this->initDocument('json'); $results->show(); - $this->end_document('json'); + $this->endDocument('json'); } /** diff --git a/lib/api.php b/lib/api.php index 95a0779ad..0801d2823 100644 --- a/lib/api.php +++ b/lib/api.php @@ -106,7 +106,7 @@ class ApiAction extends Action return parent::element($tag, $attrs, $content); } - function twitter_user_array($profile, $get_notice=false) + function twitterUserArray($profile, $get_notice=false) { $twitter_user = array(); @@ -133,7 +133,7 @@ class ApiAction extends Action $twitter_user['friends_count'] = $profile->subscriptionCount(); - $twitter_user['created_at'] = $this->date_twitter($profile->created); + $twitter_user['created_at'] = $this->dateTwitter($profile->created); $twitter_user['favourites_count'] = $profile->faveCount(); // British spelling! @@ -179,24 +179,24 @@ class ApiAction extends Action $notice = $profile->getCurrentNotice(); if ($notice) { # don't get user! - $twitter_user['status'] = $this->twitter_status_array($notice, false); + $twitter_user['status'] = $this->twitterStatusArray($notice, false); } } return $twitter_user; } - function twitter_status_array($notice, $include_user=true) + function twitterStatusArray($notice, $include_user=true) { $profile = $notice->getProfile(); $twitter_status = array(); $twitter_status['text'] = $notice->content; $twitter_status['truncated'] = false; # Not possible on StatusNet - $twitter_status['created_at'] = $this->date_twitter($notice->created); + $twitter_status['created_at'] = $this->dateTwitter($notice->created); $twitter_status['in_reply_to_status_id'] = ($notice->reply_to) ? intval($notice->reply_to) : null; - $twitter_status['source'] = $this->source_link($notice->source); + $twitter_status['source'] = $this->sourceLink($notice->source); $twitter_status['id'] = intval($notice->id); $replier_profile = null; @@ -239,14 +239,14 @@ class ApiAction extends Action if ($include_user) { # Don't get notice (recursive!) - $twitter_user = $this->twitter_user_array($profile, false); + $twitter_user = $this->twitterUserArray($profile, false); $twitter_status['user'] = $twitter_user; } return $twitter_status; } - function twitter_group_array($group) + function twitterGroupArray($group) { $twitter_group=array(); $twitter_group['id']=$group->id; @@ -261,12 +261,12 @@ class ApiAction extends Action $twitter_group['homepage']=$group->homepage; $twitter_group['description']=$group->description; $twitter_group['location']=$group->location; - $twitter_group['created']=$this->date_twitter($group->created); - $twitter_group['modified']=$this->date_twitter($group->modified); + $twitter_group['created']=$this->dateTwitter($group->created); + $twitter_group['modified']=$this->dateTwitter($group->modified); return $twitter_group; } - function twitter_rss_group_array($group) + function twitterRssGroupArray($group) { $entry = array(); $entry['content']=$group->description; @@ -284,7 +284,7 @@ class ApiAction extends Action return $entry; } - function twitter_rss_entry_array($notice) + function twitterRssEntryArray($notice) { $profile = $notice->getProfile(); $entry = array(); @@ -341,19 +341,19 @@ class ApiAction extends Action } - function twitter_relationship_array($source, $target) + function twitterRelationshipArray($source, $target) { $relationship = array(); $relationship['source'] = - $this->relationship_details_array($source, $target); + $this->relationshipDetailsArray($source, $target); $relationship['target'] = - $this->relationship_details_array($target, $source); + $this->relationshipDetailsArray($target, $source); return array('relationship' => $relationship); } - function relationship_details_array($source, $target) + function relationshipDetailsArray($source, $target) { $details = array(); @@ -380,14 +380,14 @@ class ApiAction extends Action return $details; } - function show_twitter_xml_relationship($relationship) + function showTwitterXmlRelationship($relationship) { $this->elementStart('relationship'); foreach($relationship as $element => $value) { if ($element == 'source' || $element == 'target') { $this->elementStart($element); - $this->show_xml_relationship_details($value); + $this->showXmlRelationshipDetails($value); $this->elementEnd($element); } } @@ -395,26 +395,26 @@ class ApiAction extends Action $this->elementEnd('relationship'); } - function show_xml_relationship_details($details) + function showXmlRelationshipDetails($details) { foreach($details as $element => $value) { $this->element($element, null, $value); } } - function show_twitter_xml_status($twitter_status) + function showTwitterXmlStatus($twitter_status) { $this->elementStart('status'); foreach($twitter_status as $element => $value) { switch ($element) { case 'user': - $this->show_twitter_xml_user($twitter_status['user']); + $this->showTwitterXmlUser($twitter_status['user']); break; case 'text': $this->element($element, null, common_xml_safe_str($value)); break; case 'attachments': - $this->show_xml_attachments($twitter_status['attachments']); + $this->showXmlAttachments($twitter_status['attachments']); break; default: $this->element($element, null, $value); @@ -423,7 +423,7 @@ class ApiAction extends Action $this->elementEnd('status'); } - function show_twitter_xml_group($twitter_group) + function showTwitterXmlGroup($twitter_group) { $this->elementStart('group'); foreach($twitter_group as $element => $value) { @@ -432,12 +432,12 @@ class ApiAction extends Action $this->elementEnd('group'); } - function show_twitter_xml_user($twitter_user, $role='user') + function showTwitterXmlUser($twitter_user, $role='user') { $this->elementStart($role); foreach($twitter_user as $element => $value) { if ($element == 'status') { - $this->show_twitter_xml_status($twitter_user['status']); + $this->showTwitterXmlStatus($twitter_user['status']); } else { $this->element($element, null, $value); } @@ -445,7 +445,7 @@ class ApiAction extends Action $this->elementEnd($role); } - function show_xml_attachments($attachments) { + function showXmlAttachments($attachments) { if (!empty($attachments)) { $this->elementStart('attachments', array('type' => 'array')); foreach ($attachments as $attachment) { @@ -459,7 +459,7 @@ class ApiAction extends Action } } - function show_twitter_rss_item($entry) + function showTwitterRssItem($entry) { $this->elementStart('item'); $this->element('title', null, $entry['title']); @@ -483,59 +483,59 @@ class ApiAction extends Action $this->elementEnd('item'); } - function show_json_objects($objects) + function showJsonObjects($objects) { print(json_encode($objects)); } - function show_single_xml_status($notice) + function showSingleXmlStatus($notice) { - $this->init_document('xml'); - $twitter_status = $this->twitter_status_array($notice); - $this->show_twitter_xml_status($twitter_status); - $this->end_document('xml'); + $this->initDocument('xml'); + $twitter_status = $this->twitterStatusArray($notice); + $this->showTwitterXmlStatus($twitter_status); + $this->endDocument('xml'); } function show_single_json_status($notice) { - $this->init_document('json'); - $status = $this->twitter_status_array($notice); - $this->show_json_objects($status); - $this->end_document('json'); + $this->initDocument('json'); + $status = $this->twitterStatusArray($notice); + $this->showJsonObjects($status); + $this->endDocument('json'); } - function show_xml_timeline($notice) + function showXmlTimeline($notice) { - $this->init_document('xml'); + $this->initDocument('xml'); $this->elementStart('statuses', array('type' => 'array')); if (is_array($notice)) { foreach ($notice as $n) { - $twitter_status = $this->twitter_status_array($n); - $this->show_twitter_xml_status($twitter_status); + $twitter_status = $this->twitterStatusArray($n); + $this->showTwitterXmlStatus($twitter_status); } } else { while ($notice->fetch()) { - $twitter_status = $this->twitter_status_array($notice); - $this->show_twitter_xml_status($twitter_status); + $twitter_status = $this->twitterStatusArray($notice); + $this->showTwitterXmlStatus($twitter_status); } } $this->elementEnd('statuses'); - $this->end_document('xml'); + $this->endDocument('xml'); } - function show_rss_timeline($notice, $title, $link, $subtitle, $suplink=null) + function showRssTimeline($notice, $title, $link, $subtitle, $suplink=null) { - $this->init_document('rss'); + $this->initDocument('rss'); $this->element('title', null, $title); $this->element('link', null, $link); if (!is_null($suplink)) { - # For FriendFeed's SUP protocol + // For FriendFeed's SUP protocol $this->element('link', array('xmlns' => 'http://www.w3.org/2005/Atom', 'rel' => 'http://api.friendfeed.com/2008/03#sup', 'href' => $suplink, @@ -547,23 +547,23 @@ class ApiAction extends Action if (is_array($notice)) { foreach ($notice as $n) { - $entry = $this->twitter_rss_entry_array($n); - $this->show_twitter_rss_item($entry); + $entry = $this->twitterRssEntryArray($n); + $this->showTwitterRssItem($entry); } } else { while ($notice->fetch()) { - $entry = $this->twitter_rss_entry_array($notice); - $this->show_twitter_rss_item($entry); + $entry = $this->twitterRssEntryArray($notice); + $this->showTwitterRssItem($entry); } } - $this->end_twitter_rss(); + $this->endTwitterRss(); } - function show_atom_timeline($notice, $title, $id, $link, $subtitle=null, $suplink=null, $selfuri=null) + function showAtomTimeline($notice, $title, $id, $link, $subtitle=null, $suplink=null, $selfuri=null) { - $this->init_document('atom'); + $this->initDocument('atom'); $this->element('title', null, $title); $this->element('id', null, $id); @@ -594,14 +594,14 @@ class ApiAction extends Action } } - $this->end_document('atom'); + $this->endDocument('atom'); } - function show_rss_groups($group, $title, $link, $subtitle) + function showRssGroups($group, $title, $link, $subtitle) { - $this->init_document('rss'); + $this->initDocument('rss'); $this->element('title', null, $title); $this->element('link', null, $link); @@ -611,17 +611,17 @@ class ApiAction extends Action if (is_array($group)) { foreach ($group as $g) { - $twitter_group = $this->twitter_rss_group_array($g); - $this->show_twitter_rss_item($twitter_group); + $twitter_group = $this->twitterRssGroupArray($g); + $this->showTwitterRssItem($twitter_group); } } else { while ($group->fetch()) { - $twitter_group = $this->twitter_rss_group_array($group); - $this->show_twitter_rss_item($twitter_group); + $twitter_group = $this->twitterRssGroupArray($group); + $this->showTwitterRssItem($twitter_group); } } - $this->end_twitter_rss(); + $this->endTwitterRss(); } @@ -655,7 +655,7 @@ class ApiAction extends Action switch ($element) { case 'sender': case 'recipient': - $this->show_twitter_xml_user($value, $element); + $this->showTwitterXmlUser($value, $element); break; case 'text': $this->element($element, null, common_xml_safe_str($value)); @@ -679,11 +679,11 @@ class ApiAction extends Action $dmsg['sender_id'] = $message->from_profile; $dmsg['text'] = trim($message->content); $dmsg['recipient_id'] = $message->to_profile; - $dmsg['created_at'] = $this->date_twitter($message->created); + $dmsg['created_at'] = $this->dateTwitter($message->created); $dmsg['sender_screen_name'] = $from_profile->nickname; $dmsg['recipient_screen_name'] = $to_profile->nickname; - $dmsg['sender'] = $this->twitter_user_array($from_profile, false); - $dmsg['recipient'] = $this->twitter_user_array($to_profile, false); + $dmsg['sender'] = $this->twitterUserArray($from_profile, false); + $dmsg['recipient'] = $this->twitterUserArray($to_profile, false); return $dmsg; } @@ -725,24 +725,24 @@ class ApiAction extends Action function showSingleXmlDirectMessage($message) { - $this->init_document('xml'); + $this->initDocument('xml'); $dmsg = $this->directMessageArray($message); $this->showXmlDirectMessage($dmsg); - $this->end_document('xml'); + $this->endDocument('xml'); } function showSingleJsonDirectMessage($message) { - $this->init_document('json'); + $this->initDocument('json'); $dmsg = $this->directMessageArray($message); - $this->show_json_objects($dmsg); - $this->end_document('json'); + $this->showJsonObjects($dmsg); + $this->endDocument('json'); } - function show_atom_groups($group, $title, $id, $link, $subtitle=null, $selfuri=null) + function showAtomGroups($group, $title, $id, $link, $subtitle=null, $selfuri=null) { - $this->init_document('atom'); + $this->initDocument('atom'); $this->element('title', null, $title); $this->element('id', null, $id); @@ -766,143 +766,143 @@ class ApiAction extends Action } } - $this->end_document('atom'); + $this->endDocument('atom'); } - function show_json_timeline($notice) + function showJsonTimeline($notice) { - $this->init_document('json'); + $this->initDocument('json'); $statuses = array(); if (is_array($notice)) { foreach ($notice as $n) { - $twitter_status = $this->twitter_status_array($n); + $twitter_status = $this->twitterStatusArray($n); array_push($statuses, $twitter_status); } } else { while ($notice->fetch()) { - $twitter_status = $this->twitter_status_array($notice); + $twitter_status = $this->twitterStatusArray($notice); array_push($statuses, $twitter_status); } } - $this->show_json_objects($statuses); + $this->showJsonObjects($statuses); - $this->end_document('json'); + $this->endDocument('json'); } - function show_json_groups($group) + function showJsonGroups($group) { - $this->init_document('json'); + $this->initDocument('json'); $groups = array(); if (is_array($group)) { foreach ($group as $g) { - $twitter_group = $this->twitter_group_array($g); + $twitter_group = $this->twitterGroupArray($g); array_push($groups, $twitter_group); } } else { while ($group->fetch()) { - $twitter_group = $this->twitter_group_array($group); + $twitter_group = $this->twitterGroupArray($group); array_push($groups, $twitter_group); } } - $this->show_json_objects($groups); + $this->showJsonObjects($groups); - $this->end_document('json'); + $this->endDocument('json'); } - function show_xml_groups($group) + function showXmlGroups($group) { - $this->init_document('xml'); + $this->initDocument('xml'); $this->elementStart('groups', array('type' => 'array')); if (is_array($group)) { foreach ($group as $g) { - $twitter_group = $this->twitter_group_array($g); - $this->show_twitter_xml_group($twitter_group); + $twitter_group = $this->twitterGroupArray($g); + $this->showTwitterXmlGroup($twitter_group); } } else { while ($group->fetch()) { - $twitter_group = $this->twitter_group_array($group); - $this->show_twitter_xml_group($twitter_group); + $twitter_group = $this->twitterGroupArray($group); + $this->showTwitterXmlGroup($twitter_group); } } $this->elementEnd('groups'); - $this->end_document('xml'); + $this->endDocument('xml'); } - function show_twitter_xml_users($user) + function showTwitterXmlUsers($user) { - $this->init_document('xml'); + $this->initDocument('xml'); $this->elementStart('users', array('type' => 'array')); if (is_array($user)) { foreach ($user as $u) { - $twitter_user = $this->twitter_user_array($u); - $this->show_twitter_xml_user($twitter_user); + $twitter_user = $this->twitterUserArray($u); + $this->showTwitterXmlUser($twitter_user); } } else { while ($user->fetch()) { - $twitter_user = $this->twitter_user_array($user); - $this->show_twitter_xml_user($twitter_user); + $twitter_user = $this->twitterUserArray($user); + $this->showTwitterXmlUser($twitter_user); } } $this->elementEnd('users'); - $this->end_document('xml'); + $this->endDocument('xml'); } - function show_json_users($user) + function showJsonUsers($user) { - $this->init_document('json'); + $this->initDocument('json'); $users = array(); if (is_array($user)) { foreach ($user as $u) { - $twitter_user = $this->twitter_user_array($u); + $twitter_user = $this->twitterUserArray($u); array_push($users, $twitter_user); } } else { while ($user->fetch()) { - $twitter_user = $this->twitter_user_array($user); + $twitter_user = $this->twitterUserArray($user); array_push($users, $twitter_user); } } - $this->show_json_objects($users); + $this->showJsonObjects($users); - $this->end_document('json'); + $this->endDocument('json'); } - function show_single_json_group($group) + function showSingleJsonGroup($group) { - $this->init_document('json'); - $twitter_group = $this->twitter_group_array($group); - $this->show_json_objects($twitter_group); - $this->end_document('json'); + $this->initDocument('json'); + $twitter_group = $this->twitterGroupArray($group); + $this->showJsonObjects($twitter_group); + $this->endDocument('json'); } function show_single_xml_group($group) { - $this->init_document('xml'); - $twitter_group = $this->twitter_group_array($group); - $this->show_twitter_xml_group($twitter_group); - $this->end_document('xml'); + $this->initDocument('xml'); + $twitter_group = $this->twitterGroupArray($group); + $this->showTwitterXmlGroup($twitter_group); + $this->endDocument('xml'); } - function date_twitter($dt) + function dateTwitter($dt) { $dateStr = date('d F Y H:i:s', strtotime($dt)); $d = new DateTime($dateStr, new DateTimeZone('UTC')); @@ -910,24 +910,7 @@ class ApiAction extends Action return $d->format('D M d H:i:s O Y'); } - // XXX: Candidate for a general utility method somewhere? - function count_subscriptions($profile) - { - - $count = 0; - $sub = new Subscription(); - $sub->subscribed = $profile->id; - - $count = $sub->find(); - - if ($count > 0) { - return $count - 1; - } else { - return 0; - } - } - - function init_document($type='xml') + function initDocument($type='xml') { switch ($type) { case 'xml': @@ -945,11 +928,11 @@ class ApiAction extends Action break; case 'rss': header("Content-Type: application/rss+xml; charset=utf-8"); - $this->init_twitter_rss(); + $this->initTwitterRss(); break; case 'atom': header('Content-Type: application/atom+xml; charset=utf-8'); - $this->init_twitter_atom(); + $this->initTwitterAtom(); break; default: $this->clientError(_('Not a supported data format.')); @@ -959,7 +942,7 @@ class ApiAction extends Action return; } - function end_document($type='xml') + function endDocument($type='xml') { switch ($type) { case 'xml': @@ -974,10 +957,10 @@ class ApiAction extends Action } break; case 'rss': - $this->end_twitter_rss(); + $this->endTwitterRss(); break; case 'atom': - $this->end_twitter_rss(); + $this->endTwitterRss(); break; default: $this->clientError(_('Not a supported data format.')); @@ -1001,17 +984,17 @@ class ApiAction extends Action header('HTTP/1.1 '.$code.' '.$status_string); if ($format == 'xml') { - $this->init_document('xml'); + $this->initDocument('xml'); $this->elementStart('hash'); $this->element('error', null, $msg); $this->element('request', null, $_SERVER['REQUEST_URI']); $this->elementEnd('hash'); - $this->end_document('xml'); + $this->endDocument('xml'); } elseif ($format == 'json'){ - $this->init_document('json'); + $this->initDocument('json'); $error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']); print(json_encode($error_array)); - $this->end_document('json'); + $this->endDocument('json'); } else { // If user didn't request a useful format, throw a regular client error @@ -1034,21 +1017,21 @@ class ApiAction extends Action header('HTTP/1.1 '.$code.' '.$status_string); if ($content_type == 'xml') { - $this->init_document('xml'); + $this->initDocument('xml'); $this->elementStart('hash'); $this->element('error', null, $msg); $this->element('request', null, $_SERVER['REQUEST_URI']); $this->elementEnd('hash'); - $this->end_document('xml'); + $this->endDocument('xml'); } else { - $this->init_document('json'); + $this->initDocument('json'); $error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']); print(json_encode($error_array)); - $this->end_document('json'); + $this->endDocument('json'); } } - function init_twitter_rss() + function initTwitterRss() { $this->startXML(); $this->elementStart('rss', array('version' => '2.0', 'xmlns:atom'=>'http://www.w3.org/2005/Atom')); @@ -1056,14 +1039,14 @@ class ApiAction extends Action Event::handle('StartApiRss', array($this)); } - function end_twitter_rss() + function endTwitterRss() { $this->elementEnd('channel'); $this->elementEnd('rss'); $this->endXML(); } - function init_twitter_atom() + function initTwitterAtom() { $this->startXML(); // FIXME: don't hardcode the language here! @@ -1073,21 +1056,21 @@ class ApiAction extends Action Event::handle('StartApiAtom', array($this)); } - function end_twitter_atom() + function endTwitterAtom() { $this->elementEnd('feed'); $this->endXML(); } - function show_profile($profile, $content_type='xml', $notice=null, $includeStatuses=true) + function showProfile($profile, $content_type='xml', $notice=null, $includeStatuses=true) { - $profile_array = $this->twitter_user_array($profile, $includeStatuses); + $profile_array = $this->twitterUserArray($profile, $includeStatuses); switch ($content_type) { case 'xml': - $this->show_twitter_xml_user($profile_array); + $this->showTwitterXmlUser($profile_array); break; case 'json': - $this->show_json_objects($profile_array); + $this->showJsonObjects($profile_array); break; default: $this->clientError(_('Not a supported data format.')); @@ -1155,7 +1138,7 @@ class ApiAction extends Action } } - function source_link($source) + function sourceLink($source) { $source_name = _($source); switch ($source) { diff --git a/lib/twitter.php b/lib/twitter.php index b49e2e119..afc3f55ba 100644 --- a/lib/twitter.php +++ b/lib/twitter.php @@ -23,7 +23,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { define('TWITTER_SERVICE', 1); // Twitter is foreign_service ID 1 -function update_twitter_user($twitter_id, $screen_name) +function updateTwitter_user($twitter_id, $screen_name) { $uri = 'http://twitter.com/' . $screen_name; $fuser = new Foreign_user(); @@ -115,7 +115,7 @@ function save_twitter_user($twitter_id, $screen_name) // Only update if Twitter screen name has changed if ($fuser->nickname != $screen_name) { - $result = update_twitter_user($twitter_id, $screen_name); + $result = updateTwitter_user($twitter_id, $screen_name); common_debug('Twitter bridge - Updated nickname (and URI) for Twitter user ' . "$fuser->id to $screen_name, was $fuser->nickname"); diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index 9a750bbc8..0c7c1240c 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -246,7 +246,7 @@ class RealtimePlugin extends Plugin $act = new ApiAction('/dev/null'); - $arr = $act->twitter_status_array($notice, true); + $arr = $act->twitterStatusArray($notice, true); $arr['url'] = $notice->bestUrl(); $arr['html'] = htmlspecialchars($notice->rendered); $arr['source'] = htmlspecialchars($arr['source']); -- cgit v1.2.3-54-g00ecf From 870b091693531ba9aca20a0b0fa64ec326d72725 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 12 Oct 2009 16:36:00 -0700 Subject: Added in credits. --- actions/apiaccountratelimitstatus.php | 8 ++++++-- actions/apiaccountverifycredentials.php | 6 +++++- actions/apiblockcreate.php | 15 ++++++++------- actions/apiblockdestroy.php | 3 ++- actions/apidirectmessage.php | 8 +++++++- actions/apidirectmessagenew.php | 11 ++++++++--- actions/apifavoritecreate.php | 6 +++++- actions/apifavoritedestroy.php | 6 +++++- actions/apifriendshipscreate.php | 6 +++++- actions/apifriendshipsdestroy.php | 6 +++++- actions/apifriendshipsexists.php | 8 ++++++-- actions/apifriendshipsshow.php | 18 +++++++++++------- actions/apigroupcreate.php | 5 +++++ actions/apigroupismember.php | 7 ++++++- actions/apigroupjoin.php | 7 ++++++- actions/apigroupleave.php | 11 ++++++++--- actions/apigrouplist.php | 8 +++++++- actions/apigrouplistall.php | 6 ++++++ actions/apigroupmembership.php | 18 ++++++++++++------ actions/apigroupshow.php | 8 +++++++- actions/apihelptest.php | 2 ++ actions/apistatusesdestroy.php | 16 +++++++++++++--- actions/apistatusesshow.php | 14 +++++++++++++- actions/apistatusesupdate.php | 16 +++++++++++++--- actions/apistatusnetconfig.php | 2 ++ actions/apistatusnetversion.php | 6 ++++-- actions/apisubscriptions.php | 6 +++++- actions/apitimelinefavorites.php | 7 +++++-- actions/apitimelinefriends.php | 14 +++++++++++++- actions/apitimelinegroup.php | 6 ++++++ actions/apitimelinementions.php | 15 +++++++++++++-- actions/apitimelinepublic.php | 14 +++++++++++++- actions/apitimelinetag.php | 8 +++++++- actions/apitimelineuser.php | 15 +++++++++++++-- actions/apiuserfollowers.php | 6 +++++- actions/apiuserfriends.php | 6 +++++- actions/apiusershow.php | 8 +++++++- lib/api.php | 10 ++++++++++ lib/apiauth.php | 9 ++++++++- lib/apibareauth.php | 16 +++++++++++++++- lib/twitterbasicauthclient.php | 10 ++++++++-- 41 files changed, 310 insertions(+), 67 deletions(-) (limited to 'actions/apistatusesupdate.php') diff --git a/actions/apiaccountratelimitstatus.php b/actions/apiaccountratelimitstatus.php index af86dae6a..96179f175 100644 --- a/actions/apiaccountratelimitstatus.php +++ b/actions/apiaccountratelimitstatus.php @@ -21,6 +21,8 @@ * * @category API * @package StatusNet + * @author Evan Prodromou + * @author Robin Millette * @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 @@ -31,14 +33,16 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apibareauth.php'; +require_once INSTALLDIR . '/lib/apibareauth.php'; /** * We don't have a rate limit, but some clients check this method. - * It always returns the same thing: 100 hits left. + * It always returns the same thing: 150 hits left. * * @category API * @package StatusNet + * @author Evan Prodromou + * @author Robin Millette * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apiaccountverifycredentials.php b/actions/apiaccountverifycredentials.php index 8b976bbf3..08b201dbf 100644 --- a/actions/apiaccountverifycredentials.php +++ b/actions/apiaccountverifycredentials.php @@ -21,6 +21,8 @@ * * @category API * @package StatusNet + * @author Evan Prodromou + * @author Robin Millette * @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 @@ -31,7 +33,7 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apiauth.php'; +require_once INSTALLDIR . '/lib/apiauth.php'; /** * Check a user's credentials. Returns an HTTP 200 OK response code and a @@ -40,6 +42,8 @@ require_once INSTALLDIR.'/lib/apiauth.php'; * * @category API * @package StatusNet + * @author Evan Prodromou + * @author Robin Millette * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apiblockcreate.php b/actions/apiblockcreate.php index e003e5ee9..1cab2df5d 100644 --- a/actions/apiblockcreate.php +++ b/actions/apiblockcreate.php @@ -21,6 +21,7 @@ * * @category API * @package StatusNet + * @author Evan Prodromou * @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 @@ -34,12 +35,13 @@ if (!defined('STATUSNET')) { require_once INSTALLDIR . '/lib/apiauth.php'; /** - * Blocks the user specified in the ID parameter as the authenticating user. - * Destroys a friendship to the blocked user if it exists. Returns the + * Blocks the user specified in the ID parameter as the authenticating user. + * Destroys a friendship to the blocked user if it exists. Returns the * blocked user in the requested format when successful. * * @category API * @package StatusNet + * @author Evan Prodromou * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -47,7 +49,6 @@ require_once INSTALLDIR . '/lib/apiauth.php'; class ApiBlockCreateAction extends ApiAuthAction { - var $user = null; var $other = null; /** @@ -91,13 +92,13 @@ class ApiBlockCreateAction extends ApiAuthAction ); return; } - + if (empty($this->user) || empty($this->other)) { $this->clientError(_('No such user!'), 404, $this->format); return; } - - if ($this->user->hasBlocked($this->other) + + if ($this->user->hasBlocked($this->other) || $this->user->block($this->other) ) { $this->initDocument($this->format); @@ -106,7 +107,7 @@ class ApiBlockCreateAction extends ApiAuthAction } else { $this->serverError(_('Block user failed.'), 500, $this->format); } - + } } diff --git a/actions/apiblockdestroy.php b/actions/apiblockdestroy.php index 470b60ea5..16dbf94ca 100644 --- a/actions/apiblockdestroy.php +++ b/actions/apiblockdestroy.php @@ -21,6 +21,7 @@ * * @category API * @package StatusNet + * @author Evan Prodromou * @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 @@ -39,6 +40,7 @@ require_once INSTALLDIR . '/lib/apiauth.php'; * * @category API * @package StatusNet + * @author Evan Prodromou * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -46,7 +48,6 @@ require_once INSTALLDIR . '/lib/apiauth.php'; class ApiBlockDestroyAction extends ApiAuthAction { - var $user = null; var $other = null; /** diff --git a/actions/apidirectmessage.php b/actions/apidirectmessage.php index 4e55886d9..a21fe86d2 100644 --- a/actions/apidirectmessage.php +++ b/actions/apidirectmessage.php @@ -21,6 +21,9 @@ * * @category API * @package StatusNet + * @author Adrian Lang + * @author Evan Prodromou + * @author Robin Millette * @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 @@ -31,13 +34,16 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apiauth.php'; +require_once INSTALLDIR . '/lib/apiauth.php'; /** * Show a list of direct messages from or to the authenticating user * * @category API * @package StatusNet + * @author Adrian Lang + * @author Evan Prodromou + * @author Robin Millette * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apidirectmessagenew.php b/actions/apidirectmessagenew.php index 6984c8d10..fa6cafbe8 100644 --- a/actions/apidirectmessagenew.php +++ b/actions/apidirectmessagenew.php @@ -21,6 +21,9 @@ * * @category API * @package StatusNet + * @author Adrian Lang + * @author Evan Prodromou + * @author Robin Millette * @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 @@ -31,7 +34,7 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apiauth.php'; +require_once INSTALLDIR . '/lib/apiauth.php'; /** * Creates a new direct message from the authenticating user to @@ -39,6 +42,9 @@ require_once INSTALLDIR.'/lib/apiauth.php'; * * @category API * @package StatusNet + * @author Adrian Lang + * @author Evan Prodromou + * @author Robin Millette * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -47,7 +53,6 @@ require_once INSTALLDIR.'/lib/apiauth.php'; class ApiDirectMessageNewAction extends ApiAuthAction { var $source = null; - var $user = null; var $other = null; var $content = null; @@ -151,7 +156,7 @@ class ApiDirectMessageNewAction extends ApiAuthAction // Note: sending msgs to yourself is allowed by Twitter - $errmsg = 'Don\'t send a message to yourself; ' . + $errmsg = 'Don\'t send a message to yourself; ' . 'just say it to yourself quietly instead.' $this->clientError(_($errmsg), 403, $this->format); diff --git a/actions/apifavoritecreate.php b/actions/apifavoritecreate.php index 2a185f607..a80a6492e 100644 --- a/actions/apifavoritecreate.php +++ b/actions/apifavoritecreate.php @@ -21,6 +21,8 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou * @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 @@ -31,7 +33,7 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apiauth.php'; +require_once INSTALLDIR . '/lib/apiauth.php'; /** * Favorites the status specified in the ID parameter as the authenticating user. @@ -39,6 +41,8 @@ require_once INSTALLDIR.'/lib/apiauth.php'; * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apifavoritedestroy.php b/actions/apifavoritedestroy.php index f954a5076..f131d1c7f 100644 --- a/actions/apifavoritedestroy.php +++ b/actions/apifavoritedestroy.php @@ -21,6 +21,8 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou * @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 @@ -31,7 +33,7 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apiauth.php'; +require_once INSTALLDIR . '/lib/apiauth.php'; /** * Un-favorites the status specified in the ID parameter as the authenticating user. @@ -39,6 +41,8 @@ require_once INSTALLDIR.'/lib/apiauth.php'; * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apifriendshipscreate.php b/actions/apifriendshipscreate.php index fe4e9e9a2..a824e734b 100644 --- a/actions/apifriendshipscreate.php +++ b/actions/apifriendshipscreate.php @@ -21,6 +21,8 @@ * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou * @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 @@ -31,7 +33,7 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apiauth.php'; +require_once INSTALLDIR . '/lib/apiauth.php'; /** * Allows the authenticating users to follow (subscribe) the user specified in @@ -40,6 +42,8 @@ require_once INSTALLDIR.'/lib/apiauth.php'; * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apifriendshipsdestroy.php b/actions/apifriendshipsdestroy.php index f0f6c062b..3d9b7e001 100644 --- a/actions/apifriendshipsdestroy.php +++ b/actions/apifriendshipsdestroy.php @@ -21,6 +21,8 @@ * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou * @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 @@ -31,7 +33,7 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apiauth.php'; +require_once INSTALLDIR . '/lib/apiauth.php'; /** * Allows the authenticating users to unfollow (unsubscribe) the user specified in @@ -40,6 +42,8 @@ require_once INSTALLDIR.'/lib/apiauth.php'; * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apifriendshipsexists.php b/actions/apifriendshipsexists.php index 93be5f84e..ae50c512c 100644 --- a/actions/apifriendshipsexists.php +++ b/actions/apifriendshipsexists.php @@ -21,6 +21,8 @@ * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou * @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 @@ -31,14 +33,16 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/api.php'; +require_once INSTALLDIR . '/lib/api.php'; /** - * Tests for the existence of friendship between two users. Will return true if + * Tests for the existence of friendship between two users. Will return true if * user_a follows user_b, otherwise will return false. * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apifriendshipsshow.php b/actions/apifriendshipsshow.php index c5aed238f..8fc436738 100644 --- a/actions/apifriendshipsshow.php +++ b/actions/apifriendshipsshow.php @@ -21,6 +21,8 @@ * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou * @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 @@ -31,13 +33,15 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apibareauth.php'; +require_once INSTALLDIR . '/lib/apibareauth.php'; /** * Outputs detailed information about the relationship between two users * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -65,7 +69,7 @@ class ApiFriendshipsShowAction extends ApiBareAuthAction $source_screen_name = $this->trimmed('source_screen_name'); $target_id = (int)$this->trimmed('target_id'); $target_screen_name = $this->trimmed('target_screen_name'); - + if (!empty($source_id)) { $this->source = User::staticGet($source_id); } elseif (!empty($source_screen_name)) { @@ -90,7 +94,7 @@ class ApiFriendshipsShowAction extends ApiBareAuthAction * * @return boolean true or false */ - + function requiresAuth() { if (common_config('site', 'private')) { @@ -125,7 +129,7 @@ class ApiFriendshipsShowAction extends ApiBareAuthAction $this->clientError(_('API method not found!'), 404); return; } - + if (empty($this->source)) { $this->clientError( _('Could not determine source user.'), @@ -133,7 +137,7 @@ class ApiFriendshipsShowAction extends ApiBareAuthAction ); return; } - + if (empty($this->target)) { $this->clientError( _('Could not find target user.'), @@ -141,7 +145,7 @@ class ApiFriendshipsShowAction extends ApiBareAuthAction ); return; } - + $result = $this->twitterRelationshipArray($this->source, $this->target); switch ($this->format) { @@ -158,7 +162,7 @@ class ApiFriendshipsShowAction extends ApiBareAuthAction default: break; } - + } } diff --git a/actions/apigroupcreate.php b/actions/apigroupcreate.php index aeae1c2b2..cdb2afb5b 100644 --- a/actions/apigroupcreate.php +++ b/actions/apigroupcreate.php @@ -22,6 +22,8 @@ * @category API * @package StatusNet * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @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 @@ -39,6 +41,9 @@ require_once INSTALLDIR . '/lib/apiauth.php'; * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apigroupismember.php b/actions/apigroupismember.php index 6cf327012..a8a40a6b3 100644 --- a/actions/apigroupismember.php +++ b/actions/apigroupismember.php @@ -21,6 +21,9 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @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 @@ -38,6 +41,9 @@ require_once INSTALLDIR . '/lib/apibareauth.php'; * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -45,7 +51,6 @@ require_once INSTALLDIR . '/lib/apibareauth.php'; class ApiGroupIsMemberAction extends ApiBareAuthAction { - var $user = null; var $group = null; /** diff --git a/actions/apigroupjoin.php b/actions/apigroupjoin.php index f930aa519..071cd9290 100644 --- a/actions/apigroupjoin.php +++ b/actions/apigroupjoin.php @@ -21,6 +21,9 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @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 @@ -38,6 +41,9 @@ require_once INSTALLDIR . '/lib/apiauth.php'; * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -45,7 +51,6 @@ require_once INSTALLDIR . '/lib/apiauth.php'; class ApiGroupJoinAction extends ApiAuthAction { - var $user = null; var $group = null; /** diff --git a/actions/apigroupleave.php b/actions/apigroupleave.php index 4e3192ac0..0d4bb9e4d 100644 --- a/actions/apigroupleave.php +++ b/actions/apigroupleave.php @@ -21,6 +21,9 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @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 @@ -38,6 +41,9 @@ require_once INSTALLDIR . '/lib/apiauth.php'; * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -45,7 +51,6 @@ require_once INSTALLDIR . '/lib/apiauth.php'; class ApiGroupLeaveAction extends ApiAuthAction { - var $user = null; var $group = null; /** @@ -117,13 +122,13 @@ class ApiGroupLeaveAction extends ApiAuthAction $this->serverError( sprintf( _('Could not remove user %s to group %s.'), - $this->user->nickname, + $this->user->nickname, $this->$group->nickname ) ); return; } - + switch($this->format) { case 'xml': $this->show_single_xml_group($this->group); diff --git a/actions/apigrouplist.php b/actions/apigrouplist.php index 1fc31831a..c529c1e40 100644 --- a/actions/apigrouplist.php +++ b/actions/apigrouplist.php @@ -21,6 +21,9 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @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 @@ -38,6 +41,9 @@ require_once INSTALLDIR . '/lib/apibareauth.php'; * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -59,7 +65,7 @@ class ApiGroupListAction extends ApiBareAuthAction function prepare($args) { parent::prepare($args); - + $this->user = $this->getTargetUser($id); $this->groups = $this->getGroups(); diff --git a/actions/apigrouplistall.php b/actions/apigrouplistall.php index ef96a08bd..89469f36f 100644 --- a/actions/apigrouplistall.php +++ b/actions/apigrouplistall.php @@ -21,6 +21,9 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @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 @@ -38,6 +41,9 @@ require_once INSTALLDIR . '/lib/api.php'; * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apigroupmembership.php b/actions/apigroupmembership.php index 27f77029e..b31e47b39 100644 --- a/actions/apigroupmembership.php +++ b/actions/apigroupmembership.php @@ -21,6 +21,9 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @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 @@ -34,10 +37,13 @@ if (!defined('STATUSNET')) { require_once INSTALLDIR . '/lib/api.php'; /** - * List 20 newest members of the group specified by name or ID. + * List 20 newest members of the group specified by name or ID. * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -103,7 +109,7 @@ class ApiGroupMembershipAction extends ApiAction /** * Fetch the members of a group * - * @return array $profiles list of profiles + * @return array $profiles list of profiles */ function getProfiles() @@ -112,9 +118,9 @@ class ApiGroupMembershipAction extends ApiAction $profile = $this->group->getMembers( ($this->page - 1) * $this->count, - $this->count, - $this->since_id, - $this->max_id, + $this->count, + $this->since_id, + $this->max_id, $this->since ); @@ -157,7 +163,7 @@ class ApiGroupMembershipAction extends ApiAction * An entity tag for this list of groups * * Returns an Etag based on the action name, language - * the group id, and timestamps of the first and last + * the group id, and timestamps of the first and last * user who has joined the group * * @return string etag diff --git a/actions/apigroupshow.php b/actions/apigroupshow.php index 8969ae194..2bdb22bc4 100644 --- a/actions/apigroupshow.php +++ b/actions/apigroupshow.php @@ -21,6 +21,9 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @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 @@ -31,13 +34,16 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/api.php'; +require_once INSTALLDIR . '/lib/api.php'; /** * Outputs detailed information about the group specified by ID * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apihelptest.php b/actions/apihelptest.php index 4691cbf99..e4ef55f2e 100644 --- a/actions/apihelptest.php +++ b/actions/apihelptest.php @@ -21,6 +21,7 @@ * * @category API * @package StatusNet + * @author Evan Prodromou * @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 @@ -38,6 +39,7 @@ require_once INSTALLDIR . '/lib/api.php'; * * @category API * @package StatusNet + * @author Evan Prodromou * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apistatusesdestroy.php b/actions/apistatusesdestroy.php index 74a1310a2..8dc8793b5 100644 --- a/actions/apistatusesdestroy.php +++ b/actions/apistatusesdestroy.php @@ -21,6 +21,12 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To + * @author Tom Blankenship + * @author Mike Cochrane + * @author Robin Millette * @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 @@ -31,13 +37,19 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apiauth.php'; +require_once INSTALLDIR . '/lib/apiauth.php'; /** * Deletes one of the authenticating user's statuses (notices). * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To + * @author Tom Blankenship + * @author Mike Cochrane + * @author Robin Millette * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -45,8 +57,6 @@ require_once INSTALLDIR.'/lib/apiauth.php'; class ApiStatusesDestroyAction extends ApiAuthAction { - - var $user = null; var $status = null; /** diff --git a/actions/apistatusesshow.php b/actions/apistatusesshow.php index 5d32a0bfc..3be22ca59 100644 --- a/actions/apistatusesshow.php +++ b/actions/apistatusesshow.php @@ -21,6 +21,12 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To + * @author Tom Blankenship + * @author Mike Cochrane + * @author Robin Millette * @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 @@ -31,13 +37,19 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/api.php'; +require_once INSTALLDIR . '/lib/api.php'; /** * Returns the notice specified by id as a Twitter-style status and inline user * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To + * @author Tom Blankenship + * @author Mike Cochrane + * @author Robin Millette * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php index 479654be8..0d71e1512 100644 --- a/actions/apistatusesupdate.php +++ b/actions/apistatusesupdate.php @@ -21,6 +21,12 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To + * @author Tom Blankenship + * @author Mike Cochrane + * @author Robin Millette * @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 @@ -31,13 +37,19 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apiauth.php'; +require_once INSTALLDIR . '/lib/apiauth.php'; /** * Updates the authenticating user's status (posts a notice). * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To + * @author Tom Blankenship + * @author Mike Cochrane + * @author Robin Millette * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -45,8 +57,6 @@ require_once INSTALLDIR.'/lib/apiauth.php'; class ApiStatusesUpdateAction extends ApiAuthAction { - - var $user = null; var $source = null; var $status = null; var $in_reply_to_status_id = null; diff --git a/actions/apistatusnetconfig.php b/actions/apistatusnetconfig.php index a93570698..ed1d151bf 100644 --- a/actions/apistatusnetconfig.php +++ b/actions/apistatusnetconfig.php @@ -21,6 +21,7 @@ * * @category API * @package StatusNet + * @author Evan Prodromou * @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 @@ -42,6 +43,7 @@ require_once INSTALLDIR . '/lib/api.php'; * * @category API * @package StatusNet + * @author Evan Prodromou * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apistatusnetversion.php b/actions/apistatusnetversion.php index 6af9bdd1a..e73ab983b 100644 --- a/actions/apistatusnetversion.php +++ b/actions/apistatusnetversion.php @@ -21,6 +21,7 @@ * * @category API * @package StatusNet + * @author Evan Prodromou * @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,6 +42,7 @@ require_once INSTALLDIR . '/lib/api.php'; * * @category API * @package StatusNet + * @author Evan Prodromou * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -88,8 +90,8 @@ class ApiStatusnetVersionAction extends ApiAction break; default: $this->clientError( - _('API method not found!'), - 404, + _('API method not found!'), + 404, $this->format ); break; diff --git a/actions/apisubscriptions.php b/actions/apisubscriptions.php index a952e20b8..bc68dd192 100644 --- a/actions/apisubscriptions.php +++ b/actions/apisubscriptions.php @@ -21,6 +21,8 @@ * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou * @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 @@ -31,7 +33,7 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apibareauth.php'; +require_once INSTALLDIR . '/lib/apibareauth.php'; /** * This class outputs a list of profiles as Twitter-style user and status objects. @@ -40,6 +42,8 @@ require_once INSTALLDIR.'/lib/apibareauth.php'; * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apitimelinefavorites.php b/actions/apitimelinefavorites.php index c85e56264..b8ae74f13 100644 --- a/actions/apitimelinefavorites.php +++ b/actions/apitimelinefavorites.php @@ -21,8 +21,9 @@ * * @category API * @package StatusNet - * @author Zach Copley - * @copyright 2009 StatusNet, Inc. + * @author Craig Andrews + * @author Evan Prodromou + * @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 * @link http://status.net/ */ @@ -39,6 +40,8 @@ require_once INSTALLDIR.'/lib/apibareauth.php'; * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apitimelinefriends.php b/actions/apitimelinefriends.php index 90f3b3c06..1ea35866e 100644 --- a/actions/apitimelinefriends.php +++ b/actions/apitimelinefriends.php @@ -21,6 +21,12 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To + * @author mac65 + * @author Mike Cochrane + * @author Robin Millette * @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 @@ -31,7 +37,7 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apibareauth.php'; +require_once INSTALLDIR . '/lib/apibareauth.php'; /** * Returns the most recent notices (default 20) posted by the target user. @@ -39,6 +45,12 @@ require_once INSTALLDIR.'/lib/apibareauth.php'; * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To + * @author mac65 + * @author Mike Cochrane + * @author Robin Millette * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apitimelinegroup.php b/actions/apitimelinegroup.php index 2a6f35d72..5d0542918 100644 --- a/actions/apitimelinegroup.php +++ b/actions/apitimelinegroup.php @@ -21,6 +21,9 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @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 @@ -38,6 +41,9 @@ require_once INSTALLDIR . '/lib/api.php'; * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apitimelinementions.php b/actions/apitimelinementions.php index c25fb0a0e..fe5ff0f28 100644 --- a/actions/apitimelinementions.php +++ b/actions/apitimelinementions.php @@ -21,6 +21,12 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To + * @author mac65 + * @author Mike Cochrane + * @author Robin Millette * @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 @@ -31,13 +37,19 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apibareauth.php'; +require_once INSTALLDIR . '/lib/apibareauth.php'; /** * Returns the most recent (default 20) mentions (status containing @nickname) * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To + * @author mac65 + * @author Mike Cochrane + * @author Robin Millette * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -46,7 +58,6 @@ require_once INSTALLDIR.'/lib/apibareauth.php'; class ApiTimelineMentionsAction extends ApiBareAuthAction { - var $user = null; var $notices = null; /** diff --git a/actions/apitimelinepublic.php b/actions/apitimelinepublic.php index 4bff4adb6..58e267734 100644 --- a/actions/apitimelinepublic.php +++ b/actions/apitimelinepublic.php @@ -21,6 +21,12 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To + * @author mac65 + * @author Mike Cochrane + * @author Robin Millette * @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 @@ -31,13 +37,19 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/api.php'; +require_once INSTALLDIR . '/lib/api.php'; /** * Returns the most recent notices (default 20) posted by everybody * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To + * @author mac65 + * @author Mike Cochrane + * @author Robin Millette * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apitimelinetag.php b/actions/apitimelinetag.php index cf211b173..a274daac0 100644 --- a/actions/apitimelinetag.php +++ b/actions/apitimelinetag.php @@ -21,6 +21,9 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @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 @@ -31,13 +34,16 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/api.php'; +require_once INSTALLDIR . '/lib/api.php'; /** * Returns the 20 most recent notices tagged by a given tag * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apitimelineuser.php b/actions/apitimelineuser.php index e7fac3e7a..285735fd1 100644 --- a/actions/apitimelineuser.php +++ b/actions/apitimelineuser.php @@ -21,6 +21,12 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To + * @author mac65 + * @author Mike Cochrane + * @author Robin Millette * @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 @@ -31,7 +37,7 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apibareauth.php'; +require_once INSTALLDIR . '/lib/apibareauth.php'; /** * Returns the most recent notices (default 20) posted by the authenticating @@ -40,6 +46,12 @@ require_once INSTALLDIR.'/lib/apibareauth.php'; * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To + * @author mac65 + * @author Mike Cochrane + * @author Robin Millette * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -48,7 +60,6 @@ require_once INSTALLDIR.'/lib/apibareauth.php'; class ApiTimelineUserAction extends ApiBareAuthAction { - var $user = null; var $notices = null; /** diff --git a/actions/apiuserfollowers.php b/actions/apiuserfollowers.php index 5c0243449..e8d92a773 100644 --- a/actions/apiuserfollowers.php +++ b/actions/apiuserfollowers.php @@ -21,6 +21,8 @@ * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou * @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 @@ -31,7 +33,7 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apibareauth.php'; +require_once INSTALLDIR . '/lib/apibareauth.php'; /** * Ouputs the authenticating user's followers (subscribers), each with @@ -40,6 +42,8 @@ require_once INSTALLDIR.'/lib/apibareauth.php'; * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apiuserfriends.php b/actions/apiuserfriends.php index 8a42e36b9..741a26e58 100644 --- a/actions/apiuserfriends.php +++ b/actions/apiuserfriends.php @@ -21,6 +21,8 @@ * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou * @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 @@ -31,7 +33,7 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apibareauth.php'; +require_once INSTALLDIR . '/lib/apibareauth.php'; /** * Ouputs the authenticating user's friends (subscriptions), each with @@ -40,6 +42,8 @@ require_once INSTALLDIR.'/lib/apibareauth.php'; * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/actions/apiusershow.php b/actions/apiusershow.php index db942d1a5..b3a939b43 100644 --- a/actions/apiusershow.php +++ b/actions/apiusershow.php @@ -21,6 +21,9 @@ * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou + * @author mac65 * @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 @@ -31,7 +34,7 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/api.php'; +require_once INSTALLDIR . '/lib/api.php'; /** * Ouputs information for a user, specified by ID or screen name. @@ -39,6 +42,9 @@ require_once INSTALLDIR.'/lib/api.php'; * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou + * @author mac65 * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/lib/api.php b/lib/api.php index db2d24fbd..7a63a4a78 100644 --- a/lib/api.php +++ b/lib/api.php @@ -21,6 +21,11 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Dan Moore + * @author Evan Prodromou + * @author Jeffery To + * @author Toby Inkster * @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 @@ -36,6 +41,11 @@ if (!defined('STATUSNET')) { * * @category API * @package StatusNet + * @author Craig Andrews + * @author Dan Moore + * @author Evan Prodromou + * @author Jeffery To + * @author Toby Inkster * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/lib/apiauth.php b/lib/apiauth.php index 4e5e0ccd9..2f2e44a26 100644 --- a/lib/apiauth.php +++ b/lib/apiauth.php @@ -21,7 +21,14 @@ * * @category API * @package StatusNet - * @author Zach Copley + * @author Adrian Lang + * @author Brenda Wallace + * @author Craig Andrews + * @author Dan Moore + * @author Evan Prodromou + * @author mEDI + * @author Sarven Capadisli + * @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 * @link http://status.net/ diff --git a/lib/apibareauth.php b/lib/apibareauth.php index 0ae477f46..2d29c1ddd 100644 --- a/lib/apibareauth.php +++ b/lib/apibareauth.php @@ -23,7 +23,14 @@ * * @category API * @package StatusNet - * @author Zach Copley + * @author Adrian Lang + * @author Brenda Wallace + * @author Craig Andrews + * @author Dan Moore + * @author Evan Prodromou + * @author mEDI + * @author Sarven Capadisli + * @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 * @link http://status.net/ @@ -41,6 +48,13 @@ require_once INSTALLDIR.'/lib/apiauth.php'; * * @category API * @package StatusNet + * @author Adrian Lang + * @author Brenda Wallace + * @author Craig Andrews + * @author Dan Moore + * @author Evan Prodromou + * @author mEDI + * @author Sarven Capadisli * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ diff --git a/lib/twitterbasicauthclient.php b/lib/twitterbasicauthclient.php index fd331fbdc..1040d72fb 100644 --- a/lib/twitterbasicauthclient.php +++ b/lib/twitterbasicauthclient.php @@ -36,8 +36,14 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { * * @category Integration * @package StatusNet - * @author Zach Copley - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @author Adrian Lang + * @author Brenda Wallace + * @author Craig Andrews + * @author Dan Moore + * @author Evan Prodromou + * @author mEDI + * @author Sarven Capadisli + * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ * */ -- cgit v1.2.3-54-g00ecf From 2d0aba49d913b7d4598073d5ff56237f736731d0 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 27 Oct 2009 21:45:56 -0700 Subject: Implement media upload in the API --- actions/apistatusesupdate.php | 72 ++++++++++++++++++++-------- lib/mediafile.php | 106 +++++++++++++++++++++--------------------- 2 files changed, 106 insertions(+), 72 deletions(-) (limited to 'actions/apistatusesupdate.php') diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php index 0d71e1512..b7128d084 100644 --- a/actions/apistatusesupdate.php +++ b/actions/apistatusesupdate.php @@ -38,6 +38,7 @@ if (!defined('STATUSNET')) { } require_once INSTALLDIR . '/lib/apiauth.php'; +require_once INSTALLDIR . '/lib/mediafile.php'; /** * Updates the authenticating user's status (posts a notice). @@ -60,7 +61,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction var $source = null; var $status = null; var $in_reply_to_status_id = null; - static $reserved_sources = array('web', 'omb', 'mail', 'xmpp', 'api'); /** @@ -76,25 +76,8 @@ class ApiStatusesUpdateAction extends ApiAuthAction { parent::prepare($args); - $this->user = $this->auth_user; - - if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->format); - return false; - } - + $this->user = $this->auth_user; $this->status = $this->trimmed('status'); - - if (empty($this->status)) { - $this->clientError( - 'Client must provide a \'status\' parameter with a value.', - 400, - $this->format - ); - - return false; - } - $this->source = $this->trimmed('source'); if (empty($this->source) || in_array($source, $this->reserved_sources)) { @@ -129,6 +112,27 @@ class ApiStatusesUpdateAction extends ApiAuthAction return; } + if (empty($_POST) && $_SERVER['CONTENT_LENGTH']) { + $this->clientError(sprintf(_('The server was unable to handle ' . + 'that much POST data (%s bytes) due to its current configuration.'), + $_SERVER['CONTENT_LENGTH'])); + return; + } + + if (empty($this->user)) { + $this->clientError(_('No such user!'), 404, $this->format); + return; + } + + if (empty($this->status)) { + $this->clientError( + 'Client must provide a \'status\' parameter with a value.', + 400, + $this->format + ); + return; + } + $status_shortened = common_shorten_links($this->status); if (Notice::contentTooLong($status_shortened)) { @@ -187,14 +191,42 @@ class ApiStatusesUpdateAction extends ApiAuthAction } } + $upload = null; + + common_debug('looking for attachment'); + + $upload = MediaFile::fromUpload('media', $this->user); + + common_debug("uploaded file = " . var_export($upload, true)); + + if (isset($upload)) { + common_debug('newNotice: found an upload'); + + $status_shortened .= ' ' . $upload->shortUrl(); + + common_debug('content w/upload = ' . $status_shortened); + + if (Notice::contentTooLong($status_shortened)) { + $upload->delete(); + $this->clientError(sprintf(_('Max notice size is %d chars, including attachment URL.'), + Notice::maxContent())); + } else { + common_debug('content not too long'); + } + } + $this->notice = Notice::saveNew( $this->user->id, - html_entity_decode($this->status, ENT_NOQUOTES, 'UTF-8'), + html_entity_decode($status_shortened, ENT_NOQUOTES, 'UTF-8'), $this->source, 1, $reply_to ); + if (isset($upload)) { + $upload->attachToNotice($this->notice); + } + common_broadcast_notice($this->notice); } diff --git a/lib/mediafile.php b/lib/mediafile.php index be101cdca..31868daec 100644 --- a/lib/mediafile.php +++ b/lib/mediafile.php @@ -31,9 +31,9 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -class MediaFile +class MediaFile { - + var $filename = null; var $fileRecord = null; var $user = null; @@ -46,16 +46,16 @@ class MediaFile if ($user == null) { $this->user = common_current_user(); } - + common_debug('in MediaFile constructor'); - + $this->filename = $filename; $this->mimetype = $mimetype; - + common_debug('storing file'); $this->fileRecord = $this->storeFile(); common_debug('finished storing file'); - + $this->fileurl = common_local_url('attachment', array('attachment' => $this->fileRecord->id)); @@ -67,24 +67,24 @@ class MediaFile common_debug('shortening file url'); $this->short_fileurl = common_shorten_url($this->fileurl); common_debug('shortened file url = ' . $short_fileurl); - + // Also, not sure this is necessary -- Zach $this->maybeAddRedir($this->fileRecord->id, $this->short_fileurl); - + common_debug("MediaFile: end of constructor"); } - + function attachToNotice($notice) { common_debug('MediaFile::attachToNotice() -- doing File_to_post'); File_to_post::processNew($this->fileRecord->id, $notice->id); common_debug('MediaFile done doing File_to_post'); - + $this->maybeAddRedir($this->fileRecord->id, - common_local_url('file', array('notice' => $notice->id))); + common_local_url('file', array('notice' => $notice->id))); } - - function shortUrl() + + function shortUrl() { return $this->short_fileurl; } @@ -115,12 +115,12 @@ class MediaFile $file_id = $file->insert(); if (!$file_id) { - + common_debug("storeFile: problem inserting new file"); common_log_db_error($file, "INSERT", __FILE__); throw new ClientException(_('There was a database error while saving your file. Please try again.')); } - + common_debug('finished storing file'); return $file; @@ -133,15 +133,15 @@ class MediaFile function maybeAddRedir($file_id, $url) { - + common_debug("maybeAddRedir: looking up url: $url for file id $file_id"); $file_redir = File_redirection::staticGet('url', $url); if (empty($file_redir)) { - + common_debug("maybeAddRedir: $url is not in the db"); - + $file_redir = new File_redirection; $file_redir->url = $url; $file_redir->file_id = $file_id; @@ -153,20 +153,24 @@ class MediaFile throw new ClientException(_('There was a database error while saving your file. Please try again.')); } } else { - + common_debug("maybeAddRedir: no need to add $url, it's already in the db"); } } - static function fromUpload($param = 'media') + static function fromUpload($param = 'media', $user = null) { common_debug("fromUpload: param = $param"); - + + if (empty($user)) { + $user = common_current_user(); + } + if (!isset($_FILES[$param]['error'])){ common_debug('no file found'); return; } - + switch ($_FILES[$param]['error']) { case UPLOAD_ERR_OK: // success, jump out break; @@ -183,7 +187,7 @@ class MediaFile @unlink($_FILES[$param]['tmp_name']); throw new ClientException(_('The uploaded file was only' . ' partially uploaded.')); - return; + return; case UPLOAD_ERR_NO_TMP_DIR: throw new ClientException(_('Missing a temporary folder.')); return; @@ -197,24 +201,22 @@ class MediaFile throw new ClientException(_('System error uploading file.')); return; } - - $user = common_current_user(); - + if (!MediaFile::respectsQuota($user, $_FILES['attach']['size'])) { - + // Should never actually get here - + @unlink($_FILES[$param]['tmp_name']); throw new ClientException(_('File exceeds user\'s quota!')); return; } $mimetype = MediaFile::getUploadedFileType($_FILES[$param]['tmp_name']); - + $filename = null; - + if (isset($mimetype)) { - + $basename = basename($_FILES[$param]['name']); $filename = File::filename($user->getProfile(), $basename, $mimetype); $filepath = File::path($filename); @@ -222,44 +224,44 @@ class MediaFile common_debug("filepath = " . $filepath); $result = move_uploaded_file($_FILES[$param]['tmp_name'], $filepath); - - if (!$result) { + + if (!$result) { throw new ClientException(_('File could not be moved to destination directory.')); return; } - + } else { throw new ClientException(_('Could not determine file\'s mime-type!')); return; } - + return new MediaFile($user, $filename, $mimetype); } - static function fromFilehandle($user, $fh) { + static function fromFilehandle($fh, $user) { $stream = stream_get_meta_data($fh); if (MediaFile::respectsQuota($user, filesize($stream['uri']))) { - + // Should never actually get here - + throw new ClientException(_('File exceeds user\'s quota!')); return; } $mimetype = MediaFile::getUploadedFileType($fh); - + $filename = null; - + if (isset($mimetype)) { $filename = File::filename($user->getProfile(), "email", $mimetype); $filepath = File::path($filename); - + $result = copy($stream['uri'], $filepath) && chmod($filepath, 0664); - + if (!$result) { throw new ClientException(_('File could not be moved to destination directory.' . $stream['uri'] . ' ' . $filepath)); @@ -268,33 +270,33 @@ class MediaFile throw new ClientException(_('Could not determine file\'s mime-type!')); return; } - + return new MediaFile($user, $filename, $mimetype); } static function getUploadedFileType($f) { require_once 'MIME/Type.php'; - + common_debug("in getUploadedFileType"); $cmd = &PEAR::getStaticProperty('MIME_Type', 'fileCmd'); $cmd = common_config('attachments', 'filecommand'); - + $filetype = null; - + if (is_string($f)) { - + // assuming a filename - + $filetype = MIME_Type::autoDetect($f); } else { - + // assuming a filehandle - + $stream = stream_get_meta_data($f); $filetype = MIME_Type::autoDetect($stream['uri']); } - + if (in_array($filetype, common_config('attachments', 'supported'))) { return $filetype; } @@ -308,7 +310,7 @@ class MediaFile _('%s is not a supported filetype on this server.'), $filetype) . $hint); } - static function respectsQuota($user, $filesize) + static function respectsQuota($user, $filesize) { $file = new File; $result = $file->isRespectsQuota($user, $filesize); -- cgit v1.2.3-54-g00ecf From e5a2f895a074a6eaaf8184f101503b1520ed780b Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 28 Oct 2009 17:12:22 -0700 Subject: Rearanged a couple things & removed debugging statements --- actions/apistatusesupdate.php | 46 +++++++++++++++------------------- actions/newnotice.php | 26 ++++++++------------ lib/mediafile.php | 57 ++++++------------------------------------- 3 files changed, 36 insertions(+), 93 deletions(-) (limited to 'actions/apistatusesupdate.php') diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php index b7128d084..3a030f0fe 100644 --- a/actions/apistatusesupdate.php +++ b/actions/apistatusesupdate.php @@ -112,10 +112,12 @@ class ApiStatusesUpdateAction extends ApiAuthAction return; } - if (empty($_POST) && $_SERVER['CONTENT_LENGTH']) { - $this->clientError(sprintf(_('The server was unable to handle ' . - 'that much POST data (%s bytes) due to its current configuration.'), - $_SERVER['CONTENT_LENGTH'])); + if (empty($this->status)) { + $this->clientError( + 'Client must provide a \'status\' parameter with a value.', + 400, + $this->format + ); return; } @@ -124,12 +126,10 @@ class ApiStatusesUpdateAction extends ApiAuthAction return; } - if (empty($this->status)) { - $this->clientError( - 'Client must provide a \'status\' parameter with a value.', - 400, - $this->format - ); + // Workaround for PHP returning empty $_FILES when POST length > PHP settings + + if (empty($_POST) && ($_SERVER['CONTENT_LENGTH'] > 0)) { + $this->clientError(_('Unable to handle that much POST data!')); return; } @@ -192,27 +192,19 @@ class ApiStatusesUpdateAction extends ApiAuthAction } $upload = null; - - common_debug('looking for attachment'); - $upload = MediaFile::fromUpload('media', $this->user); - common_debug("uploaded file = " . var_export($upload, true)); - if (isset($upload)) { - common_debug('newNotice: found an upload'); - - $status_shortened .= ' ' . $upload->shortUrl(); - - common_debug('content w/upload = ' . $status_shortened); + $status_shortened .= ' ' . $upload->shortUrl(); - if (Notice::contentTooLong($status_shortened)) { - $upload->delete(); - $this->clientError(sprintf(_('Max notice size is %d chars, including attachment URL.'), - Notice::maxContent())); - } else { - common_debug('content not too long'); - } + if (Notice::contentTooLong($status_shortened)) { + $upload->delete(); + $msg = _( + 'Max notice size is %d chars, ' . + 'including attachment URL.' + ); + $this->clientError(sprintf($msg, Notice::maxContent())); + } } $this->notice = Notice::saveNew( diff --git a/actions/newnotice.php b/actions/newnotice.php index 5100e79e1..59fb9f461 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -164,27 +164,21 @@ class NewnoticeAction extends Action } $upload = null; - - common_debug('looking for attachment'); - $upload = MediaFile::fromUpload('attach'); - common_debug("uploaded file = " . var_export($upload, true)); - if (isset($upload)) { - common_debug('newNotice: found an upload'); - $content_shortened .= ' ' . $upload->shortUrl(); + $content_shortened .= ' ' . $upload->shortUrl(); - common_debug('content w/upload = ' . $content_shortened); - - if (Notice::contentTooLong($content_shortened)) { - $upload->delete(); - $this->clientError(sprintf(_('Max notice size is %d chars, including attachment URL.'), - Notice::maxContent())); - } else { - common_debug('content not too long'); - } + if (Notice::contentTooLong($content_shortened)) { + $upload->delete(); + $this->clientError( + sprintf( + _('Max notice size is %d chars, including attachment URL.'), + Notice::maxContent() + ) + ); + } } $notice = Notice::saveNew($user->id, $content_shortened, 'web', 1, diff --git a/lib/mediafile.php b/lib/mediafile.php index 4aa8211c3..40f37ba61 100644 --- a/lib/mediafile.php +++ b/lib/mediafile.php @@ -47,39 +47,21 @@ class MediaFile $this->user = common_current_user(); } - common_debug('in MediaFile constructor'); - - $this->filename = $filename; - $this->mimetype = $mimetype; - - common_debug('storing file'); + $this->filename = $filename; + $this->mimetype = $mimetype; $this->fileRecord = $this->storeFile(); - common_debug('finished storing file'); $this->fileurl = common_local_url('attachment', array('attachment' => $this->fileRecord->id)); - common_debug('$this->fileurl() = ' . $this->fileurl); - - // not sure this is necessary -- Zach $this->maybeAddRedir($this->fileRecord->id, $this->fileurl); - - common_debug('shortening file url'); $this->short_fileurl = common_shorten_url($this->fileurl); - common_debug('shortened file url = ' . $short_fileurl); - - // Also, not sure this is necessary -- Zach $this->maybeAddRedir($this->fileRecord->id, $this->short_fileurl); - - common_debug("MediaFile: end of constructor"); } function attachToNotice($notice) { - common_debug('MediaFile::attachToNotice() -- doing File_to_post'); File_to_post::processNew($this->fileRecord->id, $notice->id); - common_debug('MediaFile done doing File_to_post'); - $this->maybeAddRedir($this->fileRecord->id, common_local_url('file', array('notice' => $notice->id))); } @@ -98,31 +80,21 @@ class MediaFile function storeFile() { $file = new File; - $file->filename = $this->filename; - - common_debug('storing ' . $this->filename); - - $file->url = File::url($this->filename); - common_debug('file->url = ' . $file->url); - - $filepath = File::path($this->filename); - common_debug('filepath = ' . $filepath); - $file->size = filesize($filepath); - $file->date = time(); + $file->filename = $this->filename; + $file->url = File::url($this->filename); + $filepath = File::path($this->filename); + $file->size = filesize($filepath); + $file->date = time(); $file->mimetype = $this->mimetype; $file_id = $file->insert(); if (!$file_id) { - - common_debug("storeFile: problem inserting new file"); common_log_db_error($file, "INSERT", __FILE__); throw new ClientException(_('There was a database error while saving your file. Please try again.')); } - common_debug('finished storing file'); - return $file; } @@ -133,15 +105,10 @@ class MediaFile function maybeAddRedir($file_id, $url) { - - common_debug("maybeAddRedir: looking up url: $url for file id $file_id"); - $file_redir = File_redirection::staticGet('url', $url); if (empty($file_redir)) { - common_debug("maybeAddRedir: $url is not in the db"); - $file_redir = new File_redirection; $file_redir->url = $url; $file_redir->file_id = $file_id; @@ -152,22 +119,16 @@ class MediaFile common_log_db_error($file_redir, "INSERT", __FILE__); throw new ClientException(_('There was a database error while saving your file. Please try again.')); } - } else { - - common_debug("maybeAddRedir: no need to add $url, it's already in the db"); } } static function fromUpload($param = 'media', $user = null) { - common_debug("fromUpload: param = $param"); - if (empty($user)) { $user = common_current_user(); } if (!isset($_FILES[$param]['error'])){ - common_debug('no file found'); return; } @@ -221,8 +182,6 @@ class MediaFile $filename = File::filename($user->getProfile(), $basename, $mimetype); $filepath = File::path($filename); - common_debug("filepath = " . $filepath); - $result = move_uploaded_file($_FILES[$param]['tmp_name'], $filepath); if (!$result) { @@ -277,8 +236,6 @@ class MediaFile static function getUploadedFileType($f) { require_once 'MIME/Type.php'; - common_debug("in getUploadedFileType"); - $cmd = &PEAR::getStaticProperty('MIME_Type', 'fileCmd'); $cmd = common_config('attachments', 'filecommand'); -- cgit v1.2.3-54-g00ecf From 03a1436a1c07c0867ca748560b37457f99ea1d66 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 28 Oct 2009 17:29:21 -0700 Subject: Trap ClientExceptions from media upload process and hand them off to API error handler --- actions/apistatusesupdate.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'actions/apistatusesupdate.php') diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php index 3a030f0fe..898a4bd72 100644 --- a/actions/apistatusesupdate.php +++ b/actions/apistatusesupdate.php @@ -192,7 +192,13 @@ class ApiStatusesUpdateAction extends ApiAuthAction } $upload = null; - $upload = MediaFile::fromUpload('media', $this->user); + + try { + $upload = MediaFile::fromUpload('media', $this->user); + } catch (ClientException $ce) { + $this->clientError($ce->getMessage()); + return; + } if (isset($upload)) { $status_shortened .= ' ' . $upload->shortUrl(); -- cgit v1.2.3-54-g00ecf From 1e6aff69d69e09495638b60831c0548aae0b9773 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 3 Nov 2009 09:41:36 -0800 Subject: Fix reference to sources class variable --- actions/apistatusesupdate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actions/apistatusesupdate.php') diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php index 898a4bd72..b9c0832a4 100644 --- a/actions/apistatusesupdate.php +++ b/actions/apistatusesupdate.php @@ -80,7 +80,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction $this->status = $this->trimmed('status'); $this->source = $this->trimmed('source'); - if (empty($this->source) || in_array($source, $this->reserved_sources)) { + if (empty($this->source) || in_array($source, self::$reserved_sources)) { $this->source = 'api'; } -- cgit v1.2.3-54-g00ecf From 527427d3e0752a371b1b6421dabec5cc1c7e19ad Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 4 Nov 2009 21:00:26 -0800 Subject: Implement update avatar via API (/api/account/update_profile_image.format) --- actions/apiaccountupdateprofileimage.php | 145 +++++++++++++++++++++++++++++++ actions/apistatusesupdate.php | 2 +- extlib/MIME/Type.php | 2 +- lib/imagefile.php | 2 +- lib/router.php | 3 + 5 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 actions/apiaccountupdateprofileimage.php (limited to 'actions/apistatusesupdate.php') diff --git a/actions/apiaccountupdateprofileimage.php b/actions/apiaccountupdateprofileimage.php new file mode 100644 index 000000000..416fee45a --- /dev/null +++ b/actions/apiaccountupdateprofileimage.php @@ -0,0 +1,145 @@ +. + * + * @category API + * @package StatusNet + * @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 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR . '/lib/apiauth.php'; + +/** + * Updates the authenticating user's profile image. Note that this API method + * expects raw multipart data, not a URL to an image. + * + * @category API + * @package StatusNet + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class ApiAccountUpdateProfileImageAction extends ApiAuthAction +{ + + /** + * Take arguments for running + * + * @param array $args $_REQUEST args + * + * @return boolean success flag + * + */ + + function prepare($args) + { + parent::prepare($args); + + $this->user = $this->auth_user; + + return true; + } + + /** + * Handle the request + * + * Check whether the credentials are valid and output the result + * + * @param array $args $_REQUEST data (unused) + * + * @return void + */ + + function handle($args) + { + parent::handle($args); + + if ($_SERVER['REQUEST_METHOD'] != 'POST') { + $this->clientError( + _('This method requires a POST.'), + 400, $this->format + ); + return; + } + + if (empty($this->user)) { + $this->clientError(_('No such user!'), 404, $this->format); + return; + } + + // Workaround for PHP returning empty $_FILES when POST length > PHP settings + + if (empty($_FILES) && ($_SERVER['CONTENT_LENGTH'] > 0)) { + common_debug('content-length = ' . $_SERVER['CONTENT_LENGTH']); + $this->clientError(_('Unable to handle that much POST data!')); + return; + } + + try { + $imagefile = ImageFile::fromUpload('image'); + } catch (Exception $e) { + $this->clientError($e->getMessage(), 400, $this->format); + return; + } + + $filename = Avatar::filename( + $user->id, + image_type_to_extension($imagefile->type), + null, + 'tmp'.common_timestamp() + ); + + $filepath = Avatar::path($filename); + + move_uploaded_file($imagefile->filepath, $filepath); + + $profile = $this->user->getProfile(); + + if (empty($profile)) { + $this->clientError(_('User has no profile.')); + return; + } + + $profile->setOriginal($filename); + + common_broadcast_profile($profile); + + $twitter_user = $this->twitterUserArray($this->user->getProfile(), true); + + if ($this->format == 'xml') { + $this->initDocument('xml'); + $this->showTwitterXmlUser($twitter_user); + $this->endDocument('xml'); + } elseif ($this->format == 'json') { + $this->initDocument('json'); + $this->showJsonObjects($twitter_user); + $this->endDocument('json'); + } + } + +} diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php index b9c0832a4..82fe5a537 100644 --- a/actions/apistatusesupdate.php +++ b/actions/apistatusesupdate.php @@ -128,7 +128,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction // Workaround for PHP returning empty $_FILES when POST length > PHP settings - if (empty($_POST) && ($_SERVER['CONTENT_LENGTH'] > 0)) { + if (empty($_FILES) && ($_SERVER['CONTENT_LENGTH'] > 0)) { $this->clientError(_('Unable to handle that much POST data!')); return; } diff --git a/extlib/MIME/Type.php b/extlib/MIME/Type.php index c335f8d92..e0e9c9ee6 100644 --- a/extlib/MIME/Type.php +++ b/extlib/MIME/Type.php @@ -513,7 +513,7 @@ class MIME_Type return PEAR::raiseError("Can't find file command \"{$fileCmd}\""); } - $cmd->pushCommand($fileCmd, "-bi " . escapeshellarg($file)); + $cmd->pushCommand($fileCmd, "-bI " . escapeshellarg($file)); $res = $cmd->execute(); unset($cmd); diff --git a/lib/imagefile.php b/lib/imagefile.php index cd2f87e6b..cf1668f20 100644 --- a/lib/imagefile.php +++ b/lib/imagefile.php @@ -72,7 +72,7 @@ class ImageFile break; case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: - throw new Exception(sprintf(_('That file is too big. The maximum file size is %d.'), + throw new Exception(sprintf(_('That file is too big. The maximum file size is %s.'), ImageFile::maxFileSize())); return; case UPLOAD_ERR_PARTIAL: diff --git a/lib/router.php b/lib/router.php index 0ddda473c..eb931e5b0 100644 --- a/lib/router.php +++ b/lib/router.php @@ -428,6 +428,9 @@ class Router $m->connect('api/account/verify_credentials.:format', array('action' => 'ApiAccountVerifyCredentials')); + $m->connect('api/account/update_profile_image.:format', + array('action' => 'ApiAccountUpdateProfileImage')); + // special case where verify_credentials is called w/out a format $m->connect('api/account/verify_credentials', -- cgit v1.2.3-54-g00ecf From b522c401e66e5b5d7e000c1bf25fd4b4a4d0558f Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 6 Nov 2009 17:21:08 -0800 Subject: Better workaround for PHP returning empty $_POST and $_FILES when POST length > post_max_size in php.ini. I also added this check to avatar upload, which was failing with huge files. --- actions/apiaccountupdateprofileimage.php | 20 +++++++++++++------- actions/apistatusesupdate.php | 21 ++++++++++++++------- actions/avatarsettings.php | 16 +++++++++++++++- lib/designsettings.php | 13 ++++++++----- 4 files changed, 50 insertions(+), 20 deletions(-) (limited to 'actions/apistatusesupdate.php') diff --git a/actions/apiaccountupdateprofileimage.php b/actions/apiaccountupdateprofileimage.php index 416fee45a..72fb361bf 100644 --- a/actions/apiaccountupdateprofileimage.php +++ b/actions/apiaccountupdateprofileimage.php @@ -87,16 +87,22 @@ class ApiAccountUpdateProfileImageAction extends ApiAuthAction return; } - if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->format); + // Workaround for PHP returning empty $_POST and $_FILES when POST + // length > post_max_size in php.ini + + if (empty($_FILES) + && empty($_POST) + && ($_SERVER['CONTENT_LENGTH'] > 0) + ) { + $msg = _('The server was unable to handle that much POST ' . + 'data (%s bytes) due to its current configuration.'); + + $this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH'])); return; } - // Workaround for PHP returning empty $_FILES when POST length > PHP settings - - if (empty($_FILES) && ($_SERVER['CONTENT_LENGTH'] > 0)) { - common_debug('content-length = ' . $_SERVER['CONTENT_LENGTH']); - $this->clientError(_('Unable to handle that much POST data!')); + if (empty($this->user)) { + $this->clientError(_('No such user!'), 404, $this->format); return; } diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php index 82fe5a537..e369fa71e 100644 --- a/actions/apistatusesupdate.php +++ b/actions/apistatusesupdate.php @@ -112,6 +112,20 @@ class ApiStatusesUpdateAction extends ApiAuthAction return; } + // Workaround for PHP returning empty $_POST and $_FILES when POST + // length > post_max_size in php.ini + + if (empty($_FILES) + && empty($_POST) + && ($_SERVER['CONTENT_LENGTH'] > 0) + ) { + $msg = _('The server was unable to handle that much POST ' . + 'data (%s bytes) due to its current configuration.'); + + $this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH'])); + return; + } + if (empty($this->status)) { $this->clientError( 'Client must provide a \'status\' parameter with a value.', @@ -126,13 +140,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction return; } - // Workaround for PHP returning empty $_FILES when POST length > PHP settings - - if (empty($_FILES) && ($_SERVER['CONTENT_LENGTH'] > 0)) { - $this->clientError(_('Unable to handle that much POST data!')); - return; - } - $status_shortened = common_shorten_links($this->status); if (Notice::contentTooLong($status_shortened)) { diff --git a/actions/avatarsettings.php b/actions/avatarsettings.php index ded419dd7..879e44842 100644 --- a/actions/avatarsettings.php +++ b/actions/avatarsettings.php @@ -244,11 +244,25 @@ class AvatarsettingsAction extends AccountSettingsAction function handlePost() { + // Workaround for PHP returning empty $_POST and $_FILES when POST + // length > post_max_size in php.ini + + if (empty($_FILES) + && empty($_POST) + && ($_SERVER['CONTENT_LENGTH'] > 0) + ) { + $msg = _('The server was unable to handle that much POST ' . + 'data (%s bytes) due to its current configuration.'); + + $this->showForm(sprintf($msg, $_SERVER['CONTENT_LENGTH'])); + return; + } + // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->show_form(_('There was a problem with your session token. '. + $this->showForm(_('There was a problem with your session token. '. 'Try again, please.')); return; } diff --git a/lib/designsettings.php b/lib/designsettings.php index 820d534f2..5ce9ddeda 100644 --- a/lib/designsettings.php +++ b/lib/designsettings.php @@ -271,17 +271,20 @@ class DesignSettingsAction extends AccountSettingsAction function handlePost() { - // XXX: Robin's workaround for a bug in PHP where $_POST - // and $_FILE are empty in the case that the uploaded - // file is bigger than PHP is configured to handle. - if ($_SERVER['REQUEST_METHOD'] == 'POST') { - if (empty($_POST) && $_SERVER['CONTENT_LENGTH']) { + // Workaround for PHP returning empty $_POST and $_FILES when POST + // length > post_max_size in php.ini + + if (empty($_FILES) + && empty($_POST) + && ($_SERVER['CONTENT_LENGTH'] > 0) + ) { $msg = _('The server was unable to handle that much POST ' . 'data (%s bytes) due to its current configuration.'); $this->showForm(sprintf($msg, $_SERVER['CONTENT_LENGTH'])); + return; } } -- cgit v1.2.3-54-g00ecf From 221b779e88e51b70a2c3509798154c461203e636 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Sun, 8 Nov 2009 23:10:44 +0100 Subject: Harmonise UI message "No such user." --- actions/apiaccountupdateprofileimage.php | 2 +- actions/apiblockcreate.php | 2 +- actions/apiblockdestroy.php | 2 +- actions/apidirectmessage.php | 2 +- actions/apidirectmessagenew.php | 2 +- actions/apigroupcreate.php | 2 +- actions/apigroupismember.php | 2 +- actions/apigroupjoin.php | 2 +- actions/apigroupleave.php | 2 +- actions/apigrouplist.php | 2 +- actions/apistatusesupdate.php | 2 +- actions/apisubscriptions.php | 2 +- actions/apitimelinefavorites.php | 2 +- actions/apitimelinefriends.php | 2 +- actions/apitimelinementions.php | 2 +- actions/apitimelineuser.php | 2 +- actions/microsummary.php | 2 +- actions/newmessage.php | 2 +- actions/remotesubscribe.php | 2 +- lib/oauthstore.php | 4 ++-- 20 files changed, 21 insertions(+), 21 deletions(-) (limited to 'actions/apistatusesupdate.php') diff --git a/actions/apiaccountupdateprofileimage.php b/actions/apiaccountupdateprofileimage.php index 72fb361bf..2f8e9628c 100644 --- a/actions/apiaccountupdateprofileimage.php +++ b/actions/apiaccountupdateprofileimage.php @@ -102,7 +102,7 @@ class ApiAccountUpdateProfileImageAction extends ApiAuthAction } if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->format); + $this->clientError(_('No such user.'), 404, $this->format); return; } diff --git a/actions/apiblockcreate.php b/actions/apiblockcreate.php index 1cab2df5d..4f941f6c3 100644 --- a/actions/apiblockcreate.php +++ b/actions/apiblockcreate.php @@ -94,7 +94,7 @@ class ApiBlockCreateAction extends ApiAuthAction } if (empty($this->user) || empty($this->other)) { - $this->clientError(_('No such user!'), 404, $this->format); + $this->clientError(_('No such user.'), 404, $this->format); return; } diff --git a/actions/apiblockdestroy.php b/actions/apiblockdestroy.php index 16dbf94ca..328f18ab0 100644 --- a/actions/apiblockdestroy.php +++ b/actions/apiblockdestroy.php @@ -93,7 +93,7 @@ class ApiBlockDestroyAction extends ApiAuthAction } if (empty($this->user) || empty($this->other)) { - $this->clientError(_('No such user!'), 404, $this->format); + $this->clientError(_('No such user.'), 404, $this->format); return; } diff --git a/actions/apidirectmessage.php b/actions/apidirectmessage.php index a21fe86d2..5b3f412ad 100644 --- a/actions/apidirectmessage.php +++ b/actions/apidirectmessage.php @@ -74,7 +74,7 @@ class ApiDirectMessageAction extends ApiAuthAction $this->user = $this->auth_user; if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->format); + $this->clientError(_('No such user.'), 404, $this->format); return; } diff --git a/actions/apidirectmessagenew.php b/actions/apidirectmessagenew.php index ca1ee70dd..fed6acc30 100644 --- a/actions/apidirectmessagenew.php +++ b/actions/apidirectmessagenew.php @@ -72,7 +72,7 @@ class ApiDirectMessageNewAction extends ApiAuthAction $this->user = $this->auth_user; if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->format); + $this->clientError(_('No such user.'), 404, $this->format); return; } diff --git a/actions/apigroupcreate.php b/actions/apigroupcreate.php index f66e83073..895dfb7ab 100644 --- a/actions/apigroupcreate.php +++ b/actions/apigroupcreate.php @@ -109,7 +109,7 @@ class ApiGroupCreateAction extends ApiAuthAction } if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->format); + $this->clientError(_('No such user.'), 404, $this->format); return; } diff --git a/actions/apigroupismember.php b/actions/apigroupismember.php index a8a40a6b3..a822d18dd 100644 --- a/actions/apigroupismember.php +++ b/actions/apigroupismember.php @@ -87,7 +87,7 @@ class ApiGroupIsMemberAction extends ApiBareAuthAction parent::handle($args); if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->format); + $this->clientError(_('No such user.'), 404, $this->format); return; } diff --git a/actions/apigroupjoin.php b/actions/apigroupjoin.php index 071cd9290..ffda3986f 100644 --- a/actions/apigroupjoin.php +++ b/actions/apigroupjoin.php @@ -96,7 +96,7 @@ class ApiGroupJoinAction extends ApiAuthAction } if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->format); + $this->clientError(_('No such user.'), 404, $this->format); return; } diff --git a/actions/apigroupleave.php b/actions/apigroupleave.php index 0d4bb9e4d..8665ea1aa 100644 --- a/actions/apigroupleave.php +++ b/actions/apigroupleave.php @@ -96,7 +96,7 @@ class ApiGroupLeaveAction extends ApiAuthAction } if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->format); + $this->clientError(_('No such user.'), 404, $this->format); return; } diff --git a/actions/apigrouplist.php b/actions/apigrouplist.php index c529c1e40..7b05f8a96 100644 --- a/actions/apigrouplist.php +++ b/actions/apigrouplist.php @@ -87,7 +87,7 @@ class ApiGroupListAction extends ApiBareAuthAction parent::handle($args); if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->format); + $this->clientError(_('No such user.'), 404, $this->format); return; } diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php index e369fa71e..5c23accca 100644 --- a/actions/apistatusesupdate.php +++ b/actions/apistatusesupdate.php @@ -136,7 +136,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction } if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->format); + $this->clientError(_('No such user.'), 404, $this->format); return; } diff --git a/actions/apisubscriptions.php b/actions/apisubscriptions.php index bc68dd192..2c691bb84 100644 --- a/actions/apisubscriptions.php +++ b/actions/apisubscriptions.php @@ -84,7 +84,7 @@ class ApiSubscriptionsAction extends ApiBareAuthAction $this->user = $this->getTargetUser($this->arg('id')); if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->format); + $this->clientError(_('No such user.'), 404, $this->format); return false; } diff --git a/actions/apitimelinefavorites.php b/actions/apitimelinefavorites.php index b8ae74f13..f84d7b4cb 100644 --- a/actions/apitimelinefavorites.php +++ b/actions/apitimelinefavorites.php @@ -67,7 +67,7 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction $this->user = $this->getTargetUser($this->arg('id')); if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->format); + $this->clientError(_('No such user.'), 404, $this->format); return; } diff --git a/actions/apitimelinefriends.php b/actions/apitimelinefriends.php index 66dd3f2b2..e84f77372 100644 --- a/actions/apitimelinefriends.php +++ b/actions/apitimelinefriends.php @@ -76,7 +76,7 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction $this->user = $this->getTargetUser($this->arg('id')); if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->format); + $this->clientError(_('No such user.'), 404, $this->format); return; } diff --git a/actions/apitimelinementions.php b/actions/apitimelinementions.php index fe5ff0f28..0956ccdce 100644 --- a/actions/apitimelinementions.php +++ b/actions/apitimelinementions.php @@ -76,7 +76,7 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction $this->user = $this->getTargetUser($this->arg('id')); if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->format); + $this->clientError(_('No such user.'), 404, $this->format); return; } diff --git a/actions/apitimelineuser.php b/actions/apitimelineuser.php index 285735fd1..ca1d21772 100644 --- a/actions/apitimelineuser.php +++ b/actions/apitimelineuser.php @@ -78,7 +78,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction $this->user = $this->getTargetUser($this->arg('id')); if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->format); + $this->clientError(_('No such user.'), 404, $this->format); return; } diff --git a/actions/microsummary.php b/actions/microsummary.php index 5c01a9ce0..5c761e8bb 100644 --- a/actions/microsummary.php +++ b/actions/microsummary.php @@ -59,7 +59,7 @@ class MicrosummaryAction extends Action $user = User::staticGet('nickname', $nickname); if (!$user) { - $this->clientError(_('No such user'), 404); + $this->clientError(_('No such user.'), 404); return; } diff --git a/actions/newmessage.php b/actions/newmessage.php index 095a7d1d3..0db2e7181 100644 --- a/actions/newmessage.php +++ b/actions/newmessage.php @@ -113,7 +113,7 @@ class NewmessageAction extends Action $this->other = User::staticGet('id', $this->to); if (!$this->other) { - $this->clientError(_('No such user'), 404); + $this->clientError(_('No such user.'), 404); return false; } diff --git a/actions/remotesubscribe.php b/actions/remotesubscribe.php index aee2a5d8e..74025cf80 100644 --- a/actions/remotesubscribe.php +++ b/actions/remotesubscribe.php @@ -151,7 +151,7 @@ class RemotesubscribeAction extends Action $this->profile_url = $this->trimmed('profile_url'); if (!$this->profile_url) { - $this->showForm(_('No such user')); + $this->showForm(_('No such user.')); return; } diff --git a/lib/oauthstore.php b/lib/oauthstore.php index d617a7df7..a4ea5ad4d 100644 --- a/lib/oauthstore.php +++ b/lib/oauthstore.php @@ -351,7 +351,7 @@ class StatusNetOAuthDataStore extends OAuthDataStore $author = User::staticGet('uri', $author_uri); } if (!$author) { - throw new Exception('No such user'); + throw new Exception('No such user.'); } common_log(LOG_DEBUG, print_r($author, true), __FILE__); @@ -407,7 +407,7 @@ class StatusNetOAuthDataStore extends OAuthDataStore $user = User::staticGet('uri', $uri); } if (!$user) { - throw new Exception('No such user'); + throw new Exception('No such user.'); } return $user; } -- cgit v1.2.3-54-g00ecf From 27e6a3f36fb9a41d316bdd4fccd5e98c7a3e9ddc Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 10 Nov 2009 15:36:55 -0500 Subject: add lat and long parameters to api/statuses/update --- actions/apistatusesupdate.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'actions/apistatusesupdate.php') diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php index 5c23accca..7ddf7703b 100644 --- a/actions/apistatusesupdate.php +++ b/actions/apistatusesupdate.php @@ -61,6 +61,9 @@ class ApiStatusesUpdateAction extends ApiAuthAction var $source = null; var $status = null; var $in_reply_to_status_id = null; + var $lat = null; + var $lon = null; + static $reserved_sources = array('web', 'omb', 'mail', 'xmpp', 'api'); /** @@ -79,6 +82,8 @@ class ApiStatusesUpdateAction extends ApiAuthAction $this->user = $this->auth_user; $this->status = $this->trimmed('status'); $this->source = $this->trimmed('source'); + $this->lat = $this->trimmed('lat'); + $this->lon = $this->trimmed('long'); if (empty($this->source) || in_array($source, self::$reserved_sources)) { $this->source = 'api'; @@ -198,6 +203,12 @@ class ApiStatusesUpdateAction extends ApiAuthAction } } + $location = null; + + if (!empty($this->lat) && !empty($this->lon)) { + $location = Location::fromLatLon($this->lat, $this->lon); + } + $upload = null; try { @@ -225,7 +236,13 @@ class ApiStatusesUpdateAction extends ApiAuthAction html_entity_decode($status_shortened, ENT_NOQUOTES, 'UTF-8'), $this->source, 1, - $reply_to + $reply_to, + null, + null, + empty($location) ? null : $location->lat, + empty($location) ? null : $location->lon, + empty($location) ? null : $location->location_id, + empty($location) ? null : $location->location_ns ); if (isset($upload)) { -- cgit v1.2.3-54-g00ecf From 18835403fcea146c15488157435c2d98f25bc093 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 18 Nov 2009 09:29:55 -0800 Subject: Notice: Undefined variable: source in actions/apistatusesupdate.php on line 88 --- actions/apistatusesupdate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actions/apistatusesupdate.php') diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php index 7ddf7703b..85a7c8c08 100644 --- a/actions/apistatusesupdate.php +++ b/actions/apistatusesupdate.php @@ -85,7 +85,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction $this->lat = $this->trimmed('lat'); $this->lon = $this->trimmed('long'); - if (empty($this->source) || in_array($source, self::$reserved_sources)) { + if (empty($this->source) || in_array($this->source, self::$reserved_sources)) { $this->source = 'api'; } -- cgit v1.2.3-54-g00ecf