summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2011-11-12 17:02:02 +0100
committerAndreas Gohr <andi@splitbrain.org>2011-11-12 17:02:02 +0100
commit6df843ee8dd8133de3e4e8d5cb742d2afa5f6761 (patch)
tree41aca69d56f536810baefcd780214569d85af502 /inc
parent76efd6d0637bb67b7dadf65f29a945fe2ce5fc25 (diff)
downloadrpg-6df843ee8dd8133de3e4e8d5cb742d2afa5f6761.tar.gz
rpg-6df843ee8dd8133de3e4e8d5cb742d2afa5f6761.tar.bz2
Make use of new Mailer class in notify()
It now uses inline diff format for diff HTML mails
Diffstat (limited to 'inc')
-rw-r--r--inc/common.php74
1 files changed, 34 insertions, 40 deletions
diff --git a/inc/common.php b/inc/common.php
index 0c769c50d..b624c334c 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -1087,7 +1087,7 @@ function notify($id,$who,$rev='',$summary='',$minor=false,$replace=array()){
global $conf;
global $INFO;
- // decide if there is something to do
+ // decide if there is something to do, eg. whom to mail
if($who == 'admin'){
if(empty($conf['notify'])) return; //notify enabled?
$text = rawLocale('mailtext');
@@ -1112,49 +1112,43 @@ function notify($id,$who,$rev='',$summary='',$minor=false,$replace=array()){
return; //just to be safe
}
- $ip = clientIP();
- $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('@NEWPAGE@',wl($id,'',true,'&'),$text);
- $text = str_replace('@PAGE@',$id,$text);
- $text = str_replace('@TITLE@',$conf['title'],$text);
- $text = str_replace('@DOKUWIKIURL@',DOKU_URL,$text);
- $text = str_replace('@SUMMARY@',$summary,$text);
- $text = str_replace('@USER@',$_SERVER['REMOTE_USER'],$text);
- $text = str_replace('@NAME@',$INFO['userinfo']['name'],$text);
- $text = str_replace('@MAIL@',$INFO['userinfo']['mail'],$text);
-
- foreach ($replace as $key => $substitution) {
- $text = str_replace('@'.strtoupper($key).'@',$substitution, $text);
- }
+ // prepare replacements (keys not set in hrep will be taken from trep)
+ $trep = array(
+ 'NEWPAGE' => wl($id,'',true,'&'),
+ 'PAGE' => $id,
+ 'SUMMARY' => $summary
+ );
+ $trep = array_merge($trep,$replace);
+ $hrep = array();
+ // prepare content
if($who == 'register'){
- $subject = $lang['mail_new_user'].' '.$summary;
+ $subject = $lang['mail_new_user'].' '.$summary;
}elseif($rev){
- $subject = $lang['mail_changed'].' '.$id;
- $text = str_replace('@OLDPAGE@',wl($id,"rev=$rev",true,'&'),$text);
- $df = new Diff(explode("\n",rawWiki($id,$rev)),
- explode("\n",rawWiki($id)));
- $dformat = new UnifiedDiffFormatter();
- $diff = $dformat->format($df);
+ $subject = $lang['mail_changed'].' '.$id;
+ $trep['OLDPAGE'] = wl($id,"rev=$rev",true,'&');
+ $df = new Diff(explode("\n",rawWiki($id,$rev)),
+ explode("\n",rawWiki($id)));
+ $dformat = new UnifiedDiffFormatter();
+ $tdiff = $dformat->format($df);
+ $dformat = new InlineDiffFormatter();
+ $hdiff = $dformat->format($df);
}else{
- $subject=$lang['mail_newpage'].' '.$id;
- $text = str_replace('@OLDPAGE@','none',$text);
- $diff = rawWiki($id);
- }
- $text = str_replace('@DIFF@',$diff,$text);
- if(empty($conf['mailprefix'])) {
- if(utf8_strlen($conf['title']) < 20) {
- $subject = '['.$conf['title'].'] '.$subject;
- }else{
- $subject = '['.utf8_substr($conf['title'], 0, 20).'...] '.$subject;
- }
- }else{
- $subject = '['.$conf['mailprefix'].'] '.$subject;
- }
- mail_send($to,$subject,$text,$conf['mailfrom'],'',$bcc);
+ $subject = $lang['mail_newpage'].' '.$id;
+ $trep['OLDPAGE'] = '---';
+ $tdiff = rawWiki($id);
+ $hdiff = nl2br(hsc($tdiff));
+ }
+ $trep['DIFF'] = $tdiff;
+ $hrep['DIFF'] = $hdiff;
+
+ // send mail
+ $mail = new Mailer();
+ $mail->to($to);
+ $mail->bcc($bcc);
+ $mail->subject($subject);
+ $mail->setBody($text,$trep);
+ return $mail->send();
}
/**