Fix error messages after initial loading of comment guest dialog
authorMatthias Schmidt <gravatronics@live.com>
Sun, 13 Aug 2017 17:51:52 +0000 (19:51 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 13 Aug 2017 17:51:52 +0000 (19:51 +0200)
Fix #2372

wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Comment/Add.js
wcfsetup/install/files/lib/data/comment/CommentAction.class.php

index 254e4de164d8d2b7c333f19c4dd8aac645ff01a8..40cd9cdd84efbfe39816cc475b1bbf05ce7bc72d 100644 (file)
@@ -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();
index f414a27c6e3732f5940552492378b77a94d41961..9ff393959397fd3dab6465154f94445b98322a0f 100644 (file)
@@ -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 [