3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2011, StatusNet, Inc.
6 * Stream of notices that reference an URL
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Affero General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Affero General Public License for more details.
20 * You should have received a copy of the GNU Affero General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * @author Evan Prodromou <evan@status.net>
26 * @copyright 2011 StatusNet, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
28 * @link http://status.net/
31 if (!defined('GNUSOCIAL')) { exit(1); }
33 class FileNoticeStream extends ScopingNoticeStream
35 function __construct($file, Profile $scoped=null)
37 parent::__construct(new CachingNoticeStream(new RawFileNoticeStream($file),
38 'file:notice-ids:'.$file->id),
44 * Raw stream for a file
48 * @author Evan Prodromou <evan@status.net>
49 * @copyright 2011 StatusNet, Inc.
50 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
51 * @link http://status.net/
54 class RawFileNoticeStream extends NoticeStream
56 protected $file = null;
58 function __construct($file)
64 * Stream of notices linking to this URL
66 * @param integer $offset Offset to show; default is 0
67 * @param integer $limit Limit of notices to show
68 * @param integer $since_id Since this notice
69 * @param integer $max_id Before this notice
71 * @return array ids of notices that link to this file
73 function getNoticeIds($offset, $limit, $since_id, $max_id)
75 $f2p = new File_to_post();
78 $f2p->selectAdd('post_id');
80 $f2p->file_id = $this->file->id;
82 Notice::addWhereSinceId($f2p, $since_id, 'post_id', 'modified');
83 Notice::addWhereMaxId($f2p, $max_id, 'post_id', 'modified');
85 $f2p->orderBy('modified DESC, post_id DESC');
87 if (!is_null($offset)) {
88 $f2p->limit($offset, $limit);
94 while ($f2p->fetch()) {
95 $ids[] = $f2p->post_id;