X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fnewnotice.php;h=9face9644356a0a08375f3dfdeee1dda5d7a7059;hb=9a0e71f9bf3329004949a0cef61abb5a354c7688;hp=572adbb23978edd12113aa8a889a4e8a2b07439b;hpb=12c475c101c070cbcc4c63f7b1049f6d3282b9ee;p=quix0rs-gnu-social.git diff --git a/actions/newnotice.php b/actions/newnotice.php index 572adbb239..9face96443 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -90,7 +90,7 @@ class NewnoticeAction extends Action $this->clientError(_('Not logged in.')); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { - // CSRF protection - token set in common_notice_form() + // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { $this->clientError(_('There was a problem with your session token. '. @@ -98,7 +98,12 @@ class NewnoticeAction extends Action return; } - $this->saveNewNotice(); + try { + $this->saveNewNotice(); + } catch (Exception $e) { + $this->showForm($e->getMessage()); + return; + } } else { $this->showForm(); } @@ -123,15 +128,13 @@ class NewnoticeAction extends Action $content = $this->trimmed('status_textarea'); if (!$content) { - $this->showForm(_('No content!')); - return; + $this->clientError(_('No content!')); } else { $content_shortened = common_shorten_links($content); if (mb_strlen($content_shortened) > 140) { - $this->showForm(_('That\'s too long. '. - 'Max notice size is 140 chars.')); - return; + $this->clientError(_('That\'s too long. '. + 'Max notice size is 140 chars.')); } } @@ -141,9 +144,9 @@ class NewnoticeAction extends Action if ($cmd) { if ($this->boolean('ajax')) { - $cmd->execute(new AjaxWebChannel()); + $cmd->execute(new AjaxWebChannel($this)); } else { - $cmd->execute(new WebChannel()); + $cmd->execute(new WebChannel($this)); } return; } @@ -154,14 +157,14 @@ class NewnoticeAction extends Action ($replyto == 'false') ? null : $replyto); if (is_string($notice)) { - $this->showForm($notice); + $this->clientError($notice); return; } common_broadcast_notice($notice); if ($this->boolean('ajax')) { - $this->startHTML('text/xml;charset=utf-8', true); + $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); $this->element('title', null, _('Notice posted')); $this->elementEnd('head'); @@ -195,7 +198,7 @@ class NewnoticeAction extends Action function ajaxErrorMsg($msg) { - common_start_html('text/xml;charset=utf-8', true); + $this->startHTML('text/xml;charset=utf-8', true); $this->elementStart('head'); $this->element('title', null, _('Ajax Error')); $this->elementEnd('head');