예제 #1
0
 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();
 }
예제 #2
0
 public function render($item)
 {
     if (!is_null($item)) {
         $parts = explode('\\', get_class($item));
         $class = array_pop($parts);
         $view = Template::load('Search/Type/' . $class);
         $view->result = $item;
         return $view->render();
     }
 }