summaryrefslogtreecommitdiff
path: root/classes/Profile.php
diff options
context:
space:
mode:
authorRobin Millette <millette@controlyourself.ca>2009-05-18 17:18:57 -0400
committerRobin Millette <millette@controlyourself.ca>2009-05-18 17:18:57 -0400
commit0271859c2425daff6fbaeac74aee6d6a9fcdce16 (patch)
treea93565653ec11237b71a2bcf87d6fbe2fcbcb9f8 /classes/Profile.php
parent5897dfa4c37d6a44bcde5dc7569c8b0d30f21b84 (diff)
Added personal tag page: http://example.com/MY_NICK/tag/A_TAG
Diffstat (limited to 'classes/Profile.php')
-rw-r--r--classes/Profile.php54
1 files changed, 51 insertions, 3 deletions
diff --git a/classes/Profile.php b/classes/Profile.php
index ae5641d79..afc0ea4f7 100644
--- a/classes/Profile.php
+++ b/classes/Profile.php
@@ -153,18 +153,66 @@ class Profile extends Memcached_DataObject
return null;
}
- function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
+ function getTaggedNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null, $tag=null)
+ {
+ // XXX: I'm not sure this is going to be any faster. It probably isn't.
+ $ids = Notice::stream(array($this, '_streamTaggedDirect'),
+ array(),
+ 'profile:notice_ids:' . $this->id,
+ $offset, $limit, $since_id, $before_id, $since, $tag);
+ common_debug(print_r($ids, true));
+ return Notice::getStreamByIds($ids);
+ }
+
+ function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
{
// XXX: I'm not sure this is going to be any faster. It probably isn't.
$ids = Notice::stream(array($this, '_streamDirect'),
array(),
'profile:notice_ids:' . $this->id,
- $offset, $limit, $since_id, $before_id);
+ $offset, $limit, $since_id, $before_id, $since);
return Notice::getStreamByIds($ids);
}
- function _streamDirect($offset, $limit, $since_id, $before_id, $since)
+ function _streamTaggedDirect($offset, $limit, $since_id, $before_id, $since=null, $tag=null)
+ {
+ common_debug('_streamTaggedDirect()');
+ $notice = new Notice();
+ $notice->profile_id = $this->id;
+ $query = "select id from notice join notice_tag on id=notice_id where tag='" . $notice->escape($tag) . "' and profile_id=" . $notice->escape($notice->profile_id);
+ if ($since_id != 0) {
+ $query .= " and id > $since_id";
+ }
+
+ if ($before_id != 0) {
+ $query .= " and id < $before_id";
+ }
+
+ if (!is_null($since)) {
+ $query .= " and created > '" . date('Y-m-d H:i:s', $since) . "'";
+ }
+
+ $query .= ' order by id DESC';
+
+ if (!is_null($offset)) {
+ $query .= " limit $offset, $limit";
+ }
+ $notice->query($query);
+ $ids = array();
+
+ while ($notice->fetch()) {
+ common_debug(print_r($notice, true));
+ $ids[] = $notice->id;
+ }
+
+ return $ids;
+ }
+
+
+
+
+ function _streamDirect($offset, $limit, $since_id, $before_id, $since = null)
{
$notice = new Notice();