/** * When the form is submitted with a non 'save' button */ protected function onFakeSubmit() { if ($this->request->isPost()) { if (!empty($this->formData['preview'])) { $this->addMessage($this->_('Preview updated')); return; } if (!empty($this->formData['sendtest'])) { $this->mailer->setTo($this->formData['to']); // Make sure at least one template is set (for single language projects) $template = reset($this->formData['gctt']); $languageId = key($this->formData['gctt']); if ($this->formData['send_language']) { foreach ($this->formData['gctt'] as $languageId => $templateLanguage) { // Find the current template (for multi language projects) if ($templateLanguage['gctt_lang'] == $this->formData['send_language']) { $template = $templateLanguage; } } } // \MUtil_Echo::track($this->formData); $errors = false; if (!$template['gctt_subject']) { $this->addMessage(sprintf($this->_('Subject required for %s part.'), strtoupper($template['gctt_lang']))); $errors = true; } if (!$template['gctt_body']) { $this->addMessage(sprintf($this->_('Body required for %s part.'), strtoupper($template['gctt_lang']))); $errors = true; } if ($errors) { return; } $this->mailer->setFrom($this->formData['from']); $this->mailer->setSubject($template['gctt_subject']); $this->mailer->setBody($template['gctt_body'], 'Bbcode'); $this->mailer->setTemplateId($this->formData['gct_id_template']); $this->mailer->send(); $this->addMessage(sprintf($this->_('Test mail sent to %s'), $this->formData['to'])); } } }