123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class FileNoticeStream extends ScopingNoticeStream
- {
- function __construct($file, Profile $scoped=null)
- {
- parent::__construct(new CachingNoticeStream(new RawFileNoticeStream($file),
- 'file:notice-ids:'.$file->id),
- $scoped);
- }
- }
- class RawFileNoticeStream extends NoticeStream
- {
- protected $file = null;
- function __construct($file)
- {
- $this->file = $file;
- }
-
- function getNoticeIds($offset, $limit, $since_id, $max_id)
- {
- $f2p = new File_to_post();
- $f2p->selectAdd();
- $f2p->selectAdd('post_id');
- $f2p->file_id = $this->file->id;
- Notice::addWhereSinceId($f2p, $since_id, 'post_id', 'modified');
- Notice::addWhereMaxId($f2p, $max_id, 'post_id', 'modified');
- $f2p->orderBy('modified DESC, post_id DESC');
- if (!is_null($offset)) {
- $f2p->limit($offset, $limit);
- }
- $ids = array();
- if ($f2p->find()) {
- while ($f2p->fetch()) {
- $ids[] = $f2p->post_id;
- }
- }
- return $ids;
- }
- }
|