From: Matthias Schmidt Date: Sun, 13 Aug 2017 17:51:52 +0000 (+0200) Subject: Fix error messages after initial loading of comment guest dialog X-Git-Tag: 3.1.0_Alpha_1~35 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4c122f726324f81a0d63ddec8c8ab46580cf1ddb;p=GitHub%2FWoltLab%2FWCF.git Fix error messages after initial loading of comment guest dialog Fix #2372 --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Comment/Add.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Comment/Add.js index 254e4de164..40cd9cdd84 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Comment/Add.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Comment/Add.js @@ -57,7 +57,7 @@ define(['Ajax', 'Core', 'EventHandler', 'Language', 'Dom/ChangeListener', 'Dom/U UiScroll.element(this._container, (function() { window.jQuery(this._textarea).redactor('WoltLabCaret.endOfEditor'); }).bind(this)); - } + } }).bind(this)); // handle submit button @@ -279,7 +279,7 @@ define(['Ajax', 'Core', 'EventHandler', 'Language', 'Dom/ChangeListener', 'Dom/U // insert HTML //noinspection JSCheckFunctionSignatures DomUtil.insertHtml(data.returnValues.template, this._container, 'after'); - + UiNotification.show(Language.get('wcf.global.success.add')); DomChangeListener.trigger(); diff --git a/wcfsetup/install/files/lib/data/comment/CommentAction.class.php b/wcfsetup/install/files/lib/data/comment/CommentAction.class.php index f414a27c6e..9ff3939593 100644 --- a/wcfsetup/install/files/lib/data/comment/CommentAction.class.php +++ b/wcfsetup/install/files/lib/data/comment/CommentAction.class.php @@ -263,9 +263,12 @@ class CommentAction extends AbstractDatabaseObjectAction implements IMessageInli CommentHandler::enforceFloodControl(); $this->readInteger('objectID', false, 'data'); + $this->readBoolean('requireGuestDialog', true); - $this->validateUsername(); - $this->validateCaptcha(); + if (!$this->parameters['requireGuestDialog']) { + $this->validateUsername(); + $this->validateCaptcha(); + } $this->validateMessage(true); $objectType = $this->validateObjectType(); @@ -283,11 +286,13 @@ class CommentAction extends AbstractDatabaseObjectAction implements IMessageInli * @return string[] */ public function addComment() { - if (!empty($this->validationErrors)) { - if (!empty($this->parameters['data']['username'])) { - WCF::getSession()->register('username', $this->parameters['data']['username']); + if ($this->parameters['requireGuestDialog'] || !empty($this->validationErrors)) { + if (!empty($this->validationErrors)) { + if (!empty($this->parameters['data']['username'])) { + WCF::getSession()->register('username', $this->parameters['data']['username']); + } + WCF::getTPL()->assign('errorType', $this->validationErrors); } - WCF::getTPL()->assign('errorType', $this->validationErrors); $guestDialog = $this->getGuestDialog(); return [