3 * StatusNet, the distributed open-source microblogging tool
5 * Show most recent notices that are repeats in user's inbox
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Evan Prodromou <evan@status.net>
25 * @copyright 2009 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('GNUSOCIAL')) { exit(1); }
33 * Show most recent notices that are repeats in user's inbox
37 * @author Evan Prodromou <evan@status.net>
38 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
39 * @link http://status.net/
41 class ApiTimelineRetweetedToMeAction extends ApiAuthAction
43 const DEFAULTCOUNT = 20;
45 const MAXNOTICES = 3200;
48 var $cnt = self::DEFAULTCOUNT;
54 * Take arguments for running
56 * @param array $args $_REQUEST args
58 * @return boolean success flag
60 protected function prepare(array $args=array())
62 parent::prepare($args);
64 $cnt = $this->int('count', self::DEFAULTCOUNT, self::MAXCOUNT, 1);
66 $page = $this->int('page', 1, (self::MAXNOTICES/$this->cnt));
68 $since_id = $this->int('since_id');
70 $max_id = $this->int('max_id');
78 * show a timeline of the user's repeated notices
82 protected function handle()
86 $offset = ($this->page-1) * $this->cnt;
89 // TRANS: Title for Atom feed "repeated to me". %s is the user nickname.
90 $title = sprintf(_("Repeated to %s"), $this->scoped->getNickname());
92 // @todo FIXME: $profile is not defined.
93 // TRANS: Subtitle for API action that shows most recent notices that are repeats in user's inbox.
94 // TRANS: %1$s is the sitename, %2$s is a user nickname, %3$s is a user profile name.
95 _('%1$s notices that were to repeated to %2$s / %3$s.'),
96 $sitename, $this->scoped->getNickname(), $profile->getBestName()
98 $taguribase = TagURI::base();
99 $id = "tag:$taguribase:RepeatedToMe:" . $this->scoped->id;
101 $link = common_local_url(
103 array('nickname' => $this->scoped->getNickname())
106 $strm = $this->scoped->repeatedToMe($offset, $limit, $this->since_id, $this->max_id);
108 switch ($this->format) {
110 $this->showXmlTimeline($strm);
113 $this->showJsonTimeline($strm);
116 header('Content-Type: application/atom+xml; charset=utf-8');
118 $atom = new AtomNoticeFeed($this->scoped->getUser());
121 $atom->setTitle($title);
122 $atom->setSubtitle($subtitle);
123 $atom->setUpdated('now');
124 $atom->addLink($link);
126 $id = $this->arg('id');
128 $atom->setSelfLink($self);
129 $atom->addEntryFromNotices($strm);
131 $this->raw($atom->getString());
135 header('Content-Type: ' . ActivityStreamJSONDocument::CONTENT_TYPE);
136 $doc = new ActivityStreamJSONDocument($this->scoped->getUser());
137 $doc->setTitle($title);
138 $doc->addLink($link, 'alternate', 'text/html');
139 $doc->addItemsFromNotices($strm);
140 $this->raw($doc->asString());
143 // TRANS: Client error displayed when coming across a non-supported API method.
144 $this->clientError(_('API method not found.'), $code = 404);
150 * Return true if read only.
154 * @param array $args other arguments
156 * @return boolean is read only action?
158 function isReadOnly($args)