mirror of
https://github.com/e107inc/e107.git
synced 2025-08-05 06:07:32 +02:00
Mail template work. Quick-Add-User now has it's own template also.
This commit is contained in:
@@ -302,30 +302,43 @@ if (isset ($_POST['adduser']))
|
||||
$message = '';
|
||||
$user_data['user_password'] = $userMethods->HashPassword($savePassword,$user_data['user_login']);
|
||||
$user_data['user_join'] = time();
|
||||
|
||||
if ($userMethods->needEmailPassword())
|
||||
{
|
||||
// Save separate password encryption for use with email address
|
||||
$user_data['user_prefs'] = serialize(array('email_password' => $userMethods->HashPassword($savePassword,$user_data['user_email'])));
|
||||
}
|
||||
|
||||
$userMethods->userClassUpdate($allData['data'],'userall');
|
||||
// Set any initial classes
|
||||
$userMethods->addNonDefaulted($user_data);
|
||||
validatorClass :: addFieldTypes($userMethods->userVettingInfo,$allData);
|
||||
//FIXME - (SecretR) there is a better way to fix this (missing default value, sql error in strict mode - user_realm is to be deleted from DB later)
|
||||
$allData['data']['user_realm'] = '';
|
||||
|
||||
if ($sql->db_Insert('user',$allData))
|
||||
{
|
||||
// Add to admin log
|
||||
// Add to admin log
|
||||
$admin_log->log_event('USET_02',"UName: {$user_data['user_name']}; Email: {$user_data['user_email']}",E_LOG_INFORMATIVE);
|
||||
|
||||
// Add to user audit trail
|
||||
$admin_log->user_audit(USER_AUDIT_ADD_ADMIN,$user_data,0,$user_data['user_loginname']);
|
||||
$e_event->trigger('userfull',$user_data);
|
||||
|
||||
// send everything available for user data - bit sparse compared with user-generated signup
|
||||
if (isset ($_POST['sendconfemail']))
|
||||
{
|
||||
// Send confirmation email to user
|
||||
require_once (e_HANDLER.'mail.php');
|
||||
$e_message = str_replace(array('--SITE--','--LOGIN--','--PASSWORD--'),array(SITEURL,$user_data['user_login'],$savePassword),USRLAN_185).USRLAN_186;
|
||||
require_once(e_HANDLER.'mail.php');
|
||||
include_once(e107::coreTemplatePath('email','front')); //correct way to load a core template.
|
||||
|
||||
if(!isset($QUICKADDUSER_TEMPLATE))
|
||||
{
|
||||
$QUICKADDUSER_TEMPLATE = USRLAN_185.USRLAN_186;
|
||||
}
|
||||
|
||||
$e_message = str_replace(array('{SITEURL}','{LOGIN}','{USERNAME}','{PASSWORD}'),array(SITEURL,$user_data['user_name'],$user_data['user_login'],$savePassword),$QUICKADDUSER_TEMPLATE);
|
||||
|
||||
if (sendemail($user_data['user_email'],USRLAN_187.SITEURL,$e_message,$user_data['user_login'],'',''))
|
||||
{
|
||||
$message = USRLAN_188.'<br /><br />';
|
||||
@@ -335,17 +348,29 @@ if (isset ($_POST['adduser']))
|
||||
$message = USRLAN_189.'<br /><br />';
|
||||
}
|
||||
}
|
||||
|
||||
$message .= str_replace('--NAME--',$user_data['user_name'],USRLAN_174);
|
||||
|
||||
if (isset ($_POST['generateloginname']))
|
||||
$message .= '<br /><br />'.USRLAN_173.': '.$user_data['user_login'];
|
||||
{
|
||||
$message .= '<br /><br />'.USRLAN_173.': '.$user_data['user_login'];
|
||||
}
|
||||
|
||||
if (isset ($_POST['generatepassword']))
|
||||
$message .= '<br /><br />'.USRLAN_172.': '.$savePassword;
|
||||
{
|
||||
$message .= '<br /><br />'.USRLAN_172.': '.$savePassword;
|
||||
}
|
||||
|
||||
unset ($user_data);
|
||||
// Don't recycle the data once the user's been accepted without error
|
||||
}
|
||||
}
|
||||
|
||||
if (isset ($message))
|
||||
$user->show_message($message);
|
||||
{
|
||||
$user->show_message($message);
|
||||
}
|
||||
|
||||
}
|
||||
// ------- Bounce --> Unverified --------------
|
||||
if (isset ($_POST['useraction']) && $_POST['useraction'] == "reqverify")
|
||||
|
@@ -152,10 +152,11 @@ class e107Email extends PHPMailer
|
||||
private $TotalErrors = 0; // Count errors in sending emails
|
||||
private $pause_amount = 10; // Number of emails to send before pausing/resetting (or closing if SMTPkeepAlive set)
|
||||
private $pause_time = 1; // Time to pause after sending a block of emails
|
||||
|
||||
private $templateOption = array();
|
||||
public $legacyBody = FALSE; // TRUE enables legacy conversion of plain text body to HTML in HTML emails
|
||||
|
||||
/**
|
||||
public $template = "email"; // Choice of email, notify or mailout
|
||||
|
||||
/**
|
||||
* Constructor sets up all the global options, and sensible defaults - it should be the only place the prefs are accessed
|
||||
*
|
||||
* @var array $overrides - array of values which override mail-related prefs. Key is the same as the corresponding pref.
|
||||
@@ -167,7 +168,13 @@ class e107Email extends PHPMailer
|
||||
|
||||
$e107 = e107::getInstance();
|
||||
global $pref;
|
||||
|
||||
|
||||
//Load up Email Templates
|
||||
include(e107::coreTemplatePath('email','front'));
|
||||
$this->templateOption['email'] = array('header'=>$EMAIL_HEADER,'footer'=>$EMAIL_FOOTER);
|
||||
$this->templateOption['notify'] = array('header'=>$NOTIFY_HEADER,'footer'=>$NOTIFY_FOOTER);
|
||||
$this->templateOption['mailout'] = array('header'=>$MAILOUT_HEADER,'footer'=>$MAILOUT_FOOTER);
|
||||
|
||||
$this->CharSet = 'utf-8';
|
||||
$this->SetLanguage(CORE_LC);
|
||||
|
||||
@@ -709,6 +716,16 @@ class e107Email extends PHPMailer
|
||||
*/
|
||||
public function MsgHTML($message, $basedir = '')
|
||||
{
|
||||
|
||||
$tp = e107::getParser();
|
||||
|
||||
$EMAIL_HEADER = $tp->parseTemplate($this->templateOption[$this->template]['header']);
|
||||
$EMAIL_FOOTER = $tp->parseTemplate($this->templateOption[$this->template]['footer']);
|
||||
|
||||
$message = $EMAIL_HEADER.$message.$EMAIL_FOOTER;
|
||||
|
||||
|
||||
|
||||
preg_match_all("/(src|background)=([\"\'])(.*)\\2/Ui", $message, $images); // Modified to accept single quotes as well
|
||||
if(isset($images[3]))
|
||||
{
|
||||
@@ -745,8 +762,11 @@ class e107Email extends PHPMailer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->IsHTML(true);
|
||||
$this->Body = $message;
|
||||
|
||||
// print_a($message);
|
||||
$textMsg = str_replace(array('<br />', '<br>'), "\n", $message); // Modified to make sure newlines carried through
|
||||
$textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$textMsg)));
|
||||
|
@@ -185,7 +185,7 @@ define('USRLAN_181', 'Send confirmation email with password to new user');
|
||||
define('USRLAN_182', 'Invalid characters in login name');
|
||||
define('USRLAN_183', 'That login name already in use');
|
||||
define('USRLAN_184', 'Length of login name outside limits');
|
||||
define('USRLAN_185', 'A user account has been created for you at --SITE-- with the following login:<br />Login Name: --LOGIN--<br />Password: --PASSWORD--<br/><br />');
|
||||
define('USRLAN_185', 'A user account has been created for you at {SITEURL} with the following login:<br />Login Name: {LOGIN}<br />Password: {PASSWORD}<br/><br />');
|
||||
define('USRLAN_186', 'Please go to the site as soon as possible and log in, then change your password using the \'Settings\' option.<br /><br />
|
||||
You can also change other settings at the same time.<br /><br />Note that your password cannot be recovered if you lose it.');
|
||||
define('USRLAN_187', 'Access to website: ');
|
||||
|
@@ -44,19 +44,22 @@ $EMAIL_OVERRIDES = array(
|
||||
);
|
||||
*/
|
||||
|
||||
// Not used in signup email
|
||||
/**
|
||||
* Default HEADER for all emails
|
||||
*/
|
||||
$EMAIL_HEADER = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">
|
||||
<html xmlns='http://www.w3.org/1999/xhtml' >
|
||||
<head>
|
||||
<meta http-equiv='content-type' content='text/html; charset=utf-8' />
|
||||
{STYLESHEET}
|
||||
</head>
|
||||
<body>
|
||||
<div style='padding:10px'>
|
||||
";
|
||||
|
||||
|
||||
// Not used in signup email
|
||||
/**
|
||||
* Default FOOTER for all emails
|
||||
*/
|
||||
$EMAIL_FOOTER = "
|
||||
<br /><br />
|
||||
{SITENAME=link}
|
||||
@@ -65,18 +68,22 @@ $EMAIL_FOOTER = "
|
||||
</html>";
|
||||
|
||||
|
||||
//TODO - integrate into mailout routine
|
||||
/**
|
||||
* Mass-Mailing HEADER (admin->mailout)
|
||||
*/
|
||||
|
||||
$MAILOUT_HEADER = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">
|
||||
<html xmlns='http://www.w3.org/1999/xhtml' >
|
||||
<head>
|
||||
<meta http-equiv='content-type' content='text/html; charset=utf-8' />
|
||||
{STYLESHEET}
|
||||
</head>
|
||||
<body>
|
||||
<div style='padding:10px'>
|
||||
";
|
||||
|
||||
/**
|
||||
* Mass-Mailing FOOTER (admin->mailout)
|
||||
*/
|
||||
$MAILOUT_FOOTER = "
|
||||
<br /><br />
|
||||
{SITENAME=link}
|
||||
@@ -85,17 +92,22 @@ $MAILOUT_FOOTER = "
|
||||
</html>";
|
||||
|
||||
|
||||
/**
|
||||
* Notification Email HEADER (admin->notify)
|
||||
*/
|
||||
//TODO - integrate into notification routine
|
||||
$NOTIFY_HEADER = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">
|
||||
<html xmlns='http://www.w3.org/1999/xhtml' >
|
||||
<head>
|
||||
<meta http-equiv='content-type' content='text/html; charset=utf-8' />
|
||||
{STYLESHEET}
|
||||
</head>
|
||||
<body>
|
||||
<div style='padding:10px'>
|
||||
";
|
||||
|
||||
/**
|
||||
* Notification Email FOOTER (admin->notify)
|
||||
*/
|
||||
$NOTIFY_FOOTER = "
|
||||
<br /><br />
|
||||
{SITENAME=link}
|
||||
@@ -104,7 +116,9 @@ $NOTIFY_FOOTER = "
|
||||
</html>";
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* SIGNUP EMAIL TEMPLATE - BODY.
|
||||
*/
|
||||
$SIGNUPEMAIL_TEMPLATE = "
|
||||
<div style='padding:10px'>
|
||||
<div style='text-align:left; width:90%'>
|
||||
@@ -135,4 +149,15 @@ LAN_SIGNUP_97." {SITENAME}<br />
|
||||
";
|
||||
|
||||
|
||||
/*
|
||||
* QUICK ADD USER EMAIL TEMPLATE - BODY.
|
||||
* This is the email that is sent when an admin creates a user account in admin. "Quick Add User"
|
||||
USRLAN_185 = A user account has been created for you at {SITEURL} with the following login:<br />Login Name: {LOGIN}<br />Password: {PASSWORD}<br/><br />
|
||||
USRLAN_186 = Please go to the site as soon as possible and log in, then change your password using the \'Settings\' option.<br /><br />
|
||||
You can also change other settings at the same time.<br /><br />Note that your password cannot be recovered if you lose it.
|
||||
*/
|
||||
|
||||
$QUICKADDUSER_TEMPLATE = "<div style='padding:10px'>".USRLAN_185.USRLAN_186."</div>";
|
||||
|
||||
|
||||
?>
|
Reference in New Issue
Block a user