/** * @param $xml * @return mixed */ public function execBlock($xml) { $errors = array(); $submit = false; $values = $this->request->getGPAsArray(); if ($this->request->post('mailform')) { $submit = true; $required = $values['required']; $fields = $values['field']; $this->validation->setData($fields); $this->validation->addRule('email', 'email'); $errorMessages = array(); foreach ($required as $field => $val) { $this->validation->addRule($field, 'notEmpty'); $errorMessages = array_merge($errorMessages, array($field => array($field => $this->translation->getTranslation('Please fill out the field')))); } $this->validation->setErrorMessages($errorMessages); $check = $this->validation->check(); if ($check === true) { $msg = $this->mail->getMessageInstance(); $msg->setFrom(array($fields['email'])); $msg->setSubject($this->config->get('MAILFORM_SUBJECT')->value); $msg->setTo(explode(',', $this->config->get('MAILFORM_TO')->value)); $this->template->assign('fields', $fields); $msg->setBody($this->template->fetch('Extension/Mailform/Mail'), 'text/html'); $this->mail->send(); } else { $errors = $check; } } $this->mailformController->renderHtml($submit, $values, $errors); }
/** * */ public function getContent() { $values = array(); $errors = array(); $result = array(); if ($this->request->isPost()) { $fields = $this->request->post('field'); $this->validation->setData($fields); $this->validation->addRule('email', 'email')->addRule('subject', 'notEmpty')->addRule('name', 'notEmpty')->addRule('description', 'notEmpty')->addRule('reproduce', 'notEmpty'); $check = $this->validation->check(); if ($check === true) { $params = array('fields' => $fields, 'client_info' => array('version' => \Fraym\Core::VERSION, 'php_version' => phpversion(), 'os' => php_uname('s'), 'apc_enabled' => APC_ENABLED, 'image_processor' => IMAGE_PROCESSOR, 'server' => $_SERVER, 'env' => ENV)); $result = $this->request->send(self::BUGREPORT_URL, $params); } else { $errors = $check; } } $this->view->assign('result', $result); $this->view->assign('values', $values); $this->view->assign('errors', $errors); return $this->siteManagerController->getIframeContent($this->view->fetch('BugReport')); }
/** * @param $xml * @return mixed */ public function execBlock($xml) { $errors = []; $submit = false; $values = $this->request->getGPAsArray(); $requiredFields = $this->getRequiredFields($xml); $formHash = $this->createFormHash($requiredFields); if ($this->request->post('mailform')) { $required = $values['required']; $fields = $values['field']; if ($this->isFormValid($formHash, $this->getValidationRules($required))) { $submit = true; $this->validation->setData($fields); $this->validation->addRule('email', 'email'); $errorMessages = []; foreach ($requiredFields as $field => $val) { $this->validation->addRule($field, $val['rule'], $val['param']); $errorMessages = array_merge($errorMessages, [$field => [$field => $this->translation->getTranslation('Please fill out the field')]]); } $this->validation->setErrorMessages($errorMessages); $check = $this->validation->check(); if ($check === true) { $config = json_decode($xml->mailformOptions, true); $receiver = $config[$this->locale->getLocale()->id]['email']; $subject = $config[$this->locale->getLocale()->id]['subject']; $msg = $this->mail->getMessageInstance(); $msg->setFrom([$fields['email']]); $msg->setSubject($subject); $msg->setTo(explode(',', $receiver)); $this->template->assign('fields', $fields, false); $msg->setBody($this->template->fetch('Extension/Mailform/Mail'), 'text/html'); $this->mail->send(); } else { $errors = $check; } } } $this->mailformController->renderHtml($submit, $values, $errors); }