[dokuwiki] [patch] allow for customizable change e-mail subjects

  • From: Mike Frysinger <vapier@xxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Mon, 4 Dec 2006 20:46:12 -0500

the default subject is a little to dry for me, so this patch allows users to 
customize the format via @VAR@ methods ... i added support for the @VARS@ 
that interest me, but others may want more ...

this patch will prob conflict slightly with my previous patch as they both 
work in the same function (but dont overlap any actual lines)
-mike
diff -rN -u old-dokuwiki/conf/dokuwiki.php new-dokuwiki/conf/dokuwiki.php
--- old-dokuwiki/conf/dokuwiki.php      2006-12-04 20:43:22.000000000 -0500
+++ new-dokuwiki/conf/dokuwiki.php      2006-12-04 20:43:22.000000000 -0500
@@ -83,6 +83,7 @@
 $conf['locktime']    = 15*60;            //maximum age for lockfiles (defaults 
to 15 minutes)
 $conf['fetchsize']   = 0;                //maximum size (bytes) fetch.php may 
download from extern, disabled by default
 $conf['notify']      = '';               //send change info to this email 
(leave blank for nobody)
+$conf['notify_subject'] = '[@TITLE@] @REASON@ @ID@'; //subject template for 
change emails
 $conf['registernotify'] = '';            //send info about newly registered 
users to this email (leave blank for nobody)
 $conf['mailfrom']    = '';               //use this email when sending mails
 $conf['gzip_output'] = 0;                //use gzip content encodeing for the 
output xhtml (if allowed by browser)
diff -rN -u old-dokuwiki/inc/common.php new-dokuwiki/inc/common.php
--- old-dokuwiki/inc/common.php 2006-12-04 20:43:22.000000000 -0500
+++ new-dokuwiki/inc/common.php 2006-12-04 20:43:23.000000000 -0500
@@ -851,7 +851,7 @@
   if($who == 'register'){
     $subject = $lang['mail_new_user'].' '.$summary;
   }elseif($rev){
-    $subject = $lang['mail_changed'].' '.$id;
+    $subject = 
str_replace('@REASON@',$lang['mail_changed'],$conf['notify_subject']);
     $text = str_replace('@OLDPAGE@',wl($id,"rev=$rev",true),$text);
     require_once(DOKU_INC.'inc/DifferenceEngine.php');
     $df  = new Diff(split("\n",rawWiki($id,$rev)),
@@ -859,12 +859,16 @@
     $dformat = new UnifiedDiffFormatter();
     $diff    = $dformat->format($df);
   }else{
-    $subject=$lang['mail_newpage'].' '.$id;
+    $subject = 
str_replace('@REASON@',$lang['mail_changed'],$conf['notify_subject']);
     $text = str_replace('@OLDPAGE@','none',$text);
     $diff = rawWiki($id);
   }
   $text = str_replace('@DIFF@',$diff,$text);
-  $subject = '['.$conf['title'].'] '.$subject;
+  $subject = str_replace('@DATE@',date($conf['dformat']),$subject);
+  $subject = str_replace('@PAGE@',$id,$subject);
+  $subject = str_replace('@TITLE@',$conf['title'],$subject);
+  $subject = str_replace('@SUMMARY@',$summary,$subject);
+  $subject = str_replace('@USER@',$_SERVER['REMOTE_USER'],$subject);
 
   mail_send($to,$subject,$text,$conf['mailfrom'],'',$bcc);
 }
diff -rN -u old-dokuwiki/lib/plugins/config/lang/en/lang.php 
new-dokuwiki/lib/plugins/config/lang/en/lang.php
--- old-dokuwiki/lib/plugins/config/lang/en/lang.php    2006-12-04 
20:43:22.000000000 -0500
+++ new-dokuwiki/lib/plugins/config/lang/en/lang.php    2006-12-04 
20:43:23.000000000 -0500
@@ -109,6 +109,7 @@
 $lang['locktime']    = 'Maximum age for lock files (sec)';
 $lang['fetchsize']   = 'Maximum size (bytes) fetch.php may download from 
extern';
 $lang['notify']      = 'Send change notifications to this email address';
+$lang['notify_subject'] = 'Subject to use in notification emails';
 $lang['registernotify'] = 'Send info on newly registered users to this email 
address';
 $lang['mailfrom']    = 'Email address to use for automatic mails';
 $lang['gzip_output'] = 'Use gzip Content-Encoding for xhtml';
diff -rN -u old-dokuwiki/lib/plugins/config/settings/config.metadata.php 
new-dokuwiki/lib/plugins/config/settings/config.metadata.php
--- old-dokuwiki/lib/plugins/config/settings/config.metadata.php        
2006-12-04 20:43:22.000000000 -0500
+++ new-dokuwiki/lib/plugins/config/settings/config.metadata.php        
2006-12-04 20:43:23.000000000 -0500
@@ -129,6 +129,7 @@
 $meta['htmlok']      = array('onoff');
 $meta['phpok']       = array('onoff');
 $meta['notify']      = array('email');
+$meta['notify_subject'] = array('string');
 $meta['subscribers'] = array('onoff');
 $meta['locktime']    = array('numeric');
 $meta['cachetime']   = array('numeric');

Other related posts: