X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fgroupnoticestream.php;h=2d6e7b37cb4b6328b928e8d69ead7c631c4df739;hb=93524c4be384a9d75cdb4cd3413894bb4e39de6b;hp=a6aa2c352c29f300e3ee9d03d3a7c0ec6992b1f3;hpb=22bf63bb469327f77708d734d7277274ed4735ef;p=quix0rs-gnu-social.git diff --git a/lib/groupnoticestream.php b/lib/groupnoticestream.php index a6aa2c352c..2d6e7b37cb 100644 --- a/lib/groupnoticestream.php +++ b/lib/groupnoticestream.php @@ -1,14 +1,97 @@ -. + * + * @category Stream + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ -class GroupNoticeStream extends CachingNoticeStream +if (!defined('GNUSOCIAL')) { exit(1); } + +/** + * Stream of notices for a group + * + * @category Stream + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ +class GroupNoticeStream extends ScopingNoticeStream { - function __construct($group) + 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) { - parent::__construct(new RawGroupNoticeStream($group), - 'user_group:notice_ids:' . $group->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; } } +/** + * Stream of notices for a group + * + * @category Stream + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ class RawGroupNoticeStream extends NoticeStream { protected $group;