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