<classname>wcf\system\user\notification\object\type\ArticleUserNotificationObjectType</classname>
<category>com.woltlab.wcf.page</category>
</type>
+ <type>
+ <name>com.woltlab.wcf.likeableArticle.notification</name>
+ <definitionname>com.woltlab.wcf.notification.objectType</definitionname>
+ <classname>wcf\system\user\notification\object\type\LikeUserNotificationObjectType</classname>
+ <category>com.woltlab.wcf.page</category>
+ </type>
<type>
<name>com.woltlab.wcf.article.recentActivityEvent</name>
<definitionname>com.woltlab.wcf.user.recentActivityEvent</definitionname>
<classname>wcf\system\user\notification\event\ArticleUserNotificationEvent</classname>
<preset>1</preset>
</event>
+ <event>
+ <name>like</name>
+ <objecttype>com.woltlab.wcf.likeableArticle.notification</objecttype>
+ <classname>wcf\system\user\notification\event\ArticleLikeUserNotificationEvent</classname>
+ <options>module_like</options>
+ <preset>1</preset>
+ </event>
<event>
<name>registration</name>
<?php
namespace wcf\data\article;
+use wcf\data\like\Like;
use wcf\data\like\object\AbstractLikeObject;
+use wcf\data\reaction\object\IReactionObject;
+use wcf\system\user\notification\object\LikeUserNotificationObject;
+use wcf\system\user\notification\UserNotificationHandler;
+use wcf\system\WCF;
/**
* Likeable object implementation for cms articles.
* @method Article getDecoratedObject()
* @mixin Article
*/
-class LikeableArticle extends AbstractLikeObject {
+class LikeableArticle extends AbstractLikeObject implements IReactionObject {
/**
* @inheritDoc
*/
public function getLanguageID() {
return null;
}
+
+ /**
+ * @inheritDoc
+ */
+ public function sendNotification(Like $like) {
+ if ($this->getDecoratedObject()->userID != WCF::getUser()->userID) {
+ $notificationObject = new LikeUserNotificationObject($like);
+ UserNotificationHandler::getInstance()->fireEvent(
+ 'like',
+ 'com.woltlab.wcf.likeableArticle.notification',
+ $notificationObject,
+ [$this->getDecoratedObject()->userID]
+ );
+ }
+ }
}
--- /dev/null
+<?php
+namespace wcf\system\user\notification\event;
+use wcf\data\article\category\ArticleCategory;
+use wcf\data\article\LikeableArticle;
+use wcf\data\user\UserProfile;
+use wcf\system\cache\runtime\ViewableArticleRuntimeCache;
+use wcf\system\user\notification\object\LikeUserNotificationObject;
+use wcf\system\user\storage\UserStorageHandler;
+use wcf\system\WCF;
+
+/**
+ * User notification event for post likes.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2020 WoltLab GmbH
+ * @license WoltLab License <http://www.woltlab.com/license-agreement.html>
+ * @package WoltLabSuite\Core\System\User\Notification\Event
+ * @since 5.3
+ *
+ * @method LikeUserNotificationObject getUserNotificationObject()
+ */
+class ArticleLikeUserNotificationEvent extends AbstractSharedUserNotificationEvent implements ITestableUserNotificationEvent {
+ use TTestableLikeUserNotificationEvent {
+ TTestableLikeUserNotificationEvent::canBeTriggeredByGuests insteadof TTestableUserNotificationEvent;
+ }
+ use TTestableArticleUserNotificationEvent;
+ use TTestableCategorizedUserNotificationEvent;
+ use TTestableUserNotificationEvent;
+ use TReactionUserNotificationEvent;
+
+ /**
+ * @inheritDoc
+ */
+ protected $stackable = true;
+
+ /**
+ * @inheritDoc
+ */
+ protected function prepare() {
+ ViewableArticleRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->objectID);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getTitle() {
+ $count = count($this->getAuthors());
+ if ($count > 1) {
+ return $this->getLanguage()->getDynamicVariable('wcf.article.like.notification.title.stacked', [
+ 'count' => $count,
+ 'timesTriggered' => $this->notification->timesTriggered
+ ]);
+ }
+
+ return $this->getLanguage()->getDynamicVariable('wcf.article.like.notification.title');
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getMessage() {
+ $article = ViewableArticleRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->objectID);
+ $authors = array_values($this->getAuthors());
+ $count = count($authors);
+
+ if ($count > 1) {
+ return $this->getLanguage()->getDynamicVariable('wcf.article.like.notification.message.stacked', [
+ 'author' => $this->author,
+ 'authors' => $authors,
+ 'count' => $count,
+ 'others' => $count - 1,
+ 'article' => $article,
+ 'reactions' => $this->getReactionsForAuthors(),
+ ]);
+ }
+
+ return $this->getLanguage()->getDynamicVariable('wcf.article.like.notification.message', [
+ 'author' => $this->author,
+ 'article' => $article,
+ 'userNotificationObject' => $this->getUserNotificationObject(),
+ 'reactions' => $this->getReactionsForAuthors(),
+ ]);
+ }
+
+ /** @noinspection PhpMissingParentCallCommonInspection */
+ /**
+ * @inheritDoc
+ */
+ public function getEmailMessage($notificationType = 'instant') {
+ // not supported
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getLink() {
+ return ViewableArticleRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->objectID)->getLink();
+ }
+
+ /** @noinspection PhpMissingParentCallCommonInspection */
+ /**
+ * @inheritDoc
+ */
+ public function supportsEmailNotification() {
+ return false;
+ }
+
+ /** @noinspection PhpMissingParentCallCommonInspection */
+ /**
+ * @inheritDoc
+ */
+ public function checkAccess() {
+ if (!ViewableArticleRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->objectID)->canRead()) {
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'wbbUnreadWatchedThreads');
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'unreadArticles');
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'unreadWatchedArticles');
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'unreadArticlesByCategory');
+
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ protected static function createTestLikeObject(UserProfile $recipient, UserProfile $author) {
+ return new LikeableArticle(self::getTestArticle(self::createTestCategory(ArticleCategory::OBJECT_TYPE_NAME), $author));
+ }
+
+ /**
+ * @inheritDoc
+ */
+ protected static function getTestLikeableObjectTypeName() {
+ return 'com.woltlab.wcf.likeableArticle';
+ }
+}
<item name="wcf.article.search.results"><![CDATA[Suchergebnisse]]></item>
<item name="wcf.article.publicationStatus.0"><![CDATA[Dieser Artikel wurde noch nicht veröffentlicht.]]></item>
<item name="wcf.article.publicationStatus.2"><![CDATA[Dieser Artikel wird am {@$publicationDate|plainTime} veröffentlicht.]]></item>
+ <item name="wcf.article.like.notification.title"><![CDATA[Reaktion auf {if LANGUAGE_USE_INFORMAL_VARIANT}deinen{else}Ihren{/if} Artikel]]></item>
+ <item name="wcf.article.like.notification.title.stacked"><![CDATA[{#$count} Benutzer haben auf {if LANGUAGE_USE_INFORMAL_VARIANT}deinen{else}Ihren{/if} Artikel reagiert]]></item>
+ <item name="wcf.article.like.notification.message"><![CDATA[{@$author->getAnchorTag()} hat auf {if LANGUAGE_USE_INFORMAL_VARIANT}deinen{else}Ihren{/if} Artikel <a href="{$article->getLink()}">{$article->getTitle()}</a> reagiert ({implode from=$reactions key=reactionID item=count}{@$__wcf->getReactionHandler()->getReactionTypeByID($reactionID)->renderIcon()}×{#$count}{/implode}).]]></item>
+ <item name="wcf.article.like.notification.message.stacked"><![CDATA[{if $count < 4}{@$authors[0]->getAnchorTag()}{if $count == 2} und {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} und {@$authors[2]->getAnchorTag()}{/if}{else}{@$authors[0]->getAnchorTag()} und {#$others} weitere{/if} haben auf {if LANGUAGE_USE_INFORMAL_VARIANT}deinen{else}Ihren{/if} Artikel <a href="{$article->getLink()}">{$article->getTitle()}</a> reagiert ({implode from=$reactions key=reactionID item=count}{@$__wcf->getReactionHandler()->getReactionTypeByID($reactionID)->renderIcon()}×{#$count}{/implode}).]]></item>
</category>
<category name="wcf.attachment">
<item name="wcf.attachment.file.info"><![CDATA[({@$attachment->filesize|filesize}, <b>{#$attachment->downloads}</b> Mal heruntergeladen{if $attachment->downloads > 0}, zuletzt: {@$attachment->lastDownloadTime|time}{/if})]]></item>
<item name="wcf.user.notification.com.woltlab.wcf.page.notification.comment"><![CDATA[Neuer Kommentar auf einer Seite]]></item>
<item name="wcf.user.notification.com.woltlab.wcf.page.response.notification.commentResponse"><![CDATA[Neue Antwort auf einen Kommentar auf einer Seite]]></item>
<item name="wcf.user.notification.com.woltlab.wcf.page.response.notification.commentResponseOwner"><![CDATA[Neue Antwort auf {if LANGUAGE_USE_INFORMAL_VARIANT}deinen{else}Ihren{/if} Kommentar auf einer Seite]]></item>
+ <item name="wcf.user.notification.com.woltlab.wcf.likeableArticle.notification.like"><![CDATA[Jemand hat auf {if LANGUAGE_USE_INFORMAL_VARIANT}deinen{else}Ihren{/if} Artikel reagiert]]></item>
<item name="wcf.user.notification.pageComment.title"><![CDATA[Neuer Kommentar (Seite)]]></item>
<item name="wcf.user.notification.pageComment.title.stacked"><![CDATA[{#$timesTriggered} neue Kommentare (Seite)]]></item>
<item name="wcf.user.notification.pageComment.message"><![CDATA[{if !$author->userID}Ein Gast{else}{@$author->getAnchorTag()}{/if} hat einen Kommentar auf der Seite <a href="{$page->getLink()}#comment{@$commentID}">{$page->getTitle()}</a> verfasst.]]></item>
<item name="wcf.article.search.results"><![CDATA[Search Results]]></item>
<item name="wcf.article.publicationStatus.0"><![CDATA[This article has not been published yet.]]></item>
<item name="wcf.article.publicationStatus.2"><![CDATA[This article will be published on {@$publicationDate|plainTime}.]]></item>
+ <item name="wcf.article.like.notification.title"><![CDATA[Reaction to your article]]></item>
+ <item name="wcf.article.like.notification.title.stacked"><![CDATA[{#$count} users reacted to your article]]></item>
+ <item name="wcf.article.like.notification.message"><![CDATA[{@$author->getAnchorTag()} reacted to your article <a href="{$article->getLink()}">{$article->getTitle()}</a> ({implode from=$reactions key=reactionID item=count}{@$__wcf->getReactionHandler()->getReactionTypeByID($reactionID)->renderIcon()}×{#$count}{/implode}).]]></item>
+ <item name="wcf.article.like.notification.message.stacked"><![CDATA[{if $count < 4}{@$authors[0]->getAnchorTag()}{if $count == 2} and {else}, {/if}{@$authors[1]->getAnchorTag()}{if $count == 3} and {@$authors[2]->getAnchorTag()}{/if}{else}{@$authors[0]->getAnchorTag()} and {#$others} other users{/if} reacted to article <a href="{$article->getLink()}">{$article->getTitle()}</a> ({implode from=$reactions key=reactionID item=count}{@$__wcf->getReactionHandler()->getReactionTypeByID($reactionID)->renderIcon()}×{#$count}{/implode}).]]></item>
</category>
<category name="wcf.attachment">
<item name="wcf.attachment.file.info"><![CDATA[({@$attachment->filesize|filesize}, downloaded <b>{#$attachment->downloads}</b> times{if $attachment->downloads > 0}, last: {@$attachment->lastDownloadTime|time}{/if})]]></item>
<item name="wcf.user.notification.com.woltlab.wcf.page.notification.comment"><![CDATA[Notify me when new comments are written on pages]]></item>
<item name="wcf.user.notification.com.woltlab.wcf.page.response.notification.commentResponse"><![CDATA[Notify me when new replies to comments are written on pages]]></item>
<item name="wcf.user.notification.com.woltlab.wcf.page.response.notification.commentResponseOwner"><![CDATA[Notify me when someone replies to my comments on pages]]></item>
+ <item name="wcf.user.notification.com.woltlab.wcf.likeableArticle.notification.like"><![CDATA[Notify me when someone reacted to my articles]]></item>
<item name="wcf.user.notification.pageComment.title"><![CDATA[New Comment (Page)]]></item>
<item name="wcf.user.notification.pageComment.title.stacked"><![CDATA[{#$timesTriggered} new comments (Page)]]></item>
<item name="wcf.user.notification.pageComment.message"><![CDATA[{if !$author->userID}A guest{else}{@$author->getAnchorTag()}{/if} commented on the page <a href="{$page->getLink()}#comment{@$commentID}">{$page->getTitle()}</a>.]]></item>