diff --git a/Sources/Actions/Notify.php b/Sources/Actions/Notify.php index 47469a1385..841189290b 100644 --- a/Sources/Actions/Notify.php +++ b/Sources/Actions/Notify.php @@ -446,6 +446,20 @@ protected function setAlertPref(): void $perfs = self::getNotifyPrefs((int) self::$member_info['id'], [$this->type . '_notify_' . $this->id], true); $this->alert_pref = ((int) $perfs[(int) self::$member_info['id']][$this->type . '_notify_' . $this->id]) & self::PREF_ALERT; break; + + // And its mirror image: turn off the alerts and keep the emails. + case self::MODE_NO_ALERT: + $perfs = self::getNotifyPrefs((int) self::$member_info['id'], [$this->type . '_notify_' . $this->id], true); + $this->alert_pref = ((int) $perfs[(int) self::$member_info['id']][$this->type . '_notify_' . $this->id]) & self::PREF_EMAIL; + break; + + // $this->mode comes straight from the query string, so it can be + // anything at all. Leaving it out here means the typed property + // below is never assigned, and reading it is a fatal error rather + // than a page. + default: + $this->alert_pref = self::PREF_NONE; + break; } } diff --git a/Sources/Actions/NotifyBoard.php b/Sources/Actions/NotifyBoard.php index 347129fa8b..bff78e1f84 100644 --- a/Sources/Actions/NotifyBoard.php +++ b/Sources/Actions/NotifyBoard.php @@ -61,7 +61,9 @@ protected function setId(): void protected function saToMode(): void { if (!isset($_GET['mode']) && isset($_GET['sa'])) { - $_GET['mode'] = $_GET['sa'] == 'on' ? 3 : -1; + // 'off' is the unsubscribe link in the notification emails, so it + // means stop emailing me - not stop telling me anything at all. + $_GET['mode'] = $_GET['sa'] == 'on' ? parent::MODE_BOTH : parent::MODE_NO_EMAIL; unset($_GET['sa']); } } diff --git a/Sources/Actions/NotifyTopic.php b/Sources/Actions/NotifyTopic.php index ff92980982..8c91df460d 100644 --- a/Sources/Actions/NotifyTopic.php +++ b/Sources/Actions/NotifyTopic.php @@ -62,7 +62,9 @@ protected function setId(): void protected function saToMode(): void { if (!isset($_GET['mode']) && isset($_GET['sa'])) { - $_GET['mode'] = $_GET['sa'] == 'on' ? 3 : -1; + // 'off' is the unsubscribe link in the notification emails, so it + // means stop emailing me - not stop telling me anything at all. + $_GET['mode'] = $_GET['sa'] == 'on' ? parent::MODE_BOTH : parent::MODE_NO_EMAIL; unset($_GET['sa']); } } @@ -116,7 +118,7 @@ protected function changePref(): void [ 'id_member' => 'int', 'id_topic' => 'int', 'id_msg' => 'int', 'unwatched' => 'int', ], - $log, + [$log], ['id_member', 'id_topic'], );