X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Freplynoticestream.php;h=9eb188d54db2d43d0105a4ea48d2b395b911f64d;hb=543d968b81b97c9ebd46de063d8d70621c12015b;hp=9de8d4efaf9c49ca62b17e48e819537c2f7b4dba;hpb=c1fd36c043d97dff7e16f209e7798813c297db64;p=quix0rs-gnu-social.git diff --git a/lib/replynoticestream.php b/lib/replynoticestream.php index 9de8d4efaf..9eb188d54d 100644 --- a/lib/replynoticestream.php +++ b/lib/replynoticestream.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 mentions of me @@ -47,10 +43,14 @@ if (!defined('STATUSNET')) { class ReplyNoticeStream extends ScopingNoticeStream { - function __construct($userId) + function __construct($userId, $profile=-1) { + if (is_int($profile) && $profile == -1) { + $profile = Profile::current(); + } parent::__construct(new CachingNoticeStream(new RawReplyNoticeStream($userId), - 'reply:stream:' . $userId)); + 'reply:stream:' . $userId), + $profile); } } @@ -71,18 +71,40 @@ class RawReplyNoticeStream extends NoticeStream function __construct($userId) { + parent::__construct(); $this->userId = $userId; } function getNoticeIds($offset, $limit, $since_id, $max_id) { $reply = new Reply(); - $reply->profile_id = $this->userId; - Notice::addWhereSinceId($reply, $since_id, 'notice_id', 'modified'); - Notice::addWhereMaxId($reply, $max_id, 'notice_id', 'modified'); + $reply->selectAdd(); + $reply->selectAdd('notice_id'); + + $reply->whereAdd(sprintf('reply.profile_id = %u', $this->userId)); + + Notice::addWhereSinceId($reply, $since_id, 'notice_id', 'reply.modified'); + Notice::addWhereMaxId($reply, $max_id, 'notice_id', 'reply.modified'); + + if (!empty($this->selectVerbs)) { + // this is a little special since we have to join in Notice + $reply->joinAdd(array('notice_id', 'notice:id')); - $reply->orderBy('modified DESC, notice_id DESC'); + $filter = array_keys(array_filter($this->selectVerbs)); + if (!empty($filter)) { + // include verbs in selectVerbs with values that equate to true + $reply->whereAddIn('notice.verb', $filter, 'string'); + } + + $filter = array_keys(array_filter($this->selectVerbs, function ($v) { return !$v; })); + if (!empty($filter)) { + // exclude verbs in selectVerbs with values that equate to false + $reply->whereAddIn('!notice.verb', $filter, 'string'); + } + } + + $reply->orderBy('reply.modified DESC, reply.notice_id DESC'); if (!is_null($offset)) { $reply->limit($offset, $limit); @@ -98,4 +120,4 @@ class RawReplyNoticeStream extends NoticeStream return $ids; } -} \ No newline at end of file +}