summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2011-11-12 17:50:47 +0100
committerAndreas Gohr <andi@splitbrain.org>2011-11-12 17:50:47 +0100
commitd7169d19cde6fc49e27e7444e424549212339ff9 (patch)
tree50e43e13dd1bbc0e1a079908d37bc19e5cef1325 /inc
parent6df843ee8dd8133de3e4e8d5cb742d2afa5f6761 (diff)
downloadrpg-d7169d19cde6fc49e27e7444e424549212339ff9.tar.gz
rpg-d7169d19cde6fc49e27e7444e424549212339ff9.tar.bz2
Replaced mail_send calls with new Mailer class
Diffstat (limited to 'inc')
-rw-r--r--inc/auth.php42
-rw-r--r--inc/media.php34
-rw-r--r--inc/subscription.php18
3 files changed, 44 insertions, 50 deletions
diff --git a/inc/auth.php b/inc/auth.php
index eff984b36..49346a84f 100644
--- a/inc/auth.php
+++ b/inc/auth.php
@@ -667,16 +667,17 @@ function auth_sendPassword($user,$password){
if(!$userinfo['mail']) return false;
$text = rawLocale('password');
- $text = str_replace('@DOKUWIKIURL@',DOKU_URL,$text);
- $text = str_replace('@FULLNAME@',$userinfo['name'],$text);
- $text = str_replace('@LOGIN@',$user,$text);
- $text = str_replace('@PASSWORD@',$password,$text);
- $text = str_replace('@TITLE@',$conf['title'],$text);
-
- return mail_send($userinfo['name'].' <'.$userinfo['mail'].'>',
- $lang['regpwmail'],
- $text,
- $conf['mailfrom']);
+ $trep = array(
+ 'FULLNAME' => $userinfo['name'],
+ 'LOGIN' => $user,
+ 'PASSWORD' => $password
+ );
+
+ $mail = new Mailer();
+ $mail->to($userinfo['name'].' <'.$userinfo['mail'].'>');
+ $mail->subject($lang['regpwmail']);
+ $mail->setBody($text,$trep);
+ return $mail->send();
}
/**
@@ -906,16 +907,17 @@ function act_resendpwd(){
io_saveFile($tfile,$user);
$text = rawLocale('pwconfirm');
- $text = str_replace('@DOKUWIKIURL@',DOKU_URL,$text);
- $text = str_replace('@FULLNAME@',$userinfo['name'],$text);
- $text = str_replace('@LOGIN@',$user,$text);
- $text = str_replace('@TITLE@',$conf['title'],$text);
- $text = str_replace('@CONFIRM@',$url,$text);
-
- if(mail_send($userinfo['name'].' <'.$userinfo['mail'].'>',
- $lang['regpwmail'],
- $text,
- $conf['mailfrom'])){
+ $trep = array(
+ 'FULLNAME' => $userinfo['name'],
+ 'LOGIN' => $user,
+ 'CONFIRM' => $url
+ );
+
+ $mail = new Mailer();
+ $mail->to($userinfo['name'].' <'.$userinfo['mail'].'>');
+ $mail->subject($lang['regpwmail']);
+ $mail->setBody($text,$trep);
+ if($mail->send()){
msg($lang['resendpwdconfirm'],1);
}else{
msg($lang['regmailfail'],-1);
diff --git a/inc/media.php b/inc/media.php
index 9d3e90a54..4e014877b 100644
--- a/inc/media.php
+++ b/inc/media.php
@@ -514,6 +514,7 @@ function media_contentcheck($file,$mime){
* Send a notify mail on uploads
*
* @author Andreas Gohr <andi@splitbrain.org>
+ * @fixme this should embed thumbnails of images in HTML version
*/
function media_notify($id,$file,$mime,$old_rev=false){
global $lang;
@@ -521,31 +522,24 @@ function media_notify($id,$file,$mime,$old_rev=false){
global $INFO;
if(empty($conf['notify'])) return; //notify enabled?
- $ip = clientIP();
-
$text = rawLocale('uploadmail');
- $text = str_replace('@DATE@',dformat(),$text);
- $text = str_replace('@BROWSER@',$_SERVER['HTTP_USER_AGENT'],$text);
- $text = str_replace('@IPADDRESS@',$ip,$text);
- $text = str_replace('@HOSTNAME@',gethostsbyaddrs($ip),$text);
- $text = str_replace('@DOKUWIKIURL@',DOKU_URL,$text);
- $text = str_replace('@USER@',$_SERVER['REMOTE_USER'],$text);
- $text = str_replace('@MIME@',$mime,$text);
- $text = str_replace('@MEDIA@',ml($id,'',true,'&',true),$text);
- $text = str_replace('@SIZE@',filesize_h(filesize($file)),$text);
- if ($old_rev && $conf['mediarevisions']) {
- $text = str_replace('@OLD@', ml($id, "rev=$old_rev", true, '&', true), $text);
- } else {
- $text = str_replace('@OLD@', '', $text);
- }
+ $trep = array(
+ 'MIME' => $mime,
+ 'MEDIA' => ml($id,'',true,'&',true),
+ 'SIZE' => filesize_h(filesize($file)),
+ );
- if(empty($conf['mailprefix'])) {
- $subject = '['.$conf['title'].'] '.$lang['mail_upload'].' '.$id;
+ if ($old_rev && $conf['mediarevisions']) {
+ $trep['OLD'] = ml($id, "rev=$old_rev", true, '&', true);
} else {
- $subject = '['.$conf['mailprefix'].'] '.$lang['mail_upload'].' '.$id;
+ $trep['OLD'] = '---';
}
- mail_send($conf['notify'],$subject,$text,$conf['mailfrom']);
+ $mail = new Mailer();
+ $mail->to($conf['notify']);
+ $mail->subject($lang['mail_upload'].' '.$id);
+ $mail->setBody($text,$trep);
+ return $mail->send();
}
/**
diff --git a/inc/subscription.php b/inc/subscription.php
index c94f17ad0..e9f17bc28 100644
--- a/inc/subscription.php
+++ b/inc/subscription.php
@@ -377,18 +377,16 @@ function subscription_send_list($subscriber_mail, $ids, $ns_id) {
*/
function subscription_send($subscriber_mail, $replaces, $subject, $id, $template) {
global $conf;
+ global $lang;
$text = rawLocale($template);
- $replaces = array_merge($replaces, array('TITLE' => $conf['title'],
- 'DOKUWIKIURL' => DOKU_URL,
- 'PAGE' => $id));
-
- foreach ($replaces as $key => $substitution) {
- $text = str_replace('@'.strtoupper($key).'@', $substitution, $text);
- }
+ $trep = array_merge($replaces, array('PAGE' => $id));
- global $lang;
$subject = $lang['mail_' . $subject] . ' ' . $id;
- mail_send('', '['.$conf['title'].'] '. $subject, $text,
- $conf['mailfrom'], '', $subscriber_mail);
+ $mail = new Mailer();
+ $mail->bcc($subscriber_mail);
+ $mail->subject($subject);
+ $mail->setBody($text,$trep);
+
+ return $mail->send();
}