Update recent activities when the author of an article changes
authorMarcel Werk <burntime@woltlab.com>
Fri, 5 Jun 2020 11:20:54 +0000 (13:20 +0200)
committerMarcel Werk <burntime@woltlab.com>
Fri, 5 Jun 2020 11:20:54 +0000 (13:20 +0200)
Closes #3356

wcfsetup/install/files/lib/data/article/ArticleAction.class.php

index e7c80bc22ddf4ec60b4fe5fd9f84ba79c39f0076..874e185665592f0f2c05f76604ea0a1f0304d181 100644 (file)
@@ -307,6 +307,22 @@ class ArticleAction extends AbstractDatabaseObjectAction {
                                ArticleEditor::updateArticleCounter($usersToArticles);
                        }
                }
+               
+               // update author in recent activities
+               if (isset($this->parameters['data']['userID'])) {
+                       $sql = "UPDATE wcf".WCF_N."_user_activity_event SET userID = ? WHERE objectTypeID = ? AND objectID = ?";
+                       $statement = WCF::getDB()->prepareStatement($sql);
+                       
+                       foreach ($this->objects as $articleEditor) {
+                               if ($articleEditor->userID != $this->parameters['data']['userID']) {
+                                       $statement->execute([
+                                               $this->parameters['data']['userID'],
+                                               UserActivityEventHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.article.recentActivityEvent'),
+                                               $articleEditor->articleID,
+                                       ]);
+                               }
+                       }
+               }
        }
        
        /**