diff --git a/inc/auth.php b/inc/auth.php index 9c458338dce7ca3264a94b83bdfaee382e8724ce..29a46b37eea38c74c75405256fa3ffb453ea5492 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -780,23 +780,19 @@ function register() { return false; } - // create substitutions for use in notification email - $substitutions = array( - 'NEWUSER' => $login, - 'NEWNAME' => $fullname, - 'NEWEMAIL' => $email, - ); + // send notification about the new user + $subscription = new Subscription(); + $subscription->send_register($login, $fullname, $email); + // are we done? if(!$conf['autopasswd']) { msg($lang['regsuccess2'], 1); - notify('', 'register', '', $login, false, $substitutions); return true; } - // autogenerated password? then send him the password + // autogenerated password? then send password to user if(auth_sendPassword($login, $pass)) { msg($lang['regsuccess'], 1); - notify('', 'register', '', $login, false, $substitutions); return true; } else { msg($lang['regmailfail'], -1); diff --git a/inc/common.php b/inc/common.php index d17061a1bde3718fdd2ad64bda0c5aea149e8f62..20e0af3896be88e6db77fa1252b7ebd9e135b7e9 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1126,36 +1126,13 @@ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = $to = $data['addresslist']; if(empty($to)) return false; $tpl = 'subscr_single'; - } elseif($who == 'register') { - if(empty($conf['registernotify'])) return false; - $text = rawLocale('registermail'); - $to = $conf['registernotify']; } else { return false; //just to be safe } // prepare content - if($who == 'register') { - $subject = $lang['mail_new_user'].' '.$summary; - } else { - $subscription = new Subscription(); - return $subscription->send_diff($to, $tpl, $id, $rev, $summary); - } - - - // send mail - $mail = new Mailer(); - $mail->to($to); - $mail->subject($subject); - $mail->setBody($text, $trep, $hrep); - if($who == 'subscribers') { - $mail->setHeader( - 'List-Unsubscribe', - '<'.wl($id, array('do'=> 'subscribe'), true, '&').'>', - false - ); - } - return $mail->send(); + $subscription = new Subscription(); + return $subscription->send_diff($to, $tpl, $id, $rev, $summary); } /** diff --git a/inc/subscription.php b/inc/subscription.php index 4757b216ce1a34eef7c6009c8a5ab74edb4b5f85..bfbd9524424caf8b91be193d17285d1c9eb5095c 100644 --- a/inc/subscription.php +++ b/inc/subscription.php @@ -429,9 +429,18 @@ class Subscription { ); } + /** + * Send a notify mail on new registration + * + * @author Andreas Gohr <andi@splitbrain.org> + * + * @param string $login login name of the new user + * @param string $fullname full name of the new user + * @param string $email email address of the new user + * @return bool true if a mail was sent + */ public function send_register($login, $fullname, $email) { global $conf; - global $ID; if(empty($conf['registernotify'])) return false; $trep = array( @@ -443,7 +452,7 @@ class Subscription { return $this->send( $conf['registernotify'], 'new_user', - $ID, + $login, 'registermail', $trep ); @@ -486,10 +495,10 @@ class Subscription { * @param string $subscriber_mail The target mail address * @param array $ids Array of ids * @param string $ns_id The id of the namespace - * @return bool + * @return bool true if a mail was sent */ protected function send_list($subscriber_mail, $ids, $ns_id) { - if(count($ids) === 0) return; + if(count($ids) === 0) return false; $tlist = ''; $hlist = '<ul>'; @@ -526,7 +535,7 @@ class Subscription { * @param string $subscriber_mail The target mail address * @param string $subject The lang id of the mail subject (without the * prefix “mail_â€) - * @param string $id The page or namespace id + * @param string $context The context of this mail, eg. page or namespace id * @param string $template The name of the mail template * @param array $trep Predefined parameters used to parse the * template (in text format) @@ -534,17 +543,11 @@ class Subscription { * template (in HTML format), null to default to $trep * @return bool */ - protected function send($subscriber_mail, $subject, $id, $template, $trep, $hrep = null) { + protected function send($subscriber_mail, $subject, $context, $template, $trep, $hrep = null) { global $lang; $text = rawLocale($template); - $trep = array_merge( - $trep, array( - - ) - ); - - $subject = $lang['mail_'.$subject].' '.$id; + $subject = $lang['mail_'.$subject].' '.$context; $mail = new Mailer(); $mail->bcc($subscriber_mail); $mail->subject($subject);