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