]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/conversationnoticestream.php
Merge branch 'limitdist' into limitdist2
[quix0rs-gnu-social.git] / lib / conversationnoticestream.php
1 <?php
2
3 class ConversationNoticeStream extends CachingNoticeStream
4 {
5     function __construct($id)
6     {
7         parent::__construct(new RawConversationNoticeStream($id),
8                             'notice:conversation_ids:'.$id);
9     }
10 }
11
12 class RawConversationNoticeStream extends NoticeStream
13 {
14     protected $id;
15
16     function __construct($id)
17     {
18         $this->id = $id;
19     }
20
21     function getNoticeIds($offset=0, $limit=20, $since_id=0, $max_id=0)
22     {
23         $notice = new Notice();
24
25         $notice->selectAdd(); // clears it
26         $notice->selectAdd('id');
27
28         $notice->conversation = $this->id;
29
30         $notice->orderBy('created DESC, id DESC');
31
32         if (!is_null($offset)) {
33             $notice->limit($offset, $limit);
34         }
35
36         Notice::addWhereSinceId($notice, $since_id);
37         Notice::addWhereMaxId($notice, $max_id);
38
39         $ids = array();
40
41         if ($notice->find()) {
42             while ($notice->fetch()) {
43                 $ids[] = $notice->id;
44             }
45         }
46
47         $notice->free();
48         $notice = NULL;
49
50         return $ids;
51     }
52 }