/** * 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); }
/** * Load the item data */ protected function loadData() { $this->id = $this->getParameter('id', 'int', null); if ($this->id == null || !BackendMailengineModel::existsTemplate($this->id)) { $this->redirect(BackendModel::createURLForAction('templates') . '&error=non-existing'); } $this->record = BackendMailengineModel::getTemplate($this->id); }
/** * Execute the action */ public function execute() { $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id !== null && BackendMailengineModel::existsTemplate($this->id)) { parent::execute(); $this->record = (array) BackendMailengineModel::getTemplate($this->id); BackendMailengineModel::deleteTemplate($this->id); BackendModel::triggerEvent($this->getModule(), 'after_delete_template', array('id' => $this->id)); $this->redirect(BackendModel::createURLForAction('templates') . '&report=deleted&var=' . urlencode($this->record['title'])); } else { $this->redirect(BackendModel::createURLForAction('templates') . '&error=non-existing'); } }