From a06e4bdbecc28dbf2b0581783ddc6dc97a03d530 Mon Sep 17 00:00:00 2001
From: Sebastian Harl <sh@tokkee.org>
Date: Thu, 15 Jun 2006 21:44:19 +0200
Subject: [PATCH] register notify #826

A small patch for dokuwiki which enables dokuwiki to notify the
administrator about new user registrations

darcs-hash:20060615194419-022eb-51630aff3c6d93abc656742fc0bc723b93f97734.gz
---
 conf/dokuwiki.php            |  1 +
 inc/auth.php                 |  2 ++
 inc/common.php               |  9 ++++++++-
 inc/lang/de/lang.php         |  1 +
 inc/lang/de/registermail.txt | 10 ++++++++++
 inc/lang/en/lang.php         |  1 +
 inc/lang/en/registermail.txt | 10 ++++++++++
 7 files changed, 33 insertions(+), 1 deletion(-)
 create mode 100644 inc/lang/de/registermail.txt
 create mode 100644 inc/lang/en/registermail.txt

diff --git a/conf/dokuwiki.php b/conf/dokuwiki.php
index e92171322..ad99e5516 100644
--- a/conf/dokuwiki.php
+++ b/conf/dokuwiki.php
@@ -76,6 +76,7 @@ $conf['purgeonadd']  = 1;                //purge cache when a new file is added
 $conf['locktime']    = 15*60;            //maximum age for lockfiles (defaults to 15 minutes)
 $conf['fetchsize']   = 2*1024*1024;      //maximum size (bytes) fetch.php may download from extern
 $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['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
diff --git a/inc/auth.php b/inc/auth.php
index a61e08ad5..72c87552d 100644
--- a/inc/auth.php
+++ b/inc/auth.php
@@ -495,12 +495,14 @@ function register(){
 
   if (!$conf['autopasswd']) {
     msg($lang['regsuccess2'],1);
+    notify('', 'register', '', $_POST['login'], false);
     return true;
   }
 
   // autogenerated password? then send him the password
   if (auth_sendPassword($_POST['login'],$pass)){
     msg($lang['regsuccess'],1);
+    notify('', 'register', '', $_POST['login'], false);
     return true;
   }else{
     msg($lang['regmailfail'],-1);
diff --git a/inc/common.php b/inc/common.php
index 9638fb204..975c70098 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -1122,6 +1122,11 @@ function notify($id,$who,$rev='',$summary='',$minor=false){
     if(empty($bcc)) return;
     $to   = '';
     $text = rawLocale('subscribermail');
+  }elseif($who == 'register'){
+    if(empty($conf['registernotify'])) return;
+    $text = rawLocale('registermail');
+    $to   = $conf['registernotify'];
+    $bcc  = '';
   }else{
     return; //just to be safe
   }
@@ -1137,7 +1142,9 @@ function notify($id,$who,$rev='',$summary='',$minor=false){
   $text = str_replace('@SUMMARY@',$summary,$text);
   $text = str_replace('@USER@',$_SERVER['REMOTE_USER'],$text);
 
-  if($rev){
+  if($who == 'register'){
+    $subject = $lang['mail_new_user'].' '.$summary;
+  }elseif($rev){
     $subject = $lang['mail_changed'].' '.$id;
     $text = str_replace('@OLDPAGE@',wl($id,"rev=$rev",true),$text);
     require_once(DOKU_INC.'inc/DifferenceEngine.php');
diff --git a/inc/lang/de/lang.php b/inc/lang/de/lang.php
index 07ada3b13..9f0247d82 100644
--- a/inc/lang/de/lang.php
+++ b/inc/lang/de/lang.php
@@ -123,6 +123,7 @@ $lang['summary']    = 'Zusammenfassung';
 
 $lang['mail_newpage'] = 'Neue Seite:';
 $lang['mail_changed'] = 'Seite geaendert:';
+$lang['mail_new_user'] = 'Neuer Benutzer:';
 
 $lang['nosmblinks'] = 'Das Verlinken von Windows Freigaben funktioniert nur im Microsoft Internet Explorer.\nDer Link kann jedoch durch Kopieren und Einfügen verwendet werden.';
 
diff --git a/inc/lang/de/registermail.txt b/inc/lang/de/registermail.txt
new file mode 100644
index 000000000..d209d155e
--- /dev/null
+++ b/inc/lang/de/registermail.txt
@@ -0,0 +1,10 @@
+Ein neuer Benutzer hat sich registriert. Hier sind die Details:
+
+Date        : @DATE@
+Browser     : @BROWSER@
+IP-Address  : @IPADDRESS@
+Hostname    : @HOSTNAME@
+
+-- 
+Diese Mail kommt vom DokuWiki auf
+@DOKUWIKIURL@
diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php
index b80668ea3..ff2e7cd84 100644
--- a/inc/lang/en/lang.php
+++ b/inc/lang/en/lang.php
@@ -133,6 +133,7 @@ $lang['summary']    = 'Edit summary';
 
 $lang['mail_newpage'] = 'page added:';
 $lang['mail_changed'] = 'page changed:';
+$lang['mail_new_user'] = 'New user:';
 
 $lang['nosmblinks'] = 'Linking to Windows shares only works in Microsoft Internet Explorer.\nYou still can copy and paste the link.';
 
diff --git a/inc/lang/en/registermail.txt b/inc/lang/en/registermail.txt
new file mode 100644
index 000000000..53ffcab70
--- /dev/null
+++ b/inc/lang/en/registermail.txt
@@ -0,0 +1,10 @@
+A new user has registered. Here are the details:
+
+Date        : @DATE@
+Browser     : @BROWSER@
+IP-Address  : @IPADDRESS@
+Hostname    : @HOSTNAME@
+
+-- 
+This mail was generated by DokuWiki at
+@DOKUWIKIURL@
-- 
GitLab