From 5526795c71a703486ddd19bf986e6a0cf7309945 Mon Sep 17 00:00:00 2001
From: Guy Brand <gb@unistra.fr>
Date: Fri, 31 Dec 2010 15:46:43 +0100
Subject: [PATCH] Allow a prefix for subject of sent mails (Close FS#2021)

---
 conf/dokuwiki.php                               |  1 +
 inc/common.php                                  | 11 +++++++----
 lib/plugins/config/lang/en/lang.php             |  1 +
 lib/plugins/config/settings/config.metadata.php |  1 +
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/conf/dokuwiki.php b/conf/dokuwiki.php
index 2405494e0..90fbb8174 100644
--- a/conf/dokuwiki.php
+++ b/conf/dokuwiki.php
@@ -99,6 +99,7 @@ $conf['fetchsize']   = 0;                //maximum size (bytes) fetch.php may do
 $conf['notify']      = '';               //send change info to this email (leave blank for nobody)
 $conf['registernotify'] = '';            //send info about newly registered users to this email (leave blank for nobody)
 $conf['mailfrom']    = '';               //use this email when sending mails
+$conf['mailprefix']  = '';               //use this as prefix of outgoing mails
 $conf['gzip_output'] = 0;                //use gzip content encodeing for the output xhtml (if allowed by browser)
 $conf['gdlib']       = 2;                //the GDlib version (0, 1 or 2) 2 tries to autodetect
 $conf['im_convert']  = '';               //path to ImageMagicks convert (will be used instead of GD)
diff --git a/inc/common.php b/inc/common.php
index a1c4580a6..6ea6d56d8 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -1128,12 +1128,15 @@ function notify($id,$who,$rev='',$summary='',$minor=false,$replace=array()){
         $diff = rawWiki($id);
     }
     $text = str_replace('@DIFF@',$diff,$text);
-    if(utf8_strlen($conf['title']) < 20) {
-        $subject = '['.$conf['title'].'] '.$subject;
+    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 = '['.utf8_substr($conf['title'], 0, 20).'...] '.$subject;
+        $subject = '['.$conf['mailprefix'].'] '.$subject;
     }
-
     mail_send($to,$subject,$text,$conf['mailfrom'],'',$bcc);
 }
 
diff --git a/lib/plugins/config/lang/en/lang.php b/lib/plugins/config/lang/en/lang.php
index a944d6bd7..18bfb56fa 100644
--- a/lib/plugins/config/lang/en/lang.php
+++ b/lib/plugins/config/lang/en/lang.php
@@ -125,6 +125,7 @@ $lang['fetchsize']   = 'Maximum size (bytes) fetch.php may download from extern'
 $lang['notify']      = 'Send change notifications to this email address';
 $lang['registernotify'] = 'Send info on newly registered users to this email address';
 $lang['mailfrom']    = 'Email address to use for automatic mails';
+$lang['mailprefix']  = 'Email subject prefix to use for automatic mails';
 $lang['gzip_output'] = 'Use gzip Content-Encoding for xhtml';
 $lang['gdlib']       = 'GD Lib version';
 $lang['im_convert']  = 'Path to ImageMagick\'s convert tool';
diff --git a/lib/plugins/config/settings/config.metadata.php b/lib/plugins/config/settings/config.metadata.php
index c2c3a2d0c..f5eb1da18 100644
--- a/lib/plugins/config/settings/config.metadata.php
+++ b/lib/plugins/config/settings/config.metadata.php
@@ -177,6 +177,7 @@ $meta['canonical']   = array('onoff');
 $meta['fnencode']    = array('multichoice','_choices' => array('url','safe','utf-8'));
 $meta['autoplural']  = array('onoff');
 $meta['mailfrom']    = array('richemail');
+$meta['mailprefix']  = array('string');
 $meta['compress']    = array('onoff');
 $meta['gzip_output'] = array('onoff');
 $meta['hidepages']   = array('string');
-- 
GitLab