Ejemplo n.º 1
0
 /**
  * Validate the form
  */
 protected function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         $fields = $this->frm->getFields();
         $fields['email']->isFilled(BL::err('FieldIsRequired'));
         if ($this->frm->isCorrect()) {
             //--Get the mail
             $mailing = BackendMailengineModel::get($this->id);
             //--Get the template
             $template = BackendMailengineModel::getTemplate($mailing['template_id']);
             //--Create basic mail
             $text = BackendMailengineModel::createMail($mailing, $template);
             $mailing['from_email'] = $template['from_email'];
             $mailing['from_name'] = html_entity_decode($template['from_name']);
             $mailing['reply_email'] = $template['reply_email'];
             $mailing['reply_name'] = html_entity_decode($template['reply_name']);
             $emails = explode(',', $fields['email']->getValue());
             if (!empty($emails)) {
                 foreach ($emails as $email) {
                     $email = trim($email);
                     if (\SpoonFilter::isEmail($email)) {
                         //--Send test mailing
                         BackendMailengineModel::sendMail(html_entity_decode($mailing['subject']), $text, $email, 'Test Recepient', $mailing);
                     }
                 }
             }
             //--Redirect
             \SpoonHTTP::redirect(BackendModel::createURLForAction('index', $this->module) . "&id=" . $this->id . "&report=TestEmailSend");
         }
     }
     $this->frm->parse($this->tpl);
 }
Ejemplo n.º 2
0
 /**
  * Load the data
  */
 protected function loadData()
 {
     $this->id = $this->getParameter('id', 'int', null);
     if ($this->id == null || !BackendMailengineModel::exists($this->id)) {
         $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing');
     }
     $this->record = BackendMailengineModel::get($this->id);
 }
Ejemplo n.º 3
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendMailengineModel::exists($this->id)) {
         parent::execute();
         $this->record = (array) BackendMailengineModel::get($this->id);
         BackendMailengineModel::delete($this->id);
         BackendSearchModel::removeIndex($this->getModule(), $this->id);
         BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id));
         $this->redirect(BackendModel::createURLForAction('index') . '&report=deleted&var=' . urlencode($this->record['subject']));
     } else {
         $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing');
     }
 }