]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/newmessage.php
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into testing
[quix0rs-gnu-social.git] / actions / newmessage.php
index a0b17fc18a5ec315eac3c25b13c5c7f1c271dcb7..25e58feab30c294ec6ef7bec4857a29de5316760 100644 (file)
@@ -99,7 +99,9 @@ class NewmessageAction extends Action
         $user = common_current_user();
 
         if (!$user) {
-            $this->clientError(_('Only logged-in users can send direct messages.'), 403);
+            /* Go log in, and then come back. */
+            common_set_returnto($_SERVER['REQUEST_URI']);
+            common_redirect(common_local_url('login'));
             return false;
         }
 
@@ -111,7 +113,7 @@ class NewmessageAction extends Action
             $this->other = User::staticGet('id', $this->to);
 
             if (!$this->other) {
-                $this->clientError(_('No such user'), 404);
+                $this->clientError(_('No such user.'), 404);
                 return false;
             }
 
@@ -171,7 +173,7 @@ class NewmessageAction extends Action
             return;
         }
 
-        $this->notify($user, $this->other, $message);
+        $message->notify();
 
         if ($this->boolean('ajax')) {
             $this->startHTML('text/xml;charset=utf-8');
@@ -180,7 +182,7 @@ class NewmessageAction extends Action
             $this->elementEnd('head');
             $this->elementStart('body');
             $this->element('p', array('id' => 'command_result'),
-                sprintf(_('Direct message to %s sent'),
+                sprintf(_('Direct message to %s sent.'),
                     $this->other->nickname));
             $this->elementEnd('body');
             $this->elementEnd('html');
@@ -221,7 +223,21 @@ class NewmessageAction extends Action
         }
 
         $this->msg = $msg;
-        $this->showPage();
+        if ($this->trimmed('ajax')) {
+            header('Content-Type: text/xml;charset=utf-8');
+            $this->xw->startDocument('1.0', 'UTF-8');
+            $this->elementStart('html');
+            $this->elementStart('head');
+            $this->element('title', null, _('New message'));
+            $this->elementEnd('head');
+            $this->elementStart('body');
+            $this->showNoticeForm();
+            $this->elementEnd('body');
+            $this->endHTML();
+        }
+        else {
+            $this->showPage();
+        }
     }
 
     function showPageNotice()
@@ -231,12 +247,6 @@ class NewmessageAction extends Action
         }
     }
 
-    function notify($from, $to, $message)
-    {
-        mail_notify_message($message, $from, $to);
-        // XXX: Jabber, SMS notifications... probably queued
-    }
-
     // Do nothing (override)
 
     function showNoticeForm()