123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class ReplyNoticeStream extends ScopingNoticeStream
- {
- function __construct($userId, Profile $scoped=null)
- {
- parent::__construct(new CachingNoticeStream(new RawReplyNoticeStream($userId),
- 'reply:stream:' . $userId),
- $scoped);
- }
- }
- class RawReplyNoticeStream extends NoticeStream
- {
- protected $userId;
- function __construct($userId)
- {
- parent::__construct();
- $this->userId = $userId;
- }
- function getNoticeIds($offset, $limit, $since_id, $max_id)
- {
- $reply = new Reply();
- $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)) {
-
- $reply->joinAdd(array('notice_id', 'notice:id'));
- $filter = array_keys(array_filter($this->selectVerbs));
- if (!empty($filter)) {
-
- $reply->whereAddIn('notice.verb', $filter, 'string');
- }
- $filter = array_keys(array_filter($this->selectVerbs, function ($v) { return !$v; }));
- if (!empty($filter)) {
-
- $reply->whereAddIn('!notice.verb', $filter, 'string');
- }
- }
- $reply->orderBy('reply.modified DESC, reply.notice_id DESC');
- if (!is_null($offset)) {
- $reply->limit($offset, $limit);
- }
- $ids = array();
- if ($reply->find()) {
- while ($reply->fetch()) {
- $ids[] = $reply->notice_id;
- }
- }
- return $ids;
- }
- }
|