From: Joshua Rüsweg Date: Sat, 15 Jul 2017 20:58:41 +0000 (+0200) Subject: Ass user trophy received user notification X-Git-Tag: 3.1.0_Alpha_1~256 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e2501ba23fe9972999f16ef233e57e3e34519a62;p=GitHub%2FWoltLab%2FWCF.git Ass user trophy received user notification See #2315 --- diff --git a/com.woltlab.wcf/userNotificationEvent.xml b/com.woltlab.wcf/userNotificationEvent.xml index 07d121f8d5..e702745230 100644 --- a/com.woltlab.wcf/userNotificationEvent.xml +++ b/com.woltlab.wcf/userNotificationEvent.xml @@ -65,5 +65,14 @@ wcf\system\user\notification\event\ExpiringPaidSubscriptionUserUserNotificationEvent module_paid_subscription + + + received + com.woltlab.wcf.userTrophy.notification + wcf\system\user\notification\event\UserTrophyReceivedNotificationEvent + 1 + module_trophy + user.profile.trophy.canSeeTrophies + diff --git a/wcfsetup/install/files/lib/data/user/trophy/UserTrophyAction.class.php b/wcfsetup/install/files/lib/data/user/trophy/UserTrophyAction.class.php index 418b59314f..a10888ac33 100644 --- a/wcfsetup/install/files/lib/data/user/trophy/UserTrophyAction.class.php +++ b/wcfsetup/install/files/lib/data/user/trophy/UserTrophyAction.class.php @@ -3,6 +3,8 @@ namespace wcf\data\user\trophy; use wcf\data\user\UserAction; use wcf\data\AbstractDatabaseObjectAction; use wcf\system\exception\PermissionDeniedException; +use wcf\system\user\notification\object\UserTrophyNotificationObject; +use wcf\system\user\notification\UserNotificationHandler; /** * Provides user trophy actions. @@ -31,6 +33,10 @@ class UserTrophyAction extends AbstractDatabaseObjectAction { ] ]))->executeAction(); + UserNotificationHandler::getInstance()->fireEvent('received', 'com.woltlab.wcf.userTrophy.notification', new UserTrophyNotificationObject($returnValues), [ + $returnValues->userID + ]); + return $returnValues; } diff --git a/wcfsetup/install/files/lib/system/user/notification/event/UserTrophyReceivedNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/UserTrophyReceivedNotificationEvent.class.php new file mode 100644 index 0000000000..14e7bfe6d9 --- /dev/null +++ b/wcfsetup/install/files/lib/system/user/notification/event/UserTrophyReceivedNotificationEvent.class.php @@ -0,0 +1,50 @@ + + * @package WoltLabSuite\Core\System\User\Notification\Object\Type + */ +class UserTrophyReceivedNotificationEvent extends AbstractUserNotificationEvent { + /** + * @inheritDoc + */ + public function getTitle() { + return $this->getLanguage()->get('wcf.user.notification.com.woltlab.wcf.userTrophy.notification.received'); + } + + /** + * @inheritDoc + */ + public function getMessage() { + return $this->getLanguage()->getDynamicVariable('wcf.user.notification.trophy.received.message', [ + 'userTrophy' => $this->userNotificationObject, + 'author' => $this->author + ]); + } + + /** + * @inheritDoc + */ + public function supportsEmailNotification() { + return false; + } + + /** + * @inheritDoc + */ + public function getLink() { + return $this->userNotificationObject->getTrophy()->getLink(); + } + + /** + * @inheritDoc + */ + public function checkAccess() { + return $this->userNotificationObject->getDecoratedObject()->canSee(); + } +} diff --git a/wcfsetup/install/files/lib/system/user/notification/object/UserTrophyNotificationObject.class.php b/wcfsetup/install/files/lib/system/user/notification/object/UserTrophyNotificationObject.class.php index 0451ea714a..ae8d258bf3 100644 --- a/wcfsetup/install/files/lib/system/user/notification/object/UserTrophyNotificationObject.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/object/UserTrophyNotificationObject.class.php @@ -4,7 +4,7 @@ use wcf\data\user\trophy\UserTrophy; use wcf\data\DatabaseObjectDecorator; /** - * Represents a following user as a notification object. + * Represents a user trophy notification object. * * @author Joshua Ruesweg * @copyright 2001-2017 WoltLab GmbH @@ -16,26 +16,26 @@ use wcf\data\DatabaseObjectDecorator; */ class UserTrophyNotificationObject extends DatabaseObjectDecorator implements IUserNotificationObject { /** - * @inheritdoc + * @inheritDoc */ protected static $baseClass = UserTrophy::class; /** - * @inheritdoc + * @inheritDoc */ public function getTitle() { return $this->getDecoratedObject()->getTrophy()->getTitle(); } /** - * @inheritdoc + * @inheritDoc */ public function getURL() { return $this->getDecoratedObject()->getTrophy()->getLink(); } /** - * @inheritdoc + * @inheritDoc */ public function getAuthorID() { return $this->getDecoratedObject()->userID; diff --git a/wcfsetup/install/files/lib/system/user/notification/object/type/UserTrophyNotificationObjectType.class.php b/wcfsetup/install/files/lib/system/user/notification/object/type/UserTrophyNotificationObjectType.class.php index 580b5a878b..9bc4feebe9 100644 --- a/wcfsetup/install/files/lib/system/user/notification/object/type/UserTrophyNotificationObjectType.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/object/type/UserTrophyNotificationObjectType.class.php @@ -14,17 +14,17 @@ use wcf\system\user\notification\object\UserTrophyNotificationObject; */ class UserTrophyNotificationObjectType extends AbstractUserNotificationObjectType { /** - * @inheritdoc + * @inheritDoc */ protected static $decoratorClassName = UserTrophyNotificationObject::class; /** - * @inheritdoc + * @inheritDoc */ protected static $objectClassName = UserTrophy::class; /** - * @inheritdoc + * @inheritDoc */ protected static $objectListClassName = UserTrophyList::class; } diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 36e9d83547..cbd456bb88 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -3884,6 +3884,8 @@ Benachrichtigungen auf {PAGE_TITLE|language + + getTrophy()->getLink()}">{$userTrophy->getTrophy()->getTitle()}“ erhalten.]]> diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 39176eef21..cebdf6667f 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -3873,6 +3873,8 @@ your notifications on {PAGE_TITLE|language} + + getTrophy()->getLink()}">{$userTrophy->getTrophy()->getTitle()}“.]]>