diff options
-rw-r--r-- | inc/common.php | 74 |
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(); } /** |