diff options
author | Andreas Gohr <andi@splitbrain.org> | 2011-11-12 17:00:25 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2011-11-12 17:00:25 +0100 |
commit | 76efd6d0637bb67b7dadf65f29a945fe2ce5fc25 (patch) | |
tree | 294c8da8542643c00406f63e1f276b0ec30e590a | |
parent | abbf08905d37ee82c6dda4c2afdbb54383c91517 (diff) | |
download | rpg-76efd6d0637bb67b7dadf65f29a945fe2ce5fc25.tar.gz rpg-76efd6d0637bb67b7dadf65f29a945fe2ce5fc25.tar.bz2 |
Copy all text replacements to HTML replacements in Mailer
With this change it's easy to just set the replacements for HTML that
need special attention.
-rw-r--r-- | inc/Mailer.class.php | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/inc/Mailer.class.php b/inc/Mailer.class.php index b86a9d8f2..09e457243 100644 --- a/inc/Mailer.class.php +++ b/inc/Mailer.class.php @@ -139,14 +139,22 @@ class Mailer { public function setBody($text, $textrep=null, $htmlrep=null, $html=null){ global $INFO; global $conf; + $htmlrep = (array) $htmlrep; + $textrep = (array) $textrep; // create HTML from text if not given if(is_null($html)){ $html = hsc($text); $html = nl2br($text); } - if(!is_null($textrep) && is_null($htmlrep)){ - $htmlrep = array_map('hsc',$textrep); + // copy over all replacements missing for HTML (autolink URLs) + foreach($textrep as $key => $value){ + if(isset($htmlrep[$key])) continue; + if(preg_match('/^https?:\/\//i',$value)){ + $htmlrep[$key] = '<a href="'.hsc($value).'">'.hsc($value).'</a>'; + }else{ + $htmlrep[$key] = hsc($value); + } } // prepare default replacements |