]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apidirectmessage.php
Merge remote branch 'statusnet/1.0.x' into irc-plugin
[quix0rs-gnu-social.git] / actions / apidirectmessage.php
index 87ae44d7a5d53dd9e36a90774f3b29e055cd3208..7a0f46274cbde24478e222da8bdcbbce2bd50f1a 100644 (file)
@@ -21,6 +21,9 @@
  *
  * @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
@@ -31,13 +34,16 @@ 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 <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/
@@ -45,13 +51,7 @@ require_once INSTALLDIR.'/lib/apiauth.php';
 
 class ApiDirectMessageAction extends ApiAuthAction
 {
-    var $format       = null;
     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;
@@ -71,27 +71,15 @@ class ApiDirectMessageAction extends ApiAuthAction
     {
         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);
+            $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')) {
 
@@ -122,8 +110,6 @@ class ApiDirectMessageAction extends ApiAuthAction
             $this->id = "tag:$taguribase:DirectMessages:" . $this->user->id;
         }
 
-        $this->format = $this->arg('format');
-
         $this->messages = $this->getMessages();
 
         return true;
@@ -167,7 +153,7 @@ class ApiDirectMessageAction extends ApiAuthAction
             $this->showJsonDirectMessages();
             break;
         default:
-            $this->clientError(_('API method not found!'), $code = 404);
+            $this->clientError(_('API method not found.'), $code = 404);
             break;
         }
     }
@@ -196,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();
@@ -250,8 +231,9 @@ class ApiDirectMessageAction extends ApiAuthAction
 
     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);
@@ -259,7 +241,7 @@ class ApiDirectMessageAction extends ApiAuthAction
         }
 
         $this->elementEnd('direct-messages');
-        $this->end_document('xml');
+        $this->endDocument('xml');
     }
 
     /**
@@ -270,7 +252,7 @@ class ApiDirectMessageAction extends ApiAuthAction
 
     function showJsonDirectMessages()
     {
-        $this->init_document('json');
+        $this->initDocument('json');
 
         $dmsgs = array();
 
@@ -279,8 +261,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');
     }
 
     /**
@@ -291,7 +273,7 @@ class ApiDirectMessageAction extends ApiAuthAction
 
     function showRssDirectMessages()
     {
-        $this->init_document('rss');
+        $this->initDocument('rss');
 
         $this->element('title', null, $this->title);
 
@@ -312,10 +294,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();
     }
 
     /**
@@ -326,7 +308,7 @@ class ApiDirectMessageAction extends ApiAuthAction
 
     function showAtomDirectMessages()
     {
-        $this->init_document('atom');
+        $this->initDocument('atom');
 
         $this->element('title', null, $this->title);
         $this->element('id', null, $this->id);
@@ -354,7 +336,7 @@ class ApiDirectMessageAction extends ApiAuthAction
             $this->showTwitterAtomEntry($entry);
         }
 
-        $this->end_document('atom');
+        $this->endDocument('atom');
     }
 
     /**