summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorRobin Millette <millette@controlyourself.ca>2009-06-10 14:18:41 -0400
committerRobin Millette <millette@controlyourself.ca>2009-06-10 14:18:41 -0400
commitba6beaa3104c81b8b6e624aad28c9f0ce89af8dc (patch)
treeceed868811c836ab46d60c6c73ab6f386b75d8d6 /actions
parente120cb1a5300f2e38820aa05ec9ac21073a934e0 (diff)
parent5469e46ef5bd464559a648fdc02b285313132155 (diff)
Merge branch '0.8.x' of git@gitorious.org:+laconica-developers/laconica/dev into 0.8.x
Diffstat (limited to 'actions')
-rw-r--r--actions/all.php11
-rw-r--r--actions/api.php4
-rw-r--r--actions/favorited.php11
-rw-r--r--actions/groupmembers.php11
-rw-r--r--actions/groups.php11
-rw-r--r--actions/inbox.php21
-rw-r--r--actions/outbox.php13
-rw-r--r--actions/public.php11
-rw-r--r--actions/replies.php11
-rw-r--r--actions/showfavorites.php12
-rw-r--r--actions/showgroup.php11
-rw-r--r--actions/shownotice.php2
-rw-r--r--actions/showstream.php11
-rw-r--r--actions/tag.php11
-rw-r--r--actions/twitapiaccount.php24
-rw-r--r--actions/twitapidirect_messages.php6
-rw-r--r--actions/twitapistatuses.php36
-rw-r--r--actions/twitapiusers.php145
18 files changed, 99 insertions, 263 deletions
diff --git a/actions/all.php b/actions/all.php
index a53bbea07..03179a246 100644
--- a/actions/all.php
+++ b/actions/all.php
@@ -69,17 +69,6 @@ class AllAction extends ProfileAction
sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname)));
}
- /**
- * Output document relationship links
- *
- * @return void
- */
- function showRelationshipLinks()
- {
- $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
- $this->page, 'all', array('nickname' => $this->user->nickname));
- }
-
function showLocalNav()
{
$nav = new PersonalGroupNav($this);
diff --git a/actions/api.php b/actions/api.php
index b25ba99f3..b8da852b5 100644
--- a/actions/api.php
+++ b/actions/api.php
@@ -144,8 +144,8 @@ class ApiAction extends Action
}
if (in_array($fullname, $bareauth)) {
- # bareauth: only needs auth if without an argument
- if ($this->api_arg) {
+ # bareauth: only needs auth if without an argument or query param specifying user
+ if ($this->api_arg || $this->arg('id') || is_numeric($this->arg('user_id')) || $this->arg('screen_name')) {
return false;
} else {
return true;
diff --git a/actions/favorited.php b/actions/favorited.php
index 7e31303e3..c902d80f5 100644
--- a/actions/favorited.php
+++ b/actions/favorited.php
@@ -221,15 +221,4 @@ class FavoritedAction extends Action
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
$this->page, 'favorited');
}
-
- /**
- * Output document relationship links
- *
- * @return void
- */
- function showRelationshipLinks()
- {
- $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
- $this->page, 'favorited');
- }
}
diff --git a/actions/groupmembers.php b/actions/groupmembers.php
index 909935bec..21e5ebbaa 100644
--- a/actions/groupmembers.php
+++ b/actions/groupmembers.php
@@ -137,15 +137,4 @@ class GroupmembersAction extends Action
$this->page, 'groupmembers',
array('nickname' => $this->group->nickname));
}
-
- /**
- * Output document relationship links
- *
- * @return void
- */
- function showRelationshipLinks()
- {
- $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
- $this->page, 'groupmembers', array('nickname' => $this->group->nickname));
- }
}
diff --git a/actions/groups.php b/actions/groups.php
index e20acce70..26b52a5fc 100644
--- a/actions/groups.php
+++ b/actions/groups.php
@@ -129,15 +129,4 @@ class GroupsAction extends Action
$gbm = new GroupsByMembersSection($this);
$gbm->show();
}
-
- /**
- * Output document relationship links
- *
- * @return void
- */
- function showRelationshipLinks()
- {
- $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
- $this->page, 'groups', array('nickname' => $this->group->nickname));
- }
}
diff --git a/actions/inbox.php b/actions/inbox.php
index 7b5cf2d20..f14ba631f 100644
--- a/actions/inbox.php
+++ b/actions/inbox.php
@@ -46,15 +46,15 @@ require_once INSTALLDIR.'/lib/mailbox.php';
class InboxAction extends MailboxAction
{
-
+
/**
* Title of the page
*
* @return string page title
*/
-
+
function title()
- {
+ {
if ($this->page > 1) {
return sprintf(_("Inbox for %s - page %d"), $this->user->nickname,
$this->page);
@@ -64,21 +64,10 @@ class InboxAction extends MailboxAction
}
/**
- * Output document relationship links
- *
- * @return void
- */
- function showRelationshipLinks()
- {
- $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
- $this->page, 'inbox', array('nickname' => $this->user->nickname));
- }
-
- /**
* Retrieve the messages for this user and this page
*
* Does a query for the right messages
- *
+ *
* @return Message data object with stream for messages
*
* @see MailboxAction::getMessages()
@@ -95,7 +84,7 @@ class InboxAction extends MailboxAction
if ($message->find()) {
return $message;
- } else {
+ } else {
return null;
}
}
diff --git a/actions/outbox.php b/actions/outbox.php
index deef1cc87..a875e9ad9 100644
--- a/actions/outbox.php
+++ b/actions/outbox.php
@@ -63,21 +63,10 @@ class OutboxAction extends MailboxAction
}
/**
- * Output document relationship links
- *
- * @return void
- */
- function showRelationshipLinks()
- {
- $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
- $this->page, 'outbox', array('nickname' => $this->user->nickname));
- }
-
- /**
* retrieve the messages for this user and this page
*
* Does a query for the right messages
- *
+ *
* @return Message data object with stream for messages
*
* @see MailboxAction::getMessages()
diff --git a/actions/public.php b/actions/public.php
index d2f9da646..27153f131 100644
--- a/actions/public.php
+++ b/actions/public.php
@@ -136,17 +136,6 @@ class PublicAction extends Action
}
/**
- * Output document relationship links
- *
- * @return void
- */
- function showRelationshipLinks()
- {
- $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
- $this->page, 'public');
- }
-
- /**
* Extra head elements
*
* We include a <meta> element linking to the publicxrds page, for OpenID
diff --git a/actions/replies.php b/actions/replies.php
index dfb520d64..eac4d0a3a 100644
--- a/actions/replies.php
+++ b/actions/replies.php
@@ -139,17 +139,6 @@ class RepliesAction extends Action
}
/**
- * Output document relationship links
- *
- * @return void
- */
- function showRelationshipLinks()
- {
- $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
- $this->page, 'replies', array('nickname' => $this->user->nickname));
- }
-
- /**
* show the personal group nav
*
* @return void
diff --git a/actions/showfavorites.php b/actions/showfavorites.php
index eed62a2ab..865045337 100644
--- a/actions/showfavorites.php
+++ b/actions/showfavorites.php
@@ -151,18 +151,6 @@ class ShowfavoritesAction extends Action
}
/**
- * Output document relationship links
- *
- * @return void
- */
- function showRelationshipLinks()
- {
- $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
- $this->page, 'showfavorites', array('nickname' => $this->user->nickname));
- }
-
-
- /**
* show the personal group nav
*
* @return void
diff --git a/actions/showgroup.php b/actions/showgroup.php
index a7df39727..29b6fa1e6 100644
--- a/actions/showgroup.php
+++ b/actions/showgroup.php
@@ -312,17 +312,6 @@ class ShowgroupAction extends Action
}
/**
- * Output document relationship links
- *
- * @return void
- */
- function showRelationshipLinks()
- {
- $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
- $this->page, 'showgroup', array('nickname' => $this->group->nickname));
- }
-
- /**
* Fill in the sidebar.
*
* @return void
diff --git a/actions/shownotice.php b/actions/shownotice.php
index 34c8a8e94..b0d973a99 100644
--- a/actions/shownotice.php
+++ b/actions/shownotice.php
@@ -122,7 +122,7 @@ class ShownoticeAction extends Action
function lastModified()
{
- return max(strtotime($this->notice->created),
+ return max(strtotime($this->notice->modified),
strtotime($this->profile->modified),
($this->avatar) ? strtotime($this->avatar->modified) : 0);
}
diff --git a/actions/showstream.php b/actions/showstream.php
index 678a3174c..e2f4e24d4 100644
--- a/actions/showstream.php
+++ b/actions/showstream.php
@@ -147,17 +147,6 @@ class ShowstreamAction extends ProfileAction
sprintf(_('FOAF for %s'), $this->user->nickname)));
}
- /**
- * Output document relationship links
- *
- * @return void
- */
- function showRelationshipLinks()
- {
- $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
- $this->page, 'showstream', array('nickname' => $this->user->nickname));
- }
-
function extraHead()
{
// for remote subscriptions etc.
diff --git a/actions/tag.php b/actions/tag.php
index e9351d241..f5ca06f05 100644
--- a/actions/tag.php
+++ b/actions/tag.php
@@ -76,17 +76,6 @@ class TagAction extends Action
sprintf(_('Feed for tag %s'), $this->tag)));
}
- /**
- * Output document relationship links
- *
- * @return void
- */
- function showRelationshipLinks()
- {
- $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
- $this->page, 'tag', array('tag' => $this->tag));
- }
-
function showPageNotice()
{
return sprintf(_('Messages tagged "%s", most recent first'), $this->tag);
diff --git a/actions/twitapiaccount.php b/actions/twitapiaccount.php
index 68a18cb57..8b956f897 100644
--- a/actions/twitapiaccount.php
+++ b/actions/twitapiaccount.php
@@ -98,9 +98,31 @@ class TwitapiaccountAction extends TwitterapiAction
$this->serverError(_('API method under construction.'), $code=501);
}
+ // We don't have a rate limit, but some clients check this method.
+ // It always returns the same thing: 100 hit left.
function rate_limit_status($args, $apidata)
{
parent::handle($args);
- $this->serverError(_('API method under construction.'), $code=501);
+
+ $type = $apidata['content-type'];
+ $this->init_document($type);
+
+ if ($apidata['content-type'] == 'xml') {
+ $this->elementStart('hash');
+ $this->element('remaining-hits', array('type' => 'integer'), 100);
+ $this->element('hourly-limit', array('type' => 'integer'), 100);
+ $this->element('reset-time', array('type' => 'datetime'), null);
+ $this->element('reset_time_in_seconds', array('type' => 'integer'), 0);
+ $this->elementEnd('hash');
+ } elseif ($apidata['content-type'] == 'json') {
+
+ $out = array('reset_time_in_seconds' => 0,
+ 'remaining_hits' => 100,
+ 'hourly_limit' => 100,
+ 'reset_time' => '');
+ print json_encode($out);
+ }
+
+ $this->end_document($type);
}
}
diff --git a/actions/twitapidirect_messages.php b/actions/twitapidirect_messages.php
index 7101db8df..d2dbdb619 100644
--- a/actions/twitapidirect_messages.php
+++ b/actions/twitapidirect_messages.php
@@ -43,7 +43,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction
$count = $this->arg('count');
$since = $this->arg('since');
$since_id = $this->arg('since_id');
- $before_id = $this->arg('before_id');
+ $max_id = $this->arg('max_id');
$page = $this->arg('page');
@@ -74,8 +74,8 @@ class Twitapidirect_messagesAction extends TwitterapiAction
$link = $server . $user->nickname . '/outbox';
}
- if ($before_id) {
- $message->whereAdd("id < $before_id");
+ if ($max_id) {
+ $message->whereAdd("id <= $max_id");
}
if ($since_id) {
diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php
index 3abeba367..1fbde6639 100644
--- a/actions/twitapistatuses.php
+++ b/actions/twitapistatuses.php
@@ -45,22 +45,21 @@ class TwitapistatusesAction extends TwitterapiAction
$page = $this->arg('page');
$since_id = $this->arg('since_id');
- $before_id = $this->arg('before_id');
+ $max_id = $this->arg('max_id');
- // NOTE: page, since_id, and before_id are extensions to Twitter API -- TB
if (!$page) {
$page = 1;
}
if (!$since_id) {
$since_id = 0;
}
- if (!$before_id) {
- $before_id = 0;
+ if (!$max_id) {
+ $max_id = 0;
}
$since = strtotime($this->arg('since'));
- $notice = Notice::publicStream((($page-1)*$MAX_PUBSTATUSES), $MAX_PUBSTATUSES, $since_id, $before_id, $since);
+ $notice = Notice::publicStream((($page-1)*$MAX_PUBSTATUSES), $MAX_PUBSTATUSES, $since_id, $max_id, $since);
if ($notice) {
@@ -97,7 +96,7 @@ class TwitapistatusesAction extends TwitterapiAction
$since_id = $this->arg('since_id');
$count = $this->arg('count');
$page = $this->arg('page');
- $before_id = $this->arg('before_id');
+ $max_id = $this->arg('max_id');
if (!$page) {
$page = 1;
@@ -111,9 +110,8 @@ class TwitapistatusesAction extends TwitterapiAction
$since_id = 0;
}
- // NOTE: before_id is an extension to Twitter API -- TB
- if (!$before_id) {
- $before_id = 0;
+ if (!$max_id) {
+ $max_id = 0;
}
$since = strtotime($this->arg('since'));
@@ -133,7 +131,7 @@ class TwitapistatusesAction extends TwitterapiAction
$link = common_local_url('all', array('nickname' => $user->nickname));
$subtitle = sprintf(_('Updates from %1$s and friends on %2$s!'), $user->nickname, $sitename);
- $notice = $user->noticesWithFriends(($page-1)*20, $count, $since_id, $before_id, $since);
+ $notice = $user->noticesWithFriends(($page-1)*20, $count, $since_id, $max_id, $since);
switch($apidata['content-type']) {
case 'xml':
@@ -184,7 +182,7 @@ class TwitapistatusesAction extends TwitterapiAction
$since = $this->arg('since');
$since_id = $this->arg('since_id');
$page = $this->arg('page');
- $before_id = $this->arg('before_id');
+ $max_id = $this->arg('max_id');
if (!$page) {
$page = 1;
@@ -198,9 +196,8 @@ class TwitapistatusesAction extends TwitterapiAction
$since_id = 0;
}
- // NOTE: before_id is an extensions to Twitter API -- TB
- if (!$before_id) {
- $before_id = 0;
+ if (!$max_id) {
+ $max_id = 0;
}
$since = strtotime($this->arg('since'));
@@ -220,7 +217,7 @@ class TwitapistatusesAction extends TwitterapiAction
# XXX: since
- $notice = $user->getNotices((($page-1)*20), $count, $since_id, $before_id, $since);
+ $notice = $user->getNotices((($page-1)*20), $count, $since_id, $max_id, $since);
switch($apidata['content-type']) {
case 'xml':
@@ -353,7 +350,7 @@ class TwitapistatusesAction extends TwitterapiAction
$count = $this->arg('count');
$page = $this->arg('page');
$since_id = $this->arg('since_id');
- $before_id = $this->arg('before_id');
+ $max_id = $this->arg('max_id');
$user = $this->get_user($apidata['api_arg'], $apidata);
$this->auth_user = $apidata['user'];
@@ -380,15 +377,14 @@ class TwitapistatusesAction extends TwitterapiAction
$since_id = 0;
}
- // NOTE: before_id is an extension to Twitter API -- TB
- if (!$before_id) {
- $before_id = 0;
+ if (!$max_id) {
+ $max_id = 0;
}
$since = strtotime($this->arg('since'));
$notice = $user->getReplies((($page-1)*20),
- $count, $since_id, $before_id, $since);
+ $count, $since_id, $max_id, $since);
$notices = array();
while ($notice->fetch()) {
diff --git a/actions/twitapiusers.php b/actions/twitapiusers.php
index 1542cfb33..b90bbfa98 100644
--- a/actions/twitapiusers.php
+++ b/actions/twitapiusers.php
@@ -25,110 +25,61 @@ class TwitapiusersAction extends TwitterapiAction
{
function show($args, $apidata)
- {
+ {
parent::handle($args);
- if (!in_array($apidata['content-type'], array('xml', 'json'))) {
+ if (!in_array($apidata['content-type'], array('xml', 'json'))) {
$this->clientError(_('API method not found!'), $code = 404);
return;
}
-
- $user = null;
- $email = $this->arg('email');
- $user_id = $this->arg('user_id');
-
- if ($email) {
- $user = User::staticGet('email', $email);
- } elseif ($user_id) {
- $user = $this->get_user($user_id);
- } elseif (isset($apidata['api_arg'])) {
- $user = $this->get_user($apidata['api_arg']);
- } elseif (isset($apidata['user'])) {
- $user = $apidata['user'];
- }
-
- if (!$user) {
- // XXX: Twitter returns a random(?) user instead of throwing and err! -- Zach
- $this->client_error(_('Not found.'), 404, $apidata['content-type']);
- return;
- }
-
- $profile = $user->getProfile();
-
- if (!$profile) {
- common_server_error(_('User has no profile.'));
- return;
- }
-
- $twitter_user = $this->twitter_user_array($profile, true);
-
- // Add in extended user fields offered up by this method
- $twitter_user['created_at'] = $this->date_twitter($profile->created);
-
- $subbed = DB_DataObject::factory('subscription');
- $subbed->subscriber = $profile->id;
- $subbed_count = (int) $subbed->count() - 1;
-
- $notices = DB_DataObject::factory('notice');
- $notices->profile_id = $profile->id;
- $notice_count = (int) $notices->count();
-
- $twitter_user['friends_count'] = (is_int($subbed_count)) ? $subbed_count : 0;
- $twitter_user['statuses_count'] = (is_int($notice_count)) ? $notice_count : 0;
-
- // Other fields Twitter sends...
- $twitter_user['profile_background_color'] = '';
- $twitter_user['profile_background_image_url'] = '';
- $twitter_user['profile_text_color'] = '';
- $twitter_user['profile_link_color'] = '';
- $twitter_user['profile_sidebar_fill_color'] = '';
- $twitter_user['profile_sidebar_border_color'] = '';
- $twitter_user['profile_background_tile'] = false;
-
- $faves = DB_DataObject::factory('fave');
- $faves->user_id = $user->id;
- $faves_count = (int) $faves->count();
- $twitter_user['favourites_count'] = $faves_count;
-
- $timezone = 'UTC';
-
- if ($user->timezone) {
- $timezone = $user->timezone;
- }
-
- $t = new DateTime;
- $t->setTimezone(new DateTimeZone($timezone));
- $twitter_user['utc_offset'] = $t->format('Z');
- $twitter_user['time_zone'] = $timezone;
-
- if (isset($apidata['user'])) {
-
- $twitter_user['following'] = $apidata['user']->isSubscribed($profile);
-
- // Notifications on?
- $sub = Subscription::pkeyGet(array('subscriber' =>
- $apidata['user']->id, 'subscribed' => $profile->id));
-
- if ($sub) {
- $twitter_user['notifications'] = ($sub->jabber || $sub->sms);
- }
- }
-
- if ($apidata['content-type'] == 'xml') {
- $this->init_document('xml');
- $this->show_twitter_xml_user($twitter_user);
- $this->end_document('xml');
- } elseif ($apidata['content-type'] == 'json') {
- $this->init_document('json');
- $this->show_json_objects($twitter_user);
- $this->end_document('json');
- } else {
-
- // This is in case 'show' was called via /account/verify_credentials
- // without a format (xml or json).
+
+ $user = null;
+ $email = $this->arg('email');
+ $user_id = $this->arg('user_id');
+
+ // XXX: email field deprecated in Twitter's API
+
+ // XXX: Also: need to add screen_name param
+
+ if ($email) {
+ $user = User::staticGet('email', $email);
+ } elseif ($user_id) {
+ $user = $this->get_user($user_id);
+ } elseif (isset($apidata['api_arg'])) {
+ $user = $this->get_user($apidata['api_arg']);
+ } elseif (isset($apidata['user'])) {
+ $user = $apidata['user'];
+ }
+
+ if (!$user) {
+ $this->client_error(_('Not found.'), 404, $apidata['content-type']);
+ return;
+ }
+
+ $profile = $user->getProfile();
+
+ if (!$profile) {
+ common_server_error(_('User has no profile.'));
+ return;
+ }
+
+ $twitter_user = $this->twitter_user_array($profile, true);
+
+ if ($apidata['content-type'] == 'xml') {
+ $this->init_document('xml');
+ $this->show_twitter_xml_user($twitter_user);
+ $this->end_document('xml');
+ } elseif ($apidata['content-type'] == 'json') {
+ $this->init_document('json');
+ $this->show_json_objects($twitter_user);
+ $this->end_document('json');
+ } else {
+
+ // This is in case 'show' was called via /account/verify_credentials
+ // without a format (xml or json).
header('Content-Type: text/html; charset=utf-8');
print 'Authorized';
}
- }
+ }
}