. * * @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/ */ if (!defined('GNUSOCIAL')) { exit(1); } /** * Class for notice streams * * @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/ */ abstract class NoticeStream { protected $selectVerbs = array(ActivityVerb::POST => true, ActivityVerb::DELETE => false); public function __construct() { foreach ($this->selectVerbs as $key=>$val) { // to avoid database inconsistency issues we select both relative and absolute verbs $this->selectVerbs[ActivityUtils::resolveUri($key)] = $val; $this->selectVerbs[ActivityUtils::resolveUri($key, true)] = $val; } } abstract function getNoticeIds($offset, $limit, $since_id, $max_id); function getNotices($offset, $limit, $sinceId = null, $maxId = null) { $ids = $this->getNoticeIds($offset, $limit, $sinceId, $maxId); $notices = self::getStreamByIds($ids); return $notices; } static function getStreamByIds($ids) { return Notice::multiGet('id', $ids); } static function filterVerbs(Notice $notice, array $selectVerbs) { $filter = array_keys(array_filter($selectVerbs)); if (!empty($filter)) { // include verbs in selectVerbs with values that equate to true $notice->whereAddIn('verb', $filter, $notice->columnType('verb')); } $filter = array_keys(array_filter($selectVerbs, function ($v) { return !$v; })); if (!empty($filter)) { // exclude verbs in selectVerbs with values that equate to false $notice->whereAddIn('!verb', $filter, $notice->columnType('verb')); } unset($filter); } }