From d7f96307dc84b49cce11f63260002dc77ef9641f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 11 Apr 2011 12:32:35 -0400 Subject: [PATCH] all filtering stream classes take an optional profile parameter --- lib/conversationnoticestream.php | 6 +++++- lib/favenoticestream.php | 8 ++++++-- lib/filenoticestream.php | 8 ++++++-- lib/groupnoticestream.php | 5 ++++- lib/inboxnoticestream.php | 5 ++++- lib/peopletagnoticestream.php | 8 ++++++-- lib/profilenoticestream.php | 8 ++++++-- lib/repeatedbymenoticestream.php | 8 ++++++-- lib/repeatsofmenoticestream.php | 8 ++++++-- lib/replynoticestream.php | 8 ++++++-- lib/taggedprofilenoticestream.php | 8 ++++++-- lib/tagnoticestream.php | 5 ++++- 12 files changed, 65 insertions(+), 20 deletions(-) diff --git a/lib/conversationnoticestream.php b/lib/conversationnoticestream.php index 56850fe982..66075db84f 100644 --- a/lib/conversationnoticestream.php +++ b/lib/conversationnoticestream.php @@ -46,8 +46,12 @@ if (!defined('STATUSNET')) { */ class ConversationNoticeStream extends ScopingNoticeStream { - function __construct($id, $profile = null) + function __construct($id, $profile = -1) { + if (is_int($profile) && $profile == -1) { + $profile = Profile::current(); + } + parent::__construct(new CachingNoticeStream(new RawConversationNoticeStream($id), 'notice:conversation_ids:'.$id), $profile); diff --git a/lib/favenoticestream.php b/lib/favenoticestream.php index b586a94d17..6527e5441e 100644 --- a/lib/favenoticestream.php +++ b/lib/favenoticestream.php @@ -46,7 +46,7 @@ if (!defined('STATUSNET')) { */ class FaveNoticeStream extends ScopingNoticeStream { - function __construct($user_id, $own) + function __construct($user_id, $own, $profile = -1) { $stream = new RawFaveNoticeStream($user_id, $own); if ($own) { @@ -54,7 +54,11 @@ class FaveNoticeStream extends ScopingNoticeStream } else { $key = 'fave:ids_by_user:'.$user_id; } - parent::__construct(new CachingNoticeStream($stream, $key)); + if (is_int($profile) && $profile == -1) { + $profile = Profile::current(); + } + parent::__construct(new CachingNoticeStream($stream, $key), + $profile); } } diff --git a/lib/filenoticestream.php b/lib/filenoticestream.php index 2b5e53eaf7..fba6183fc2 100644 --- a/lib/filenoticestream.php +++ b/lib/filenoticestream.php @@ -36,10 +36,14 @@ if (!defined('STATUSNET')) { class FileNoticeStream extends ScopingNoticeStream { - function __construct($file) + function __construct($file, $profile = -1) { + if (is_int($profile) && $profile == -1) { + $profile = Profile::current(); + } parent::__construct(new CachingNoticeStream(new RawFileNoticeStream($file), - 'file:notice-ids:'.$this->url)); + 'file:notice-ids:'.$this->url), + $profile); } } diff --git a/lib/groupnoticestream.php b/lib/groupnoticestream.php index 930afe6081..26784458e0 100644 --- a/lib/groupnoticestream.php +++ b/lib/groupnoticestream.php @@ -46,8 +46,11 @@ if (!defined('STATUSNET')) { */ class GroupNoticeStream extends ScopingNoticeStream { - function __construct($group, $profile = null) + function __construct($group, $profile = -1) { + if (is_int($profile) && $profile == -1) { + $profile = Profile::current(); + } parent::__construct(new CachingNoticeStream(new RawGroupNoticeStream($group), 'user_group:notice_ids:' . $group->id), $profile); diff --git a/lib/inboxnoticestream.php b/lib/inboxnoticestream.php index 09c3edb281..3250351d17 100644 --- a/lib/inboxnoticestream.php +++ b/lib/inboxnoticestream.php @@ -51,8 +51,11 @@ class InboxNoticeStream extends ScopingNoticeStream * * @param User $user User to get a stream for */ - function __construct($user, $profile = null) + function __construct($user, $profile = -1) { + if (is_int($profile) && $profile == -1) { + $profile = Profile::current(); + } // Note: we don't use CachingNoticeStream since RawInboxNoticeStream // uses Inbox::staticGet(), which is cached. parent::__construct(new RawInboxNoticeStream($user), $profile); diff --git a/lib/peopletagnoticestream.php b/lib/peopletagnoticestream.php index 34e7443da5..5eed25412f 100644 --- a/lib/peopletagnoticestream.php +++ b/lib/peopletagnoticestream.php @@ -47,10 +47,14 @@ if (!defined('STATUSNET')) { */ class PeopletagNoticeStream extends ScopingNoticeStream { - function __construct($plist) + function __construct($plist, $profile = -1) { + if (is_int($profile) && $profile == -1) { + $profile = Profile::current(); + } parent::__construct(new CachingNoticeStream(new RawPeopletagNoticeStream($plist), - 'profile_tag:notice_ids:' . $plist->id)); + 'profile_tag:notice_ids:' . $plist->id), + $profile); } } diff --git a/lib/profilenoticestream.php b/lib/profilenoticestream.php index 7ea653f8c8..64cd31abc4 100644 --- a/lib/profilenoticestream.php +++ b/lib/profilenoticestream.php @@ -47,10 +47,14 @@ if (!defined('STATUSNET')) { class ProfileNoticeStream extends ScopingNoticeStream { - function __construct($profile) + function __construct($profile, $userProfile = -1) { + if (is_int($userProfile) && $userProfile == -1) { + $userProfile = Profile::current(); + } parent::__construct(new CachingNoticeStream(new RawProfileNoticeStream($profile), - 'profile:notice_ids:' . $profile->id)); + 'profile:notice_ids:' . $profile->id), + $userProfile); } } diff --git a/lib/repeatedbymenoticestream.php b/lib/repeatedbymenoticestream.php index 98c1583d6a..4e3e34162b 100644 --- a/lib/repeatedbymenoticestream.php +++ b/lib/repeatedbymenoticestream.php @@ -47,10 +47,14 @@ if (!defined('STATUSNET')) { class RepeatedByMeNoticeStream extends ScopingNoticeStream { - function __construct($user) + function __construct($user, $profile = -1) { + if (is_int($profile) && $profile == -1) { + $profile = Profile::current(); + } parent::__construct(new CachingNoticeStream(new RawRepeatedByMeNoticeStream($user), - 'user:repeated_by_me:'.$user->id)); + 'user:repeated_by_me:'.$user->id), + $profile); } } diff --git a/lib/repeatsofmenoticestream.php b/lib/repeatsofmenoticestream.php index f51fc9e447..ec80d84314 100644 --- a/lib/repeatsofmenoticestream.php +++ b/lib/repeatsofmenoticestream.php @@ -47,10 +47,14 @@ if (!defined('STATUSNET')) { class RepeatsOfMeNoticeStream extends ScopingNoticeStream { - function __construct($user) + function __construct($user, $profile=-1) { + if (is_int($profile) && $profile == -1) { + $profile = Profile::current(); + } parent::__construct(new CachingNoticeStream(new RawRepeatsOfMeNoticeStream($user), - 'user:repeats_of_me:'.$user->id)); + 'user:repeats_of_me:'.$user->id), + $profile); } } diff --git a/lib/replynoticestream.php b/lib/replynoticestream.php index 9de8d4efaf..ec13ff9a67 100644 --- a/lib/replynoticestream.php +++ b/lib/replynoticestream.php @@ -47,10 +47,14 @@ if (!defined('STATUSNET')) { class ReplyNoticeStream extends ScopingNoticeStream { - function __construct($userId) + function __construct($userId, $profile=-1) { + if (is_int($profile) && $profile == -1) { + $profile = Profile::current(); + } parent::__construct(new CachingNoticeStream(new RawReplyNoticeStream($userId), - 'reply:stream:' . $userId)); + 'reply:stream:' . $userId), + $profile); } } diff --git a/lib/taggedprofilenoticestream.php b/lib/taggedprofilenoticestream.php index 83c304ed8f..9998b7d769 100644 --- a/lib/taggedprofilenoticestream.php +++ b/lib/taggedprofilenoticestream.php @@ -47,10 +47,14 @@ if (!defined('STATUSNET')) { class TaggedProfileNoticeStream extends ScopingNoticeStream { - function __construct($profile, $tag) + function __construct($profile, $tag, $userProfile) { + if (is_int($userProfile) && $userProfile == -1) { + $userProfile = Profile::current(); + } parent::__construct(new CachingNoticeStream(new RawTaggedProfileNoticeStream($profile, $tag), - 'profile:notice_ids_tagged:'.$profile->id.':'.Cache::keyize($tag))); + 'profile:notice_ids_tagged:'.$profile->id.':'.Cache::keyize($tag)), + $userProfile); } } diff --git a/lib/tagnoticestream.php b/lib/tagnoticestream.php index 1dcf9f14bb..567f04b7e4 100644 --- a/lib/tagnoticestream.php +++ b/lib/tagnoticestream.php @@ -47,8 +47,11 @@ if (!defined('STATUSNET')) { class TagNoticeStream extends ScopingNoticeStream { - function __construct($tag) + function __construct($tag, $profile = -1) { + if (is_int($profile) && $profile == -1) { + $profile = Profile::current(); + } parent::__construct(new CachingNoticeStream(new RawTagNoticeStream($tag), 'notice_tag:notice_ids:' . Cache::keyize($tag))); }