3 * StatusNet, the distributed open-source microblogging tool
5 * Show authenticating user's most recent notices that have been repeated
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('STATUSNET')) {
34 require_once INSTALLDIR . '/lib/apiauth.php';
35 require_once INSTALLDIR . '/lib/mediafile.php';
38 * Show authenticating user's most recent notices that have been repeated
42 * @author Evan Prodromou <evan@status.net>
43 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
44 * @link http://status.net/
46 class ApiTimelineRetweetsOfMeAction extends ApiAuthAction
48 const DEFAULTCOUNT = 20;
50 const MAXNOTICES = 3200;
53 var $cnt = self::DEFAULTCOUNT;
59 * Take arguments for running
61 * @param array $args $_REQUEST args
63 * @return boolean success flag
65 function prepare($args)
67 parent::prepare($args);
69 $cnt = $this->int('count', self::DEFAULTCOUNT, self::MAXCOUNT, 1);
71 $page = $this->int('page', 1, (self::MAXNOTICES/$this->cnt));
73 $since_id = $this->int('since_id');
75 $max_id = $this->int('max_id');
83 * show a timeline of the user's repeated notices
85 * @param array $args $_REQUEST data (unused)
89 function handle($args)
91 parent::handle($args);
93 $offset = ($this->page-1) * $this->cnt;
96 // TRANS: Title of list of repeated notices of the logged in user.
97 // TRANS: %s is the nickname of the logged in user.
98 $title = sprintf(_("Repeats of %s"), $this->auth_user->nickname);
99 $sitename = common_config('site', 'name');
101 $profile = $this->auth_user->getProfile();
104 // TRANS: Subtitle of API time with retweets of me.
105 // TRANS: %1$s is the StatusNet sitename, %2$s is the user nickname, %3$s is the user profile name.
106 _('%1$s notices that %2$s / %3$s has repeated.'),
107 $sitename, $this->auth_user->nickname, $profile->getBestName()
110 $taguribase = TagURI::base();
111 $id = "tag:$taguribase:RepeatsOfMe:" . $this->auth_user->id;
113 $link = common_local_url(
115 array('nickname' => $this->auth_user->nickname)
118 // This is a really bad query for some reason
120 if (!common_config('performance', 'high')) {
121 $strm = $this->auth_user->repeatsOfMe($offset, $limit, $this->since_id, $this->max_id);
123 $strm = new Notice();
124 $strm->whereAdd('0 = 1');
128 switch ($this->format) {
130 $this->showXmlTimeline($strm);
133 $this->showJsonTimeline($strm);
136 header('Content-Type: application/atom+xml; charset=utf-8');
137 $atom = new AtomNoticeFeed($this->auth_user);
139 $atom->setTitle($title);
140 $atom->setSubtitle($subtitle);
141 $atom->setUpdated('now');
142 $atom->addLink($link);
143 $atom->setSelfLink($this->getSelfUri());
144 $atom->addEntryFromNotices($strm);
145 $this->raw($atom->getString());
148 header('Content-Type: ' . ActivityStreamJSONDocument::CONTENT_TYPE);
149 $doc = new ActivityStreamJSONDocument($this->auth_user);
150 $doc->setTitle($title);
151 $doc->addLink($link, 'alternate', 'text/html');
152 $doc->addItemsFromNotices($strm);
153 $this->raw($doc->asString());
156 // TRANS: Client error displayed when coming across a non-supported API method.
157 $this->clientError(_('API method not found.'), 404);
163 * Return true if read only.
167 * @param array $args other arguments
169 * @return boolean is read only action?
171 function isReadOnly($args)