From c08a67094cb848e8bcd8f631aa44adf57a33b7ab Mon Sep 17 00:00:00 2001 From: mac65 Date: Tue, 30 Sep 2008 20:12:33 -0400 Subject: Add support for since_id and before_id to Twitter API. Ticket #540. darcs-hash:20081001001233-e558a-3fcc269985050021ec9b44c052206c731cc4689d.gz --- classes/Notice.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'classes/Notice.php') diff --git a/classes/Notice.php b/classes/Notice.php index 7566136ce..cb153a2e5 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -308,12 +308,38 @@ class Notice extends Memcached_DataObject return $wrapper; } - function publicStream($offset=0, $limit=20) { + function publicStream($offset=0, $limit=20, $since_id=0, $before_id=0) { + $needAnd = FALSE; + $needWhere = TRUE; + $qry = 'SELECT * FROM notice '; if (common_config('public', 'localonly')) { $qry .= ' WHERE is_local = 1 '; + $needWhere = FALSE; + $needAnd = TRUE; + } + + // NOTE: since_id and before_id are extensions to Twitter API + if ($since_id > 0) { + if ($needWhere) + $qry .= ' WHERE '; + if ($needAnd) + $qry .= ' AND '; + $qry .= ' notice.id > ' . $since_id . ' '; + $needAnd = FALSE; + $needWhere = FALSE; + } + + if ($before_id > 0) { + if ($needWhere) + $qry .= ' WHERE '; + if ($needAnd) + $qry .= ' AND '; + $qry .= ' notice.id < ' . $before_id . ' '; + $needAnd = FALSE; + $needWhere = FALSE; } return Notice::getStream($qry, -- cgit v1.2.3-54-g00ecf