/** * Unsubscribe action method * * @return void */ public function unsubscribe() { $this->prepareView('phire/unsubscribe.phtml'); $this->view->title = 'Unsubscribe'; $this->view->form = new Form\Unsubscribe($this->application->config()['forms']['Phire\\Form\\Unsubscribe']); if ($this->request->isPost()) { $this->view->form->addFilter('strip_tags')->addFilter('htmlentities', [ENT_QUOTES, 'UTF-8'])->setFieldValues($this->request->getPost()); if ($this->view->form->isValid()) { $this->view->form->clearFilters()->addFilter('html_entity_decode', [ENT_QUOTES, 'UTF-8'])->filter(); $user = new Model\User(); $user->unsubscribe($this->view->form->getFields()); $this->view->success = true; $this->view->id = $user->id; $this->sess->kill(); $this->redirect(BASE_PATH . APP_URI . '/unsubscribe?success=1'); } } $this->send(); }
/** * Unsubscribe method * * @param string $redirect * @return void */ public function unsubscribe($redirect = null) { $this->prepareView('unsubscribe.phtml', array('assets' => $this->project->getAssets(), 'acl' => $this->project->getService('acl'), 'phireNav' => $this->project->getService('phireNav'), 'phire' => new Model\Phire())); $this->view->set('title', $this->view->i18n->__('Unsubscribe')); $form = new Form\Unsubscribe($this->request->getBasePath() . $this->request->getRequestUri(), 'post'); // If form is submitted if ($this->request->isPost()) { $form->setFieldValues($this->request->getPost(), array('strip_tags' => null, 'htmlentities' => array(ENT_QUOTES, 'UTF-8'))); // If form is valid, unsubscribe the user if ($form->isValid()) { $user = new Model\User(); $user->unsubscribe($form); if ($this->project->getService('acl')->isAuth()) { $this->logout(false); } if (null !== $redirect) { Response::redirect($redirect); } else { $this->prepareView('unsubscribe.phtml', array('assets' => $this->project->getAssets())); $this->view->set('title', $this->view->i18n->__('Unsubscribe')); $this->view->set('form', ' <p>' . $this->view->i18n->__('Thank you. You have been unsubscribed from this website.') . '</p>'); $this->send(); } // Else, re-render the form with errors } else { $this->view->set('form', $form); $this->send(); } // Else, render the form } else { if ($this->project->getService('acl')->isAuth()) { $form->setFieldValues(array('email' => $this->sess->user->email)); } $this->view->set('form', $form); $this->send(); } }