From fb223639c1698e1d7813eef575e0aaebc466bf26 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 10 Jun 2016 17:52:08 -0700 Subject: [PATCH] Quick-Add-User email fixes. --- e107_admin/users.php | 4 +-- e107_handlers/mail.php | 13 ++++++++-- e107_handlers/user_model.php | 50 ++++++------------------------------ 3 files changed, 21 insertions(+), 46 deletions(-) diff --git a/e107_admin/users.php b/e107_admin/users.php index 112729a6a..aa1ae8f1f 100644 --- a/e107_admin/users.php +++ b/e107_admin/users.php @@ -1446,7 +1446,7 @@ class users_admin_ui extends e_admin_ui // activate and send password $check = $sysuser->email('quickadd', array( 'user_password' => $savePassword, - 'mail_subject' => USRLAN_187.SITENAME, + 'mail_subject' => USRLAN_187, 'activation_url' => USRLAN_246, )); break; @@ -1459,7 +1459,7 @@ class users_admin_ui extends e_admin_ui $check = $sysuser->email('quickadd', array( 'user_password' => $savePassword, - 'mail_subject' => USRLAN_187.SITENAME, + 'mail_subject' => USRLAN_187, 'activation_url' => SITEURL."signup.php?activate.".$sysuser->getId().".".$sysuser->getValue('sess'), )); break; diff --git a/e107_handlers/mail.php b/e107_handlers/mail.php index 2405b4b76..1707a2adf 100644 --- a/e107_handlers/mail.php +++ b/e107_handlers/mail.php @@ -765,7 +765,7 @@ class e107Email extends PHPMailer } $eml['shortcodes']['BODY'] = !empty($eml['body']) ? $eml['body'] : ''; // $tp->toEmail($eml['body']) : ''; - $eml['shortcodes']['SUBJECT'] = !empty($eml['subject']) ?$eml['subject'] : ''; + $eml['shortcodes']['SUBJECT'] = !empty($eml['subject']) ? $eml['subject'] : ''; $eml['shortcodes']['THEME'] = ($this->previewMode == true) ? e_THEME_ABS.$this->pref['sitetheme'].'/' : e_THEME.$this->pref['sitetheme'].'/'; // Always use front-end theme path. @@ -845,12 +845,20 @@ class e107Email extends PHPMailer if($this->debug) { // echo "

e107Email::arraySet() - line ".__LINE__."

"; + + var_dump($eml['shortcodes']); + var_dump($this->Subject); // print_a($tmpl); } unset($eml['add_html_header']); // disable other headers when template is used. - $this->Subject = $tp->parseTemplate($tmpl['subject'], true, varset($eml['shortcodes'],null)); + $this->Subject = $tp->parseTemplate($tmpl['subject'], true, varset($eml['shortcodes'],null)); + + if($this->debug) + { + var_dump($this->Subject); + } } else { @@ -1037,6 +1045,7 @@ class e107Email extends PHPMailer else { // Debug $result = true; + echo "

Subject: ".$this->Subject."

"; // echo "

SendEmail()->Body

"; // print_a($this->Body); // echo "

SendEmail()->AltBody

"; diff --git a/e107_handlers/user_model.php b/e107_handlers/user_model.php index ad0ed9491..3ab3af95f 100644 --- a/e107_handlers/user_model.php +++ b/e107_handlers/user_model.php @@ -1169,7 +1169,7 @@ class e_system_user extends e_user_model { if($this->debug) { - echo '$eml returned nothing on Line 1050 of user_model.php using $type = '.$type; + echo '$eml returned nothing on Line '.__LINE__.' of user_model.php using $type = '.$type; print_a($userInfo); } return false; @@ -1180,6 +1180,8 @@ class e_system_user extends e_user_model { echo '

$eml array

'; print_a($eml); + $temp = var_export($eml, true); + print_a($temp); } } @@ -1346,7 +1348,7 @@ class e_system_user extends e_user_model $sc['EMAIL'] = $userInfo['user_email']; $sc['ACTIVATION_URL'] = $userInfo['activation_url']; - $ret['email_subject'] = $EMAIL_TEMPLATE['signup']['subject']; // $subject; + $ret['subject'] = $EMAIL_TEMPLATE['signup']['subject']; // $subject; $ret['send_html'] = TRUE; $ret['shortcodes'] = $sc; @@ -1412,7 +1414,8 @@ class e_system_user extends e_user_model $templateName = $ret['template']; - $ret['email_subject'] = varset($EMAIL_TEMPLATE[$templateName]['subject'], $EMAIL_TEMPLATE['default']['subject']) ; // $subject; +// $ret['email_subject'] = varset($EMAIL_TEMPLATE[$templateName]['subject'], $EMAIL_TEMPLATE['default']['subject']) ; // $subject; + $ret['subject'] = $userInfo['mail_subject']; $ret['e107_header'] = $userInfo['user_id']; if (vartrue($userInfo['email_copy_to'])) { $ret['email_copy_to'] = $userInfo['email_copy_to']; } @@ -1429,51 +1432,14 @@ class e_system_user extends e_user_model $sc['PASSWORD'] = vartrue($userInfo['user_password'], '***********'); $sc['SUBJECT'] = $userInfo['mail_subject']; - - /* - $search[0] = '{LOGINNAME}'; - $replace[0] = intval($pref['allowEmailLogin']) === 0 ? $userInfo['user_loginname'] : $userInfo['user_email']; - - $search[1] = '{DISPLAYNAME}'; - $replace[1] = $userInfo['user_login'] ? $userInfo['user_login'] : $userInfo['user_name']; - - $search[2] = '{EMAIL}'; - $replace[2] = $userInfo['user_email']; - - $search[3] = '{SITENAME}'; - $replace[3] = SITENAME; - - $search[4] = '{SITEURL}'; - $replace[4] = "".SITEURL.""; - - $search[5] = '{USERNAME}'; - $replace[5] = $userInfo['user_name']; - - $search[6] = '{USERURL}'; - $replace[6] = vartrue($userInfo['user_website']) ? $userInfo['user_website'] : ""; - - $ret['email_subject'] = $subject; // str_replace($search, $replace, $subject); - performed in mail handler. - - $search[7] = '{PASSWORD}'; - $replace[7] = $pass_show ? $pass_show : '******'; - */ - - + if(isset($userInfo['activation_url'])) { $sc['ACTIVATION_URL'] = $userInfo['activation_url']; $sc['ACTIVATION_LINK'] = strpos($userInfo['activation_url'], 'http') === 0 ? ''.$userInfo['activation_url'].'' : $userInfo['activation_url']; - - /* - $search[8] = '{ACTIVATION_URL}'; - $replace[8] = $userInfo['activation_url']; - - $search[9] = '{ACTIVATION_LINK}'; - $replace[9] = strpos($userInfo['activation_url'], 'http') === 0 ? ''.$userInfo['activation_url'].'' : $userInfo['activation_url']; - */ } - $ret['send_html'] = TRUE; + $ret['send_html'] = true; $ret['email_body'] = $template; // e107::getParser()->parseTemplate(str_replace($search, $replace, $template)); - performed in mail handler. $ret['preview'] = $ret['mail_body']; // Non-standard field $ret['shortcodes'] = $sc;