]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/publicnoticestream.php
Break up stream code to use separate notice stream classes
[quix0rs-gnu-social.git] / lib / publicnoticestream.php
1 <?php
2
3 class PublicNoticeStream extends CachingNoticeStream
4 {
5     function __construct()
6     {
7         parent::__construct(new RawPublicNoticeStream(), 'public');
8     }
9 }
10
11 class RawPublicNoticeStream extends NoticeStream
12 {
13     function getNoticeIds($offset=0, $limit=20, $since_id=0, $max_id=0)
14     {
15         $notice = new Notice();
16
17         $notice->selectAdd(); // clears it
18         $notice->selectAdd('id');
19
20         $notice->orderBy('created DESC, id DESC');
21
22         if (!is_null($offset)) {
23             $notice->limit($offset, $limit);
24         }
25
26         if (common_config('public', 'localonly')) {
27             $notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC);
28         } else {
29             // -1 == blacklisted, -2 == gateway (i.e. Twitter)
30             $notice->whereAdd('is_local !='. Notice::LOCAL_NONPUBLIC);
31             $notice->whereAdd('is_local !='. Notice::GATEWAY);
32         }
33
34         Notice::addWhereSinceId($notice, $since_id);
35         Notice::addWhereMaxId($notice, $max_id);
36
37         $ids = array();
38
39         if ($notice->find()) {
40             while ($notice->fetch()) {
41                 $ids[] = $notice->id;
42             }
43         }
44
45         $notice->free();
46         $notice = NULL;
47
48         return $ids;
49     }
50 }