Automatically mark published new articles written in ACP as read
authorMatthias Schmidt <gravatronics@live.com>
Thu, 6 Jun 2019 17:13:32 +0000 (19:13 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 6 Jun 2019 17:13:32 +0000 (19:13 +0200)
wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php

index 524fa1f367b3b6da8fbfc6864082eca5ad92114d..ae2171e2525aa7f372ed79c818d813f1d68b7f8e 100644 (file)
@@ -438,12 +438,18 @@ class ArticleAddForm extends AbstractForm {
                ];
                
                $this->objectAction = new ArticleAction([], 'create', ['data' => array_merge($this->additionalFields, $data), 'content' => $content]);
+               /** @var Article $article */
                $article = $this->objectAction->executeAction()['returnValues'];
                // save labels
                if (!empty($this->labelIDs)) {
                        ArticleLabelObjectHandler::getInstance()->setLabels($this->labelIDs, $article->articleID);
                }
                
+               // mark published article as read
+               if (ARTICLE_ENABLE_VISIT_TRACKING && $article->publicationStatus == Article::PUBLISHED) {
+                       (new ArticleAction([$article], 'markAsRead'))->executeAction();
+               }
+               
                // call saved event
                $this->saved();