diff --git a/e107_core/templates/email_template.php b/e107_core/templates/email_template.php
index e6397da8b..69700a81a 100644
--- a/e107_core/templates/email_template.php
+++ b/e107_core/templates/email_template.php
@@ -321,7 +321,7 @@ $QUICKADDUSER_TEMPLATE = array(
-
+// ----------------------- Everything above this line is deprecated but may continue to work for a while ------------------------------- //
/** Standardized v2 template rewrite
@@ -334,6 +334,7 @@ $QUICKADDUSER_TEMPLATE = array(
// Default - test email and when no template specified.
$EMAIL_TEMPLATE['default']['name'] = 'Default';
+$EMAIL_TEMPLATE['default']['subject'] = '{SUBJECT} {SITENAME}';
$EMAIL_TEMPLATE['default']['header'] = "
@@ -357,8 +358,13 @@ $EMAIL_TEMPLATE['default']['footer'] = "
";
-// Signup Template.
-
+/**
+ * Signup Template.
+ * @example developer tests
+ * signup.php?preview
+ * signup.php?test
+ * signup.php?preview.aftersignup
+ */
$EMAIL_TEMPLATE['signup']['subject'] = LAN_SIGNUP_96.' {SITENAME}';
$EMAIL_TEMPLATE['signup']['header'] = $EMAIL_TEMPLATE['default']['header'];
@@ -404,15 +410,16 @@ $EMAIL_TEMPLATE['signup']['attachments'] = "";
USRLAN_186 = Please go to the site as soon as possible and log in, then change your password using the \'Settings\' option.
You can also change other settings at the same time.
Note that your password cannot be recovered if you lose it.
*/
-$EMAIL_TEMPLATE['quickadd']['header'] = $EMAIL_TEMPLATE['default']['header']; // will use default header above.
-$EMAIL_TEMPLATE['quickadd']['body'] = USRLAN_185.USRLAN_186;
-$EMAIL_TEMPLATE['quickadd']['footer'] = $EMAIL_TEMPLATE['default']['footer']; // will use default footer above.
+$EMAIL_TEMPLATE['quickadduser']['subject'] = '{SITENAME}: {SUBJECT} ';
+$EMAIL_TEMPLATE['quickadduser']['header'] = $EMAIL_TEMPLATE['default']['header']; // will use default header above.
+$EMAIL_TEMPLATE['quickadduser']['body'] = USRLAN_185.USRLAN_186;
+$EMAIL_TEMPLATE['quickadduser']['footer'] = $EMAIL_TEMPLATE['default']['footer']; // will use default footer above.
// Notify (@see admin-> notify) // TODO
-
-$EMAIL_TEMPLATE['notify']['header'] = $EMAIL_TEMPLATE['default']['header']; // will use default header above.
-$EMAIL_TEMPLATE['notify']['body'] = $EMAIL_TEMPLATE['default']['body']; // will use default header above.
-$EMAIL_TEMPLATE['notify']['footer'] = $EMAIL_TEMPLATE['default']['footer']; // will use default header above.
+$EMAIL_TEMPLATE['notify']['subject'] = '{SITENAME}: {SUBJECT} ';
+$EMAIL_TEMPLATE['notify']['header'] = $EMAIL_TEMPLATE['default']['header']; // will use default header above.
+$EMAIL_TEMPLATE['notify']['body'] = $EMAIL_TEMPLATE['default']['body']; // will use default header above.
+$EMAIL_TEMPLATE['notify']['footer'] = $EMAIL_TEMPLATE['default']['footer']; // will use default header above.
?>
\ No newline at end of file
diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php
index f0ab5df24..6aa08cff7 100644
--- a/e107_handlers/e_parse_class.php
+++ b/e107_handlers/e_parse_class.php
@@ -781,12 +781,50 @@ class e_parse extends e_parser
return $this->toHTML($text, TRUE, $extra);
}
-
+ /**
+ * @param $text - template to parse.
+ * @param boolean $parseSCFiles - parse core 'single' shortcodes
+ * @param array $extraCodes - support legacy shortcode content (eg. content within .sc) as well as simpleParse array format.
+ * @param object $eVars - XXX more info needed.
+ */
function parseTemplate($text, $parseSCFiles = TRUE, $extraCodes = null, $eVars = null)
{
+ if(!empty($extraCodes) && $this->isSimpleParse($extraCodes)) // support for a combined simple and standard template parse. - (eg. used by signup email template.)
+ {
+ $text = $this->simpleParse($text, $extraCodes, false);
+ }
+
return e107::getScParser()->parseCodes($text, $parseSCFiles, $extraCodes, $eVars);
}
+
+ /**
+ * Check if we are using the simple-Parse array format, or a legacy .sc format which contains 'return '
+ * @param array $extraCodes
+ */
+ private function isSimpleParse($extraCodes)
+ {
+
+ if(!is_array($extraCodes))
+ {
+ return false;
+ }
+
+ foreach ($extraCodes as $sc => $code)
+ {
+ if(!strpos($code, 'return '))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+
+
/**
* Simple parser
*
diff --git a/e107_handlers/mail.php b/e107_handlers/mail.php
index ba5b7a62b..d4ee98a49 100644
--- a/e107_handlers/mail.php
+++ b/e107_handlers/mail.php
@@ -599,31 +599,47 @@ class e107Email extends PHPMailer
public function arraySet($eml)
{
- if($this->debug)
- {
- print_a($eml);
- }
+
if(vartrue($eml['template'])) // @see e107_core/templates/email_template.php
{
$tp = e107::getParser();
- if($tmpl = e107::getCoreTemplate('email',$eml['template'], true, true)) // $EMAIL_TEMPLATE['default']
+ if($tmpl = e107::getCoreTemplate('email', $eml['template'], true, true)) // $EMAIL_TEMPLATE['default']
{
- $filter = array("\n", "\t");
- $tmpl['header'] = str_replace($filter,'', $tmpl['header']);
- $tmpl['footer'] = str_replace($filter,'', $tmpl['footer']);
+ // $filter = array("\n", "\t");
+ // $tmpl['header'] = str_replace($filter,'', $tmpl['header']);
+ // $tmpl['footer'] = str_replace($filter,'', $tmpl['footer']);
+
+ $eml['shortcodes']['BODY'] = $eml['email_body'];
+ $eml['shortcodes']['SUBJECT'] = $eml['email_subject'];
+
+ $emailBody = $tmpl['header']. $tmpl['body'] . $tmpl['footer'];
+
+ $eml['email_body'] = $tp->parseTemplate($emailBody, true, varset($eml['shortcodes'],null));
+
+ // $eml['email_body'] = ($tp->toEmail($tmpl['header']). str_replace('{BODY}', $eml['email_body'], $tmpl['body']). $tp->toEmail($tmpl['footer']));
+
+ if($this->debug)
+ {
+ print_a($tmpl);
+ }
- $eml['email_body'] = ($tp->toEmail($tmpl['header']). str_replace('{BODY}', $eml['email_body'], $tmpl['body']). $tp->toEmail($tmpl['footer']));
unset($eml['add_html_header']); // disable other headers when template is used.
+
+ $this->Subject = $tp->parseTemplate($tmpl['subject'], true, varset($eml['shortcodes'],null));
}
}
+ else
+ {
+ if (vartrue($eml['email_subject'])) $this->Subject = $tp->parseTemplate($eml['email_subject'], true, varset($eml['shortcodes'],null));
+ }
if (isset($eml['SMTPDebug'])) $this->SMTPDebug = $eml['SMTPDebug']; // 'FALSE' is a valid value!
- if (vartrue($eml['email_subject'])) $this->Subject = $eml['email_subject'];
+
if (vartrue($eml['email_sender_email'])) $this->From = $eml['email_sender_email'];
if (vartrue($eml['email_sender_name'])) $this->FromName = $eml['email_sender_name'];
if (vartrue($eml['email_replyto'])) $this->AddAddressList('replyto',$eml['email_replyto'],vartrue($eml['email_replytonames'],''));
@@ -640,7 +656,10 @@ class e107Email extends PHPMailer
$this->save_bouncepath = $eml['bouncepath']; // Bounce path
}
-
+ if($this->debug)
+ {
+ print_a($eml);
+ }
diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php
index 6a9bf369c..2a62d25de 100644
--- a/e107_handlers/shortcode_handler.php
+++ b/e107_handlers/shortcode_handler.php
@@ -764,15 +764,17 @@ class e_parse_shortcode
// auto-register eVars if possible - call it manually?
// $this->callScFunc($classname, 'setParserVars', $this->eVars);
}
- elseif (is_array($extraCodes))
+ elseif (is_array($extraCodes)) // Array value contains the contents of a .sc file which is then parsed. ie. return " whatever ";
{
- $this->addedCodes = &$extraCodes;
+ $this->addedCodes = &$extraCodes;
/*
foreach ($extraCodes as $sc => $code)
{
$this->scList[$sc] = $code;
}
*/
+
+ // print_a($this);
}
$ret = preg_replace_callback('#\{(\S[^\x02]*?\S)\}#', array(&$this, 'doCode'), $text);
$this->parseSCFiles = $saveParseSCFiles; // Restore previous value
@@ -781,7 +783,7 @@ class e_parse_shortcode
$this->debug_legacy = null;
- // $this->sc_style = array(); //XXX Adding this will also fix #2 above.
+ // $this->sc_style = array(); //XXX Adding this will also fix #2 above.
return $ret;
diff --git a/e107_handlers/user_model.php b/e107_handlers/user_model.php
index af786c111..570c2ce1c 100644
--- a/e107_handlers/user_model.php
+++ b/e107_handlers/user_model.php
@@ -1114,8 +1114,6 @@ class e_system_user extends e_user_model
// required for signup and quickadd email type
e107::coreLan('signup');
-
-
$EMAIL_TEMPLATE = e107::getCoreTemplate('email');
if(!is_array($EMAIL_TEMPLATE)) //BC Fixes. pre v2 alpha3.
@@ -1132,15 +1130,14 @@ class e_system_user extends e_user_model
}
// BC Fixes.
- $EMAIL_TEMPLATE['signup']['subject'] = $SIGNUPEMAIL_SUBJECT;
- $EMAIL_TEMPLATE['signup']['cc'] = $SIGNUPEMAIL_CC;
- $EMAIL_TEMPLATE['signup']['bcc'] = $SIGNUPEMAIL_BCC;
- $EMAIL_TEMPLATE['signup']['attachments']= $SIGNUPEMAIL_ATTACHMENTS;
+ $EMAIL_TEMPLATE['signup']['subject'] = $SIGNUPEMAIL_SUBJECT;
+ $EMAIL_TEMPLATE['signup']['cc'] = $SIGNUPEMAIL_CC;
+ $EMAIL_TEMPLATE['signup']['bcc'] = $SIGNUPEMAIL_BCC;
+ $EMAIL_TEMPLATE['signup']['attachments'] = $SIGNUPEMAIL_ATTACHMENTS;
+ $EMAIL_TEMPLATE['signup']['body'] = $SIGNUPEMAIL_TEMPLATE;
- $EMAIL_TEMPLATE['signup']['body'] = $SIGNUPEMAIL_TEMPLATE;
-
- $EMAIL_TEMPLATE['quickadd']['body'] = $QUICKADDUSER_TEMPLATE['email_body'];
- $EMAIL_TEMPLATE['notify']['body'] = $NOTIFY_TEMPLATE['email_body'];
+ $EMAIL_TEMPLATE['quickadduser']['body'] = $QUICKADDUSER_TEMPLATE['email_body'];
+ $EMAIL_TEMPLATE['notify']['body'] = $NOTIFY_TEMPLATE['email_body'];
}
@@ -1149,12 +1146,12 @@ class e_system_user extends e_user_model
{
case 'signup':
$template = (vartrue($SIGNUPPROVIDEREMAIL_TEMPLATE)) ? $SIGNUPPROVIDEREMAIL_TEMPLATE : $EMAIL_TEMPLATE['signup']['body'];
- $ret['template'] = false;// 'signup'; // false; // Don't allow additional headers (mailer) ??
+ $ret['template'] = 'signup'; // // false Don't allow additional headers (mailer) ??
break;
case 'quickadd':
- $template = $EMAIL_TEMPLATE['quickadd']['body'];
- $ret['template'] = 'quickadd'; // Don't allow additional headers (mailer)
+ $template = $EMAIL_TEMPLATE['quickadduser']['body'];
+ $ret['template'] = 'quickadduser'; // Don't allow additional headers (mailer)
break;
case 'notify':
@@ -1181,47 +1178,31 @@ class e_system_user extends e_user_model
$ret['e107_header'] = $userInfo['user_id'];
+
if (vartrue($EMAIL_TEMPLATE['signup']['cc'])) { $ret['email_copy_to'] = $EMAIL_TEMPLATE['signup']['cc']; }
if (vartrue($EMAIL_TEMPLATE['signup']['bcc'])) { $ret['email_bcopy_to'] = $EMAIL_TEMPLATE['signup']['bcc']; }
if (vartrue($userInfo['email_attach'])) { $ret['email_attach'] = $userInfo['mail_attach']; }
elseif (vartrue($EMAIL_TEMPLATE['signup']['attachments'])) { $ret['email_attach'] = $EMAIL_TEMPLATE['signup']['attachments']; }
$style = vartrue($SIGNUPEMAIL_LINKSTYLE) ? "style='{$SIGNUPEMAIL_LINKSTYLE}'" : "";
-
- $search[0] = '{LOGINNAME}';
- $replace[0] = intval($pref['allowEmailLogin']) === 0 ? $userInfo['user_loginname'] : $userInfo['user_email'];
-
- $search[1] = '{PASSWORD}';
- $replace[1] = $pass_show ? $pass_show : '******';
-
- $search[2] = '{ACTIVATION_LINK}';
- $replace[2] = strpos($userInfo['activation_url'], 'http') === 0 ? ''.$userInfo['activation_url'].'' : $userInfo['activation_url'];
-
- $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'] : "";
- $search[7] = '{DISPLAYNAME}';
- $replace[7] = $userInfo['user_login'] ? $userInfo['user_login'] : $userInfo['user_name'];
- $search[8] = '{EMAIL}';
- $replace[8] = $userInfo['user_email'];
+ $sc = array();
- $search[9] = '{ACTIVATION_URL}';
- $replace[9] = $userInfo['activation_url'];
-
- $subject = str_replace($search, $replace, $EMAIL_TEMPLATE['signup']['subject']);
+ $sc['LOGINNAME'] = intval($pref['allowEmailLogin']) === 0 ? $userInfo['user_loginname'] : $userInfo['user_email'];
+ $sc['PASSWORD'] = $pass_show ? $pass_show : '******';
+ $sc['ACTIVATION_LINK'] = strpos($userInfo['activation_url'], 'http') === 0 ? ''.$userInfo['activation_url'].'' : $userInfo['activation_url'];
+ // $sc['SITENAME'] = SITENAME;
+ $sc['SITEURL'] = "".SITEURL."";
+ $sc['USERNAME'] = $userInfo['user_name'];
+ $sc['USERURL'] = vartrue($userInfo['user_website']) ? $userInfo['user_website'] : "";
+ $sc['DISPLAYNAME'] = $userInfo['user_login'] ? $userInfo['user_login'] : $userInfo['user_name'];
+ $sc['EMAIL'] = $userInfo['user_email'];
+ $sc['ACTIVATION_URL'] = $userInfo['activation_url'];
- $ret['email_subject'] = $subject;
+ $ret['email_subject'] = $EMAIL_TEMPLATE['signup']['subject']; // $subject;
$ret['send_html'] = TRUE;
+ $ret['shortcodes'] = $sc;
if(!varset($EMAIL_TEMPLATE['signup']['header']))
{
@@ -1251,7 +1232,7 @@ class e_system_user extends e_user_model
}
else
{
- $HEAD = $tp->parseTemplate($EMAIL_TEMPLATE['signup']['header'], true);
+ $HEAD = ""; // $tp->parseTemplate($EMAIL_TEMPLATE['signup']['header'], true);
}
if(!varset($EMAIL_TEMPLATE['signup']['footer']))
@@ -1260,25 +1241,42 @@ class e_system_user extends e_user_model
}
else
{
- $FOOT = $tp->parseTemplate($EMAIL_TEMPLATE['signup']['footer'], true);
+ $FOOT = ""; // $tp->parseTemplate($EMAIL_TEMPLATE['signup']['footer'], true);
}
- $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
+ $ret['send_html'] = TRUE;
+ $ret['email_body'] = $HEAD.$template.$FOOT; // e107::getParser()->parseTemplate(str_replace($search,$replace,$HEAD.$template.$FOOT), true);
+ $ret['preview'] = $tp->parseTemplate($ret['email_body'],true, $sc);// Non-standard field
+ $ret['shortcodes'] = $sc;
+
+
return $ret;
}
- // all other email types
- $subject = $userInfo['email_subject'];
+ // all other email types
+ if(!$userInfo['email_subject'])
+ {
+ return array();
+ }
- if(!$subject) return array();
+ $ret['email_subject'] = $userInfo['email_subject']; // $EMAIL_TEMPLATE['signup']['subject'];
+ $ret['e107_header'] = $userInfo['user_id'];
- $ret['e107_header'] = $userInfo['user_id'];
- if (vartrue($userInfo['email_copy_to'])) { $ret['email_copy_to'] = $userInfo['email_copy_to']; }
- if (vartrue($userInfo['email_bcopy_to'])) { $ret['email_bcopy_to'] = $userInfo['email_bcopy_to']; }
- if (vartrue($userInfo['email_attach'])) { $ret['email_attach'] = $userInfo['email_attach']; }
+ if (vartrue($userInfo['email_copy_to'])) { $ret['email_copy_to'] = $userInfo['email_copy_to']; }
+ if (vartrue($userInfo['email_bcopy_to'])) { $ret['email_bcopy_to'] = $userInfo['email_bcopy_to']; }
+ if (vartrue($userInfo['email_attach'])) { $ret['email_attach'] = $userInfo['email_attach']; }
+ $sc = array();
+
+ $sc['LOGINNAME'] = intval($pref['allowEmailLogin']) === 0 ? $userInfo['user_loginname'] : $userInfo['user_email'];
+ $sc['DISPLAYNAME'] = $userInfo['user_login'] ? $userInfo['user_login'] : $userInfo['user_name'];
+ $sc['SITEURL'] = "".SITEURL."";
+ $sc['USERNAME'] = $userInfo['user_name'];
+ $sc['USERURL'] = vartrue($userInfo['user_website']) ? $userInfo['user_website'] : "";
+ $sc['PASSWORD'] = $pass_show ? $pass_show : '******';
+
+
+ /*
$search[0] = '{LOGINNAME}';
$replace[0] = intval($pref['allowEmailLogin']) === 0 ? $userInfo['user_loginname'] : $userInfo['user_email'];
@@ -1300,23 +1298,31 @@ class e_system_user extends e_user_model
$search[6] = '{USERURL}';
$replace[6] = vartrue($userInfo['user_website']) ? $userInfo['user_website'] : "";
- $ret['email_subject'] = str_replace($search, $replace, $subject);
+ $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['email_body'] = e107::getParser()->parseTemplate(str_replace($search, $replace, $template));
- $ret['preview'] = $ret['mail_body']; // Non-standard field
+ $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;
return $ret;
}
diff --git a/signup.php b/signup.php
index 8d1d7d360..6faef4e10 100644
--- a/signup.php
+++ b/signup.php
@@ -787,17 +787,11 @@ 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
-
- global $pref,$SIGNUPEMAIL_LINKSTYLE,$SIGNUPEMAIL_SUBJECT,$SIGNUPEMAIL_TEMPLATE;
if($preview == TRUE)
{
@@ -808,8 +802,18 @@ function headerjs()
$userInfo['user_website'] = "www.test-site.com"; // This may not be defined
$userInfo['user_id'] = 0;
$userInfo['user_sess'] = "1234567890ABCDEFGHIJKLMNOP";
+ $userInfo['user_email'] = 'cameron@teslapower.solar';
+ $userInfo['activation_url'] = 'http://whereever.to.activate.com/';
}
-
+
+ return e107::getSystemUser($userInfo['user_id'], false)->renderEmail('signup', $userInfo);
+
+
+
+ /*
+
+ global $pref,$SIGNUPEMAIL_LINKSTYLE,$SIGNUPEMAIL_SUBJECT,$SIGNUPEMAIL_TEMPLATE;
+ *
define('RETURNADDRESS', (substr(SITEURL, -1) == "/" ? SITEURL."signup.php?activate.".$userInfo['user_id'].".".$userInfo['user_sess'] : SITEURL."/signup.php?activate.".$userInfo['user_id'].".".$userInfo['user_sess'].".".e_LAN));
$pass_show = ($pref['user_reg_secureveri'])? '*******' : $userInfo['user_password'];
@@ -882,8 +886,10 @@ function headerjs()
$ret['preview'] = $ret['mail_body']; // Non-standard field
return $ret;
+
+ */
}
-*/
+
function render_after_signup($error_message)