X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapidirectmessage.php;h=e072e27b8319b925aee1296c6663a79e862cc381;hb=ca4bf541310eb36fae5a69697bba76a2211218f4;hp=f0013c54c5c1353ad2e78eaa135fba8e53f233d0;hpb=b08d16ef2bf5995ca2feee2d2688e0080eaf5124;p=quix0rs-gnu-social.git diff --git a/actions/apidirectmessage.php b/actions/apidirectmessage.php index f0013c54c5..e072e27b83 100644 --- a/actions/apidirectmessage.php +++ b/actions/apidirectmessage.php @@ -21,6 +21,9 @@ * * @category API * @package StatusNet + * @author Adrian Lang + * @author Evan Prodromou + * @author Robin Millette * @author Zach Copley * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 @@ -31,18 +34,20 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apiauth.php'; +require_once INSTALLDIR . '/lib/apiauth.php'; /** * Show a list of direct messages from or to the authenticating user * * @category API * @package StatusNet + * @author Adrian Lang + * @author Evan Prodromou + * @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 ApiDirectMessageAction extends ApiAuthAction { var $messages = null; @@ -58,9 +63,7 @@ class ApiDirectMessageAction extends ApiAuthAction * @param array $args $_REQUEST args * * @return boolean success flag - * */ - function prepare($args) { parent::prepare($args); @@ -68,22 +71,25 @@ class ApiDirectMessageAction extends ApiAuthAction $this->user = $this->auth_user; if (empty($this->user)) { - $this->clientError(_('No such user!'), 404, $this->format); + // TRANS: Client error given when a user was not found (404). + $this->clientError(_('No such user.'), 404, $this->format); return; } $server = common_root_url(); - $taguribase = common_config('integration', 'taguri'); + $taguribase = TagURI::base(); if ($this->arg('sent')) { // Action was called by /api/direct_messages/sent.format $this->title = sprintf( + // TRANS: Title. %s is a user nickname. _("Direct messages from %s"), $this->user->nickname ); $this->subtitle = sprintf( + // TRANS: Subtitle. %s is a user nickname. _("All the direct messages sent from %s"), $this->user->nickname ); @@ -92,10 +98,12 @@ class ApiDirectMessageAction extends ApiAuthAction $this->id = "tag:$taguribase:SentDirectMessages:" . $this->user->id; } else { $this->title = sprintf( + // TRANS: Title. %s is a user nickname. _("Direct messages to %s"), $this->user->nickname ); $this->subtitle = sprintf( + // TRANS: Subtitle. %s is a user nickname. _("All the direct messages sent to %s"), $this->user->nickname ); @@ -118,7 +126,6 @@ class ApiDirectMessageAction extends ApiAuthAction * * @return void */ - function handle($args) { parent::handle($args); @@ -130,7 +137,6 @@ class ApiDirectMessageAction extends ApiAuthAction * * @return void */ - function showMessages() { switch($this->format) { @@ -147,7 +153,8 @@ class ApiDirectMessageAction extends ApiAuthAction $this->showJsonDirectMessages(); break; default: - $this->clientError(_('API method not found!'), $code = 404); + // TRANS: Client error given when an API method was not found (404). + $this->clientError(_('API method not found.'), $code = 404); break; } } @@ -157,7 +164,6 @@ class ApiDirectMessageAction extends ApiAuthAction * * @return array notices */ - function getMessages() { $message = new Message(); @@ -176,11 +182,6 @@ class ApiDirectMessageAction extends ApiAuthAction $message->whereAdd('id > ' . $this->since_id); } - if (!empty($since)) { - $d = date('Y-m-d H:i:s', $this->since); - $message->whereAdd("created > '$d'"); - } - $message->orderBy('created DESC, id DESC'); $message->limit((($this->page - 1) * $this->count), $this->count); $message->find(); @@ -201,7 +202,6 @@ class ApiDirectMessageAction extends ApiAuthAction * * @return boolean true */ - function isReadOnly($args) { return true; @@ -212,7 +212,6 @@ class ApiDirectMessageAction extends ApiAuthAction * * @return string datestamp of the latest notice in the stream */ - function lastModified() { if (!empty($this->messages)) { @@ -227,11 +226,11 @@ class ApiDirectMessageAction extends ApiAuthAction * * @return void */ - function showXmlDirectMessages() { - $this->init_document('xml'); - $this->elementStart('direct-messages', array('type' => 'array')); + $this->initDocument('xml'); + $this->elementStart('direct-messages', array('type' => 'array', + 'xmlns:statusnet' => 'http://status.net/schema/api/1/')); foreach ($this->messages as $m) { $dm_array = $this->directMessageArray($m); @@ -239,7 +238,7 @@ class ApiDirectMessageAction extends ApiAuthAction } $this->elementEnd('direct-messages'); - $this->end_document('xml'); + $this->endDocument('xml'); } /** @@ -247,10 +246,9 @@ class ApiDirectMessageAction extends ApiAuthAction * * @return void */ - function showJsonDirectMessages() { - $this->init_document('json'); + $this->initDocument('json'); $dmsgs = array(); @@ -259,8 +257,8 @@ class ApiDirectMessageAction extends ApiAuthAction array_push($dmsgs, $dm_array); } - $this->show_json_objects($dmsgs); - $this->end_document('json'); + $this->showJsonObjects($dmsgs); + $this->endDocument('json'); } /** @@ -268,10 +266,9 @@ class ApiDirectMessageAction extends ApiAuthAction * * @return void */ - function showRssDirectMessages() { - $this->init_document('rss'); + $this->initDocument('rss'); $this->element('title', null, $this->title); @@ -292,10 +289,10 @@ class ApiDirectMessageAction extends ApiAuthAction foreach ($this->messages as $m) { $entry = $this->rssDirectMessageArray($m); - $this->show_twitter_rss_item($entry); + $this->showTwitterRssItem($entry); } - $this->end_twitter_rss(); + $this->endTwitterRss(); } /** @@ -303,10 +300,9 @@ class ApiDirectMessageAction extends ApiAuthAction * * @return void */ - function showAtomDirectMessages() { - $this->init_document('atom'); + $this->initDocument('atom'); $this->element('title', null, $this->title); $this->element('id', null, $this->id); @@ -334,7 +330,7 @@ class ApiDirectMessageAction extends ApiAuthAction $this->showTwitterAtomEntry($entry); } - $this->end_document('atom'); + $this->endDocument('atom'); } /** @@ -345,7 +341,6 @@ class ApiDirectMessageAction extends ApiAuthAction * * @return string etag */ - function etag() { if (!empty($this->messages)) { @@ -355,6 +350,7 @@ class ApiDirectMessageAction extends ApiAuthAction return '"' . implode( ':', array($this->arg('action'), + common_user_cache_hash($this->auth_user), common_language(), strtotime($this->messages[0]->created), strtotime($this->messages[$last]->created) @@ -365,5 +361,4 @@ class ApiDirectMessageAction extends ApiAuthAction return null; } - }