]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/newmessage.php
Some files got updated coding style
[quix0rs-gnu-social.git] / actions / newmessage.php
index 4ff9d8e9e93f627b96e060026f914095b97d1f63..96ada1cee8ef1d72249b5d66c6a37d07b5f6fa58 100644 (file)
  * @author    Zach Copley <zach@status.net>
  * @author    Sarven Capadisli <csarven@status.net>
  * @copyright 2008-2009 StatusNet, Inc.
+ * @copyright 2013 Free Software Foundation, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) {
+if (!defined('STATUSNET')) {
     exit(1);
 }
 
@@ -73,14 +74,10 @@ class NewmessageAction extends FormAction
      * @return void
      */
 
-    protected function prepare($args)
+    protected function prepare(array $args=array())
     {
         parent::prepare($args);
 
-        if (!common_logged_in()) {
-            $this->needLogin();
-        }
-
         $user = $this->scoped->getUser();
 
         $this->content = $this->trimmed('content');
@@ -135,13 +132,13 @@ class NewmessageAction extends FormAction
             // TRANS: Client error displayed trying to send a direct message to a user while sender and
             // TRANS: receiver are not subscribed to each other.
             $this->clientError(_('You cannot send a message to this user.'), 404);
-        } else if ($user->id == $this->other->id) {
+        } else if ($this->scoped->id == $this->other->id) {
             // TRANS: Client error displayed trying to send a direct message to self.
             $this->clientError(_('Do not send a message to yourself; ' .
                 'just say it to yourself quietly instead.'), 403);
         }
 
-        $message = Message::saveNew($user->id, $this->other->id, $this->content, 'web');
+        $message = Message::saveNew($this->scoped->id, $this->other->id, $this->content, 'web');
         $message->notify();
 
         if ($this->boolean('ajax')) {
@@ -157,10 +154,10 @@ class NewmessageAction extends FormAction
                 sprintf(_('Direct message to %s sent.'),
                     $this->other->nickname));
             $this->elementEnd('body');
-            $this->elementEnd('html');
+            $this->endHTML();
         } else {
             $url = common_local_url('outbox',
-                array('nickname' => $user->nickname));
+                array('nickname' => $this->scoped->nickname));
             common_redirect($url, 303);
         }
     }
@@ -185,7 +182,7 @@ class NewmessageAction extends FormAction
         $this->elementStart('body');
         $this->element('p', array('id' => 'error'), $msg);
         $this->elementEnd('body');
-        $this->elementEnd('html');
+        $this->endHTML();
     }
 
     function showForm($msg = null)
@@ -197,9 +194,7 @@ class NewmessageAction extends FormAction
 
         $this->msg = $msg;
         if ($this->trimmed('ajax')) {
-            header('Content-Type: text/xml;charset=utf-8');
-            $this->xw->startDocument('1.0', 'UTF-8');
-            $this->elementStart('html');
+            $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
             // TRANS: Page title on page for sending a direct message.
             $this->element('title', null, _('New message'));