*
* @category API
* @package StatusNet
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <robin@millette.info>
* @author Zach Copley <zach@status.net>
* @copyright 2009 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
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 <mail@adrianlang.de>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <robin@millette.info>
* @author Zach Copley <zach@status.net>
* @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;
- var $page = null;
- var $count = null;
- var $max_id = null;
- var $since_id = null;
- var $since = null;
var $title = null;
var $subtitle = null;
var $link = null;
* @param array $args $_REQUEST args
*
* @return boolean success flag
- *
*/
-
function prepare($args)
{
parent::prepare($args);
- if ($this->requiresAuth()) {
- if ($this->checkBasicAuthUser() == false) {
- return;
- }
- }
-
$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;
}
- $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');
-
$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
);
$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
);
*
* @return void
*/
-
function handle($args)
{
parent::handle($args);
*
* @return void
*/
-
function showMessages()
{
switch($this->format) {
$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;
}
}
*
* @return array notices
*/
-
function getMessages()
{
$message = new Message();
$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();
*
* @return boolean true
*/
-
function isReadOnly($args)
{
return true;
*
* @return string datestamp of the latest notice in the stream
*/
-
function lastModified()
{
if (!empty($this->messages)) {
*
* @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);
}
$this->elementEnd('direct-messages');
- $this->end_document('xml');
+ $this->endDocument('xml');
}
/**
*
* @return void
*/
-
function showJsonDirectMessages()
{
- $this->init_document('json');
+ $this->initDocument('json');
$dmsgs = array();
array_push($dmsgs, $dm_array);
}
- $this->show_json_objects($dmsgs);
- $this->end_document('json');
+ $this->showJsonObjects($dmsgs);
+ $this->endDocument('json');
}
/**
*
* @return void
*/
-
function showRssDirectMessages()
{
- $this->init_document('rss');
+ $this->initDocument('rss');
$this->element('title', null, $this->title);
foreach ($this->messages as $m) {
$entry = $this->rssDirectMessageArray($m);
- $this->show_twitter_rss_item($entry);
+ $this->showTwitterRssItem($entry);
}
- $this->end_twitter_rss();
+ $this->endTwitterRss();
}
/**
*
* @return void
*/
-
function showAtomDirectMessages()
{
- $this->init_document('atom');
+ $this->initDocument('atom');
$this->element('title', null, $this->title);
$this->element('id', null, $this->id);
$this->showTwitterAtomEntry($entry);
}
- $this->end_document('atom');
+ $this->endDocument('atom');
}
/**
*
* @return string etag
*/
-
function etag()
{
if (!empty($this->messages)) {
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)
return null;
}
-
}