diff --git a/config.ini b/config.ini index 884666e3..12dcc23f 100644 --- a/config.ini +++ b/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" diff --git a/src/Controllers/UserController.php b/src/Controllers/UserController.php index 5a5a64ba..08b81026 100644 --- a/src/Controllers/UserController.php +++ b/src/Controllers/UserController.php @@ -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 = []; diff --git a/src/core.php b/src/core.php index 53fefa99..4f17e858 100644 --- a/src/core.php +++ b/src/core.php @@ -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');