123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class FaveNoticeStream extends ScopingNoticeStream
- {
- function __construct(Profile $target, Profile $scoped=null)
- {
- $stream = new RawFaveNoticeStream($target, $scoped);
- if ($target->sameAs($scoped)) {
- $key = 'fave:ids_by_user_own:'.$target->getID();
- } else {
- $key = 'fave:ids_by_user:'.$target->getID();
- }
- parent::__construct(new CachingNoticeStream($stream, $key), $scoped);
- }
- }
- class RawFaveNoticeStream extends NoticeStream
- {
- protected $user_id;
- protected $own;
- protected $selectVerbs = array();
- function __construct(Profile $target, Profile $scoped=null)
- {
- parent::__construct();
- $this->user_id = $target->getID();
- $this->own = $target->sameAs($scoped);
- }
-
- function getNoticeIds($offset, $limit, $since_id, $max_id)
- {
- $fav = new Fave();
- $qry = null;
- if ($this->own) {
- $qry = 'SELECT fave.* FROM fave ';
- $qry .= 'WHERE fave.user_id = ' . $this->user_id . ' ';
- } else {
- $qry = 'SELECT fave.* FROM fave ';
- $qry .= 'INNER JOIN notice ON fave.notice_id = notice.id ';
- $qry .= 'WHERE fave.user_id = ' . $this->user_id . ' ';
- $qry .= 'AND notice.is_local != ' . Notice::GATEWAY . ' ';
- }
- if ($since_id != 0) {
- $qry .= 'AND notice_id > ' . $since_id . ' ';
- }
- if ($max_id != 0) {
- $qry .= 'AND notice_id <= ' . $max_id . ' ';
- }
-
- $qry .= 'ORDER BY modified DESC ';
- if (!is_null($offset)) {
- $qry .= "LIMIT $limit OFFSET $offset";
- }
- $fav->query($qry);
- $ids = array();
- while ($fav->fetch()) {
- $ids[] = $fav->notice_id;
- }
- $fav->free();
- unset($fav);
- return $ids;
- }
- }
|