From 0be134ecc8b38f9a1e96277a191e2abcf843dc53 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 29 Jun 2020 15:51:26 +0200 Subject: [PATCH] Redirect NotificationDisableAction to NotificationUnsubscribeForm see #3379 --- .../NotificationDisableAction.class.php | 77 +++---------------- 1 file changed, 9 insertions(+), 68 deletions(-) diff --git a/wcfsetup/install/files/lib/action/NotificationDisableAction.class.php b/wcfsetup/install/files/lib/action/NotificationDisableAction.class.php index c7adcdf48d..101e7f4be1 100644 --- a/wcfsetup/install/files/lib/action/NotificationDisableAction.class.php +++ b/wcfsetup/install/files/lib/action/NotificationDisableAction.class.php @@ -1,10 +1,7 @@ * @package WoltLabSuite\Core\Action + * @deprecated 5.3 Replaced by NotificationUnsubscribeForm */ class NotificationDisableAction extends AbstractAction { /** @@ -23,24 +21,12 @@ class NotificationDisableAction extends AbstractAction { */ public $eventID = 0; - /** - * notification event - * @var UserNotificationEvent - */ - public $event = null; - /** * user id * @var integer */ public $userID = 0; - /** - * user object - * @var User - */ - public $user = null; - /** * security token * @var string @@ -53,60 +39,15 @@ class NotificationDisableAction extends AbstractAction { public function readParameters() { parent::readParameters(); - if (isset($_REQUEST['eventID'])) { - $this->eventID = intval($_REQUEST['eventID']); - - $this->event = new UserNotificationEvent($this->eventID); - if (!$this->event->eventID) { - throw new IllegalLinkException(); - } - } - + if (isset($_REQUEST['eventID'])) $this->eventID = intval($_REQUEST['eventID']); if (isset($_REQUEST['userID'])) $this->userID = intval($_REQUEST['userID']); - $this->user = new User($this->userID); - if (!$this->user->userID) { - throw new IllegalLinkException(); - } - if (isset($_REQUEST['token'])) $this->token = StringUtil::trim($_REQUEST['token']); - if (empty($this->token) || !\hash_equals($this->user->notificationMailToken, $this->token)) { - throw new IllegalLinkException(); - } - } - - /** - * @inheritDoc - */ - public function execute() { - parent::execute(); - - if ($this->event !== null) { - $sql = "UPDATE wcf".WCF_N."_user_notification_event_to_user - SET mailNotificationType = ? - WHERE userID = ? - AND eventID = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute([ - 'none', - $this->userID, - $this->eventID - ]); - } - else { - $sql = "UPDATE wcf".WCF_N."_user_notification_event_to_user - SET mailNotificationType = ? - WHERE userID = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute([ - 'none', - $this->userID - ]); - } - - $this->executed(); - - // redirect to url - HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), WCF::getLanguage()->get('wcf.user.notification.mail.disabled')); + + HeaderUtil::redirect(LinkHandler::getInstance()->getControllerLink(NotificationUnsubscribeForm::class, [ + 'userID' => $this->userID, + 'eventID' => $this->eventID, + 'token' => $this->token, + ])); exit; } } -- 2.20.1