diff --git a/e107_core/templates/email_template.php b/e107_core/templates/email_template.php index 1325b64b4..6be78599d 100644 --- a/e107_core/templates/email_template.php +++ b/e107_core/templates/email_template.php @@ -202,6 +202,7 @@ $MAILOUT_FOOTER = " */ +// FIXME clean up the whole email template/render tempalte mess //------------------------------------------------------------- // 'SIGNUP' TEMPLATE diff --git a/e107_handlers/user_model.php b/e107_handlers/user_model.php index 6bbad5167..d3d99bc37 100644 --- a/e107_handlers/user_model.php +++ b/e107_handlers/user_model.php @@ -1150,9 +1150,9 @@ class e_system_user extends e_user_model $search[1] = '{PASSWORD}'; $replace[1] = $pass_show ? $pass_show : '******'; - + $search[2] = '{ACTIVATION_LINK}'; - $replace[2] = ''; + $replace[2] = strpos($userInfo['activation_url'], 'http') === 0 ? ''.$userInfo['activation_url'].'' : $userInfo['activation_url']; $search[3] = '{SITENAME}'; $replace[3] = SITENAME; @@ -1171,6 +1171,9 @@ class e_system_user extends e_user_model $search[8] = '{EMAIL}'; $replace[8] = $userInfo['user_email']; + + $search[9] = '{ACTIVATION_URL}'; + $replace[9] = $userInfo['activation_url']; $subject = str_replace($search, $replace, $SIGNUPEMAIL_SUBJECT); $ret['email_subject'] = $subject; @@ -1199,6 +1202,7 @@ class e_system_user extends e_user_model } $FOOT = "\n\n\n"; + $ret['send_html'] = TRUE; $ret['email_body'] = e107::getParser()->parseTemplate(str_replace($search,$replace,$HEAD.$template.$FOOT), true); $ret['preview'] = $ret['email_body'];// Non-standard field return $ret; @@ -1246,7 +1250,7 @@ class e_system_user extends e_user_model $replace[8] = $userInfo['activation_url']; $search[9] = '{ACTIVATION_LINK}'; - $replace[9] = strpos($userInfo['activation_url'], 'http') === 0 ? ''.$userInfo['activation_url'].'' : $userInfo['activation_url']; + $replace[9] = strpos($userInfo['activation_url'], 'http') === 0 ? ''.$userInfo['activation_url'].'' : $userInfo['activation_url']; } $ret['send_html'] = TRUE; diff --git a/signup.php b/signup.php index 2d547e1ac..1313a3125 100644 --- a/signup.php +++ b/signup.php @@ -611,14 +611,29 @@ if (isset($_POST['register']) && $pref['user_reg'] == 1) if (($pref['user_reg_veri'] != 2) && $allData['data']['user_email']) // Don't send if email address blank - means that its not compulsory { $allData['data']['user_id'] = $nid; // User ID - $allData['data']['user_password'] = $savePassword; // Might need to send plaintext password in the email + // FIXME build while rendering - user::renderEmail() + $allData['data']['activation_url'] = SITEURL."signup.php?activate.".$allData['data']['user_id'].".".$allData['data']['user_sess']; + // FIX missing user_name + if(!vartrue($allData['data']['user_name'])) $allData['data']['user_name'] = $allData['data']['user_login']; + + // prefered way to send user emails + $sysuser = e107::getSystemUser(false, false); + $sysuser->setData($allData['data']); + $sysuser->setId($userid); + $check = $sysuser->email('signup', array( + 'user_password' => $savePassword, // for security reasons - password passed ONLY through options + )); + + /* $eml = render_email($allData['data']); $eml['e107_header'] = $eml['userid']; require_once(e_HANDLER.'mail.php'); $mailer = new e107Email(); // FIX - sendEmail returns TRUE or error message... - if(true !== $mailer->sendEmail($allData['data']['user_email'], $allData['data']['user_name'], $eml,FALSE)) + $check = $mailer->sendEmail($allData['data']['user_email'], $allData['data']['user_name'], $eml,FALSE);*/ + + if(true !== $check) { $error_message = LAN_SIGNUP_42; // There was a problem, the registration mail was not sent, please contact the website administrator. } @@ -746,12 +761,12 @@ function headerjs() /** * Create email to send to user who just registered. - * + * DEPRECATED use $user->email() * @param array $userInfo is the array of user-related DB variables * * @return array of data for mailer - field names directly compatible */ -function render_email($userInfo, $preview = FALSE) +/*function render_email($userInfo, $preview = FALSE) { // 1 = Body // 2 = Subject @@ -781,16 +796,6 @@ function render_email($userInfo, $preview = FALSE) require_once(e_CORE.'templates/email_template.php'); } - /* Inline images now handled automatically - just include in email template with an absolute link - $inlineImages = array(); - $inlineImages = explode(",",$SIGNUPEMAIL_IMAGES); - if (vartrue($SIGNUPEMAIL_BACKGROUNDIMAGE)) - { - $inlineImages[] = $SIGNUPEMAIL_BACKGROUNDIMAGE; - } - if (count($inlineImages)) { $ret['mail_inline_images'] = implode(",",$inlineImages); } - */ - $ret['mail_recipient_id'] = $userInfo['user_id']; if (vartrue($SIGNUPEMAIL_CC)) { $ret['mail_copy_to'] = $SIGNUPEMAIL_CC; } if (vartrue($SIGNUPEMAIL_BCC)) { $ret['mail_bcopy_to'] = $SIGNUPEMAIL_BCC; } @@ -819,20 +824,7 @@ function render_email($userInfo, $preview = FALSE) $search[6] = '{USERURL}'; $replace[6] = varsettrue($userInfo['user_website']) ? $userInfo['user_website'] : ""; - /* Inline images now handled automatically - just include in email template with an absolute link - $cnt=1; - foreach($inlineImages as $img) - { - if(is_readable($inlineImages[$cnt-1])) - { - $cid_search[] = "{IMAGE".$cnt."}"; - $cid_replace[] = "\"".SITENAME."\"\n"; - $path_search[] = "{IMAGE".$cnt."}"; - $path_replace[] = "\"".SITENAME."\"\n"; - } - $cnt++; - } - */ + $subject = str_replace($search,$replace,$SIGNUPEMAIL_SUBJECT); $ret['mail_subject'] = $subject; @@ -865,7 +857,7 @@ function render_email($userInfo, $preview = FALSE) return $ret; } - +*/ function render_after_signup($error_message)