prepareNamespacetemplateReplacements();
$this->prepareDateTimereplacements();
$this->prepareLanguagePlaceholder();
$this->prepareNoincludeReplacement();
$this->prepareFieldReplacements($fields);
//set default subject
$this->subject = sprintf($this->getLang('mailsubject'), $ID);
//build html&text table, collect replyto and subject
list($table_html, $table_text) = $this->processFieldsBuildTable($fields, $mail);
//Body
if($this->mailtemplate) {
//show template
$this->patterns['__tablehtml__'] = '/@TABLEHTML@/';
$this->patterns['__tabletext__'] = '/@TABLETEXT@/';
$this->values['__tablehtml__'] = $table_html;
$this->values['__tabletext__'] = $table_text;
list($this->_mail_html, $this->_mail_text) = $this->getContent();
} else {
//show simpel listing
$this->_mail_html .= sprintf($this->getLang('mailintro')."
", dformat());
$this->_mail_html .= $table_html;
$this->_mail_text .= sprintf($this->getLang('mailintro')."\n\n", dformat());
$this->_mail_text .= $table_text;
}
$mail->setBody($this->_mail_text,null,null,$this->_mail_html);
// Reply-to
if(!empty($this->replyto)) {
$replyto = $mail->cleanAddress($this->replyto);
$mail->setHeader('Reply-To', $replyto, false);
}
// To
$to = $this->replace(implode(',',$argv)); // get recipient address(es)
$to = $mail->cleanAddress($to);
$mail->to($to);
// From
$mail->from($conf['mailfrom']);
// Subject
$this->subject = $this->replace($this->subject);
$mail->subject($this->subject);
if(!$mail->send()) {
throw new Exception($this->getLang('e_mail'));
}
return '
' . $thanks . '
'; } /** * Create html and plain table of the field * and collect values for subject and replyto * * @param helper_plugin_bureaucracyau_field[] $fields * @param Mailer $mail * @return array of html and text table */ protected function processFieldsBuildTable($fields, $mail) { global $ID; $table_html = '(.*?)
#is', $content, $matches)) {
foreach($matches[1] as $index => $codeoptions) {
list($syntax,) = explode(' ', trim($codeoptions), 2);
if($syntax == 'html') {
$html = $matches[2][$index];
}
if($syntax == 'text' || $syntax == '') {
$text = $matches[2][$index];
}
}
}
return array(
$this->replace($html),
$this->replace($text)
);
}
}
// vim:ts=4:sw=4:et:enc=utf-8: