* @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); }
/**
* Class for notice streams
*/
abstract class NoticeStream
{
+ protected $selectVerbs = array(ActivityVerb::POST => true,
+ ActivityVerb::SHARE => true);
+
+ 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)
{
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);
+ }
}