From 9b43da4b44ede419716d0f92757da90d5375fdcb Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Mon, 9 Dec 2013 21:17:43 +0100 Subject: [PATCH] Fixed unsubscribe --- .../NotificationDisableAction.class.php | 47 ++++++++++++------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/wcfsetup/install/files/lib/action/NotificationDisableAction.class.php b/wcfsetup/install/files/lib/action/NotificationDisableAction.class.php index 75325129c5..4c2bc11778 100644 --- a/wcfsetup/install/files/lib/action/NotificationDisableAction.class.php +++ b/wcfsetup/install/files/lib/action/NotificationDisableAction.class.php @@ -1,6 +1,5 @@ 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']); + + $this->event = new UserNotificationEvent($this->eventID); + if (!$this->event->eventID) { + throw new IllegalLinkException(); + } } if (isset($_REQUEST['userID'])) $this->userID = intval($_REQUEST['userID']); @@ -80,20 +82,29 @@ class NotificationDisableAction extends AbstractAction { public function execute() { parent::execute(); - // get object type - $objectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.notification.notificationType', 'com.woltlab.wcf.notification.notificationType.mail'); + 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(array( + '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(array( + 'none', + $this->userID + )); + } - // delete notification setting - $sql = "DELETE FROM wcf".WCF_N."_user_notification_event_notification_type - WHERE userID = ? - AND eventID = ? - AND notificationTypeID = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array( - $this->userID, - $this->eventID, - $objectType->objectTypeID - )); $this->executed(); // redirect to url -- 2.20.1