public function unsubscribe() { $message = 'There was an error unsubscribing you.'; $confirmLink = null; $unsubscriberEmail = $this->validateUnsubscriberEmail($this->getParam('email')); $unsubscriberHash = $this->getParam('hash', ''); if ($unsubscriberEmail && $unsubscriberHash && $this->getParam('confirmed')) { $unsubscriber['email'] = $unsubscriberEmail; $contact = $this->contactStore->findContact($unsubscriber); if ($unsubscriberHash === $this->contactStore->getUnsubscribeHash($contact->getId(), $unsubscriberEmail)) { $contact->setMarketingOptin(0); $this->contactStore->update($contact); $message = 'Good-bye! You’ve successfully unsubscribed yourself from the email list.'; } } elseif ($unsubscriberEmail && $unsubscriberHash && !$this->getParam('confirmed')) { //Show confirmation $message = null; $confirmLink = '/contact/unsubscribe?email=' . $unsubscriberEmail; $confirmLink .= '&hash=' . $unsubscriberHash . '&confirmed=1'; } else { $this->response->setResponseCode(302); $redirect = $this->config->get('site.url'); $this->response->setHeader('Location', $redirect); return; } $view = Template::load('Mailshot/unsubscribe'); $view->message = $message; $view->confirmLink = $confirmLink; return $view->render(); }
public function init() { $this->store = Store::get('Contact'); if (!empty($_SESSION[$this->getSessionKey()])) { $member = $this->store->getById($_SESSION[$this->getSessionKey()]); if (!empty($member)) { $this->active = $member; } } }
public function delete($contactId) { $contact = $this->contactStore->getById($contactId); if (!empty($contact)) { $this->contactStore->delete($contact); } return $this->redirect('/contact')->success('Contact deleted.'); }
public function delete($contactId) { $contact = $this->contactStore->getById($contactId); if (!empty($contact)) { $this->contactStore->delete($contact); } $this->successMessage('Contact deleted.', true); $this->redirect('/contact'); }