<name>needActivation</name>
<objecttype>com.woltlab.wcf.user.registration.notification</objecttype>
<classname>wcf\system\user\notification\event\UserNeedActivationUserNotificationEvent</classname>
- <permissions>admin.user.canEnableUser</permissions>
+ <permissions>admin.user.canSearchUser</permissions>
+ <preset>0</preset>
+ </event>
+ <event>
+ <name>success</name>
+ <objecttype>com.woltlab.wcf.user.registration.notification</objecttype>
+ <classname>wcf\system\user\notification\event\UserRegistrationSuccessUserNotificationEvent</classname>
+ <permissions>admin.user.canSearchUser</permissions>
<preset>0</preset>
</event>
</import>
use wcf\system\form\builder\field\validation\FormFieldValidationError;
use wcf\system\form\builder\field\validation\FormFieldValidator;
use wcf\system\request\LinkHandler;
+use wcf\system\user\command\RegistrationNotification;
use wcf\system\WCF;
use wcf\util\HeaderUtil;
use wcf\util\StringUtil;
$redirectText = WCF::getLanguage()->getDynamicVariable('wcf.user.registerActivation.success');
}
+ $command = new RegistrationNotification($this->user);
+ $command();
+
HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), $redirectText, 10, 'success', true);
exit;
use wcf\system\request\LinkHandler;
use wcf\system\user\authentication\configuration\UserAuthenticationConfigurationFactory;
use wcf\system\user\authentication\LoginRedirect;
+use wcf\system\user\command\RegistrationNotification;
use wcf\system\user\group\assignment\UserGroupAssignmentHandler;
use wcf\system\WCF;
use wcf\util\HeaderUtil;
$this->message = 'wcf.user.register.success';
UserGroupAssignmentHandler::getInstance()->checkUsers([$user->userID]);
-
- $this->fireNotificationEvent($user);
} elseif (REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER && empty($this->blacklistMatches)) {
// registering via 3rdParty leads to instant activation
if ($registerVia3rdParty) {
$this->message = 'wcf.user.register.success.awaitActivation';
}
+ $command = new RegistrationNotification($user);
+ $command();
+
if ($this->captchaObjectType) {
$this->captchaObjectType->getProcessor()->reset();
}
exit;
}
-
- /**
- * @param User $user
- * @since 5.2
- */
- protected function fireNotificationEvent(User $user)
- {
- // TODO fire notification if registration don't require activation per email or manuell from an admin
- }
-
- /**
- * @return int[]
- * @since 5.2
- */
- protected function getRecipientsForNotificationEvent()
- {
- $sql = "SELECT userID
- FROM wcf" . WCF_N . "_user_to_group
- WHERE groupID IN (
- SELECT groupID
- FROM wcf" . WCF_N . "_user_group_option_value
- WHERE optionID IN (
- SELECT optionID
- FROM wcf" . WCF_N . "_user_group_option
- WHERE optionName = ?
- )
- AND optionValue = ?
- )";
- $statement = WCF::getDB()->prepareStatement($sql, 100);
- $statement->execute([
- 'admin.user.canSearchUser',
- 1,
- ]);
-
- return $statement->fetchAll(\PDO::FETCH_COLUMN);
- }
}
--- /dev/null
+<?php
+
+namespace wcf\system\user\command;
+
+use wcf\data\user\User;
+use wcf\system\user\notification\object\UserRegistrationUserNotificationObject;
+use wcf\system\user\notification\UserNotificationHandler;
+use wcf\system\WCF;
+
+/**
+ * Send a notification of user registration status.
+ *
+ * @author Olaf Braun
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ */
+final class RegistrationNotification
+{
+ public function __construct(private readonly User $user)
+ {
+ }
+
+ public function __invoke(): void
+ {
+ if (!$this->user->requiresAdminActivation() && !$this->user->pendingActivation()) {
+ return;
+ }
+
+ $recipientIDs = $this->getRecipientsForNotificationEvent();
+ if (!empty($recipientIDs)) {
+ UserNotificationHandler::getInstance()->fireEvent(
+ $this->user->requiresAdminActivation() ? 'needActivation' : 'success',
+ 'com.woltlab.wcf.user.registration.notification',
+ new UserRegistrationUserNotificationObject($this->user),
+ $recipientIDs
+ );
+ }
+ }
+
+ /**
+ * @return int[]
+ */
+ private function getRecipientsForNotificationEvent(): array
+ {
+ $sql = "SELECT userID
+ FROM wcf1_user_to_group
+ WHERE groupID IN (
+ SELECT groupID
+ FROM wcf1_user_group_option_value
+ WHERE optionID IN (
+ SELECT optionID
+ FROM wcf1_user_group_option
+ WHERE optionName = ?
+ )
+ AND optionValue = ?
+ )";
+ $statement = WCF::getDB()->prepareStatement($sql, 100);
+ $statement->execute([
+ 'admin.user.canSearchUser',
+ 1,
+ ]);
+
+ return $statement->fetchAll(\PDO::FETCH_COLUMN);
+ }
+}
* @author Olaf Braun
* @copyright 2001-2024 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @since 6.0
+ * @since 6.1
*
* @method UserRegistrationUserNotificationObject getUserNotificationObject()
*/
--- /dev/null
+<?php
+
+namespace wcf\system\user\notification\event;
+
+use wcf\data\user\UserProfile;
+use wcf\system\request\LinkHandler;
+use wcf\system\user\notification\object\UserRegistrationUserNotificationObject;
+
+/**
+ * Notification event for users that completed the registration process.
+ *
+ * @author Olaf Braun
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ *
+ * @method UserRegistrationUserNotificationObject getUserNotificationObject()
+ */
+class UserRegistrationSuccessUserNotificationEvent extends AbstractUserNotificationEvent implements
+ ITestableUserNotificationEvent
+{
+ use TTestableUserNotificationEvent;
+
+ #[\Override]
+ public static function getTestObjects(UserProfile $recipient, UserProfile $author)
+ {
+ return [new UserRegistrationUserNotificationObject($author->getDecoratedObject())];
+ }
+
+ #[\Override]
+ public function getTitle(): string
+ {
+ return $this->getLanguage()->get('wcf.user.notification.registrationSuccess.title');
+ }
+
+ #[\Override]
+ public function getMessage()
+ {
+ return $this->getLanguage()->getDynamicVariable(
+ 'wcf.user.notification.registrationSuccess.message',
+ [
+ 'author' => $this->author,
+ 'notification' => $this->notification,
+ 'userNotificationObject' => $this->getUserNotificationObject(),
+ ]
+ );
+ }
+
+ #[\Override]
+ public function getEmailMessage($notificationType = 'instant')
+ {
+ return [
+ 'template' => 'email_notification_userRegistrationSuccess',
+ 'application' => 'wcf',
+ 'variables' => [
+ 'notification' => $this->notification,
+ 'userNotificationObject' => $this->getUserNotificationObject(),
+ ],
+ ];
+ }
+
+ #[\Override]
+ public function getLink(): string
+ {
+ return LinkHandler::getInstance()->getLink('UserEdit', [
+ 'object' => $this->getUserNotificationObject(),
+ 'isACP' => true,
+ ]);
+ }
+
+ #[\Override]
+ public function getEventHash()
+ {
+ return \sha1($this->eventID);
+ }
+}