From a2ca9d96d202d2acd4210fceec1a394f82f635ce Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 8 Jun 2009 18:55:23 +0000 Subject: [PATCH 01/23] Temporary workaround for silenting mysterious 200 OK error for XHR notice posts. The bug is sometimes reproduceable by sending a notice that includes "@someusernamethatdoesntexist". This patch doesn't throw alerts to user if server doesn't return with an XHR response but HTTP is one of 20x, 30x. --- js/util.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/util.js b/js/util.js index 3f14bc61c6..763c7d7ee3 100644 --- a/js/util.js +++ b/js/util.js @@ -178,7 +178,10 @@ $(document).ready(function(){ $('#form_notice').append(document._importNode($(".error", xhr.responseXML).get(0), true)); } else { - alert("Sorry! We had trouble sending your notice ("+xhr.status+" "+xhr.statusText+"). Please report the problem to the site administrator if this happens again."); + var HTTP20x30x = new Array(200, 201, 202, 203, 204, 205, 206, 300, 301, 302, 303, 304, 305, 306, 307); + if(jQuery.inArray(parseInt(xhr.status), HTTP20x30x) < 0) { + alert("Sorry! We had trouble sending your notice ("+xhr.status+" "+xhr.statusText+"). Please report the problem to the site administrator if this happens again."); + } } } }, From b20ac7a1fefe40e82b086df3128f06770c8b550d Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 8 Jun 2009 20:45:44 +0000 Subject: [PATCH 02/23] Clearing notice_data-test and resetting notice_text-count if the notice XHR response is empty and have a 20x,30x HTTP status --- js/util.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/util.js b/js/util.js index 763c7d7ee3..b59018fe5c 100644 --- a/js/util.js +++ b/js/util.js @@ -167,6 +167,7 @@ $(document).ready(function(){ return true; }, timeout: '60000', + url: 'http://dev.controlyourself.ca/csarven/asdfasdfasdfasdf', error: function (xhr, textStatus, errorThrown) { $("#form_notice").removeClass("processing"); $("#notice_action-submit").removeAttr("disabled"); $("#notice_action-submit").removeClass("disabled"); @@ -178,10 +179,14 @@ $(document).ready(function(){ $('#form_notice').append(document._importNode($(".error", xhr.responseXML).get(0), true)); } else { - var HTTP20x30x = new Array(200, 201, 202, 203, 204, 205, 206, 300, 301, 302, 303, 304, 305, 306, 307); + var HTTP20x30x = [200, 404, 201, 202, 203, 204, 205, 206, 300, 301, 302, 303, 304, 305, 306, 307]; if(jQuery.inArray(parseInt(xhr.status), HTTP20x30x) < 0) { alert("Sorry! We had trouble sending your notice ("+xhr.status+" "+xhr.statusText+"). Please report the problem to the site administrator if this happens again."); } + else { + $("#notice_data-text").val(""); + counter(); + } } } }, From c5378beb8355b0d5773d8464077fce70dd778026 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 8 Jun 2009 20:50:13 +0000 Subject: [PATCH 03/23] Revert "Clearing notice_data-test and resetting notice_text-count if the notice XHR" This reverts commit b20ac7a1fefe40e82b086df3128f06770c8b550d. --- js/util.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/js/util.js b/js/util.js index b59018fe5c..763c7d7ee3 100644 --- a/js/util.js +++ b/js/util.js @@ -167,7 +167,6 @@ $(document).ready(function(){ return true; }, timeout: '60000', - url: 'http://dev.controlyourself.ca/csarven/asdfasdfasdfasdf', error: function (xhr, textStatus, errorThrown) { $("#form_notice").removeClass("processing"); $("#notice_action-submit").removeAttr("disabled"); $("#notice_action-submit").removeClass("disabled"); @@ -179,14 +178,10 @@ $(document).ready(function(){ $('#form_notice').append(document._importNode($(".error", xhr.responseXML).get(0), true)); } else { - var HTTP20x30x = [200, 404, 201, 202, 203, 204, 205, 206, 300, 301, 302, 303, 304, 305, 306, 307]; + var HTTP20x30x = new Array(200, 201, 202, 203, 204, 205, 206, 300, 301, 302, 303, 304, 305, 306, 307); if(jQuery.inArray(parseInt(xhr.status), HTTP20x30x) < 0) { alert("Sorry! We had trouble sending your notice ("+xhr.status+" "+xhr.statusText+"). Please report the problem to the site administrator if this happens again."); } - else { - $("#notice_data-text").val(""); - counter(); - } } } }, From 67cb99c4428f71a19187ccc0b8ac6ad0f129b325 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 8 Jun 2009 20:52:27 +0000 Subject: [PATCH 04/23] Clearing notice_data-test and resetting notice_text-count if the notice XHR. Removed hanging text URL from previous commit. --- js/util.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/util.js b/js/util.js index 763c7d7ee3..44c3002cd5 100644 --- a/js/util.js +++ b/js/util.js @@ -178,10 +178,14 @@ $(document).ready(function(){ $('#form_notice').append(document._importNode($(".error", xhr.responseXML).get(0), true)); } else { - var HTTP20x30x = new Array(200, 201, 202, 203, 204, 205, 206, 300, 301, 302, 303, 304, 305, 306, 307); + var HTTP20x30x = [200, 404, 201, 202, 203, 204, 205, 206, 300, 301, 302, 303, 304, 305, 306, 307]; if(jQuery.inArray(parseInt(xhr.status), HTTP20x30x) < 0) { alert("Sorry! We had trouble sending your notice ("+xhr.status+" "+xhr.statusText+"). Please report the problem to the site administrator if this happens again."); } + else { + $("#notice_data-text").val(""); + counter(); + } } } }, From d9e5cda35d466ac1a428fffb72cc142922d4c211 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 9 Jun 2009 00:09:44 +0000 Subject: [PATCH 05/23] Removed 404 test --- js/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/util.js b/js/util.js index 44c3002cd5..23abba6c26 100644 --- a/js/util.js +++ b/js/util.js @@ -178,7 +178,7 @@ $(document).ready(function(){ $('#form_notice').append(document._importNode($(".error", xhr.responseXML).get(0), true)); } else { - var HTTP20x30x = [200, 404, 201, 202, 203, 204, 205, 206, 300, 301, 302, 303, 304, 305, 306, 307]; + var HTTP20x30x = [200, 201, 202, 203, 204, 205, 206, 300, 301, 302, 303, 304, 305, 306, 307]; if(jQuery.inArray(parseInt(xhr.status), HTTP20x30x) < 0) { alert("Sorry! We had trouble sending your notice ("+xhr.status+" "+xhr.statusText+"). Please report the problem to the site administrator if this happens again."); } From f4a1cd75ab6ee5cdc86491b5dc4f652fdd2ffa13 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 10 Jun 2009 08:47:46 -0700 Subject: [PATCH 06/23] Remove FIXME-marked Opera links until they actually work --- actions/all.php | 11 ---------- actions/favorited.php | 11 ---------- actions/groupmembers.php | 11 ---------- actions/groups.php | 11 ---------- actions/inbox.php | 21 +++++------------- actions/outbox.php | 13 +---------- actions/public.php | 11 ---------- actions/replies.php | 11 ---------- actions/showfavorites.php | 12 ---------- actions/showgroup.php | 11 ---------- actions/showstream.php | 11 ---------- actions/tag.php | 12 ---------- lib/action.php | 46 --------------------------------------- 13 files changed, 6 insertions(+), 186 deletions(-) diff --git a/actions/all.php b/actions/all.php index a53bbea07b..03179a2468 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/favorited.php b/actions/favorited.php index 7e31303e3b..c902d80f53 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 909935bec8..21e5ebbaa1 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 e20acce706..26b52a5fcd 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 7b5cf2d203..f14ba631fd 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); @@ -63,22 +63,11 @@ 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 deef1cc870..a875e9ad95 100644 --- a/actions/outbox.php +++ b/actions/outbox.php @@ -62,22 +62,11 @@ 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 d2f9da6460..27153f1315 100644 --- a/actions/public.php +++ b/actions/public.php @@ -135,17 +135,6 @@ class PublicAction extends Action _('Public Stream Feed (Atom)'))); } - /** - * 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 * diff --git a/actions/replies.php b/actions/replies.php index dfb520d649..eac4d0a3ae 100644 --- a/actions/replies.php +++ b/actions/replies.php @@ -138,17 +138,6 @@ class RepliesAction extends Action return array(new Feed(Feed::RSS1, $rssurl, $rsstitle)); } - /** - * 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 * diff --git a/actions/showfavorites.php b/actions/showfavorites.php index eed62a2ab3..865045337a 100644 --- a/actions/showfavorites.php +++ b/actions/showfavorites.php @@ -150,18 +150,6 @@ class ShowfavoritesAction extends Action return array(new Feed(Feed::RSS1, $feedurl, $feedtitle)); } - /** - * 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 * diff --git a/actions/showgroup.php b/actions/showgroup.php index a7df397273..29b6fa1e61 100644 --- a/actions/showgroup.php +++ b/actions/showgroup.php @@ -311,17 +311,6 @@ class ShowgroupAction extends Action $this->group->nickname))); } - /** - * 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. * diff --git a/actions/showstream.php b/actions/showstream.php index 82665e5b8b..c1a2c337a0 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -135,17 +135,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 02f3e35225..f5ca06f055 100644 --- a/actions/tag.php +++ b/actions/tag.php @@ -51,7 +51,6 @@ class TagAction extends Action $pop->show(); } - function title() { if ($this->page == 1) { @@ -77,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/lib/action.php b/lib/action.php index 6b130b6d55..7c7c52c2c1 100644 --- a/lib/action.php +++ b/lib/action.php @@ -124,7 +124,6 @@ class Action extends HTMLOutputter // lawsuit $this->showShortcutIcon(); $this->showStylesheets(); $this->showScripts(); - $this->showRelationshipLinks(); $this->showOpenSearch(); $this->showFeeds(); $this->showDescription(); @@ -261,19 +260,6 @@ class Action extends HTMLOutputter // lawsuit } } - /** - * Show document relationship links - * - * SHOULD overload - * - * @return nothing - */ - function showRelationshipLinks() - { - // output elements with appropriate HTML4.01 link types: - // http://www.w3.org/TR/html401/types.html#type-links - } - /** * Show OpenSearch headers * @@ -1055,36 +1041,4 @@ class Action extends HTMLOutputter // lawsuit { return null; } - - /** - * Generate document metadata for sequential navigation - * - * @param boolean $have_before is there something before? - * @param boolean $have_after is there something after? - * @param integer $page current page - * @param string $action current action - * @param array $args rest of query arguments - * - * @return nothing - */ - function sequenceRelationships($have_next, $have_previous, $page, $action, $args=null) - { - // Outputs machine-readable pagination in elements. - // Pattern taken from $this->pagination() method. - - // "next" is equivalent to "after" - if ($have_next) { - $pargs = array('page' => $page-1); - $this->element('link', array('rel' => 'next', - 'href' => common_local_url($action, $args, $pargs), - 'title' => _('Next'))); - } - // "previous" is equivalent to "before" - if ($have_previous=true) { // FIXME - $pargs = array('page' => $page+1); - $this->element('link', array('rel' => 'prev', - 'href' => common_local_url($action, $args, $pargs), - 'title' => _('Previous'))); - } - } } From 5469e46ef5bd464559a648fdc02b285313132155 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 10 Jun 2009 09:14:48 -0700 Subject: [PATCH 07/23] merge error in util.php --- lib/util.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/util.php b/lib/util.php index 9872d97c48..b3a94a5a01 100644 --- a/lib/util.php +++ b/lib/util.php @@ -922,7 +922,6 @@ function common_enqueue_notice_transport($notice, $transport) $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError'); common_log(LOG_ERR, 'DB error inserting queue item: ' . $last_error->message); throw new ServerException('DB error inserting queue item: ' . $last_error->message); ->>>>>>> 0.7.x:lib/util.php } common_log(LOG_DEBUG, 'complete queueing notice ID = ' . $notice->id . ' for ' . $transport); return true; From e120cb1a5300f2e38820aa05ec9ac21073a934e0 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Wed, 10 Jun 2009 14:17:46 -0400 Subject: [PATCH 08/23] Uploaded content now displays in overlay (and removed var_dump crap) --- classes/Notice.php | 6 ++---- lib/noticeform.php | 2 +- lib/noticelist.php | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index 0b1017e126..530c6daa7d 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -279,13 +279,11 @@ class Notice extends Memcached_DataObject function getUploadedAttachment() { $post = clone $this; - $query = 'select file.url as uploaded from file join file_to_post on file.id = file_id where post_id=' . $post->escape($post->id) . ' and url like "%/notice/%/file"'; + $query = 'select file.url as up, file.id as i from file join file_to_post on file.id = file_id where post_id=' . $post->escape($post->id) . ' and url like "%/notice/%/file"'; $post->query($query); $post->fetch(); - $ret = $post->uploaded; -// var_dump($post); + $ret = array($post->up, $post->i); $post->free(); -// die(); return $ret; } diff --git a/lib/noticeform.php b/lib/noticeform.php index 5d7cf194ee..3212f382ad 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -148,6 +148,7 @@ class NoticeForm extends Form $this->out->element('dd', array('id' => 'notice_text-count'), '140'); $this->out->elementEnd('dl'); + $this->out->hidden('MAX_FILE_SIZE', common_config('attachments', 'file_quota')); $this->out->element('label', array('for' => 'notice_data-attach'), _('Attach')); $this->out->element('input', array('id' => 'notice_data-attach', 'type' => 'file', @@ -157,7 +158,6 @@ class NoticeForm extends Form $this->out->hidden('notice_return-to', $this->action, 'returnto'); } $this->out->hidden('notice_in-reply-to', $this->action, 'inreplyto'); - $this->out->hidden('MAX_FILE_SIZE', common_config('attachments', 'file_quota')); } /** diff --git a/lib/noticelist.php b/lib/noticelist.php index 9ace341d80..fadc238a4d 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -366,7 +366,7 @@ class NoticeListItem extends Widget } $uploaded = $this->notice->getUploadedAttachment(); if ($uploaded) { - $this->out->element('a', array('href' => $uploaded, 'class' => 'attachment'), $uploaded); + $this->out->element('a', array('href' => $uploaded[0], 'class' => 'attachment', 'id' => 'attachment-' . $uploaded[1]), $uploaded[0]); } $this->out->elementEnd('p'); } From 4699fa7936be41e05a950b357c6b46949ad7c74d Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Wed, 10 Jun 2009 15:24:25 -0400 Subject: [PATCH 09/23] Now correctly identifiying notices with uploaded content. --- classes/Notice.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/classes/Notice.php b/classes/Notice.php index e4dade7806..eb51bbd8f1 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -274,7 +274,11 @@ class Notice extends Memcached_DataObject $query = 'select file.url as up, file.id as i from file join file_to_post on file.id = file_id where post_id=' . $post->escape($post->id) . ' and url like "%/notice/%/file"'; $post->query($query); $post->fetch(); - $ret = array($post->up, $post->i); + if (empty($post->up) || empty($post->i)) { + $ret = false; + } else { + $ret = array($post->up, $post->i); + } $post->free(); return $ret; } From 361a52a9c8042c26e72e85c42aff166bd531c85d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 10 Jun 2009 13:52:15 -0700 Subject: [PATCH 10/23] some changes based on code review with zach --- classes/Notice.php | 9 +++++-- classes/Notice_inbox.php | 5 ++++ scripts/twitterstatusfetcher.php | 45 +++++--------------------------- 3 files changed, 19 insertions(+), 40 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index 895b5d2c71..45ea728234 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -120,7 +120,8 @@ class Notice extends Memcached_DataObject } } - static function saveNew($profile_id, $content, $source=null, $is_local=1, $reply_to=null, $uri=null) { + static function saveNew($profile_id, $content, $source=null, + $is_local=1, $reply_to=null, $uri=null, $created=null) { $profile = Profile::staticGet($profile_id); @@ -166,7 +167,11 @@ class Notice extends Memcached_DataObject $notice->query('BEGIN'); $notice->reply_to = $reply_to; - $notice->created = common_sql_now(); + if (!empty($created)) { + $notice->created = $created; + } else { + $notice->created = common_sql_now(); + } $notice->content = $final; $notice->rendered = common_render_content($final, $notice); $notice->source = $source; diff --git a/classes/Notice_inbox.php b/classes/Notice_inbox.php index 8a27e17478..673e187c72 100644 --- a/classes/Notice_inbox.php +++ b/classes/Notice_inbox.php @@ -85,4 +85,9 @@ class Notice_inbox extends Memcached_DataObject return $ids; } + + function &pkeyGet($kv) + { + return Memcached_DataObject::pkeyGet('Notice_inbox', $kv); + } } diff --git a/scripts/twitterstatusfetcher.php b/scripts/twitterstatusfetcher.php index a61ce1b0d1..9287b6d733 100755 --- a/scripts/twitterstatusfetcher.php +++ b/scripts/twitterstatusfetcher.php @@ -255,42 +255,11 @@ class TwitterStatusFetcher extends Daemon // check to see if we've already imported the status if (!$notice) { - $notice = new Notice(); - $notice->profile_id = $id; + $created = strftime('%Y-%m-%d %H:%M:%S', + strtotime($status->created_at));; - $notice->query('BEGIN'); - - // XXX: figure out reply_to - $notice->reply_to = null; - - // XXX: Should this be common_sql_now() instead of status create date? - - $notice->created = strftime('%Y-%m-%d %H:%M:%S', - strtotime($status->created_at)); - $notice->content = $status->text; - $notice->rendered = common_render_content($status->text, $notice); - $notice->source = 'twitter'; - $notice->is_local = 0; - $notice->uri = $uri; - - $notice_id = $notice->insert(); - - if (!$notice_id) { - common_log_db_error($notice, 'INSERT', __FILE__); - if (defined('SCRIPT_DEBUG')) { - common_debug('Could not save notice!'); - } - } - - // XXX: Figure out a better way to link Twitter replies? - $notice->saveReplies(); - - // XXX: Do we want to pollute our tag cloud with - // hashtags from Twitter? - $notice->saveTags(); - $notice->saveGroups(); - - $notice->query('COMMIT'); + $notice = Notice::saveNew($id, $status->text, 'twitter', + -2, null, $uri, $created); if (defined('SCRIPT_DEBUG')) { common_debug("Saved status $status->id" . @@ -298,13 +267,13 @@ class TwitterStatusFetcher extends Daemon } } - if (!Notice_inbox::staticGet('notice_id', $notice->id)) { - + if (!Notice_inbox::pkeyGet(array('notice_id' => $notice->id, + 'user_id' => $flink->user_id))) { // Add to inbox $inbox = new Notice_inbox(); $inbox->user_id = $flink->user_id; $inbox->notice_id = $notice->id; - $inbox->created = common_sql_now(); + $inbox->created = $notice->created; $inbox->insert(); } From eddc2af1583c45b587bf15bf93814ac7c970f64c Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 11 Jun 2009 02:10:38 +0000 Subject: [PATCH 11/23] Files no longer needed --- theme/base/images/icons/clip-big.png | Bin 11245 -> 0 bytes theme/base/images/icons/clip-inline.png | Bin 1646 -> 0 bytes theme/base/images/icons/clip.png | Bin 2298 -> 0 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 theme/base/images/icons/clip-big.png delete mode 100644 theme/base/images/icons/clip-inline.png delete mode 100644 theme/base/images/icons/clip.png diff --git a/theme/base/images/icons/clip-big.png b/theme/base/images/icons/clip-big.png deleted file mode 100644 index 3945f56cc04088032e25f4a927ae0c003daa0b60..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11245 zcmW-nbzD<#8^$M%)Q|=RMoG7H4yjQRlG5EVknTw%DM(8U1O=oU1Z9B8kj{bRXrvq7 z{oZ{(XJ^|#=Q(G0T-W!0;$La2l02q=3;+N~)YV?=nUm5qJ%Jso`gt$pkP{{H^_&K|B%TWc?S zeor6AyaO3}0Du{w{!-B(Ab%s&+1Fs^!&&!5mrTR)s;|KWHfufUZ&iP6r|am#Tn2 z*VjRyC-Jn5_s2gbe&(#MEq?c$YUOx$Tg-P8)_y3j*K3djWFd-TcFoN?50Ie)NQFOB z7<%CN1ZB3w(aW+|obh8(f5OAXH6|@BZDMQ7dUSKQ`ol8xQVLZWPNWi|fR+L=1LFXs zq~U$FFFf7v@#g;^Xo(U_XxU+dj47(P-z|vt9$qNWMDR{dPO4ozT;5a3haOe@t{e8| zF3@(Zsw&sw$jBP9+oCDF>@$VGyb6u6C+;pIJNU@pFqX8vF`;Y28;SJw#gq2_XM`^v z-?i!tsbo@6qg0;T@Uj0#ZlM?cyG`Rb#wqaV8Hj0}x zv6MQIz1TUoeVZnaF}?cuLS>b8z4cH6uQd9vGhT(4Yy0V z%^Ufea6j2TN|l$oc4=y`7owuykVxdM*y%6&rCmC6f_lu#b#B)w9%=}FRrnJhe7`z6 z`55T5snjddEB9rJ{^~MC{$3eXwH!Vk{sey!|5H_!o2(7WLDusu+VKJk;d=OUA$Qt) zoO_%L%l*zo`cRyG8xxZ8MCv>3iGy&C7c=mc*HD<2rDx>fyTM3J273CRhDr~EVgr?4PF{k%YyaXKNh>gl12ki){FN{6$1niva(8!zecl~b>&!>Yo@x2Dl; zi#d;f`gZpcG(r27`BpKY_u4SfAD<7R{!dWPS966v|se?78**Su2pz}6aD z^!9dWjF^fA^zso9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Ma4fV)iG%52ihh#L;7en=sILN=4Y+c=! z5bt(d)c0vD!+(l{VFaoH(`V~5ezHk~v?NC!1bvb{PF`OtD}}b&E!YUalITT#0x%VN zk@OQ5)~^6re?$Iiw|ptvs)q8|e9Z;QGqZNuEmZ2mcN$<&4{WPPRxB{uz_()hO9K_G(#}Fd4S4y?AiE@> zFhY`yjyT5u!+ROsqpDs`T+Ni}nVG~fCj((xVijcDJ1FM%qmqRjN;9dU$V5rBAt3AN zEcn3jwH?W>Zef?d1hV1ctOUbe{J^P^0DE{T_7w&nuVm9<~ifUTnb E2ZOICi2wiq diff --git a/theme/base/images/icons/clip-inline.png b/theme/base/images/icons/clip-inline.png deleted file mode 100644 index 870f8b2e8ff32f1b5e19a9a2389648bfdfd47ec9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1646 zcmV-!29f!RP)71Q{00004b3#c}2nYxW zd95B}{OcTWhu4z*Pi$1#~vVrphs~40I$efG23$1a(&&Fb+O8)mEZW0{~4pk z__m|bQSWxUy@U_~j{?kImQAnxVC8fcba*cxys&d7ZYbBCe`)Uxu6;@$+CP#6ve)n*qFyw?Oyf!g-)k-Orhh-V|d z>OI)I7C#_{3yv1NrSs`d(3k0vv3X+)E`58cg|^ZfilRyf2M7DDR%?L#^O{gkQ_saD zMN+4z6gN`;7t39r8?jBh?O>z1adDzAG1w8)q4FQ_pT{!R`20Sj*XwnY39%7E2mtuv zmGP%!mAwAGK>&aqpX_)n?$x-eZew>aIU!l4AJ98-J-z@4Gyu@;^?JuiSd9Qcfe->V zf_

7o0oApk((p~9tYr0poajCs5eryGwN+i8xzCwMsSwl3RNoT>09>Fg*xJB1yg#FVhM!Gl)q}-@4LE=+7>22_*=$Zih&=I5 z?#A4R)YnoEIj%dNQecIuwzAd`(HCI|g+j;f3g&LijYxSd<&ep2nwKCX#I@XLp+XfQ zgCt0rU@+J=Iy&l^7$E?_ho60z$R%>WcubxkPQd9cWi3}Jo~l$R6sPTW`{a=V0POm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qd6951J07*qoM6N<$g7o%7FaQ7m From 806439758823e3fe6e51ec56ce653760902af2aa Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 12 Jun 2009 01:31:22 -0700 Subject: [PATCH 12/23] Ticket #1611 and a bunch of code cleanup --- actions/twitapiaccount.php | 19 +- actions/twitapiblocks.php | 10 +- actions/twitapidirect_messages.php | 76 +++--- actions/twitapifavorites.php | 82 +++--- actions/twitapifriendships.php | 36 ++- actions/twitapihelp.php | 4 +- actions/twitapistatuses.php | 399 +++++++++++++---------------- actions/twitapiusers.php | 13 +- lib/twitterapi.php | 95 +++++-- 9 files changed, 361 insertions(+), 373 deletions(-) diff --git a/actions/twitapiaccount.php b/actions/twitapiaccount.php index 8b956f897a..b5e7b91da7 100644 --- a/actions/twitapiaccount.php +++ b/actions/twitapiaccount.php @@ -17,7 +17,9 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} require_once(INSTALLDIR.'/lib/twitterapi.php'); @@ -51,7 +53,8 @@ class TwitapiaccountAction extends TwitterapiAction parent::handle($args); if ($_SERVER['REQUEST_METHOD'] != 'POST') { - $this->clientError(_('This method requires a POST.'), 400, $apidata['content-type']); + $this->clientError(_('This method requires a POST.'), + 400, $apidata['content-type']); return; } @@ -60,24 +63,20 @@ class TwitapiaccountAction extends TwitterapiAction if (!is_null($location) && mb_strlen($location) > 255) { // XXX: But Twitter just truncates and runs with it. -- Zach - $this->clientError(_('That\'s too long. Max notice size is 255 chars.'), 406, $apidate['content-type']); + $this->clientError(_('That\'s too long. Max notice size is 255 chars.'), + 406, $apidate['content-type']); return; } - $user = $apidata['user']; + $user = $apidata['user']; // Always the auth user $profile = $user->getProfile(); - if (!$profile) { - $this->serverError(_('User has no profile.')); - return; - } - $orig_profile = clone($profile); $profile->location = $location; $result = $profile->update($orig_profile); - if (!$result) { + if (empty($result)) { common_log_db_error($profile, 'UPDATE', __FILE__); $this->serverError(_('Couldn\'t save profile.')); return; diff --git a/actions/twitapiblocks.php b/actions/twitapiblocks.php index 8135adef3c..0e35091622 100644 --- a/actions/twitapiblocks.php +++ b/actions/twitapiblocks.php @@ -17,7 +17,9 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} require_once(INSTALLDIR.'/lib/twitterapi.php'); @@ -31,12 +33,12 @@ class TwitapiblocksAction extends TwitterapiAction $blockee = $this->get_user($apidata['api_arg'], $apidata); - if (!$blockee) { + if (empty($blockee)) { $this->clientError('Not Found', 404, $apidata['content-type']); return; } - $user = $apidata['user']; + $user = $apidata['user']; // Always the auth user if ($user->hasBlocked($blockee) || $user->block($blockee)) { $type = $apidata['content-type']; @@ -53,7 +55,7 @@ class TwitapiblocksAction extends TwitterapiAction parent::handle($args); $blockee = $this->get_user($apidata['api_arg'], $apidata); - if (!$blockee) { + if (empty($blockee)) { $this->clientError('Not Found', 404, $apidata['content-type']); return; } diff --git a/actions/twitapidirect_messages.php b/actions/twitapidirect_messages.php index d2dbdb619b..85c788d6a6 100644 --- a/actions/twitapidirect_messages.php +++ b/actions/twitapidirect_messages.php @@ -17,7 +17,9 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} require_once(INSTALLDIR.'/lib/twitterapi.php'); @@ -38,42 +40,34 @@ class Twitapidirect_messagesAction extends TwitterapiAction function show_messages($args, $apidata, $type) { - $user = $apidata['user']; + $user = $apidata['user']; // Always the auth user - $count = $this->arg('count'); - $since = $this->arg('since'); - $since_id = $this->arg('since_id'); - $max_id = $this->arg('max_id'); - - $page = $this->arg('page'); - - if (!$page) { - $page = 1; - } - - if (!$count) { - $count = 20; - } - - $message = new Message(); - - $title = null; + $message = new Message(); + $title = null; $subtitle = null; - $link = null; - $server = common_root_url(); + $link = null; + $server = common_root_url(); if ($type == 'received') { $message->to_profile = $user->id; $title = sprintf(_("Direct messages to %s"), $user->nickname); - $subtitle = sprintf(_("All the direct messages sent to %s"), $user->nickname); + $subtitle = sprintf(_("All the direct messages sent to %s"), + $user->nickname); $link = $server . $user->nickname . '/inbox'; } else { $message->from_profile = $user->id; $title = _('Direct Messages You\'ve Sent'); - $subtitle = sprintf(_("All the direct messages sent from %s"), $user->nickname); + $subtitle = sprintf(_("All the direct messages sent from %s"), + $user->nickname); $link = $server . $user->nickname . '/outbox'; } + $page = (int)$this->arg('page', 1); + $count = (int)$this->arg('count', 20); + $max_id = (int)$this->arg('max_id', 0); + $since_id = (int)$this->arg('since_id', 0); + $since = $this->arg('since'); + if ($max_id) { $message->whereAdd("id <= $max_id"); } @@ -82,25 +76,23 @@ class Twitapidirect_messagesAction extends TwitterapiAction $message->whereAdd("id > $since_id"); } - $since = strtotime($this->arg('since')); - if ($since) { $d = date('Y-m-d H:i:s', $since); $message->whereAdd("created > '$d'"); } $message->orderBy('created DESC, id DESC'); - $message->limit((($page-1)*20), $count); + $message->limit((($page-1)*$count), $count); $message->find(); switch($apidata['content-type']) { - case 'xml': + case 'xml': $this->show_xml_dmsgs($message); break; - case 'rss': + case 'rss': $this->show_rss_dmsgs($message, $title, $link, $subtitle); break; - case 'atom': + case 'atom': $selfuri = common_root_url() . 'api/direct_messages'; $selfuri .= ($type == 'received') ? '.atom' : '/sent.atom'; $taguribase = common_config('integration', 'taguri'); @@ -111,12 +103,13 @@ class Twitapidirect_messagesAction extends TwitterapiAction $id = "tag:$taguribase:DirectMessages:" . $user->id; } - $this->show_atom_dmsgs($message, $title, $link, $subtitle, $selfuri, $id); + $this->show_atom_dmsgs($message, $title, $link, $subtitle, + $selfuri, $id); break; - case 'json': + case 'json': $this->show_json_dmsgs($message); break; - default: + default: $this->clientError(_('API method not found!'), $code = 404); } @@ -128,22 +121,24 @@ class Twitapidirect_messagesAction extends TwitterapiAction parent::handle($args); if ($_SERVER['REQUEST_METHOD'] != 'POST') { - $this->clientError(_('This method requires a POST.'), 400, $apidata['content-type']); + $this->clientError(_('This method requires a POST.'), + 400, $apidata['content-type']); return; } $user = $apidata['user']; - $source = $this->trimmed('source'); // Not supported by Twitter. + $source = $this->trimmed('source'); // Not supported by Twitter. $reserved_sources = array('web', 'omb', 'mail', 'xmpp', 'api'); - if (!$source || in_array($source, $reserved_sources)) { + if (empty($source) || in_array($source, $reserved_sources)) { $source = 'api'; } $content = $this->trimmed('text'); - if (!$content) { - $this->clientError(_('No message text!'), $code = 406, $apidata['content-type']); + if (empty($content)) { + $this->clientError(_('No message text!'), + $code = 406, $apidata['content-type']); } else { $content_shortened = common_shorten_links($content); if (mb_strlen($content_shortened) > 140) { @@ -155,8 +150,9 @@ class Twitapidirect_messagesAction extends TwitterapiAction $other = $this->get_user($this->trimmed('user')); - if (!$other) { - $this->clientError(_('Recipient user not found.'), $code = 403, $apidata['content-type']); + if (empty($other)) { + $this->clientError(_('Recipient user not found.'), + $code = 403, $apidata['content-type']); return; } else if (!$user->mutuallySubscribed($other)) { $this->clientError(_('Can\'t send direct messages to users who aren\'t your friend.'), diff --git a/actions/twitapifavorites.php b/actions/twitapifavorites.php index 31dce341b7..8656adbe86 100644 --- a/actions/twitapifavorites.php +++ b/actions/twitapifavorites.php @@ -17,7 +17,9 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} require_once(INSTALLDIR.'/lib/twitterapi.php'); @@ -31,50 +33,39 @@ class TwitapifavoritesAction extends TwitterapiAction $this->auth_user = $apidata['user']; $user = $this->get_user($apidata['api_arg'], $apidata); - if (!$user) { + if (empty($user)) { $this->clientError('Not Found', 404, $apidata['content-type']); return; } $profile = $user->getProfile(); - if (!$profile) { - $this->serverError(_('User has no profile.')); - return; - } - - $page = $this->arg('page'); - - if (!$page) { - $page = 1; - } - - if (!$count) { - $count = 20; - } - - $notice = $user->favoriteNotices((($page-1)*20), $count); - - if (!$notice) { - $this->serverError(_('Could not retrieve favorite notices.')); - return; - } - - $sitename = common_config('site', 'name'); - $title = sprintf(_('%s / Favorites from %s'), $sitename, $user->nickname); + $sitename = common_config('site', 'name'); + $title = sprintf(_('%s / Favorites from %s'), $sitename, + $user->nickname); $taguribase = common_config('integration', 'taguri'); - $id = "tag:$taguribase:Favorites:".$user->id; - $link = common_local_url('favorites', array('nickname' => $user->nickname)); - $subtitle = sprintf(_('%s updates favorited by %s / %s.'), $sitename, $profile->getBestName(), $user->nickname); + $id = "tag:$taguribase:Favorites:".$user->id; + $link = common_local_url('favorites', + array('nickname' => $user->nickname)); + $subtitle = sprintf(_('%s updates favorited by %s / %s.'), $sitename, + $profile->getBestName(), $user->nickname); + + $page = (int)$this->arg('page', 1); + $count = (int)$this->arg('count', 20); + $max_id = (int)$this->arg('max_id', 0); + $since_id = (int)$this->arg('since_id', 0); + $since = $this->arg('since'); + + $notice = $user->favoriteNotices(($page-1)*$count, $count); switch($apidata['content-type']) { - case 'xml': + case 'xml': $this->show_xml_timeline($notice); break; - case 'rss': + case 'rss': $this->show_rss_timeline($notice, $title, $link, $subtitle); break; - case 'atom': + case 'atom': if (isset($apidata['api_arg'])) { $selfuri = $selfuri = common_root_url() . 'api/favorites/' . $apidata['api_arg'] . '.atom'; @@ -82,12 +73,13 @@ class TwitapifavoritesAction extends TwitterapiAction $selfuri = $selfuri = common_root_url() . 'api/favorites.atom'; } - $this->show_atom_timeline($notice, $title, $id, $link, $subtitle, null, $selfuri); + $this->show_atom_timeline($notice, $title, $id, $link, + $subtitle, null, $selfuri); break; - case 'json': + case 'json': $this->show_json_timeline($notice); break; - default: + default: $this->clientError(_('API method not found!'), $code = 404); } @@ -100,7 +92,8 @@ class TwitapifavoritesAction extends TwitterapiAction // Check for RESTfulness if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) { // XXX: Twitter just prints the err msg, no XML / JSON. - $this->clientError(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']); + $this->clientError(_('This method requires a POST or DELETE.'), + 400, $apidata['content-type']); return; } @@ -109,25 +102,27 @@ class TwitapifavoritesAction extends TwitterapiAction return; } - $this->auth_user = $apidata['user']; - $user = $this->auth_user; + $user = $apidata['user']; // Always the auth user + $notice_id = $apidata['api_arg']; $notice = Notice::staticGet($notice_id); - if (!$notice) { - $this->clientError(_('No status found with that ID.'), 404, $apidata['content-type']); + if (empty($notice)) { + $this->clientError(_('No status found with that ID.'), + 404, $apidata['content-type']); return; } // XXX: Twitter lets you fave things repeatedly via api. if ($user->hasFave($notice)) { - $this->clientError(_('This notice is already a favorite!'), 403, $apidata['content-type']); + $this->clientError(_('This notice is already a favorite!'), + 403, $apidata['content-type']); return; } $fave = Fave::addNew($user, $notice); - if (!$fave) { + if (empty($fave)) { $this->serverError(_('Could not create favorite.')); return; } @@ -149,7 +144,8 @@ class TwitapifavoritesAction extends TwitterapiAction $this->serverError(_('API method under construction.'), $code=501); } - // XXX: these two funcs swiped from faves. Maybe put in util.php, or some common base class? + // XXX: these two funcs swiped from faves. + // Maybe put in util.php, or some common base class? function notify($fave, $notice, $user) { diff --git a/actions/twitapifriendships.php b/actions/twitapifriendships.php index 2f8250e0dc..b1c277748a 100644 --- a/actions/twitapifriendships.php +++ b/actions/twitapifriendships.php @@ -17,7 +17,9 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} require_once(INSTALLDIR.'/lib/twitterapi.php'); @@ -29,23 +31,25 @@ class TwitapifriendshipsAction extends TwitterapiAction parent::handle($args); if ($_SERVER['REQUEST_METHOD'] != 'POST') { - $this->clientError(_('This method requires a POST.'), 400, $apidata['content-type']); + $this->clientError(_('This method requires a POST.'), + 400, $apidata['content-type']); return; } - $id = $apidata['api_arg']; - + $id = $apidata['api_arg']; $other = $this->get_user($id); - if (!$other) { - $this->clientError(_('Could not follow user: User not found.'), 403, $apidata['content-type']); + if (empty($other)) { + $this->clientError(_('Could not follow user: User not found.'), + 403, $apidata['content-type']); return; } $user = $apidata['user']; if ($user->isSubscribed($other)) { - $errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname); + $errmsg = sprintf(_('Could not follow user: %s is already on your list.'), + $other->nickname); $this->clientError($errmsg, 403, $apidata['content-type']); return; } @@ -60,8 +64,9 @@ class TwitapifriendshipsAction extends TwitterapiAction $result = $sub->insert(); - if (!$result) { - $errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname); + if (empty($result)) { + $errmsg = sprintf(_('Could not follow user: %s is already on your list.'), + $other->nickname); $this->clientError($errmsg, 400, $apidata['content-type']); return; } @@ -82,7 +87,8 @@ class TwitapifriendshipsAction extends TwitterapiAction parent::handle($args); if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) { - $this->clientError(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']); + $this->clientError(_('This method requires a POST or DELETE.'), + 400, $apidata['content-type']); return; } @@ -91,7 +97,7 @@ class TwitapifriendshipsAction extends TwitterapiAction # We can't subscribe to a remote person, but we can unsub $other = $this->get_profile($id); - $user = $apidata['user']; + $user = $apidata['user']; // Alwyas the auth user $sub = new Subscription(); $sub->subscriber = $user->id; @@ -102,7 +108,8 @@ class TwitapifriendshipsAction extends TwitterapiAction $sub->delete(); $sub->query('COMMIT'); } else { - $this->clientError(_('You are not friends with the specified user.'), 403, $apidata['content-type']); + $this->clientError(_('You are not friends with the specified user.'), + 403, $apidata['content-type']); return; } @@ -128,8 +135,9 @@ class TwitapifriendshipsAction extends TwitterapiAction $user_a = $this->get_user($user_a_id); $user_b = $this->get_user($user_b_id); - if (!$user_a || !$user_b) { - $this->clientError(_('Two user ids or screen_names must be supplied.'), 400, $apidata['content-type']); + if (empty($user_a) || empty($user_b)) { + $this->clientError(_('Two user ids or screen_names must be supplied.'), + 400, $apidata['content-type']); return; } diff --git a/actions/twitapihelp.php b/actions/twitapihelp.php index db5892baf2..bdef1314af 100644 --- a/actions/twitapihelp.php +++ b/actions/twitapihelp.php @@ -17,7 +17,9 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} require_once(INSTALLDIR.'/lib/twitterapi.php'); diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php index 1fbde6639f..94f624afb9 100644 --- a/actions/twitapistatuses.php +++ b/actions/twitapistatuses.php @@ -17,7 +17,9 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} require_once(INSTALLDIR.'/lib/twitterapi.php'); @@ -26,64 +28,45 @@ class TwitapistatusesAction extends TwitterapiAction function public_timeline($args, $apidata) { - parent::handle($args); - - $sitename = common_config('site', 'name'); - $title = sprintf(_("%s public timeline"), $sitename); - - $taguribase = common_config('integration', 'taguri'); - $id = "tag:$taguribase:PublicTimeline"; - $link = common_root_url(); - - $subtitle = sprintf(_("%s updates from everyone!"), $sitename); - - // Number of public statuses to return by default -- Twitter sends 20 - $MAX_PUBSTATUSES = 20; - - // FIXME: To really live up to the spec we need to build a list + // XXX: To really live up to the spec we need to build a list // of notices by users who have custom avatars, so fix this SQL -- Zach - $page = $this->arg('page'); - $since_id = $this->arg('since_id'); - $max_id = $this->arg('max_id'); + parent::handle($args); - if (!$page) { - $page = 1; - } - if (!$since_id) { - $since_id = 0; - } - if (!$max_id) { - $max_id = 0; - } + $sitename = common_config('site', 'name'); + $title = sprintf(_("%s public timeline"), $sitename); + $taguribase = common_config('integration', 'taguri'); + $id = "tag:$taguribase:PublicTimeline"; + $link = common_root_url(); + $subtitle = sprintf(_("%s updates from everyone!"), $sitename); - $since = strtotime($this->arg('since')); + $page = (int)$this->arg('page', 1); + $count = (int)$this->arg('count', 20); + $max_id = (int)$this->arg('max_id', 0); + $since_id = (int)$this->arg('since_id', 0); + $since = $this->arg('since'); - $notice = Notice::publicStream((($page-1)*$MAX_PUBSTATUSES), $MAX_PUBSTATUSES, $since_id, $max_id, $since); + $notice = Notice::publicStream(($page-1)*$count, $count, $since_id, + $max_id, $since); - if ($notice) { - - switch($apidata['content-type']) { - case 'xml': - $this->show_xml_timeline($notice); - break; - case 'rss': - $this->show_rss_timeline($notice, $title, $link, $subtitle); - break; - case 'atom': - $selfuri = common_root_url() . 'api/statuses/public_timeline.atom'; - $this->show_atom_timeline($notice, $title, $id, $link, $subtitle, null, $selfuri); - break; - case 'json': - $this->show_json_timeline($notice); - break; - default: - $this->clientError(_('API method not found!'), $code = 404); - break; - } - - } else { - $this->serverError(_('Couldn\'t find any statuses.'), $code = 503); + switch($apidata['content-type']) { + case 'xml': + $this->show_xml_timeline($notice); + break; + case 'rss': + $this->show_rss_timeline($notice, $title, $link, $subtitle); + break; + case 'atom': + $selfuri = common_root_url() . 'api/statuses/public_timeline.atom'; + $this->show_atom_timeline($notice, $title, $id, $link, + $subtitle, null, $selfuri); + break; + case 'json': + $this->show_json_timeline($notice); + break; + default: + $this->clientError(_('API method not found!'), $code = 404); + break; } } @@ -92,68 +75,57 @@ class TwitapistatusesAction extends TwitterapiAction { parent::handle($args); - $since = $this->arg('since'); - $since_id = $this->arg('since_id'); - $count = $this->arg('count'); - $page = $this->arg('page'); - $max_id = $this->arg('max_id'); - - if (!$page) { - $page = 1; - } - - if (!$count) { - $count = 20; - } - - if (!$since_id) { - $since_id = 0; - } - - if (!$max_id) { - $max_id = 0; - } - - $since = strtotime($this->arg('since')); $user = $this->get_user($apidata['api_arg'], $apidata); $this->auth_user = $user; if (empty($user)) { - $this->clientError(_('No such user!'), 404, $apidata['content-type']); + $this->clientError(_('No such user!'), 404, + $apidata['content-type']); return; } - $profile = $user->getProfile(); - $sitename = common_config('site', 'name'); - $title = sprintf(_("%s and friends"), $user->nickname); + $profile = $user->getProfile(); + $sitename = common_config('site', 'name'); + $title = sprintf(_("%s and friends"), $user->nickname); $taguribase = common_config('integration', 'taguri'); - $id = "tag:$taguribase:FriendsTimeline:" . $user->id; - $link = common_local_url('all', array('nickname' => $user->nickname)); - $subtitle = sprintf(_('Updates from %1$s and friends on %2$s!'), $user->nickname, $sitename); + $id = "tag:$taguribase:FriendsTimeline:" . $user->id; + $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, $max_id, $since); + $page = (int)$this->arg('page', 1); + $count = (int)$this->arg('count', 20); + $max_id = (int)$this->arg('max_id', 0); + $since_id = (int)$this->arg('since_id', 0); + $since = $this->arg('since'); + + $notice = $user->noticesWithFriends(($page-1)*$count, + $count, $since_id, $max_id,$since); switch($apidata['content-type']) { - case 'xml': + case 'xml': $this->show_xml_timeline($notice); break; - case 'rss': + case 'rss': $this->show_rss_timeline($notice, $title, $link, $subtitle); break; - case 'atom': + case 'atom': if (isset($apidata['api_arg'])) { $selfuri = common_root_url() . - 'api/statuses/friends_timeline/' . $apidata['api_arg'] . '.atom'; + 'api/statuses/friends_timeline/' . + $apidata['api_arg'] . '.atom'; } else { $selfuri = common_root_url() . 'api/statuses/friends_timeline.atom'; } - $this->show_atom_timeline($notice, $title, $id, $link, $subtitle, null, $selfuri); + $this->show_atom_timeline($notice, $title, $id, $link, + $subtitle, null, $selfuri); break; - case 'json': + case 'json': $this->show_json_timeline($notice); break; - default: + default: $this->clientError(_('API method not found!'), $code = 404); } @@ -166,48 +138,21 @@ class TwitapistatusesAction extends TwitterapiAction $this->auth_user = $apidata['user']; $user = $this->get_user($apidata['api_arg'], $apidata); - if (!$user) { + if (empty($user)) { $this->clientError('Not Found', 404, $apidata['content-type']); return; } $profile = $user->getProfile(); - if (!$profile) { - $this->serverError(_('User has no profile.')); - return; - } - - $count = $this->arg('count'); - $since = $this->arg('since'); - $since_id = $this->arg('since_id'); - $page = $this->arg('page'); - $max_id = $this->arg('max_id'); - - if (!$page) { - $page = 1; - } - - if (!$count) { - $count = 20; - } - - if (!$since_id) { - $since_id = 0; - } - - if (!$max_id) { - $max_id = 0; - } - - $since = strtotime($this->arg('since')); - - $sitename = common_config('site', 'name'); - $title = sprintf(_("%s timeline"), $user->nickname); + $sitename = common_config('site', 'name'); + $title = sprintf(_("%s timeline"), $user->nickname); $taguribase = common_config('integration', 'taguri'); - $id = "tag:$taguribase:UserTimeline:".$user->id; - $link = common_local_url('showstream', array('nickname' => $user->nickname)); - $subtitle = sprintf(_('Updates from %1$s on %2$s!'), $user->nickname, $sitename); + $id = "tag:$taguribase:UserTimeline:".$user->id; + $link = common_local_url('showstream', + array('nickname' => $user->nickname)); + $subtitle = sprintf(_('Updates from %1$s on %2$s!'), + $user->nickname, $sitename); # FriendFeed's SUP protocol # Also added RSS and Atom feeds @@ -215,26 +160,34 @@ class TwitapistatusesAction extends TwitterapiAction $suplink = common_local_url('sup', null, null, $user->id); header('X-SUP-ID: '.$suplink); - # XXX: since + $page = (int)$this->arg('page', 1); + $count = (int)$this->arg('count', 20); + $max_id = (int)$this->arg('max_id', 0); + $since_id = (int)$this->arg('since_id', 0); + $since = $this->arg('since'); - $notice = $user->getNotices((($page-1)*20), $count, $since_id, $max_id, $since); + $notice = $user->getNotices(($page-1)*$count, + $count, $since_id, $max_id, $since); switch($apidata['content-type']) { case 'xml': $this->show_xml_timeline($notice); break; case 'rss': - $this->show_rss_timeline($notice, $title, $link, $subtitle, $suplink); + $this->show_rss_timeline($notice, $title, $link, + $subtitle, $suplink); break; case 'atom': if (isset($apidata['api_arg'])) { $selfuri = common_root_url() . - 'api/statuses/user_timeline/' . $apidata['api_arg'] . '.atom'; + 'api/statuses/user_timeline/' . + $apidata['api_arg'] . '.atom'; } else { $selfuri = common_root_url() . 'api/statuses/user_timeline.atom'; } - $this->show_atom_timeline($notice, $title, $id, $link, $subtitle, $suplink, $selfuri); + $this->show_atom_timeline($notice, $title, $id, $link, + $subtitle, $suplink, $selfuri); break; case 'json': $this->show_json_timeline($notice); @@ -247,7 +200,6 @@ class TwitapistatusesAction extends TwitterapiAction function update($args, $apidata) { - parent::handle($args); if (!in_array($apidata['content-type'], array('xml', 'json'))) { @@ -256,21 +208,24 @@ class TwitapistatusesAction extends TwitterapiAction } if ($_SERVER['REQUEST_METHOD'] != 'POST') { - $this->clientError(_('This method requires a POST.'), 400, $apidata['content-type']); + $this->clientError(_('This method requires a POST.'), + 400, $apidata['content-type']); return; } - $this->auth_user = $apidata['user']; - $user = $this->auth_user; + $user = $apidata['user']; // Always the auth user + $status = $this->trimmed('status'); $source = $this->trimmed('source'); - $in_reply_to_status_id = intval($this->trimmed('in_reply_to_status_id')); + $in_reply_to_status_id = + intval($this->trimmed('in_reply_to_status_id')); $reserved_sources = array('web', 'omb', 'mail', 'xmpp', 'api'); - if (!$source || in_array($source, $reserved_sources)) { + + if (empty($source) || in_array($source, $reserved_sources)) { $source = 'api'; } - if (!$status) { + if (empty($status)) { // XXX: Note: In this case, Twitter simply returns '200 OK' // No error is given, but the status is not posted to the @@ -288,9 +243,9 @@ class TwitapistatusesAction extends TwitterapiAction // as "truncated." Sending this error may screw up some clients // that assume Twitter will truncate for them. Should we just // truncate too? -- Zach - $this->clientError(_('That\'s too long. Max notice size is 140 chars.'), $code = 406, $apidata['content-type']); + $this->clientError(_('That\'s too long. Max notice size is 140 chars.'), + $code = 406, $apidata['content-type']); return; - } } @@ -321,13 +276,15 @@ class TwitapistatusesAction extends TwitterapiAction if ($reply) { $reply_to = $in_reply_to_status_id; } else { - $this->clientError(_('Not found'), $code = 404, $apidata['content-type']); + $this->clientError(_('Not found'), $code = 404, + $apidata['content-type']); return; } } - $notice = Notice::saveNew($user->id, html_entity_decode($status, ENT_NOQUOTES, 'UTF-8'), - $source, 1, $reply_to); + $notice = Notice::saveNew($user->id, + html_entity_decode($status, ENT_NOQUOTES, 'UTF-8'), + $source, 1, $reply_to); if (is_string($notice)) { $this->serverError($notice); @@ -343,71 +300,55 @@ class TwitapistatusesAction extends TwitterapiAction function mentions($args, $apidata) { - parent::handle($args); - $since = $this->arg('since'); - $count = $this->arg('count'); - $page = $this->arg('page'); - $since_id = $this->arg('since_id'); - $max_id = $this->arg('max_id'); - $user = $this->get_user($apidata['api_arg'], $apidata); $this->auth_user = $apidata['user']; + + if (empty($user)) { + $this->clientError(_('No such user!'), 404, + $apidata['content-type']); + return; + } + $profile = $user->getProfile(); - $sitename = common_config('site', 'name'); - $title = sprintf(_('%1$s / Updates mentioning %2$s'), + $sitename = common_config('site', 'name'); + $title = sprintf(_('%1$s / Updates mentioning %2$s'), $sitename, $user->nickname); $taguribase = common_config('integration', 'taguri'); - $id = "tag:$taguribase:Mentions:".$user->id; - $link = common_local_url('replies', array('nickname' => $user->nickname)); - $subtitle = sprintf(_('%1$s updates that reply to updates from %2$s / %3$s.'), + $id = "tag:$taguribase:Mentions:".$user->id; + $link = common_local_url('replies', + array('nickname' => $user->nickname)); + $subtitle = sprintf(_('%1$s updates that reply to updates from %2$s / %3$s.'), $sitename, $user->nickname, $profile->getBestName()); - if (!$page) { - $page = 1; - } + $page = (int)$this->arg('page', 1); + $count = (int)$this->arg('count', 20); + $max_id = (int)$this->arg('max_id', 0); + $since_id = (int)$this->arg('since_id', 0); + $since = $this->arg('since'); - if (!$count) { - $count = 20; - } - - if (!$since_id) { - $since_id = 0; - } - - if (!$max_id) { - $max_id = 0; - } - - $since = strtotime($this->arg('since')); - - $notice = $user->getReplies((($page-1)*20), + $notice = $user->getReplies(($page-1)*$count, $count, $since_id, $max_id, $since); - $notices = array(); - - while ($notice->fetch()) { - $notices[] = clone($notice); - } switch($apidata['content-type']) { - case 'xml': - $this->show_xml_timeline($notices); + case 'xml': + $this->show_xml_timeline($notice); break; - case 'rss': - $this->show_rss_timeline($notices, $title, $link, $subtitle); + case 'rss': + $this->show_rss_timeline($notice, $title, $link, $subtitle); break; - case 'atom': + case 'atom': $selfuri = common_root_url() . ltrim($_SERVER['QUERY_STRING'], 'p='); - $this->show_atom_timeline($notices, $title, $id, $link, $subtitle, + $this->show_atom_timeline($notice, $title, $id, $link, $subtitle, null, $selfuri); break; - case 'json': - $this->show_json_timeline($notices); + case 'json': + $this->show_json_timeline($notice); break; - default: + default: $this->clientError(_('API method not found!'), $code = 404); } @@ -428,8 +369,8 @@ class TwitapistatusesAction extends TwitterapiAction } $this->auth_user = $apidata['user']; - $notice_id = $apidata['api_arg']; - $notice = Notice::staticGet($notice_id); + $notice_id = $apidata['api_arg']; + $notice = Notice::staticGet($notice_id); if ($notice) { if ($apidata['content-type'] == 'xml') { @@ -438,15 +379,16 @@ class TwitapistatusesAction extends TwitterapiAction $this->show_single_json_status($notice); } } else { - // XXX: Twitter just sets a 404 header and doens't bother to return an err msg - $this->clientError(_('No status with that ID found.'), 404, $apidata['content-type']); + // XXX: Twitter just sets a 404 header and doens't bother + // to return an err msg + $this->clientError(_('No status with that ID found.'), + 404, $apidata['content-type']); } } function destroy($args, $apidata) { - parent::handle($args); if (!in_array($apidata['content-type'], array('xml', 'json'))) { @@ -457,17 +399,18 @@ class TwitapistatusesAction extends TwitterapiAction // Check for RESTfulness if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) { // XXX: Twitter just prints the err msg, no XML / JSON. - $this->clientError(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']); + $this->clientError(_('This method requires a POST or DELETE.'), + 400, $apidata['content-type']); return; } - $this->auth_user = $apidata['user']; - $user = $this->auth_user; + $user = $apidata['user']; // Always the auth user $notice_id = $apidata['api_arg']; - $notice = Notice::staticGet($notice_id); + $notice = Notice::staticGet($notice_id); - if (!$notice) { - $this->clientError(_('No status found with that ID.'), 404, $apidata['content-type']); + if (empty($notice)) { + $this->clientError(_('No status found with that ID.'), + 404, $apidata['content-type']); return; } @@ -483,7 +426,8 @@ class TwitapistatusesAction extends TwitterapiAction $this->show_single_json_status($notice); } } else { - $this->clientError(_('You may not delete another user\'s status.'), 403, $apidata['content-type']); + $this->clientError(_('You may not delete another user\'s status.'), + 403, $apidata['content-type']); } } @@ -514,42 +458,41 @@ class TwitapistatusesAction extends TwitterapiAction function subscriptions($apidata, $other_attr, $user_attr, $onlyIDs=false) { - $this->auth_user = $apidata['user']; $user = $this->get_user($apidata['api_arg'], $apidata); - if (!$user) { + if (empty($user)) { $this->clientError('Not Found', 404, $apidata['content-type']); return; } - $page = $this->trimmed('page'); - - if (!$page || !is_numeric($page)) { - $page = 1; - } - $profile = $user->getProfile(); - if (!$profile) { - $this->serverError(_('User has no profile.')); - return; - } - $sub = new Subscription(); $sub->$user_attr = $profile->id; - $since = strtotime($this->trimmed('since')); - - if ($since) { - $d = date('Y-m-d H:i:s', $since); - $sub->whereAdd("created > '$d'"); - } - $sub->orderBy('created DESC'); + // Normally, page 100 friends at a time + if (!$onlyIDs) { - $sub->limit(($page-1)*100, 100); + $page = $this->arg('page', 1); + $count = $this->arg('count', 100); + $sub->limit(($page-1)*$count, $count); + } else { + + // If we're just looking at IDs, return + // ALL of them, unless the user specifies a page, + // in which case, return 500 per page. + + $page = $this->arg('page'); + if (!empty($page)) { + if ($page < 1) { + $page = 1; + } + $count = 500; + $sub->limit(($page-1)*$count, $count); + } } $others = array(); @@ -578,21 +521,21 @@ class TwitapistatusesAction extends TwitterapiAction function show_profiles($profiles, $type) { switch ($type) { - case 'xml': + case 'xml': $this->elementStart('users', array('type' => 'array')); foreach ($profiles as $profile) { $this->show_profile($profile); } $this->elementEnd('users'); break; - case 'json': + case 'json': $arrays = array(); foreach ($profiles as $profile) { $arrays[] = $this->twitter_user_array($profile, true); } print json_encode($arrays); break; - default: + default: $this->clientError(_('unsupported file type')); } } @@ -600,21 +543,21 @@ class TwitapistatusesAction extends TwitterapiAction function showIDs($profiles, $type) { switch ($type) { - case 'xml': + case 'xml': $this->elementStart('ids'); foreach ($profiles as $profile) { $this->element('id', null, $profile->id); } $this->elementEnd('ids'); break; - case 'json': + case 'json': $ids = array(); foreach ($profiles as $profile) { $ids[] = (int)$profile->id; } print json_encode($ids); break; - default: + default: $this->clientError(_('unsupported file type')); } } @@ -627,8 +570,8 @@ class TwitapistatusesAction extends TwitterapiAction function supported($cmd) { - - $cmdlist = array('MessageCommand', 'SubCommand', 'UnsubCommand', 'FavCommand', 'OnCommand', 'OffCommand'); + $cmdlist = array('MessageCommand', 'SubCommand', 'UnsubCommand', + 'FavCommand', 'OnCommand', 'OffCommand'); if (in_array(get_class($cmd), $cmdlist)) { return true; diff --git a/actions/twitapiusers.php b/actions/twitapiusers.php index b90bbfa985..13a8746cd0 100644 --- a/actions/twitapiusers.php +++ b/actions/twitapiusers.php @@ -17,7 +17,9 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} require_once(INSTALLDIR.'/lib/twitterapi.php'); @@ -51,18 +53,11 @@ class TwitapiusersAction extends TwitterapiAction $user = $apidata['user']; } - if (!$user) { + if (empty($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') { diff --git a/lib/twitterapi.php b/lib/twitterapi.php index ca8b03cdcd..569bc6d7a2 100644 --- a/lib/twitterapi.php +++ b/lib/twitterapi.php @@ -17,7 +17,9 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} class TwitterapiAction extends Action { @@ -521,11 +523,11 @@ class TwitterapiAction extends Action function init_document($type='xml') { switch ($type) { - case 'xml': + case 'xml': header('Content-Type: application/xml; charset=utf-8'); $this->startXML(); break; - case 'json': + case 'json': header('Content-Type: application/json; charset=utf-8'); // Check for JSONP callback @@ -534,15 +536,15 @@ class TwitterapiAction extends Action print $callback . '('; } break; - case 'rss': + case 'rss': header("Content-Type: application/rss+xml; charset=utf-8"); $this->init_twitter_rss(); break; - case 'atom': + case 'atom': header('Content-Type: application/atom+xml; charset=utf-8'); $this->init_twitter_atom(); break; - default: + default: $this->client_error(_('Not a supported data format.')); break; } @@ -553,10 +555,10 @@ class TwitterapiAction extends Action function end_document($type='xml') { switch ($type) { - case 'xml': + case 'xml': $this->endXML(); break; - case 'json': + case 'json': // Check for JSONP callback $callback = $this->arg('callback'); @@ -564,13 +566,13 @@ class TwitterapiAction extends Action print ')'; } break; - case 'rss': + case 'rss': $this->end_twitter_rss(); break; - case 'atom': + case 'atom': $this->end_twitter_rss(); break; - default: + default: $this->client_error(_('Not a supported data format.')); break; } @@ -657,13 +659,13 @@ class TwitterapiAction extends Action { $profile_array = $this->twitter_user_array($profile, true); switch ($content_type) { - case 'xml': + case 'xml': $this->show_twitter_xml_user($profile_array); break; - case 'json': + case 'json': $this->show_json_objects($profile_array); break; - default: + default: $this->client_error(_('Not a supported data format.')); return; } @@ -672,8 +674,8 @@ class TwitterapiAction extends Action function get_user($id, $apidata=null) { - if (!$id) { - + if (empty($id)) { + // Twitter supports these other ways of passing the user ID if (is_numeric($this->arg('id'))) { return User::staticGet($this->arg('id')); @@ -681,7 +683,7 @@ class TwitterapiAction extends Action $nickname = common_canonical_nickname($this->arg('id')); return User::staticGet('nickname', $nickname); } else if ($this->arg('user_id')) { - // This is to ensure that a non-numeric user_id still + // This is to ensure that a non-numeric user_id still // overrides screen_name even if it doesn't get used if (is_numeric($this->arg('user_id'))) { return User::staticGet('id', $this->arg('user_id')); @@ -693,7 +695,7 @@ class TwitterapiAction extends Action // Fall back to trying the currently authenticated user return $apidata['user']; } - + } else if (is_numeric($id)) { return User::staticGet($id); } else { @@ -720,13 +722,13 @@ class TwitterapiAction extends Action { $source_name = _($source); switch ($source) { - case 'web': - case 'xmpp': - case 'mail': - case 'omb': - case 'api': + case 'web': + case 'xmpp': + case 'mail': + case 'omb': + case 'api': break; - default: + default: $ns = Notice_source::staticGet($source); if ($ns) { $source_name = '' . $ns->name . ''; @@ -736,4 +738,49 @@ class TwitterapiAction extends Action return $source_name; } + /** + * Returns query argument or default value if not found. Certain + * parameters used throughout the API are lightly scrubbed and + * bounds checked. This overrides Action::arg(). + * + * @param string $key requested argument + * @param string $def default value to return if $key is not provided + * + * @return var $var + */ + function arg($key, $def=null) + { + + // XXX: Do even more input validation/scrubbing? + + if (array_key_exists($key, $this->args)) { + switch($key) { + case 'page': + $page = (int)$this->args['page']; + return ($page < 1) ? 1 : $page; + case 'count': + $count = (int)$this->args['count']; + if ($count < 1) { + return 20; + } elseif ($count > 200) { + return 200; + } else { + return $count; + } + case 'since_id': + $since_id = (int)$this->args['since_id']; + return ($since_id < 1) ? 0 : $since_id; + case 'max_id': + $max_id = (int)$this->args['max_id']; + return ($max_id < 1) ? 0 : $max_id; + case 'since': + return strtotime($this->args['since']); + default: + return parent::arg($key, $def); + } + } else { + return $def; + } + } + } From e2476307baa8753dc866c7a1aed485d9f6d3fcd0 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Fri, 12 Jun 2009 15:41:45 +0000 Subject: [PATCH 13/23] Updated Creative Commons namespace to current. Thanks to Toby Inkster for the patch. --- lib/rssaction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rssaction.php b/lib/rssaction.php index 2f25ed7e47..0678b8982c 100644 --- a/lib/rssaction.php +++ b/lib/rssaction.php @@ -239,7 +239,7 @@ class Rss10Action extends Action 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/', 'xmlns:cc' => - 'http://web.resource.org/cc/', + 'http://creativecommons.org/ns#', 'xmlns:content' => 'http://purl.org/rss/1.0/modules/content/', 'xmlns:foaf' => From 1627fe8f336d435e328dcc3a58e9e08cd4ef1bfe Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Fri, 12 Jun 2009 15:42:53 +0000 Subject: [PATCH 14/23] http://laconi.ca/trac/ticket/1368 Site is the space that Container sits in. Thanks to Toby Inkster for the patch. --- lib/rssaction.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rssaction.php b/lib/rssaction.php index 0678b8982c..cfb5ca44a6 100644 --- a/lib/rssaction.php +++ b/lib/rssaction.php @@ -253,10 +253,10 @@ class Rss10Action extends Action 'xmlns' => 'http://purl.org/rss/1.0/')); $this->elementStart('sioc:Site', array('rdf:about' => common_root_url())); $this->element('sioc:name', null, common_config('site', 'name')); - $this->elementStart('sioc:container_of'); + $this->elementStart('sioc:space_of'); $this->element('sioc:Container', array('rdf:about' => $channel['url'])); - $this->elementEnd('sioc:container_of'); + $this->elementEnd('sioc:space_of'); $this->elementEnd('sioc:Site'); } From 392c8d4a967f01533fd7458298e79c82486dc914 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Fri, 12 Jun 2009 16:13:45 +0000 Subject: [PATCH 15/23] http://laconi.ca/trac/ticket/863 Thanks to Toby Inkster for the patch. --- lib/rssaction.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/rssaction.php b/lib/rssaction.php index cfb5ca44a6..6f30a02f21 100644 --- a/lib/rssaction.php +++ b/lib/rssaction.php @@ -202,6 +202,9 @@ class Rss10Action extends Action $this->element('title', null, $title); $this->element('link', null, $nurl); $this->element('description', null, $profile->nickname."'s status on ".common_exact_date($notice->created)); + if ($notice->rendered) { + $this->element('content:encoded', null, common_xml_safe_str($notice->rendered)); + } $this->element('dc:date', null, common_date_w3dtf($notice->created)); $this->element('dc:creator', null, ($profile->fullname) ? $profile->fullname : $profile->nickname); $this->element('sioc:has_creator', array('rdf:resource' => $creator_uri)); From 4532babb6f3a7c8d2b155483a4a651f83cfc6c8a Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Fri, 12 Jun 2009 16:15:30 +0000 Subject: [PATCH 16/23] http://laconi.ca/trac/ticket/1370 Thanks to Toby Inkster for the patch. --- lib/rssaction.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/rssaction.php b/lib/rssaction.php index 6f30a02f21..a3a7623172 100644 --- a/lib/rssaction.php +++ b/lib/rssaction.php @@ -170,7 +170,7 @@ class Rss10Action extends Action $this->elementStart('rdf:Seq'); foreach ($this->notices as $notice) { - $this->element('sioct:MicroblogPost', array('rdf:resource' => $notice->uri)); + $this->element('rdf:li', array('rdf:resource' => $notice->uri)); } $this->elementEnd('rdf:Seq'); @@ -197,7 +197,8 @@ class Rss10Action extends Action $profile = Profile::staticGet($notice->profile_id); $nurl = common_local_url('shownotice', array('notice' => $notice->id)); $creator_uri = common_profile_uri($profile); - $this->elementStart('item', array('rdf:about' => $notice->uri)); + $this->elementStart('item', array('rdf:about' => $notice->uri, + 'rdf:type' => 'http://rdfs.org/sioc/types#MicroblogPost')); $title = $profile->nickname . ': ' . common_xml_safe_str(trim($notice->content)); $this->element('title', null, $title); $this->element('link', null, $nurl); From 8524990512d41e9aa7114b6a3b5af073eeb9aabb Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Fri, 12 Jun 2009 16:18:58 +0000 Subject: [PATCH 17/23] http://laconi.ca/trac/ticket/1367 Thanks to Toby Inkster for the patch. --- lib/rssaction.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/rssaction.php b/lib/rssaction.php index a3a7623172..eafdbf131d 100644 --- a/lib/rssaction.php +++ b/lib/rssaction.php @@ -208,7 +208,8 @@ class Rss10Action extends Action } $this->element('dc:date', null, common_date_w3dtf($notice->created)); $this->element('dc:creator', null, ($profile->fullname) ? $profile->fullname : $profile->nickname); - $this->element('sioc:has_creator', array('rdf:resource' => $creator_uri)); + $this->element('foaf:maker', array('rdf:resource' => $creator_uri)); + $this->element('sioc:has_creator', array('rdf:resource' => $creator_uri.'#acct')); $this->element('laconica:postIcon', array('rdf:resource' => $profile->avatarUrl())); $this->element('cc:licence', array('rdf:resource' => common_config('license', 'url'))); $this->elementEnd('item'); @@ -220,15 +221,15 @@ class Rss10Action extends Action foreach ($this->creators as $uri => $profile) { $id = $profile->id; $nickname = $profile->nickname; - $this->elementStart('sioc:User', array('rdf:about' => $uri)); + $this->elementStart('foaf:Agent', array('rdf:about' => $uri)); $this->element('foaf:nick', null, $nickname); if ($profile->fullname) { $this->element('foaf:name', null, $profile->fullname); } - $this->element('sioc:id', null, $id); + $this->element('foaf:holdsAccount', array('rdf:resource' => $uri.'#acct')); $avatar = $profile->avatarUrl(); - $this->element('sioc:avatar', array('rdf:resource' => $avatar)); - $this->elementEnd('sioc:User'); + $this->element('foaf:depiction', array('rdf:resource' => $avatar)); + $this->elementEnd('foaf:Agent'); } } From 4c61f98cd027df2ed45ed250840405bebc232e1a Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Fri, 12 Jun 2009 17:24:18 +0000 Subject: [PATCH 18/23] Takes care of http://laconi.ca/trac/ticket/1372 and a minor part of http://laconi.ca/trac/ticket/1367 One of the bugs was to replace foaf:knows with the weaker sioc:follows. This is done, but foaf:knows is also retained when the subscription is bidirectional. Primary topic of the file is an Agent rather than a Person. rdfs:comment replaced by bio:olb which is a fairly popular RDF property for one-line biographies rdf:about attribute to the elements in a manner consistent with the RSS 1.0 feed. Changed the OnlineAccount's homepage property to an accountProfilePage property. Will be added to FOAF spec soon (already widely used). Added a property from the Agent to their profile page. Thanks to Toby Inkster for the patch. http://buzzword.org.uk/2009/laconica-0.7.3-foafsioc.patch --- actions/foaf.php | 127 +++++++++++++++++++++++++++++------------------ 1 file changed, 79 insertions(+), 48 deletions(-) diff --git a/actions/foaf.php b/actions/foaf.php index 2d5b78d123..fb0172eb90 100644 --- a/actions/foaf.php +++ b/actions/foaf.php @@ -82,14 +82,18 @@ class FoafAction extends Action 'http://www.w3.org/2000/01/rdf-schema#', 'xmlns:geo' => 'http://www.w3.org/2003/01/geo/wgs84_pos#', + 'xmlns:bio' => + 'http://purl.org/vocab/bio/0.1/', + 'xmlns:sioc' => + 'http://rdfs.org/sioc/ns#', 'xmlns' => 'http://xmlns.com/foaf/0.1/')); // This is the document about the user $this->showPpd('', $this->user->uri); - // XXX: might not be a person - $this->elementStart('Person', array('rdf:about' => + // Would be nice to tell if they were a Person or not (e.g. a #person usertag?) + $this->elementStart('Agent', array('rdf:about' => $this->user->uri)); $this->element('mbox_sha1sum', null, sha1('mailto:' . $this->user->email)); if ($this->profile->fullname) { @@ -98,8 +102,11 @@ class FoafAction extends Action if ($this->profile->homepage) { $this->element('homepage', array('rdf:resource' => $this->profile->homepage)); } + if ($this->profile->profileurl) { + $this->element('weblog', array('rdf:resource' => $this->profile->profileurl)); + } if ($this->profile->bio) { - $this->element('rdfs:comment', null, $this->profile->bio); + $this->element('bio:olb', null, $this->profile->bio); } // XXX: more structured location data if ($this->profile->location) { @@ -110,10 +117,7 @@ class FoafAction extends Action $this->elementEnd('based_near'); } - $this->showMicrobloggingAccount($this->profile, common_root_url()); - $avatar = $this->profile->getOriginalAvatar(); - if ($avatar) { $this->elementStart('img'); $this->elementStart('Image', array('rdf:about' => $avatar->url)); @@ -129,39 +133,8 @@ class FoafAction extends Action $this->elementEnd('img'); } - // Get people user is subscribed to - - $person = array(); - - $sub = new Subscription(); - $sub->subscriber = $this->profile->id; - $sub->whereAdd('subscriber != subscribed'); - - if ($sub->find()) { - while ($sub->fetch()) { - if (!empty($sub->token)) { - $other = Remote_profile::staticGet('id', $sub->subscribed); - } else { - $other = User::staticGet('id', $sub->subscribed); - } - if (empty($other)) { - common_debug('Got a bad subscription: '.print_r($sub,true)); - continue; - } - $this->element('knows', array('rdf:resource' => $other->uri)); - $person[$other->uri] = array(LISTENEE, - $other->id, - $other->nickname, - (empty($sub->token)) ? 'User' : 'Remote_profile'); - $other->free(); - $other = null; - unset($other); - } - } - - $sub->free(); - $sub = null; - unset($sub); + $person = $this->showMicrobloggingAccount($this->profile, + common_root_url(), $this->user->uri, false); // Get people who subscribe to user @@ -198,7 +171,15 @@ class FoafAction extends Action $sub = null; unset($sub); - $this->elementEnd('Person'); + foreach ($person as $uri => $p) { + list($type, $id, $nickname, $cls) = $p; + if ($type == BOTH) { + $this->element('knows', array('rdf:resource' => $uri)); + } + } + + $this->elementEnd('Agent'); + foreach ($person as $uri => $p) { $foaf_url = null; @@ -207,16 +188,18 @@ class FoafAction extends Action $foaf_url = common_local_url('foaf', array('nickname' => $nickname)); } $profile = Profile::staticGet($id); - $this->elementStart('Person', array('rdf:about' => $uri)); - if ($type == LISTENER || $type == BOTH) { + $this->elementStart('Agent', array('rdf:about' => $uri)); + if ($type == BOTH) { $this->element('knows', array('rdf:resource' => $this->user->uri)); } - $this->showMicrobloggingAccount($profile, ($cls == 'User') ? - common_root_url() : null); + $this->showMicrobloggingAccount($profile, + ($cls == 'User') ? common_root_url() : null, + $uri, + true); if ($foaf_url) { $this->element('rdfs:seeAlso', array('rdf:resource' => $foaf_url)); } - $this->elementEnd('Person'); + $this->elementEnd('Agent'); if ($foaf_url) { $this->showPpd($foaf_url, $uri); } @@ -237,18 +220,66 @@ class FoafAction extends Action $this->elementEnd('PersonalProfileDocument'); } - function showMicrobloggingAccount($profile, $service=null) + function showMicrobloggingAccount($profile, $service=null, $useruri=null, $isSubscriber=false) { + $attr = array(); + if ($useruri) { + $attr['rdf:about'] = $useruri . '#acct'; + } + // Their account $this->elementStart('holdsAccount'); - $this->elementStart('OnlineAccount'); + $this->elementStart('OnlineAccount', $attr); if ($service) { $this->element('accountServiceHomepage', array('rdf:resource' => $service)); } $this->element('accountName', null, $profile->nickname); - $this->element('homepage', array('rdf:resource' => $profile->profileurl)); + $this->element('accountProfilePage', array('rdf:resource' => $profile->profileurl)); + if ($useruri) { + $this->element('sioc:account_of', array('rdf:resource'=>$useruri)); + } + + $person = array(); + + if ($isSubscriber) { + $this->element('sioc:follows', array('rdf:resource'=>$this->user->uri . '#acct')); + } else { + // Get people user is subscribed to + $sub = new Subscription(); + $sub->subscriber = $profile->id; + $sub->whereAdd('subscriber != subscribed'); + + if ($sub->find()) { + while ($sub->fetch()) { + if (!empty($sub->token)) { + $other = Remote_profile::staticGet('id', $sub->subscribed); + } else { + $other = User::staticGet('id', $sub->subscribed); + } + if (empty($other)) { + common_debug('Got a bad subscription: '.print_r($sub,true)); + continue; + } + $this->element('sioc:follows', array('rdf:resource' => $other->uri.'#acct')); + $person[$other->uri] = array(LISTENEE, + $other->id, + $other->nickname, + (empty($sub->token)) ? 'User' : 'Remote_profile'); + $other->free(); + $other = null; + unset($other); + } + } + + $sub->free(); + $sub = null; + unset($sub); + } + $this->elementEnd('OnlineAccount'); $this->elementEnd('holdsAccount'); + + return $person; } } From fc6154fe4dc093780d610f97c0d9213bb26060fe Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 12 Jun 2009 16:56:43 -0700 Subject: [PATCH 19/23] Add a method to check for registered event handlers --- lib/event.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/event.php b/lib/event.php index d815ae54ba..4ccee17e66 100644 --- a/lib/event.php +++ b/lib/event.php @@ -110,4 +110,32 @@ class Event { } return ($result !== false); } + + /** + * Check to see if an event handler exists + * + * Look to see if there's any handler for a given event, or narrow + * by providing the name of a specific plugin class. + * + * @param string $name Name of the event to look for + * @param string $plugin Optional name of the plugin class to look for + * + * @return boolean flag saying whether such a handler exists + * + */ + + public static function hasHandler($name, $plugin=null) { + if (array_key_exists($name, Event::$_handlers)) { + if (isset($plugin)) { + foreach (Event::$_handlers[$name] as $handler) { + if (get_class($handler[0]) == $plugin) { + return true; + } + } + } else { + return true; + } + } + return false; + } } From 79fa050125971625229a586f1ffed1a0ea504510 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 12 Jun 2009 17:05:31 -0700 Subject: [PATCH 20/23] Remove useless method --- actions/tag.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/actions/tag.php b/actions/tag.php index f5ca06f055..d0ad797ebc 100644 --- a/actions/tag.php +++ b/actions/tag.php @@ -76,11 +76,6 @@ class TagAction extends Action sprintf(_('Feed for tag %s'), $this->tag))); } - function showPageNotice() - { - return sprintf(_('Messages tagged "%s", most recent first'), $this->tag); - } - function showContent() { $notice = Notice_tag::getStream($this->tag, (($this->page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1); From 89d0583b91a237448b9f7ea3b0ae303072631447 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 12 Jun 2009 17:06:42 -0700 Subject: [PATCH 21/23] Fixes Ticket #1607 - empty 'page-notice' definition lists were being output in a bunch of places. --- lib/action.php | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/lib/action.php b/lib/action.php index 7643e5afb8..89a8c8f4d3 100644 --- a/lib/action.php +++ b/lib/action.php @@ -575,20 +575,32 @@ class Action extends HTMLOutputter // lawsuit /** * Show page notice block. * + * Only show the block if a subclassed action has overrided + * Action::showPageNotice(), or an event handler is registered for + * the StartShowPageNotice event, in which case we assume the + * 'page_notice' definition list is desired. This is to prevent + * empty 'page_notice' definition lists from being output everywhere. + * * @return nothing */ function showPageNoticeBlock() { - $this->elementStart('dl', array('id' => 'page_notice', - 'class' => 'system_notice')); - $this->element('dt', null, _('Page notice')); - $this->elementStart('dd'); - if (Event::handle('StartShowPageNotice', array($this))) { - $this->showPageNotice(); - Event::handle('EndShowPageNotice', array($this)); + $rmethod = new ReflectionMethod($this, 'showPageNotice'); + $dclass = $rmethod->getDeclaringClass()->getName(); + + if ($dclass != 'Action' || Event::hasHandler('StartShowPageNotice')) { + + $this->elementStart('dl', array('id' => 'page_notice', + 'class' => 'system_notice')); + $this->element('dt', null, _('Page notice')); + $this->elementStart('dd'); + if (Event::handle('StartShowPageNotice', array($this))) { + $this->showPageNotice(); + Event::handle('EndShowPageNotice', array($this)); + } + $this->elementEnd('dd'); + $this->elementEnd('dl'); } - $this->elementEnd('dd'); - $this->elementEnd('dl'); } /** From c594d99167c51f9525721e90fc865adad70e2b03 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 12 Jun 2009 19:02:13 -0700 Subject: [PATCH 22/23] Child notices should have thier own ID on their LIs, not the parent's --- actions/conversation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/conversation.php b/actions/conversation.php index 0d7cb9a874..20c68986cb 100644 --- a/actions/conversation.php +++ b/actions/conversation.php @@ -207,7 +207,7 @@ class ConversationTree extends NoticeList // We take responsibility for doing the li $this->out->elementStart('li', array('class' => 'hentry notice', - 'id' => 'notice-' . $this->notice->id)); + 'id' => 'notice-' . $id)); $item = $this->newListItem($notice); $item->show(); From dbbb3a4fb558ee4372e157612f3e053a87a53a8e Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Sat, 13 Jun 2009 00:53:23 -0400 Subject: [PATCH 23/23] Dynamic notice item insertion for conversation page. --- js/util.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/js/util.js b/js/util.js index 786b763eee..fd2500d447 100644 --- a/js/util.js +++ b/js/util.js @@ -203,10 +203,20 @@ $(document).ready(function(){ else { li = $("li", xml).get(0); if ($("#"+li.id).length == 0) { - $("#notices_primary .notices").prepend(document._importNode(li, true)); - $("#notices_primary .notice:first").css({display:"none"}); - $("#notices_primary .notice:first").fadeIn(2500); - NoticeReply(); + var notice_irt_value = $('#notice_in-reply-to').val(); + var notice_irt = '#notices_primary #notice-'+notice_irt_value; + if($('body')[0].id == 'conversation') { + if(notice_irt_value.length > 0 && $(notice_irt+' .notices').length < 1) { + $(notice_irt).append('
    '); + } + $($(notice_irt+' .notices')[0]).append(document._importNode(li, true)); + } + else { + $("#notices_primary .notices").prepend(document._importNode(li, true)); + } + $('#'+li.id).css({display:'none'}); + $('#'+li.id).fadeIn(2500); + NoticeReply(); } } $("#notice_data-text").val(""); @@ -310,4 +320,3 @@ function NoticeAttachments() { } ); } -