Commit 8ef69661 authored by Henning Leutz's avatar Henning Leutz 🥋

Merge branch 'dev'

parents 1bcdf841 505a1789
......@@ -1209,6 +1209,14 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/RegistrationSignUp'
Input.addClass('quiqqer-registration-field-error');
self.$tooltips[tipId] = Tip;
// destroy after 5 seconds
(function () {
Tip.hide();
Tip.destroy();
Input.set('data-has-tooltip', '');
delete self.$tooltips[this];
}).delay(3000, tipId);
});
}
......
......@@ -240,6 +240,10 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [
self.$onSuccess();
if (self.getAttribute('ownRedirectOnLogin')) {
return;
}
if (typeof self.getAttribute('onSuccess') === 'function') {
self.getAttribute('onSuccess')(self);
return;
......
......@@ -11,6 +11,33 @@ use QUI;
*/
class SendUserMails extends QUI\System\Console\Tool
{
/**
* Mail settings
*
* @var array
*/
protected $mail = [
'body' => '',
'senderMail' => '',
'senderName' => '',
'subject' => ''
];
/**
* @var array
*/
protected $recipients = [];
/**
* General settings
*
* @var array
*/
protected $settings = [
'setNewPassword' => false,
'forcePasswordReset' => true
];
/**
* Constructor
*/
......@@ -78,6 +105,25 @@ class SendUserMails extends QUI\System\Console\Tool
$groupIds = explode(',', $groupIds);
}
// GENERATE NEW PASSWORD?
$this->writeLn(
"Shall a new password be generated for each user? The new password will be available via the"
." [password] placeholder in the e-mail body. (y/N): "
);
$generatePassword = mb_strtolower($this->readInput()) === 'y';
$forcePasswordReset = false;
if ($generatePassword) {
$this->writeLn(
"Shall users be forced to set a new password immediately after logging in with their"
." generated password? (Y/n): "
);
$input = $this->readInput();
$forcePasswordReset = empty($input) || mb_strtolower($input) !== 'n';
}
// ORDER BY
$this->writeLn("ORDER BY clause for the `users` table (leave empty to use default order): ");
$orderBy = $this->readInput();
......@@ -142,6 +188,8 @@ class SendUserMails extends QUI\System\Console\Tool
$this->writeLn("Include INACTIVE users: ".($inactiveUsers ? "YES" : "NO"));
$this->writeLn("User languages: ".implode(', ', $languages));
$this->writeLn("User groups: ".(empty($groupIds) ? "ALL" : implode(', ', $groupIds)));
$this->writeLn("Generate new password: ".($generatePassword ? "YES" : "NO"));
$this->writeLn("Force password reset: ".($forcePasswordReset ? "YES" : "NO"));
$this->writeLn("ORDER BY: ".(empty($orderBy) ? "DEFAULT" : $orderBy));
$this->writeLn("\nE-Mail subject: ".$subject);
$this->writeLn("\nE-Mail sender mail: ".$senderMail);
......@@ -151,6 +199,15 @@ class SendUserMails extends QUI\System\Console\Tool
." ".(count($result) - count($recipients))." users have no e-mail address and are ignored."
);
$this->mail['body'] = $body;
$this->mail['senderMail'] = $senderMail;
$this->mail['senderName'] = $senderName;
$this->mail['subject'] = $subject;
$this->recipients = $recipients;
$this->settings['forcePasswordReset'] = $forcePasswordReset;
$this->settings['setNewPassword'] = $generatePassword;
// TEST MAIL
$this->writeLn("\n\nSend test mail? (Y/n): ");
$testMail = mb_strtolower($this->readInput()) !== 'n';
......@@ -161,19 +218,7 @@ class SendUserMails extends QUI\System\Console\Tool
if (!empty($testEmailAddress)) {
$this->writeLn("\nSend test mail...");
$this->sendMails(
$body,
$senderMail,
$senderName,
$subject,
[
0 => [
'username' => 'Test-User',
'email' => $testEmailAddress
]
]
);
$this->write(" SENT!");
$this->sendMails($testEmailAddress);
}
}
......@@ -186,21 +231,31 @@ class SendUserMails extends QUI\System\Console\Tool
return;
}
$this->sendMails($body, $senderMail, $senderName, $subject, $recipients);
$this->sendMails();
$this->exitSuccess();
}
/**
* @param string $body
* @param string $senderMail
* @param string $senderName
* @param string $subject
* @param array $recipients
* @param string $testMailAddress (optional) - If set, a single test mail will be sent to this address
* @return void
*/
protected function sendMails($body, $senderMail, $senderName, $subject, $recipients)
protected function sendMails($testMailAddress = null)
{
$Users = QUI::getUsers();
$SystemUser = $Users->getSystemUser();
if ($testMailAddress === null) {
$recipients = $this->recipients;
} else {
$recipients = [
0 => [
'username' => 'Test-User',
'email' => $testMailAddress
]
];
}
// Queue mails
foreach ($recipients as $recipient) {
if (!empty($recipient['firstname']) && !empty($recipient['lastname'])) {
......@@ -209,24 +264,60 @@ class SendUserMails extends QUI\System\Console\Tool
$name = $recipient['username'];
}
$email = $recipient['email'];
$email = $recipient['email'];
$newPassword = '';
if (!$testMailAddress && $this->settings['setNewPassword']) {
$this->writeLn("Generating new password for $email...");
try {
$User = $Users->get($recipient['id']);
$newPassword = QUI\Security\Password::generateRandom();
$User->setPassword($newPassword, $SystemUser);
$this->write(" OK!");
if ($this->settings['forcePasswordReset']) {
$this->writeLn("Set force new password...");
$User->setAttribute('quiqqer.set.new.password', true);
$User->save($SystemUser);
$this->write(" OK!");
}
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
$this->write(" Error: ".$Exception->getMessage());
}
}
$body = str_replace(
['[name]', '[email]'],
[$name, $email],
$body
['[name]', '[email]', '[password]'],
[$name, $email, $newPassword],
$this->mail['body']
);
$Mailer = QUI::getMailManager()->getMailer();
$Mailer->setFrom($senderMail);
$Mailer->setFromName($senderName);
$Mailer->setSubject($subject);
$Mailer->setFrom($this->mail['senderMail']);
$Mailer->setFromName($this->mail['senderName']);
$Mailer->setSubject($this->mail['subject']);
$Mailer->setHTML(true);
$Mailer->setBody($body);
$Mailer->addRecipient($email);
$Mailer->send();
$this->writeLn("Sending mail to $name ($email)...");
try {
$Mailer->send();
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
$this->write(" Error: ".$Exception->getMessage());
continue;
}
$this->write(" OK!");
}
}
......@@ -237,7 +328,7 @@ class SendUserMails extends QUI\System\Console\Tool
*/
protected function exitSuccess()
{
$this->writeLn("Mails have been successfully queued and will be sent via cron.");
$this->writeLn("\n\nMails have been successfully queued and will be sent via cron.");
$this->writeLn("");
exit(0);
......
......@@ -19,21 +19,7 @@
.quiqqer-fu-login-container {
position: relative;
}
.quiqqer-fu-login-container h2 {
text-align: center;
position: relative;
}
.quiqqer-fu-login-container h2:after {
background: #3986dd;
bottom: -10px;
content: '';
height: 2px;
left: calc(50% - 40px);
position: absolute;
width: 80px;
width: 100%;
}
.quiqqer-fu-login-social-entry {
......
......@@ -15,7 +15,9 @@
{else}
<section class="quiqqer-fu-login-container" style="display: none">
<h2>{locale group="quiqqer/frontend-users" var="control.login.title"}</h2>
{if $this->getAttribute('header')}
<h2>{locale group="quiqqer/frontend-users" var="control.login.title"}</h2>
{/if}
<div class="quiqqer-fu-login-social">
{foreach $authenticators as $entry}
......
......@@ -30,12 +30,13 @@ class Login extends QUI\Control
'authenticators' => [],
'Authenticator' => false, // currently executed Registrar
'mail' => true, // show mail authenticator
'passwordReset' => true // show password reset
'passwordReset' => true, // show password reset
'header' => true // show header title
]);
$this->setAttributes($attributes);
$this->addCSSFile(dirname(__FILE__).'/Login.css');
$this->addCSSFile(dirname(__FILE__) . '/Login.css');
$this->addCSSClass('quiqqer-fu-login');
$this->setJavaScriptControl(
......@@ -124,7 +125,7 @@ class Login extends QUI\Control
'showPasswordReset' => $showPasswordReset
]);
return $Engine->fetch(dirname(__FILE__).'/Login.html');
return $Engine->fetch(dirname(__FILE__) . '/Login.html');
}
/**
......
......@@ -12,7 +12,9 @@
{locale group="quiqqer/frontend-users" var="message.types.registration.already_registered"}
</div>
{else}
<h2>{locale group="quiqqer/frontend-users" var="control.registration.sign.up.title"}</h2>
{if $this->getAttribute('header')}
<h2>{locale group="quiqqer/frontend-users" var="control.registration.sign.up.title"}</h2>
{/if}
{if $msgSuccess}
<div class="message-success">
......
......@@ -37,14 +37,15 @@ class RegistrationSignUp extends QUI\Control
'Registrar' => false, // currently executed Registrar
'content' => '', // right content
'registration-trial' => false // use registration trial
'registration-trial' => false, // use registration trial
'header' => true // how header title
]);
$this->setAttributes($attributes);
$this->id = QUI\FrontendUsers\Handler::getInstance()->createRegistrationId();
$this->addCSSFile(\dirname(__FILE__).'/RegistrationSignUp.css');
$this->addCSSFile(\dirname(__FILE__) . '/RegistrationSignUp.css');
$this->addCSSClass('quiqqer-fu-registrationSignUp');
$this->setJavaScriptControl(
......@@ -117,7 +118,7 @@ class RegistrationSignUp extends QUI\Control
]);
$Engine->assign([
'captchaHTML' => $Engine->fetch(\dirname(__FILE__).'/RegistrationSignUp.Captcha.html')
'captchaHTML' => $Engine->fetch(\dirname(__FILE__) . '/RegistrationSignUp.Captcha.html')
]);
// default stuff
......@@ -183,7 +184,7 @@ class RegistrationSignUp extends QUI\Control
case 'userdelete':
$msgSuccess = QUI::getLocale()->get(
'quiqqer/frontend-users',
'RegistrationSignUp.message.success.'.$_GET['success']
'RegistrationSignUp.message.success.' . $_GET['success']
);
$showLoggedInWarning = false;
......@@ -198,7 +199,7 @@ class RegistrationSignUp extends QUI\Control
case 'userdelete':
$msgError = QUI::getLocale()->get(
'quiqqer/frontend-users',
'RegistrationSignUp.message.error.'.$_GET['error']
'RegistrationSignUp.message.error.' . $_GET['error']
);
$showLoggedInWarning = false;
......@@ -231,7 +232,7 @@ class RegistrationSignUp extends QUI\Control
'redirect' => $redirect
]);
return $Engine->fetch(\dirname(__FILE__).'/RegistrationSignUp.html');
return $Engine->fetch(\dirname(__FILE__) . '/RegistrationSignUp.html');
}
/**
......
......@@ -374,7 +374,16 @@ class Events
}
clearInterval(waitForRequireEventRegister);
registerNewLogin();
var loadQUI = function () {
return Promise.resolve();
};
if (typeof whenQuiLoaded === 'function') {
loadQUI = whenQuiLoaded;
}
loadQUI().then(registerNewLogin);
}, 200);
})();
</script>";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment