From 57feeb566a0cb2c544545dbfc616437cae69b923 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Fri, 11 Sep 2009 22:37:37 -0400 Subject: Add a parameter named 'inreplyto' to the 'notice/new' page, so urls can inclue 'inreplyto' id's. Also add 'inreplyto' to the urls sent in emails. --- actions/newnotice.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/newnotice.php b/actions/newnotice.php index 00a822860..6e3720e09 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -431,13 +431,14 @@ class NewnoticeAction extends Action $content = $this->trimmed('status_textarea'); if (!$content) { $replyto = $this->trimmed('replyto'); + $inreplyto = $this->trimmed('inreplyto'); $profile = Profile::staticGet('nickname', $replyto); if ($profile) { $content = '@' . $profile->nickname . ' '; } } - $notice_form = new NoticeForm($this, '', $content); + $notice_form = new NoticeForm($this, '', $content, null, $inreplyto); $notice_form->show(); } -- cgit v1.2.3-54-g00ecf From 29d937d04ef1d5bf83493a16e90dc4b9b7b5a059 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Sat, 12 Sep 2009 17:11:55 -0400 Subject: Check if the avatar exists before trying to delete it. Fixes http://status.net/trac/ticket/1868 --- actions/avatarsettings.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'actions') diff --git a/actions/avatarsettings.php b/actions/avatarsettings.php index 02a684b38..ded419dd7 100644 --- a/actions/avatarsettings.php +++ b/actions/avatarsettings.php @@ -362,13 +362,13 @@ class AvatarsettingsAction extends AccountSettingsAction $profile = $user->getProfile(); $avatar = $profile->getOriginalAvatar(); - $avatar->delete(); + if($avatar) $avatar->delete(); $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); - $avatar->delete(); + if($avatar) $avatar->delete(); $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE); - $avatar->delete(); + if($avatar) $avatar->delete(); $avatar = $profile->getAvatar(AVATAR_MINI_SIZE); - $avatar->delete(); + if($avatar) $avatar->delete(); $this->showForm(_('Avatar deleted.'), true); } -- cgit v1.2.3-54-g00ecf From 940ea07d4a72becfbdcb434e7043937618c45a61 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Sun, 13 Sep 2009 00:01:23 -0400 Subject: Response for request token doesn't contain omb_version Fixes http://status.net/trac/ticket/681 Sorry it took a year to accept this patch, dho :'-( --- actions/requesttoken.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/requesttoken.php b/actions/requesttoken.php index 48fe1db08..a17efcdd5 100644 --- a/actions/requesttoken.php +++ b/actions/requesttoken.php @@ -72,7 +72,7 @@ class RequesttokenAction extends Action $req = OAuthRequest::from_request('POST', common_local_url('requesttoken')); $server = omb_oauth_server(); $token = $server->fetch_request_token($req); - print $token; + print $token.'&omb_version='.OMB_VERSION_01; } catch (OAuthException $e) { $this->serverError($e->getMessage()); } -- cgit v1.2.3-54-g00ecf From 80ba0603c65e1f2365f019128b656a042a2b82d0 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 15 Sep 2009 12:59:32 -0700 Subject: Make it impossible to delete self-subscriptions via the API --- actions/twitapifriendships.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'actions') diff --git a/actions/twitapifriendships.php b/actions/twitapifriendships.php index f2ea46910..eea8945c3 100644 --- a/actions/twitapifriendships.php +++ b/actions/twitapifriendships.php @@ -99,6 +99,12 @@ class TwitapifriendshipsAction extends TwitterapiAction $other = $this->get_profile($id); $user = $apidata['user']; // Alwyas the auth user + if ($user->id == $other->id) { + $this->clientError(_("You cannot unfollow yourself!"), + 403, $apidata['content-type']); + return; + } + $sub = new Subscription(); $sub->subscriber = $user->id; $sub->subscribed = $other->id; -- cgit v1.2.3-54-g00ecf From c4ef2346b864b293fc4c4b02c72b07d18718d0cf Mon Sep 17 00:00:00 2001 From: Christopher Vollick Date: Wed, 16 Sep 2009 05:07:33 -0400 Subject: Pagination of user/tag was navigating to wrong page. Fixes bug #1736. --- actions/showstream.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/showstream.php b/actions/showstream.php index 4d3067eed..89285b13c 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -380,8 +380,13 @@ class ShowstreamAction extends ProfileAction $this->showEmptyListMessage(); } + $args = array('nickname' => $this->user->nickname); + if (!empty($this->tag)) + { + $args['tag'] = $this->tag; + } $this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page, - 'showstream', array('nickname' => $this->user->nickname)); + 'showstream', $args); } function showAnonymousMessage() -- cgit v1.2.3-54-g00ecf From 74296fa12c7813ad5cdc80750173c11912b5860f Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Sat, 19 Sep 2009 18:34:07 -0700 Subject: Make statuses/home_timeline return the same thing as statuses/friends_timeline to support apps trying to use the new retweet API method. --- actions/twitapistatuses.php | 5 +++++ lib/router.php | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'actions') diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php index edee239a0..5e2867ea8 100644 --- a/actions/twitapistatuses.php +++ b/actions/twitapistatuses.php @@ -136,6 +136,11 @@ class TwitapistatusesAction extends TwitterapiAction } + function home_timeline($args, $apidata) + { + call_user_func(array($this, 'friends_timeline'), $args, $apidata); + } + function user_timeline($args, $apidata) { parent::handle($args); diff --git a/lib/router.php b/lib/router.php index 0505c9942..5529e60ac 100644 --- a/lib/router.php +++ b/lib/router.php @@ -272,12 +272,12 @@ class Router $m->connect('api/statuses/:method', array('action' => 'api', 'apiaction' => 'statuses'), - array('method' => '(public_timeline|friends_timeline|user_timeline|update|replies|mentions|show|friends|followers|featured)(\.(atom|rss|xml|json))?')); + array('method' => '(public_timeline|home_timeline|friends_timeline|user_timeline|update|replies|mentions|show|friends|followers|featured)(\.(atom|rss|xml|json))?')); $m->connect('api/statuses/:method/:argument', array('action' => 'api', 'apiaction' => 'statuses'), - array('method' => '(|user_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)')); + array('method' => '(user_timeline|home_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)')); // users @@ -436,7 +436,7 @@ class Router $m->connect('api/statuses/:method/:argument', array('action' => 'api', 'apiaction' => 'statuses'), - array('method' => '(|user_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)')); + array('method' => '(user_timeline|home_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)')); $m->connect('api/statusnet/groups/:method/:argument', array('action' => 'api', -- cgit v1.2.3-54-g00ecf From 3d30ad83f881a69d76b57a9af051fef308644987 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 24 Sep 2009 16:52:32 -0400 Subject: Implemented join and leave groups api methods --- actions/twitapigroups.php | 124 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) (limited to 'actions') diff --git a/actions/twitapigroups.php b/actions/twitapigroups.php index 4deb1b764..493144e77 100644 --- a/actions/twitapigroups.php +++ b/actions/twitapigroups.php @@ -293,6 +293,105 @@ require_once INSTALLDIR.'/lib/twitterapi.php'; } } + function join($args, $apidata) + { + parent::handle($args); + + common_debug("in groups api action"); + + $this->auth_user = $apidata['user']; + $group = $this->get_group($apidata['api_arg'], $apidata); + + if (empty($group)) { + $this->clientError('Not Found', 404, $apidata['content-type']); + return false; + } + + if($this->auth_user->isMember($group)){ + $this->clientError(_('You are already a member of that group'), $code = 403); + return false; + } + + if (Group_block::isBlocked($group, $this->auth_user->getProfile())) { + $this->clientError(_('You have been blocked from that group by the admin.'), 403); + return false; + } + + $member = new Group_member(); + + $member->group_id = $group->id; + $member->profile_id = $this->auth_user->id; + $member->created = common_sql_now(); + + $result = $member->insert(); + + if (!$result) { + common_log_db_error($member, 'INSERT', __FILE__); + $this->serverError(sprintf(_('Could not join user %s to group %s'), + $this->auth_user->nickname, $group->nickname)); + } + + switch($apidata['content-type']) { + case 'xml': + $this->show_single_xml_group($group); + break; + case 'json': + $this->show_single_json_group($group); + break; + default: + $this->clientError(_('API method not found!'), $code = 404); + } + } + + function leave($args, $apidata) + { + parent::handle($args); + + common_debug("in groups api action"); + + $this->auth_user = $apidata['user']; + $group = $this->get_group($apidata['api_arg'], $apidata); + + if (empty($group)) { + $this->clientError('Not Found', 404, $apidata['content-type']); + return false; + } + + if(! $this->auth_user->isMember($group)){ + $this->clientError(_('You are not a member of that group'), $code = 403); + return false; + } + + $member = new Group_member(); + + $member->group_id = $group->id; + $member->profile_id = $this->auth_user->id; + + if (!$member->find(true)) { + $this->serverError(_('Could not find membership record.')); + return; + } + + $result = $member->delete(); + + if (!$result) { + common_log_db_error($member, 'INSERT', __FILE__); + $this->serverError(sprintf(_('Could not remove user %s to group %s'), + $this->auth_user->nickname, $group->nickname)); + } + + switch($apidata['content-type']) { + case 'xml': + $this->show_single_xml_group($group); + break; + case 'json': + $this->show_single_json_group($group); + break; + default: + $this->clientError(_('API method not found!'), $code = 404); + } + } + function is_member($args, $apidata) { parent::handle($args); @@ -326,4 +425,29 @@ require_once INSTALLDIR.'/lib/twitterapi.php'; $this->clientError(_('API method not found!'), $code = 404); } } + + function create($args, $apidata) + { + die("todo"); + } + + function update($args, $apidata) + { + die("todo"); + } + + function update_group_logo($args, $apidata) + { + die("todo"); + } + + function destroy($args, $apidata) + { + die("todo"); + } + + function tag($args, $apidata) + { + die("todo"); + } } -- cgit v1.2.3-54-g00ecf From e566219299b339fb649eb8a21bd37e8c93844375 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 24 Sep 2009 15:10:55 -0700 Subject: Output If-Modified-Since header for all RSS 1.0 feeds (again) --- actions/allrss.php | 1 + actions/favoritesrss.php | 11 ++++++----- actions/grouprss.php | 1 + actions/publicrss.php | 18 ++++++++++++++++-- actions/repliesrss.php | 1 + actions/userrss.php | 7 ++++--- lib/rssaction.php | 36 ++++++++++++++++++------------------ 7 files changed, 47 insertions(+), 28 deletions(-) (limited to 'actions') diff --git a/actions/allrss.php b/actions/allrss.php index 57efb73f0..28b1be27d 100644 --- a/actions/allrss.php +++ b/actions/allrss.php @@ -68,6 +68,7 @@ class AllrssAction extends Rss10Action $this->clientError(_('No such user.')); return false; } else { + $this->notices = $this->getNotices($this->limit); return true; } } diff --git a/actions/favoritesrss.php b/actions/favoritesrss.php index 2d5ce9854..62f06e841 100644 --- a/actions/favoritesrss.php +++ b/actions/favoritesrss.php @@ -50,11 +50,11 @@ require_once INSTALLDIR.'/lib/rssaction.php'; */ class FavoritesrssAction extends Rss10Action { - + /** The user whose favorites to display */ - + var $user = null; - + /** * Find the user to display by supplied nickname * @@ -66,7 +66,7 @@ class FavoritesrssAction extends Rss10Action function prepare($args) { parent::prepare($args); - + $nickname = $this->trimmed('nickname'); $this->user = User::staticGet('nickname', $nickname); @@ -74,10 +74,11 @@ class FavoritesrssAction extends Rss10Action $this->clientError(_('No such user.')); return false; } else { + $this->notices = $this->getNotices($this->limit); return true; } } - + /** * Get notices * diff --git a/actions/grouprss.php b/actions/grouprss.php index 70c1ded48..6a6b55e78 100644 --- a/actions/grouprss.php +++ b/actions/grouprss.php @@ -104,6 +104,7 @@ class groupRssAction extends Rss10Action return false; } + $this->notices = $this->getNotices($this->limit); return true; } diff --git a/actions/publicrss.php b/actions/publicrss.php index 593888b9f..0c5d061cb 100644 --- a/actions/publicrss.php +++ b/actions/publicrss.php @@ -49,9 +49,23 @@ require_once INSTALLDIR.'/lib/rssaction.php'; */ class PublicrssAction extends Rss10Action { + /** + * Read arguments and initialize members + * + * @param array $args Arguments from $_REQUEST + * @return boolean success + */ + + function prepare($args) + { + parent::prepare($args); + $this->notices = $this->getNotices($this->limit); + return true; + } + /** * Initialization. - * + * * @return boolean true */ function init() @@ -73,7 +87,7 @@ class PublicrssAction extends Rss10Action while ($notice->fetch()) { $notices[] = clone($notice); } - + return $notices; } diff --git a/actions/repliesrss.php b/actions/repliesrss.php index c71c9226f..76aae21ad 100644 --- a/actions/repliesrss.php +++ b/actions/repliesrss.php @@ -38,6 +38,7 @@ class RepliesrssAction extends Rss10Action $this->clientError(_('No such user.')); return false; } else { + $this->notices = $this->getNotices($this->limit); return true; } } diff --git a/actions/userrss.php b/actions/userrss.php index fa6d588cd..e6f697092 100644 --- a/actions/userrss.php +++ b/actions/userrss.php @@ -25,7 +25,6 @@ require_once(INSTALLDIR.'/lib/rssaction.php'); class UserrssAction extends Rss10Action { - var $user = null; var $tag = null; function prepare($args) @@ -39,6 +38,7 @@ class UserrssAction extends Rss10Action $this->clientError(_('No such user.')); return false; } else { + $this->notices = $this->getNotices($this->limit); return true; } } @@ -64,10 +64,10 @@ class UserrssAction extends Rss10Action function getNotices($limit=0) { - $user = $this->user; - + if (is_null($user)) { + common_debug('null user'); return null; } @@ -75,6 +75,7 @@ class UserrssAction extends Rss10Action $notices = array(); while ($notice->fetch()) { + common_debug("notice"); $notices[] = clone($notice); } diff --git a/lib/rssaction.php b/lib/rssaction.php index dd0f1005a..faf6bec7d 100644 --- a/lib/rssaction.php +++ b/lib/rssaction.php @@ -78,25 +78,12 @@ class Rss10Action extends Action function prepare($args) { parent::prepare($args); + $this->limit = (int) $this->trimmed('limit'); + if ($this->limit == 0) { $this->limit = DEFAULT_RSS_LIMIT; } - return true; - } - - /** - * Handle a request - * - * @param array $args Arguments from $_REQUEST - * - * @return void - */ - - function handle($args) - { - // Parent handling, including cache check - parent::handle($args); if (common_config('site', 'private')) { if (!isset($_SERVER['PHP_AUTH_USER'])) { @@ -122,8 +109,21 @@ class Rss10Action extends Action } } - // Get the list of notices - $this->notices = $this->getNotices($this->limit); + return true; + } + + /** + * Handle a request + * + * @param array $args Arguments from $_REQUEST + * + * @return void + */ + + function handle($args) + { + // Parent handling, including cache check + parent::handle($args); $this->showRss(); } @@ -140,7 +140,7 @@ class Rss10Action extends Action } /** - * Get the notices to output in this stream + * Get the notices to output in this stream. * * @return array an array of Notice objects sorted in reverse chron */ -- cgit v1.2.3-54-g00ecf From b617c608ea0d66451eb2dcd75e1e1c58c179d8e6 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 24 Sep 2009 15:28:25 -0700 Subject: Left a couple debugging statements in (removed) --- actions/userrss.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'actions') diff --git a/actions/userrss.php b/actions/userrss.php index e6f697092..19e610551 100644 --- a/actions/userrss.php +++ b/actions/userrss.php @@ -67,7 +67,6 @@ class UserrssAction extends Rss10Action $user = $this->user; if (is_null($user)) { - common_debug('null user'); return null; } @@ -75,7 +74,6 @@ class UserrssAction extends Rss10Action $notices = array(); while ($notice->fetch()) { - common_debug("notice"); $notices[] = clone($notice); } -- cgit v1.2.3-54-g00ecf