use wcf\system\request\LinkHandler;
use wcf\system\search\SearchIndexManager;
use wcf\system\tagging\TagEngine;
+use wcf\system\user\activity\event\UserActivityEventHandler;
use wcf\system\user\notification\object\ArticleUserNotificationObject;
use wcf\system\user\notification\UserNotificationHandler;
use wcf\system\user\object\watch\UserObjectWatchHandler;
'com.woltlab.wcf.article.notification',
new ArticleUserNotificationObject($article)
);
+
+ UserActivityEventHandler::getInstance()->fireEvent('com.woltlab.wcf.article.recentActivityEvent', $article->articleID, null, $article->userID, $article->time);
}
return $article;
$publicationStatus = (isset($this->parameters['data']['publicationStatus'])) ? $this->parameters['data']['publicationStatus'] : null;
if ($publicationStatus !== null) {
- $usersToArticles = $resetNotifications = [];
+ $usersToArticles = $resetArticleIDs = [];
/** @var ArticleEditor $articleEditor */
foreach ($this->objects as $articleEditor) {
if ($publicationStatus != $articleEditor->publicationStatus) {
'com.woltlab.wcf.article.notification',
new ArticleUserNotificationObject($articleEditor->getDecoratedObject())
);
+
+ UserActivityEventHandler::getInstance()->fireEvent('com.woltlab.wcf.article.recentActivityEvent', $articleEditor->articleID, null, $articleEditor->userID, $articleEditor->time);
}
else {
- $resetNotifications[] = $articleEditor->articleID;
+ $resetArticleIDs[] = $articleEditor->articleID;
}
}
}
- if (!empty($resetNotifications)) {
+ if (!empty($resetArticleIDs)) {
// delete user notifications
- UserNotificationHandler::getInstance()->removeNotifications('com.woltlab.wcf.article.notification', $resetNotifications);
+ UserNotificationHandler::getInstance()->removeNotifications('com.woltlab.wcf.article.notification', $resetArticleIDs);
+ // delete recent activity events
+ UserActivityEventHandler::getInstance()->removeEvents('com.woltlab.wcf.article.recentActivityEvent', $resetArticleIDs);
}
if (!empty($usersToArticles)) {
SearchIndexManager::getInstance()->delete('com.woltlab.wcf.article', $articleContentIDs);
// delete user notifications
UserNotificationHandler::getInstance()->removeNotifications('com.woltlab.wcf.article.notification', $articleIDs);
+ // delete recent activity events
+ UserActivityEventHandler::getInstance()->removeEvents('com.woltlab.wcf.article.recentActivityEvent', $articleIDs);
}
$this->unmarkItems();
'com.woltlab.wcf.article.notification',
new ArticleUserNotificationObject($articleEditor->getDecoratedObject())
);
+
+ UserActivityEventHandler::getInstance()->fireEvent('com.woltlab.wcf.article.recentActivityEvent', $articleEditor->articleID, null, $articleEditor->userID, TIME_NOW);
}
ArticleEditor::updateArticleCounter($usersToArticles);
// delete user notifications
UserNotificationHandler::getInstance()->removeNotifications('com.woltlab.wcf.article.notification', $articleIDs);
+ // delete recent activity events
+ UserActivityEventHandler::getInstance()->removeEvents('com.woltlab.wcf.article.recentActivityEvent', $articleIDs);
+
ArticleEditor::updateArticleCounter($usersToArticles);
$this->unmarkItems();
--- /dev/null
+<?php
+namespace wcf\system\user\activity\event;
+use wcf\system\cache\runtime\ViewableArticleRuntimeCache;
+use wcf\system\SingletonFactory;
+use wcf\system\WCF;
+
+/**
+ * User activity event implementation for articles.
+ *
+ * @author Joshua Ruesweg
+ * @copyright 2001-2018 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\User\Activity\Event
+ */
+class ArticleUserActivityEvent extends SingletonFactory implements IUserActivityEvent {
+ /**
+ * @inheritDoc
+ */
+ public function prepare(array $events) {
+ $objectIDs = [];
+ foreach ($events as $event) {
+ $objectIDs[] = $event->objectID;
+ }
+
+ ViewableArticleRuntimeCache::getInstance()->cacheObjectIDs($objectIDs);
+
+ // set message
+ foreach ($events as $event) {
+ $article = ViewableArticleRuntimeCache::getInstance()->getObject($event->objectID);
+ if ($article !== null) {
+ if ($article->canRead()) {
+ $event->setIsAccessible();
+
+ $text = WCF::getLanguage()->getDynamicVariable('wcf.article.recentActivity', ['article' => $article]);
+ $event->setTitle($text);
+ $event->setDescription($article->getFormattedTeaser());
+ }
+ }
+ else {
+ $event->setIsOrphaned();
+ }
+ }
+ }
+}
<item name="wcf.article.sortField.views"><![CDATA[Zugriffe]]></item>
<item name="wcf.article.markAllAsRead"><![CDATA[Alle Artikel als gelesen markieren]]></item>
<item name="wcf.article.showArticlesWritten"><![CDATA[Artikel von {$user->username}]]></item>
+ <item name="wcf.article.recentActivity"><![CDATA[Hat den Artikel <a href="{$article->getLink()}">{$article->getTitle()}</a> verfasst.]]></item>
</category>
<category name="wcf.attachment">
<item name="wcf.user.recentActivity.com.woltlab.wcf.userTrophy.recentActivityEvent.trophyReceived"><![CDATA[Trophäe]]></item>
<item name="wcf.user.recentActivity.com.woltlab.wcf.page.recentActivityEvent"><![CDATA[Kommentar (Seite)]]></item>
<item name="wcf.user.recentActivity.com.woltlab.wcf.page.response.recentActivityEvent"><![CDATA[Antwort (Seite)]]></item>
+ <item name="wcf.user.recentActivity.com.woltlab.wcf.article.recentActivityEvent"><![CDATA[Artikel]]></item>
<item name="wcf.user.recentActivity.condition.excludedObjectType"><![CDATA[Ausgeschlossene Aktivitäten]]></item>
<item name="wcf.user.recentActivity.scope.all"><![CDATA[Aktivitäten aller Benutzer]]></item>
<item name="wcf.user.recentActivity.scope.followedUsers"><![CDATA[Aktivitäten von Benutzern, denen {if LANGUAGE_USE_INFORMAL_VARIANT}du folgst{else}Sie folgen{/if}]]></item>
<item name="wcf.article.sortField.views"><![CDATA[Views]]></item>
<item name="wcf.article.markAllAsRead"><![CDATA[Mark All Articles as Read]]></item>
<item name="wcf.article.showArticlesWritten"><![CDATA[Articles by {$user->username}]]></item>
+ <item name="wcf.article.recentActivity"><![CDATA[Wrote the article <a href="{$article->getLink()}">{$article->getTitle()}</a>.]]></item>
</category>
<category name="wcf.attachment">
<item name="wcf.user.recentActivity.com.woltlab.wcf.userTrophy.recentActivityEvent.trophyReceived"><![CDATA[Trophy]]></item>
<item name="wcf.user.recentActivity.com.woltlab.wcf.page.recentActivityEvent"><![CDATA[Comment (Page)]]></item>
<item name="wcf.user.recentActivity.com.woltlab.wcf.page.response.recentActivityEvent"><![CDATA[Reply (Page)]]></item>
+ <item name="wcf.user.recentActivity.com.woltlab.wcf.article.recentActivityEvent"><![CDATA[Article]]></item>
<item name="wcf.user.recentActivity.condition.excludedObjectType"><![CDATA[Excluded Activities]]></item>
<item name="wcf.user.recentActivity.scope.all"><![CDATA[All Activities]]></item>
<item name="wcf.user.recentActivity.scope.followedUsers"><![CDATA[Filter by Followed Users]]></item>