/** * @covers Xoops\Form\Form::setTitle */ public function testSetTitle() { $name = 'form_name'; $this->object->setTitle($name); $value = $this->object->getTitle(); $this->assertSame($name, $value); }
/** * Sends the mail and returns whether that was successful. * * @return bool * * @global string The current language. * @global array The configuration of the plugins. * @global array The localization of the plugins. * @global string The (X)HTML fragment that contains error messages. */ public function send() { global $sl, $plugin_cf, $plugin_tx, $e; $pcf = $plugin_cf['advancedform']; $ptx = $plugin_tx['advancedform']; $type = strtolower($pcf['mail_type']); $this->mail->LE = $pcf['mail_line_ending_*nix'] ? "\n" : "\r\n"; $this->mail->set('CharSet', 'UTF-8'); $this->mail->SetLanguage($sl, $this->pluginFolder . 'phpmailer/language/'); $this->mail->set('WordWrap', 72); if (!$this->determineAddresses()) { return false; } if ($this->isConfirmation) { $this->mail->set('Subject', sprintf($ptx['mail_subject_confirmation'], $this->form->getTitle(), $_SERVER['SERVER_NAME'])); } else { $this->mail->set('Subject', sprintf($ptx['mail_subject'], $this->form->getTitle(), $_SERVER['SERVER_NAME'], $_SERVER['REMOTE_ADDR'])); } $this->mail->IsHtml($type != 'text'); if ($type == 'text') { $this->mail->set('Body', $this->getBody(false)); } else { $body = $this->getBody(true); $this->mail->MsgHTML($body); $this->mail->set('AltBody', $this->getBody(false)); } if (!$this->isConfirmation) { foreach ($this->form->getFields() as $field) { $field = Field::make($field); if ($field->getType() == 'file') { $name = 'advfrm-' . $field->getName(); $this->mail->AddAttachment($_FILES[$name]['tmp_name'], stsl($_FILES[$name]['name'])); } } } if (function_exists('advfrm_custom_mail')) { $customResult = advfrm_custom_mail($this->form->getName(), $this->mail, $this->isConfirmation); if ($customResult === false) { return true; } } $ok = $this->mail->Send(); if (!$this->isConfirmation) { if (!$ok) { $message = !empty($this->mail->ErrorInfo) ? XH_hsc($this->mail->ErrorInfo) : $ptx['error_mail']; $e .= '<li>' . $message . '</li>' . PHP_EOL; } if (function_exists('XH_logMessage')) { $type = $ok ? 'info' : 'error'; $message = $ok ? $ptx['log_success'] : $ptx['log_error']; $message = sprintf($message, $this->mail->From); XH_logMessage($type, 'Advancedform', $this->form->getName(), $message); } } return $ok; }