X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fgroupnoticestream.php;h=723f064cb3523dab13b8de075fbd66b0e140ff1a;hb=e6a342b2a2edfcc9f276e172170fc0b3eb07b61d;hp=22d94d0482fcc7f1ee54884dfc692473f41ec3e0;hpb=9f1603462dce7a24d432698c4f46d7dcf1bf7c4f;p=quix0rs-gnu-social.git diff --git a/lib/groupnoticestream.php b/lib/groupnoticestream.php index 22d94d0482..723f064cb3 100644 --- a/lib/groupnoticestream.php +++ b/lib/groupnoticestream.php @@ -46,10 +46,48 @@ if (!defined('STATUSNET')) { */ class GroupNoticeStream extends ScopingNoticeStream { - function __construct($group) + var $group; + var $userProfile; + + function __construct($group, $profile = -1) { + if (is_int($profile) && $profile == -1) { + $profile = Profile::current(); + } + $this->group = $group; + $this->userProfile = $profile; + parent::__construct(new CachingNoticeStream(new RawGroupNoticeStream($group), - 'user_group:notice_ids:' . $group->id)); + 'user_group:notice_ids:' . $group->id), + $profile); + } + + function getNoticeIds($offset, $limit, $since_id, $max_id) + { + if ($this->impossibleStream()) { + return array(); + } else { + return parent::getNoticeIds($offset, $limit, $since_id, $max_id); + } + } + + function getNotices($offset, $limit, $sinceId = null, $maxId = null) + { + if ($this->impossibleStream()) { + return new ArrayWrapper(array()); + } else { + return parent::getNotices($offset, $limit, $sinceId, $maxId); + } + } + + function impossibleStream() + { + if ($this->group->force_scope && + (empty($this->userProfile) || !$this->userProfile->isMember($this->group))) { + return true; + } + + return false; } }