summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2012-11-30 13:09:15 +0100
committerAndreas Gohr <andi@splitbrain.org>2012-11-30 13:09:15 +0100
commit790b77202079261b11d425e0c814608d626eea70 (patch)
treea0ac11ba59a10a9e818508f46e6c50a2294fcb77 /inc
parent10b5c32d6486ab0884deda109b1e5947f7ec7662 (diff)
downloadrpg-790b77202079261b11d425e0c814608d626eea70.tar.gz
rpg-790b77202079261b11d425e0c814608d626eea70.tar.bz2
moved registration notification to subscription class
Diffstat (limited to 'inc')
-rw-r--r--inc/auth.php14
-rw-r--r--inc/common.php27
-rw-r--r--inc/subscription.php29
3 files changed, 23 insertions, 47 deletions
diff --git a/inc/auth.php b/inc/auth.php
index 9c458338d..29a46b37e 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 d17061a1b..20e0af389 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 4757b216c..bfbd95244 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);