<classname>wcf\system\user\notification\object\type\UserTrophyNotificationObjectType</classname>
<category>com.woltlab.wcf.user</category>
</type>
+ <type>
+ <name>com.woltlab.wcf.userTrophy.recentActivityEvent.trophyReceived</name>
+ <definitionname>com.woltlab.wcf.user.recentActivityEvent</definitionname>
+ <classname>wcf\system\user\activity\event\TrophyReceivedUserActivityEvent</classname>
+ </type>
<!-- /trophy -->
<!-- deprecated -->
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\PermissionDeniedException;
+use wcf\system\user\activity\event\UserActivityEventHandler;
use wcf\system\user\notification\object\UserTrophyNotificationObject;
use wcf\system\user\notification\UserNotificationHandler;
use wcf\system\user\storage\UserStorageHandler;
]
]))->executeAction();
+ UserActivityEventHandler::getInstance()->fireEvent('com.woltlab.wcf.userTrophy.recentActivityEvent.trophyReceived', $returnValues->getObjectID(), null, $returnValues->userID);
+
UserNotificationHandler::getInstance()->fireEvent('received', 'com.woltlab.wcf.userTrophy.notification', new UserTrophyNotificationObject($returnValues), [
$returnValues->userID
]);
if (!in_array($trophyID, array_map(function ($trophy) {
return $trophy->trophyID;
}, $this->availableTrophies))) {
- throw new UserInputException('specialTrophies' , 'invalid');
+ throw new UserInputException('specialTrophies', 'invalid');
}
}
}
--- /dev/null
+<?php
+namespace wcf\system\user\activity\event;
+use wcf\data\user\trophy\UserTrophyList;
+use wcf\system\SingletonFactory;
+use wcf\system\WCF;
+
+/**
+ * User activity event implementation for receiving a trophy.
+ *
+ * @author Joshua Ruesweg
+ * @copyright 2001-2017 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\User\Activity\Event
+ */
+class TrophyReceivedUserActivityEvent extends SingletonFactory implements IUserActivityEvent {
+ /**
+ * @inheritDoc
+ */
+ public function prepare(array $events) {
+ if (!MODULE_TROPHY || !WCF::getSession()->getPermission('user.profile.trophy.canSeeTrophies')) return;
+
+ $objectIDs = [];
+ foreach ($events as $event) {
+ $objectIDs[] = $event->objectID;
+ }
+
+ $trophyList = new UserTrophyList();
+ $trophyList->getConditionBuilder()->add("user_trophy.userTrophyID IN (?)", [$objectIDs]);
+ $trophyList->readObjects();
+ $trophies = $trophyList->getObjects();
+
+ foreach ($events as $event) {
+ if (isset($trophies[$event->objectID])) {
+ if (!$trophies[$event->objectID]->canSee()) {
+ continue;
+ }
+
+ $event->setIsAccessible();
+
+ $event->setTitle(WCF::getLanguage()->getDynamicVariable('wcf.user.trophy.recentActivity.received', ['userTrophy' => $trophies[$event->objectID]]));
+ $event->setDescription($trophies[$event->objectID]->getDescription());
+ }
+ else {
+ $event->setIsOrphaned();
+ }
+ }
+ }
+}
<item name="wcf.user.trophy.specialTrophies.description"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Wähle{else}Wählen Sie{/if} hier ihre besonderen Trophäen aus, welche im Profil und in der Nachrichten-Seitenleiste angezeigt werden.]]></item>
<item name="wcf.user.trophy.specialTrophies.error.tooMuch"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Du kannst{else}Sie können{/if} maximal {#$__wcf->session->getPermission('user.profile.trophy.maxUserSpecialTrophies')} Trophäen auswählen.]]></item>
<item name="wcf.user.trophy.specialTrophies.error.invalid"><![CDATA[Die angegebenen Trophäen sind invalid.]]></item>
+ <item name="wcf.user.trophy.recentActivity.received"><![CDATA[Hat die Trophäe „<a href="{$userTrophy->getTrophy()->getLink()}">{$userTrophy->getTrophy()->getTitle()}</a>“ erhalten.]]></item>
</category>
<category name="wcf.acp.trophy">
<item name="wcf.user.recentActivity.com.woltlab.wcf.likeableArticle.recentActivityEvent"><![CDATA[Like (Artikel)]]></item>
<item name="wcf.user.recentActivity.com.woltlab.wcf.articleComment.recentActivityEvent"><![CDATA[Kommentar (Artikel)]]></item>
<item name="wcf.user.recentActivity.com.woltlab.wcf.articleComment.response.recentActivityEvent"><![CDATA[Antwort (Artikel)]]></item>
+ <item name="wcf.user.recentActivity.com.woltlab.wcf.userTrophy.recentActivityEvent.trophyReceived"><![CDATA[Trophäe]]></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.user.trophy.specialTrophies.description"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Wähle{else}Wählen Sie{/if} hier ihre besonderen Trophäen aus, welche im Profil und in der Nachrichten-Seitenleiste angezeigt werden.]]></item>
<item name="wcf.user.trophy.specialTrophies.error.tooMuch"><![CDATA[You can choose a maximum of {#$__wcf->session->getPermission('user.profile.trophy.maxUserSpecialTrophies')} trophies.]]></item>
<item name="wcf.user.trophy.specialTrophies.error.invalid"><![CDATA[The selected trophies are invalid.]]></item>
+ <item name="wcf.user.trophy.recentActivity.received"><![CDATA[Has received the trophy “<a href="{$userTrophy->getTrophy()->getLink()}">{$userTrophy->getTrophy()->getTitle()}</a>”.]]></item>
</category>
<category name="wcf.acp.trophy">
<item name="wcf.user.recentActivity.com.woltlab.wcf.likeableArticle.recentActivityEvent"><![CDATA[Like (Article)]]></item>
<item name="wcf.user.recentActivity.com.woltlab.wcf.articleComment.recentActivityEvent"><![CDATA[Comment (Article)]]></item>
<item name="wcf.user.recentActivity.com.woltlab.wcf.articleComment.response.recentActivityEvent"><![CDATA[Reply (Article)]]></item>
+ <item name="wcf.user.recentActivity.com.woltlab.wcf.userTrophy.recentActivityEvent.trophyReceived"><![CDATA[Trophy]]></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>