/** * Unsubscribe user from forum emails * * @return void */ public function unsubscribe() { // get the token $token = Request::getCmd('t', ''); //token is required if ($token == '') { App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->get('cn') . '&active=' . $this->_name), Lang::txt('PLG_GROUPS_FORUM_UNSUBSCRIBE_MISSING_TOKEN'), 'error'); } // get the token lib $encryptor = new \Hubzero\Mail\Token(); // get token details $tokenDetails = $encryptor->decryptEmailToken($token); // make sure token details are good if (empty($tokenDetails) || !isset($tokenDetails[1]) || $this->group->get('gidNumber') != $tokenDetails[1]) { App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->get('cn') . '&active=' . $this->_name), Lang::txt('PLG_GROUPS_FORUM_UNSUBSCRIBE_INVALID_TOKEN'), 'error'); } // neede member option lib include_once PATH_CORE . DS . 'plugins' . DS . 'groups' . DS . 'memberoptions' . DS . 'memberoption.class.php'; // Find the user's group settings, do they want to get email (0 or 1)? $groupMemberOption = new GroupsTableMemberoption($this->database); $groupMemberOption->loadRecord($this->group->get('gidNumber'), $tokenDetails[0], GROUPS_MEMBEROPTION_TYPE_DISCUSSION_NOTIFICIATION); // mark that they dont want to be received anymore. $groupMemberOption->optionvalue = 0; // attempt to update if (!$groupMemberOption->save($groupMemberOption)) { App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->get('cn') . '&active=' . $this->_name), Lang::txt('PLG_GROUPS_FORUM_UNSUBSCRIBE_UNABLE_TO_UNSUBSCRIBE'), 'error'); } // success App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->get('cn') . '&active=' . $this->_name), Lang::txt('PLG_GROUPS_FORUM_UNSUBSCRIBE_SUCCESSFULLY_UNSUBSCRIBED')); }
/** * Edit settings * * @param object $group * @param object $user * @param integer $recvEmailOptionID * @param integer $recvEmailOptionValue * @return void */ protected function edit($group, $user, $recvEmailOptionID, $recvEmailOptionValue) { // HTML output // Instantiate a view $view = $this->view('default', 'browse'); // Load the options $database = App::get('db'); $recvEmailOption = new GroupsTableMemberoption($database); $recvEmailOption->loadRecord($group->get('gidNumber'), $user->id, GROUPS_MEMBEROPTION_TYPE_DISCUSSION_NOTIFICIATION); if ($recvEmailOption->id) { $view->recvEmailOptionID = $recvEmailOption->id; $view->recvEmailOptionValue = $recvEmailOption->optionvalue; } else { $view->recvEmailOptionID = 0; $view->recvEmailOptionValue = 0; } // Pass the view some info $view->option = $this->option; $view->group = $this->group; // Return the output return $view->loadTemplate(); }