7f3482ee74985c299e60c2691caf6bcdcea9d75a
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\user\notification\event;
3 use wcf\data\user\UserProfile;
4 use wcf\system\request\LinkHandler;
5 use wcf\system\user\notification\object\UserFollowUserNotificationObject;
6 use wcf\system\user\notification\object\UserRegistrationUserNotificationObject;
7
8 /**
9 * Notification event for new user registrations.
10 *
11 * @author Marcel Werk
12 * @copyright 2001-2019 WoltLab GmbH
13 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14 * @package WoltLabSuite\Core\System\User\Notification\Event
15 * @since 5.2
16 *
17 * @method UserRegistrationUserNotificationObject getUserNotificationObject()
18 */
19 class UserRegistrationUserNotificationEvent extends AbstractUserNotificationEvent implements ITestableUserNotificationEvent {
20 use TTestableUserNotificationEvent;
21
22 /**
23 * @inheritDoc
24 */
25 protected $stackable = true;
26
27 /**
28 * @inheritDoc
29 */
30 public function getTitle() {
31 $count = count($this->getAuthors());
32 if ($count > 1) {
33 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.userRegistration.title.stacked', ['count' => $count]);
34 }
35
36 return $this->getLanguage()->get('wcf.user.notification.userRegistration.title');
37 }
38
39 /**
40 * @inheritDoc
41 */
42 public function getMessage() {
43 $authors = array_values($this->getAuthors());
44 $count = count($authors);
45
46 if ($count > 1) {
47 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.userRegistration.message.stacked', [
48 'author' => $this->author,
49 'authors' => $authors,
50 'count' => $count,
51 'others' => $count - 1
52 ]);
53 }
54
55 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.userRegistration.message', ['author' => $this->author]);
56 }
57
58 /**
59 * @inheritDoc
60 */
61 public function getEmailMessage($notificationType = 'instant') {
62 return [
63 'template' => 'email_notification_userRegistration',
64 'application' => 'wcf'
65 ];
66 }
67
68 /**
69 * @inheritDoc
70 */
71 public function getLink() {
72 return LinkHandler::getInstance()->getLink('User', ['object' => $this->author]);
73 }
74
75 /**
76 * @inheritDoc
77 */
78 public function getEventHash() {
79 return sha1($this->eventID);
80 }
81
82 /**
83 * @inheritDoc
84 * @return UserFollowUserNotificationObject[]
85 */
86 public static function getTestObjects(UserProfile $recipient, UserProfile $author) {
87 return [new UserRegistrationUserNotificationObject($author)];
88 }
89 }