Confirmation e-mail sending disableable in config
This commit is contained in:
parent
6dd6163833
commit
5d5440a8f1
3 changed files with 21 additions and 12 deletions
11
config.ini
11
config.ini
|
@ -29,12 +29,13 @@ salt = "1A2/$_4xVa"
|
|||
needEmailForRegistering = 1
|
||||
needEmailForCommenting = 0
|
||||
needEmailForUploading = 1
|
||||
activationEmailSenderName = "{host} registration engine"
|
||||
activationEmailSenderEmail = "noreply@{host}"
|
||||
activationEmailSubject = "{host} activation"
|
||||
activationEmailBody = "Hello,
|
||||
confirmationEmailEnabled = 1
|
||||
confirmationEmailSenderName = "{host} registration engine"
|
||||
confirmationEmailSenderEmail = "noreply@{host}"
|
||||
confirmationEmailSubject = "{host} activation"
|
||||
confirmationEmailBody = "Hello,
|
||||
|
||||
You received this e-mail because someone registered an user with this address at {host}. If it's you, visit {link} to finish registration process, otherwise you may ignore and delete this e-mail.
|
||||
You received this e-mail because someone registered a user with this address at {host}. If it's you, visit {link} to finish registration process, otherwise you may ignore and delete this e-mail.
|
||||
|
||||
Kind regards,
|
||||
{host} registration engine"
|
||||
|
|
|
@ -9,18 +9,26 @@ class UserController
|
|||
return $user;
|
||||
}
|
||||
|
||||
private static function sendEmailConfirmation($user)
|
||||
private static function sendEmailConfirmation(&$user)
|
||||
{
|
||||
\Chibi\Registry::getContext()->mailSent = true;
|
||||
$regConfig = \Chibi\Registry::getConfig()->registration;
|
||||
|
||||
if (!$regConfig->confirmationEmailEnabled)
|
||||
{
|
||||
$user->email_confirmed = $user->email_unconfirmed;
|
||||
$user->email_unconfirmed = null;
|
||||
return;
|
||||
}
|
||||
|
||||
\Chibi\Registry::getContext()->mailSent = true;
|
||||
$tokens = [];
|
||||
$tokens['host'] = $_SERVER['HTTP_HOST'];
|
||||
$tokens['link'] = \Chibi\UrlHelper::route('user', 'activation', ['token' => $user->email_token]);
|
||||
|
||||
$body = wordwrap(TextHelper::replaceTokens($regConfig->activationEmailBody, $tokens), 70);
|
||||
$subject = TextHelper::replaceTokens($regConfig->activationEmailSubject, $tokens);
|
||||
$senderName = TextHelper::replaceTokens($regConfig->activationEmailSenderName, $tokens);
|
||||
$senderEmail = $regConfig->activationEmailSenderEmail;
|
||||
$body = wordwrap(TextHelper::replaceTokens($regConfig->confirmationEmailBody, $tokens), 70);
|
||||
$subject = TextHelper::replaceTokens($regConfig->confirmationEmailSubject, $tokens);
|
||||
$senderName = TextHelper::replaceTokens($regConfig->confirmationEmailSenderName, $tokens);
|
||||
$senderEmail = $regConfig->confirmationEmailSenderEmail;
|
||||
$recipientEmail = $user->email_unconfirmed;
|
||||
|
||||
$headers = [];
|
||||
|
|
|
@ -27,7 +27,7 @@ function configFactory()
|
|||
$configPaths =
|
||||
[
|
||||
__DIR__ . DS . '../config.ini',
|
||||
__DIR__ . DS . '../local.ini'
|
||||
__DIR__ . DS . '../local.ini',
|
||||
];
|
||||
$configPaths = array_filter($configPaths, 'file_exists');
|
||||
|
||||
|
|
Loading…
Reference in a new issue