summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorZach Copley <zach@controlyourself.ca>2009-04-23 02:17:58 +0000
committerZach Copley <zach@controlyourself.ca>2009-04-23 02:17:59 +0000
commitc4941e904316ef98582290602f8cba1d220b873a (patch)
tree3e5b2dfc1889d2d61062427f1d78dd2da7e0345a /actions
parentec5e06a542d6b06ea9b1d3de7cb309dd1088b4d4 (diff)
Added ajax responses
Diffstat (limited to 'actions')
-rw-r--r--actions/newmessage.php45
1 files changed, 42 insertions, 3 deletions
diff --git a/actions/newmessage.php b/actions/newmessage.php
index 82276ff34..52d4899ba 100644
--- a/actions/newmessage.php
+++ b/actions/newmessage.php
@@ -172,15 +172,54 @@ class NewmessageAction extends Action
$this->notify($user, $this->other, $message);
- $url = common_local_url('outbox', array('nickname' => $user->nickname));
+ if ($this->boolean('ajax')) {
+ $this->startHTML('text/xml;charset=utf-8');
+ $this->elementStart('head');
+ $this->element('title', null, _('Message sent'));
+ $this->elementEnd('head');
+ $this->elementStart('body');
+ $this->element('p', array('id' => 'command_result'),
+ sprintf(_('Direct message to %s sent'),
+ $this->other->nickname));
+ $this->elementEnd('body');
+ $this->elementEnd('html');
+ } else {
+ $url = common_local_url('outbox',
+ array('nickname' => $user->nickname));
+ common_redirect($url, 303);
+ }
+ }
- common_redirect($url, 303);
+ /**
+ * Show an Ajax-y error message
+ *
+ * Goes back to the browser, where it's shown in a popup.
+ *
+ * @param string $msg Message to show
+ *
+ * @return void
+ */
+
+ function ajaxErrorMsg($msg)
+ {
+ $this->startHTML('text/xml;charset=utf-8', true);
+ $this->elementStart('head');
+ $this->element('title', null, _('Ajax Error'));
+ $this->elementEnd('head');
+ $this->elementStart('body');
+ $this->element('p', array('id' => 'error'), $msg);
+ $this->elementEnd('body');
+ $this->elementEnd('html');
}
function showForm($msg = null)
{
- $this->msg = $msg;
+ if ($msg && $this->boolean('ajax')) {
+ $this->ajaxErrorMsg($msg);
+ return;
+ }
+ $this->msg = $msg;
$this->showPage();
}