mirror of
https://github.com/LDAPAccountManager/lam.git
synced 2025-10-03 01:39:33 +02:00
#441 SMS sending
This commit is contained in:
parent
9078e22a51
commit
25fdf5f978
3 changed files with 31 additions and 7 deletions
|
@ -435,6 +435,9 @@ $helpArray = [
|
|||
"411" => ["Headline" => _("Font"),
|
||||
"Text" => _("Please select the font for the PDF file. Dejavu will work on all systems but does not support e.g. Chinese and Japanese. The other fonts require that an appropriate font is installed on the system where the PDF is opened.")
|
||||
],
|
||||
"412" => ["Headline" => _("Send via SMS"),
|
||||
"Text" => _("Sends the password to the user via SMS.")
|
||||
],
|
||||
// 500 - 599
|
||||
// LAM Pro
|
||||
"501" => ["Headline" => _("LDAP suffix"),
|
||||
|
|
|
@ -835,8 +835,10 @@ class accountContainer {
|
|||
private $titleBarTitle;
|
||||
/** subtitle in title bar */
|
||||
private $titleBarSubtitle;
|
||||
/** send password via mail */
|
||||
/** password to send via mail */
|
||||
private $sendPasswordViaMail;
|
||||
/** password to send via SMS */
|
||||
private $sendPasswordViaSms;
|
||||
/** send password via mail to this alternate address */
|
||||
private $sendPasswordViaMailAlternateAddress;
|
||||
|
||||
|
@ -1180,9 +1182,9 @@ class accountContainer {
|
|||
}
|
||||
$forcePwdGroup->addElement(new htmlHelpLink('406'));
|
||||
$container->addField($forcePwdGroup);
|
||||
$container->addVerticalSpacer('0.25rem');
|
||||
}
|
||||
if (isLAMProVersion() && (isset($this->attributes_orig['mail'][0]) || $this->anyModuleManagesMail())) {
|
||||
$container->addVerticalSpacer('0.25rem');
|
||||
$pwdMailCheckbox = new htmlResponsiveInputCheckbox('lamPasswordChangeSendMail', false, _('Send via mail'), '407');
|
||||
$pwdMailCheckbox->setTableRowsToShow(['lamPasswordChangeMailAddress']);
|
||||
$container->add($pwdMailCheckbox);
|
||||
|
@ -1199,6 +1201,9 @@ class accountContainer {
|
|||
$container->add($alternateMailInput);
|
||||
}
|
||||
}
|
||||
if (isLAMProVersion() && (getSmsPhoneNumber($this->attributes_orig) !== null)) {
|
||||
$container->add(new htmlResponsiveInputCheckbox('lamPasswordChangeSendSms', false, _('Send via SMS'), '412'));
|
||||
}
|
||||
$container->addVerticalSpacer('0.25rem');
|
||||
// password modules
|
||||
$moduleContainer = new htmlGroup();
|
||||
|
@ -1265,13 +1270,11 @@ class accountContainer {
|
|||
'messages' => '',
|
||||
'errorsOccurred' => 'false'
|
||||
];
|
||||
$sendMail = false;
|
||||
if (isset($input['sendMail']) && ($input['sendMail'] == 'true')) {
|
||||
$sendMail = true;
|
||||
}
|
||||
$sendMail = isset($input['sendMail']) && ($input['sendMail'] == 'true');
|
||||
$sendSms = isset($input['sendSms']) && ($input['sendSms'] == 'true');
|
||||
if ($random) {
|
||||
$password1 = generateRandomPassword();
|
||||
if (!$sendMail) {
|
||||
if (!$sendMail && !$sendSms) {
|
||||
$return['messages'] .= StatusMessage('INFO', _('The password was set to:') . ' ' . htmlspecialchars($password1), '', [], true);
|
||||
}
|
||||
}
|
||||
|
@ -1325,6 +1328,9 @@ class accountContainer {
|
|||
$this->sendPasswordViaMailAlternateAddress = $input['sendMailAlternateAddress'];
|
||||
}
|
||||
}
|
||||
if (isLAMProVersion() && $sendSms) {
|
||||
$this->sendPasswordViaSms = $password1;
|
||||
}
|
||||
if ($return['errorsOccurred'] === 'false') {
|
||||
$return['messages'] .= StatusMessage('INFO', _('The new password will be stored in the directory after you save this account.'), '', [], true);
|
||||
$this->extraInfoAttributes['INFO.passwordUpdated'] = 'yes';
|
||||
|
@ -1332,6 +1338,7 @@ class accountContainer {
|
|||
$this->extraInfoAttributes['INFO.passwordChangeModules'] = implode(', ', $modules);
|
||||
$this->extraInfoAttributes['INFO.passwordChangeType'] = $random ? 'random' : 'manual';
|
||||
$this->extraInfoAttributes['INFO.sendPasswordViaEmail'] = $sendMail ? 'yes' : 'no';
|
||||
$this->extraInfoAttributes['INFO.sendPasswordViaSms'] = $sendSms ? 'yes' : 'no';
|
||||
if (!empty($input['sendMailAlternateAddress'])) {
|
||||
$this->extraInfoAttributes['INFO.sendPasswordAlternateAddress'] = $input['sendMailAlternateAddress'];
|
||||
}
|
||||
|
@ -2106,6 +2113,14 @@ class accountContainer {
|
|||
$this->sendPasswordViaMail = null;
|
||||
$this->sendPasswordViaMailAlternateAddress = null;
|
||||
}
|
||||
// send password SMS
|
||||
if (!$stopprocessing && isLAMProVersion() && ($this->sendPasswordViaSms != null)) {
|
||||
$smsMessages = sendPasswordSms($this->sendPasswordViaSms, $prePostModifyAttributes);
|
||||
if (count($smsMessages) > 0) {
|
||||
$errors = array_merge($errors, $smsMessages);
|
||||
}
|
||||
$this->sendPasswordViaSms = null;
|
||||
}
|
||||
if (!$stopprocessing) {
|
||||
// post modify actions
|
||||
foreach ($module as $singlemodule) {
|
||||
|
|
|
@ -232,6 +232,11 @@ function passwordHandleInput(random, ajaxURL, tokenName, tokenValue, okText) {
|
|||
if (lamPasswordChangeSendMailBox && lamPasswordChangeSendMailBox.checked) {
|
||||
sendMail = true;
|
||||
}
|
||||
let sendSms = false;
|
||||
const lamPasswordChangeSendSmsBox = passwordDialog.querySelector('input[name=lamPasswordChangeSendSms]');
|
||||
if (lamPasswordChangeSendSmsBox && lamPasswordChangeSendSmsBox.checked) {
|
||||
sendSms = true;
|
||||
}
|
||||
|
||||
let sendMailAlternateAddress = '';
|
||||
const lamPasswordChangeMailAddress = passwordDialog.querySelector('[name=lamPasswordChangeMailAddress]');
|
||||
|
@ -245,6 +250,7 @@ function passwordHandleInput(random, ajaxURL, tokenName, tokenValue, okText) {
|
|||
"random": random,
|
||||
"forcePasswordChange": forcePasswordChange,
|
||||
"sendMail": sendMail,
|
||||
"sendSms": sendSms,
|
||||
"sendMailAlternateAddress": sendMailAlternateAddress
|
||||
};
|
||||
let data = new FormData();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue