public function unsubscribe($params) { if (isset($_GET['confirm-result']) && $_GET['confirm-result'] === "0") { throw new RedirectException(OW_URL_HOME); } $code = $params['code']; $userId = $this->service->findUserIdByUnsubscribeCode($code); $lang = OW::getLanguage(); if (empty($userId)) { throw new RedirectAlertPageException($lang->text('notifications', 'unsubscribe_code_expired')); } if (empty($_GET['confirm-result'])) { throw new RedirectConfirmPageException($lang->text('notifications', 'unsubscribe_confirm_msg')); } $activeActions = $this->service->collectActionList(); $rules = $this->service->findRuleList($userId); $action = $params['action'] == 'all' ? null : $params['action']; foreach ($activeActions as $actionInfo) { if ($params['action'] != 'all' && $actionInfo['action'] != $params['action']) { continue; } if (empty($rules[$actionInfo['action']])) { $rule = new NOTIFICATIONS_BOL_Rule(); $rule->action = $actionInfo['action']; $rule->userId = $userId; } else { $rule = $rules[$actionInfo['action']]; } $rule->checked = false; $this->service->saveRule($rule); } throw new RedirectAlertPageException($lang->text('notifications', 'unsubscribe_completed')); }