projects
/
platal.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
wrong ext
[platal.git]
/
classes
/
plmailer.php
diff --git
a/classes/plmailer.php
b/classes/plmailer.php
index
46a854e
..
317dd64
100644
(file)
--- a/
classes/plmailer.php
+++ b/
classes/plmailer.php
@@
-28,16
+28,15
@@
class PlMail extends Smarty
private $tpl;
private $mailer = null;
private $tpl;
private $mailer = null;
- function __construct(
&$mailer,
$tpl)
+ function __construct($tpl)
{
global $globals;
$this->tpl = $tpl;
{
global $globals;
$this->tpl = $tpl;
- $this->mailer =& $mailer;
$this->caching = false;
$this->compile_check = true;
$this->template_dir = $globals->spoolroot . "/templates/";
$this->caching = false;
$this->compile_check = true;
$this->template_dir = $globals->spoolroot . "/templates/";
- $this->compile_dir = $globals->spoolroot . "/spool/
templates_c/mails
/";
+ $this->compile_dir = $globals->spoolroot . "/spool/
mails_c
/";
$this->config_dir = $globals->spoolroot . "/configs/";
$this->config_dir = $globals->spoolroot . "/configs/";
@@
-50,10
+49,21
@@
class PlMail extends Smarty
$this->register_function('add_header', Array($this, 'addHeader'));
}
$this->register_function('add_header', Array($this, 'addHeader'));
}
+ public static function &get(&$mailer, $tpl)
+ {
+ static $plmail;
+ if (!isset($plmail) || $plmail->tpl != $tpl) {
+ $plmail = new PlMail($tpl);
+ }
+ $plmail->mailer =& $mailer;
+ return $plmail;
+ }
+
public function run($html)
{
$this->assign('html_version', $html);
public function run($html)
{
$this->assign('html_version', $html);
- return $this->fetch($this->tpl);
+ $text = $this->fetch($this->tpl);
+ return $text;
}
/** used to remove the empty lines due to {from ...}, {to ...} ... functions */
}
/** used to remove the empty lines due to {from ...}, {to ...} ... functions */
@@
-138,13
+148,13
@@
class PlMailer extends Mail_Mime {
private $page = null;
private $charset;
private $page = null;
private $charset;
- function __construct($tpl = null, $charset = "
ISO-8859-15
")
+ function __construct($tpl = null, $charset = "
UTF-8
")
{
$this->charset = $charset;
$this->Mail_Mime("\n");
{
$this->charset = $charset;
$this->Mail_Mime("\n");
- $this->mail =
@
Mail::factory('sendmail', Array('sendmail_args' => '-oi'));
+ $this->mail = Mail::factory('sendmail', Array('sendmail_args' => '-oi'));
if (!is_null($tpl)) {
if (!is_null($tpl)) {
- $this->page =
new PlMail
($this, $tpl);
+ $this->page =
& PlMail::get
($this, $tpl);
}
}
}
}
@@
-153,7
+163,7
@@
class PlMailer extends Mail_Mime {
*/
private function correct_emails($email)
{
*/
private function correct_emails($email)
{
- return preg_replace('!(^|, *)([^<"]+?) *(<[^>]*>)!', '\1"\2" \3', $email);
+ return preg_replace('!(^|, *)([^<"]+?) *(<[^>]*>)!
u
', '\1"\2" \3', $email);
}
public function addTo($email)
}
public function addTo($email)
@@
-262,7
+272,10
@@
class PlMailer extends Mail_Mime {
foreach(Array('To', 'Cc', 'Bcc') as $hdr) {
if(isset($this->_headers[$hdr])) {
require_once 'Mail/RFC822.php';
foreach(Array('To', 'Cc', 'Bcc') as $hdr) {
if(isset($this->_headers[$hdr])) {
require_once 'Mail/RFC822.php';
- $addrs = array_merge($addrs, @Mail_RFC822::parseAddressList($this->_headers[$hdr]));
+ $parsed = @Mail_RFC822::parseAddressList($this->_headers[$hdr]);
+ if (is_array($parsed)) {
+ $addrs = array_merge($addrs, $parsed);
+ }
}
}
if(empty($addrs)) {
}
}
if(empty($addrs)) {
@@
-287,4
+300,5
@@
class PlMailer extends Mail_Mime {
}
}
}
}
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
?>
?>