From 92f68068186114eb2e420406d5aa2f637a3c4fb2 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Wed, 8 Jun 2016 15:50:26 +0200 Subject: [PATCH] Added recent activity event for liked articles --- com.woltlab.wcf/objectType.xml | 5 ++ ...LikeableArticleUserActivityEvent.class.php | 57 +++++++++++++++++++ wcfsetup/install/lang/de.xml | 12 ++++ wcfsetup/install/lang/en.xml | 12 ++++ 4 files changed, 86 insertions(+) create mode 100644 wcfsetup/install/files/lib/system/user/activity/event/LikeableArticleUserActivityEvent.class.php diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index e82d5c7de5..f2cd197e12 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -39,6 +39,11 @@ com.woltlab.wcf.like.likeableObject wcf\data\article\LikeableArticleProvider + + com.woltlab.wcf.likeableArticle.recentActivityEvent + com.woltlab.wcf.user.recentActivityEvent + wcf\system\user\activity\event\LikeableArticleUserActivityEvent + com.woltlab.wcf.article com.woltlab.wcf.searchableObjectType diff --git a/wcfsetup/install/files/lib/system/user/activity/event/LikeableArticleUserActivityEvent.class.php b/wcfsetup/install/files/lib/system/user/activity/event/LikeableArticleUserActivityEvent.class.php new file mode 100644 index 0000000000..7fc82bff24 --- /dev/null +++ b/wcfsetup/install/files/lib/system/user/activity/event/LikeableArticleUserActivityEvent.class.php @@ -0,0 +1,57 @@ + + * @package com.woltlab.wcf + * @subpackage system.user.activity.event + * @category Community Framework + * @since 2.2 + */ +class LikeableArticleUserActivityEvent extends SingletonFactory implements IUserActivityEvent { + /** + * @inheritDoc + */ + public function prepare(array $events) { + $articleIDs = []; + foreach ($events as $event) { + $articleIDs[] = $event->objectID; + } + + // fetch articles + $articleList = new ViewableArticleList(); + $articleList->setObjectIDs($articleIDs); + $articleList->readObjects(); + $articles = $articleList->getObjects(); + + // set message + foreach ($events as $event) { + if (isset($articles[$event->objectID])) { + $article = $articles[$event->objectID]; + + // check permissions + if (!$article->canRead()) { + continue; + } + $event->setIsAccessible(); + + // short output + $text = WCF::getLanguage()->getDynamicVariable('wcf.article.recentActivity.likedArticle', ['article' => $article]); + $event->setTitle($text); + + // output + $event->setDescription($article->getTeaser()); + } + else { + $event->setIsOrphaned(); + } + } + } +} diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 149a616568..370076461e 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1733,6 +1733,17 @@ Sie können jetzt den vollen Funktionsumfang der Seite nutzen.]]> + + + + + + + comments} Kommentar{if $article->comments != 1}e{/if}]]> + views} mal gelesen]]> + getLink()}">{$article->getTitle()}.]]> + + filesize|filesize}, {#$attachment->downloads} mal heruntergeladen{if $attachment->downloads > 0}, zuletzt: {@$attachment->lastDownloadTime|time}{/if})]]> filesize|filesize}, {#$attachment->width}×{#$attachment->height}, {#$attachment->downloads} mal angesehen]]> @@ -2956,6 +2967,7 @@ Sollten Sie sich nicht auf der Website: {@PAGE_TITLE|language} angemeldet haben, + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index c6dd700b31..c2c80ec3cc 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -1740,6 +1740,17 @@ You can now fully access the website.]]> + + + + + + + comments} Comment{if $article->comments != 1}s{/if}]]> + views} View{if $article->views != 1}s{/if}]]> + getLink()}">{$article->getTitle()}.]]> + + filesize|filesize}, downloaded {#$attachment->downloads} times{if $attachment->downloads > 0}, last: {@$attachment->lastDownloadTime|time}{/if})]]> filesize|filesize}, {#$attachment->width}×{#$attachment->height}, viewed {#$attachment->downloads} times]]> @@ -2989,6 +3000,7 @@ You can safely ignore this email if you did not register with the website: {@PAG + -- 2.20.1