X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapitimelineuser.php;h=0046c462d71cc7ef5970bdd01147378aa767eb26;hb=c4a8a6776e29a8ba96eec15a3d443ca17889be8b;hp=d50648d7c9098125b179b0aecf29a383e0172455;hpb=743c844084bae75db02570d76694f4e9b79a9aa9;p=quix0rs-gnu-social.git diff --git a/actions/apitimelineuser.php b/actions/apitimelineuser.php index d50648d7c9..0046c462d7 100644 --- a/actions/apitimelineuser.php +++ b/actions/apitimelineuser.php @@ -21,8 +21,15 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To + * @author mac65 + * @author Mike Cochrane + * @author Robin Millette * @author Zach Copley * @copyright 2009 StatusNet, Inc. + * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ @@ -31,7 +38,7 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apibareauth.php'; +require_once INSTALLDIR . '/lib/apibareauth.php'; /** * Returns the most recent notices (default 20) posted by the authenticating @@ -40,15 +47,18 @@ require_once INSTALLDIR.'/lib/apibareauth.php'; * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To + * @author mac65 + * @author Mike Cochrane + * @author Robin Millette * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class ApiTimelineUserAction extends ApiBareAuthAction { - - var $user = null; var $notices = null; /** @@ -57,23 +67,16 @@ class ApiTimelineUserAction extends ApiBareAuthAction * @param array $args $_REQUEST args * * @return boolean success flag - * */ - function prepare($args) { parent::prepare($args); - $this->page = (int)$this->arg('page', 1); - $this->count = (int)$this->arg('count', 20); - $this->max_id = (int)$this->arg('max_id', 0); - $this->since_id = (int)$this->arg('since_id', 0); - $this->since = $this->arg('since'); - $this->user = $this->getTargetUser($this->arg('id')); if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->arg('format')); + // TRANS: Client error displayed requesting most recent notices for a non-existing user. + $this->clientError(_('No such user.'), 404, $this->format); return; } @@ -91,7 +94,6 @@ class ApiTimelineUserAction extends ApiBareAuthAction * * @return void */ - function handle($args) { parent::handle($args); @@ -103,23 +105,20 @@ class ApiTimelineUserAction extends ApiBareAuthAction * * @return void */ - function showTimeline() { $profile = $this->user->getProfile(); - $sitename = common_config('site', 'name'); - $title = sprintf(_("%s timeline"), $this->user->nickname); - $taguribase = common_config('integration', 'taguri'); - $id = "tag:$taguribase:UserTimeline:" . $this->user->id; - $link = common_local_url( + // We'll use the shared params from the Atom stub + // for other feed types. + $atom = new AtomUserNoticeFeed($this->user, $this->auth_user); + + $link = common_local_url( 'showstream', array('nickname' => $this->user->nickname) ); - $subtitle = sprintf( - _('Updates from %1$s on %2$s!'), - $this->user->nickname, $sitename - ); + + $self = $this->getSelfUri(); // FriendFeed's SUP protocol // Also added RSS and Atom feeds @@ -127,38 +126,38 @@ class ApiTimelineUserAction extends ApiBareAuthAction $suplink = common_local_url('sup', null, null, $this->user->id); header('X-SUP-ID: ' . $suplink); - switch($this->arg('format')) { + switch($this->format) { case 'xml': - $this->show_xml_timeline($this->notices); + $this->showXmlTimeline($this->notices); break; case 'rss': - $this->show_rss_timeline( - $this->notices, $title, $link, - $subtitle, $suplink + $this->showRssTimeline( + $this->notices, + $atom->title, + $link, + $atom->subtitle, + $suplink, + $atom->logo, + $self ); break; case 'atom': - if (isset($apidata['api_arg'])) { - $selfuri = common_root_url() . - 'api/statuses/user_timeline/' . - $apidata['api_arg'] . '.atom'; - } else { - $selfuri = common_root_url() . - 'api/statuses/user_timeline.atom'; - } - $this->show_atom_timeline( - $this->notices, $title, $id, $link, - $subtitle, $suplink, $selfuri - ); + header('Content-Type: application/atom+xml; charset=utf-8'); + + $atom->setId($self); + $atom->setSelfLink($self); + $atom->addEntryFromNotices($this->notices); + $this->raw($atom->getString()); + break; case 'json': - $this->show_json_timeline($this->notices); + $this->showJsonTimeline($this->notices); break; default: - $this->clientError(_('API method not found!'), $code = 404); + // TRANS: Client error displayed when trying to handle an unknown API method. + $this->clientError(_('API method not found.'), $code = 404); break; } - } /** @@ -166,14 +165,13 @@ class ApiTimelineUserAction extends ApiBareAuthAction * * @return array notices */ - function getNotices() { $notices = array(); $notice = $this->user->getNotices( ($this->page-1) * $this->count, $this->count, - $this->since_id, $this->max_id, $this->since + $this->since_id, $this->max_id ); while ($notice->fetch()) { @@ -190,7 +188,6 @@ class ApiTimelineUserAction extends ApiBareAuthAction * * @return boolean true */ - function isReadOnly($args) { return true; @@ -201,7 +198,6 @@ class ApiTimelineUserAction extends ApiBareAuthAction * * @return string datestamp of the latest notice in the stream */ - function lastModified() { if (!empty($this->notices) && (count($this->notices) > 0)) { @@ -219,16 +215,15 @@ class ApiTimelineUserAction extends ApiBareAuthAction * * @return string etag */ - function etag() { if (!empty($this->notices) && (count($this->notices) > 0)) { - $last = count($this->notices) - 1; return '"' . implode( ':', array($this->arg('action'), + common_user_cache_hash($this->auth_user), common_language(), $this->user->id, strtotime($this->notices[0]->created), @@ -239,5 +234,4 @@ class ApiTimelineUserAction extends ApiBareAuthAction return null; } - }