X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fgroupnoticestream.php;h=2d6e7b37cb4b6328b928e8d69ead7c631c4df739;hb=3290227b50582ed29790f0bb10210362ca2f4093;hp=26784458e0ea1c7a7590cd068593098bcc13dab5;hpb=87d46e1ae5e5effcc985021ff5af3f10815f3d3c;p=quix0rs-gnu-social.git diff --git a/lib/groupnoticestream.php b/lib/groupnoticestream.php index 26784458e0..2d6e7b37cb 100644 --- a/lib/groupnoticestream.php +++ b/lib/groupnoticestream.php @@ -28,11 +28,7 @@ * @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 @@ -46,14 +42,43 @@ if (!defined('STATUSNET')) { */ class GroupNoticeStream extends ScopingNoticeStream { - function __construct($group, $profile = -1) + var $group; + + function __construct($group, Profile $scoped=null) { - if (is_int($profile) && $profile == -1) { - $profile = Profile::current(); - } + $this->group = $group; + parent::__construct(new CachingNoticeStream(new RawGroupNoticeStream($group), 'user_group:notice_ids:' . $group->id), - $profile); + $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 ($this->group->force_scope && + (!$this->scoped instanceof Profile || $this->scoped->isMember($this->group))) { + return true; + } + + return false; } }