Use TIME_NOW when saving articles as published
authorAlexander Ebert <ebert@woltlab.com>
Fri, 10 Mar 2017 13:50:38 +0000 (14:50 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 10 Mar 2017 13:50:38 +0000 (14:50 +0100)
See #2194

wcfsetup/install/files/acp/templates/articleAdd.tpl
wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php

index 73a053bba27f54c3d2c2609735c08b7764690c0e..4f4f5da1d60918734e209c3df3db9f8a8e58478d 100644 (file)
        <div class="formSubmit">
                <input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s">
                <input type="hidden" name="isMultilingual" value="{@$isMultilingual}">
+               <input type="hidden" name="timeNowReference" value="{@TIME_NOW}" class="medium">
                {@SECURITY_TOKEN_INPUT_TAG}
        </div>
 </form>
index 09dceba408f1a8330f33a0b73c07adcee6b5daa7..eee902bee1d6c8af475b07d4dcefd61eaabf7422 100644 (file)
@@ -228,6 +228,14 @@ class ArticleAddForm extends AbstractForm {
                        
                        $this->readImages();
                }
+               
+               if ($this->publicationStatus === Article::PUBLISHED && $this->timeObj->getTimestamp() == $_POST['timeNowReference']) {
+                       // supplied timestamp matches the time at which the form was initially requested,
+                       // use the current time instead as publication timestamp, otherwise the article
+                       // would be published in the past rather than "now"
+                       $this->timeObj->setTimestamp(TIME_NOW);
+                       $this->time = $this->timeObj->format('Y-m-d\TH:i:sP');
+               }
        }
        
        /**