Пример #1
0
 public function unsubscribe()
 {
     if (!$this->user->hasPermission('modify', 'module/journal2')) {
         throw new Exception('You do not have permissions to modify Journal2 module');
     }
     if (!isset($this->post_data['email'])) {
         throw new Exception('Parameter email was not found');
     }
     $newsletter = new Journal2Newsletter($this->registry, $this->post_data['email']);
     if ($newsletter->isSubscribed()) {
         $newsletter->unsubscribe();
     }
 }
 public function unsubscribe()
 {
     $response = array();
     if ($this->validateEmail()) {
         $newsletter = new Journal2Newsletter($this->registry, $this->request->post['email']);
         if ($newsletter->isSubscribed()) {
             $newsletter->unsubscribe();
             $response['status'] = 'success';
             $response['message'] = $this->journal2->settings->get('newsletter_unsubscribed_message', 'You have been unsubscribed from our newsletter.');
         } else {
             $response['status'] = 'error';
             $response['message'] = 'Your E-Mail was not found.';
         }
     } else {
         $response['status'] = 'error';
         $response['message'] = $this->journal2->settings->get('newsletter_invalid_email_message', 'Invalid E-Mail.');
     }
     $this->response->setOutput(json_encode($response));
 }