* @link http://status.net/
*/
-if (!defined('STATUSNET')) {
- // This check helps protect against security problems;
- // your code file can't be executed directly from the web.
- exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
/**
* Stream of notices for a group
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
-class GroupNoticeStream extends ThreadingNoticeStream
+class GroupNoticeStream extends ScopingNoticeStream
{
- function __construct($group, $profile = -1)
+ var $group;
+
+ function __construct($group, Profile $scoped=null)
+ {
+ $this->group = $group;
+
+ parent::__construct(new CachingNoticeStream(new RawGroupNoticeStream($group),
+ 'user_group:notice_ids:' . $group->id),
+ $scoped);
+ }
+
+ 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 (is_int($profile) && $profile == -1) {
- $profile = Profile::current();
+ if ($this->group->force_scope &&
+ (!$this->scoped instanceof Profile || $this->scoped->isMember($this->group))) {
+ return true;
}
- $stream = new ScopingNoticeStream(new CachingNoticeStream(new RawGroupNoticeStream($group),
- 'user_group:notice_ids:' . $group->id),
- $profile);
- parent::__construct($stream);
+ return false;
}
}