]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/groupnoticestream.php
Break up stream code to use separate notice stream classes
[quix0rs-gnu-social.git] / lib / groupnoticestream.php
1 <?
2
3 class GroupNoticeStream extends CachingNoticeStream
4 {
5     function __construct($group)
6     {
7         parent::__construct(new RawGroupNoticeStream($group),
8                             'user_group:notice_ids:' . $group->id);
9     }
10 }
11
12 class RawGroupNoticeStream extends NoticeStream
13 {
14     protected $group;
15
16     function __construct($group)
17     {
18         $this->group = $group;
19     }
20
21     function getNoticeIds($offset, $limit, $since_id, $max_id)
22     {
23         $inbox = new Group_inbox();
24
25         $inbox->group_id = $this->group->id;
26
27         $inbox->selectAdd();
28         $inbox->selectAdd('notice_id');
29
30         Notice::addWhereSinceId($inbox, $since_id, 'notice_id');
31         Notice::addWhereMaxId($inbox, $max_id, 'notice_id');
32
33         $inbox->orderBy('created DESC, notice_id DESC');
34
35         if (!is_null($offset)) {
36             $inbox->limit($offset, $limit);
37         }
38
39         $ids = array();
40
41         if ($inbox->find()) {
42             while ($inbox->fetch()) {
43                 $ids[] = $inbox->notice_id;
44             }
45         }
46
47         return $ids;
48     }
49 }