mirror of
https://github.com/LDAPAccountManager/lam.git
synced 2025-10-03 09:49:16 +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"),
|
"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.")
|
"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
|
// 500 - 599
|
||||||
// LAM Pro
|
// LAM Pro
|
||||||
"501" => ["Headline" => _("LDAP suffix"),
|
"501" => ["Headline" => _("LDAP suffix"),
|
||||||
|
|
|
@ -835,8 +835,10 @@ class accountContainer {
|
||||||
private $titleBarTitle;
|
private $titleBarTitle;
|
||||||
/** subtitle in title bar */
|
/** subtitle in title bar */
|
||||||
private $titleBarSubtitle;
|
private $titleBarSubtitle;
|
||||||
/** send password via mail */
|
/** password to send via mail */
|
||||||
private $sendPasswordViaMail;
|
private $sendPasswordViaMail;
|
||||||
|
/** password to send via SMS */
|
||||||
|
private $sendPasswordViaSms;
|
||||||
/** send password via mail to this alternate address */
|
/** send password via mail to this alternate address */
|
||||||
private $sendPasswordViaMailAlternateAddress;
|
private $sendPasswordViaMailAlternateAddress;
|
||||||
|
|
||||||
|
@ -1180,9 +1182,9 @@ class accountContainer {
|
||||||
}
|
}
|
||||||
$forcePwdGroup->addElement(new htmlHelpLink('406'));
|
$forcePwdGroup->addElement(new htmlHelpLink('406'));
|
||||||
$container->addField($forcePwdGroup);
|
$container->addField($forcePwdGroup);
|
||||||
|
$container->addVerticalSpacer('0.25rem');
|
||||||
}
|
}
|
||||||
if (isLAMProVersion() && (isset($this->attributes_orig['mail'][0]) || $this->anyModuleManagesMail())) {
|
if (isLAMProVersion() && (isset($this->attributes_orig['mail'][0]) || $this->anyModuleManagesMail())) {
|
||||||
$container->addVerticalSpacer('0.25rem');
|
|
||||||
$pwdMailCheckbox = new htmlResponsiveInputCheckbox('lamPasswordChangeSendMail', false, _('Send via mail'), '407');
|
$pwdMailCheckbox = new htmlResponsiveInputCheckbox('lamPasswordChangeSendMail', false, _('Send via mail'), '407');
|
||||||
$pwdMailCheckbox->setTableRowsToShow(['lamPasswordChangeMailAddress']);
|
$pwdMailCheckbox->setTableRowsToShow(['lamPasswordChangeMailAddress']);
|
||||||
$container->add($pwdMailCheckbox);
|
$container->add($pwdMailCheckbox);
|
||||||
|
@ -1199,6 +1201,9 @@ class accountContainer {
|
||||||
$container->add($alternateMailInput);
|
$container->add($alternateMailInput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isLAMProVersion() && (getSmsPhoneNumber($this->attributes_orig) !== null)) {
|
||||||
|
$container->add(new htmlResponsiveInputCheckbox('lamPasswordChangeSendSms', false, _('Send via SMS'), '412'));
|
||||||
|
}
|
||||||
$container->addVerticalSpacer('0.25rem');
|
$container->addVerticalSpacer('0.25rem');
|
||||||
// password modules
|
// password modules
|
||||||
$moduleContainer = new htmlGroup();
|
$moduleContainer = new htmlGroup();
|
||||||
|
@ -1265,13 +1270,11 @@ class accountContainer {
|
||||||
'messages' => '',
|
'messages' => '',
|
||||||
'errorsOccurred' => 'false'
|
'errorsOccurred' => 'false'
|
||||||
];
|
];
|
||||||
$sendMail = false;
|
$sendMail = isset($input['sendMail']) && ($input['sendMail'] == 'true');
|
||||||
if (isset($input['sendMail']) && ($input['sendMail'] == 'true')) {
|
$sendSms = isset($input['sendSms']) && ($input['sendSms'] == 'true');
|
||||||
$sendMail = true;
|
|
||||||
}
|
|
||||||
if ($random) {
|
if ($random) {
|
||||||
$password1 = generateRandomPassword();
|
$password1 = generateRandomPassword();
|
||||||
if (!$sendMail) {
|
if (!$sendMail && !$sendSms) {
|
||||||
$return['messages'] .= StatusMessage('INFO', _('The password was set to:') . ' ' . htmlspecialchars($password1), '', [], true);
|
$return['messages'] .= StatusMessage('INFO', _('The password was set to:') . ' ' . htmlspecialchars($password1), '', [], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1325,6 +1328,9 @@ class accountContainer {
|
||||||
$this->sendPasswordViaMailAlternateAddress = $input['sendMailAlternateAddress'];
|
$this->sendPasswordViaMailAlternateAddress = $input['sendMailAlternateAddress'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isLAMProVersion() && $sendSms) {
|
||||||
|
$this->sendPasswordViaSms = $password1;
|
||||||
|
}
|
||||||
if ($return['errorsOccurred'] === 'false') {
|
if ($return['errorsOccurred'] === 'false') {
|
||||||
$return['messages'] .= StatusMessage('INFO', _('The new password will be stored in the directory after you save this account.'), '', [], true);
|
$return['messages'] .= StatusMessage('INFO', _('The new password will be stored in the directory after you save this account.'), '', [], true);
|
||||||
$this->extraInfoAttributes['INFO.passwordUpdated'] = 'yes';
|
$this->extraInfoAttributes['INFO.passwordUpdated'] = 'yes';
|
||||||
|
@ -1332,6 +1338,7 @@ class accountContainer {
|
||||||
$this->extraInfoAttributes['INFO.passwordChangeModules'] = implode(', ', $modules);
|
$this->extraInfoAttributes['INFO.passwordChangeModules'] = implode(', ', $modules);
|
||||||
$this->extraInfoAttributes['INFO.passwordChangeType'] = $random ? 'random' : 'manual';
|
$this->extraInfoAttributes['INFO.passwordChangeType'] = $random ? 'random' : 'manual';
|
||||||
$this->extraInfoAttributes['INFO.sendPasswordViaEmail'] = $sendMail ? 'yes' : 'no';
|
$this->extraInfoAttributes['INFO.sendPasswordViaEmail'] = $sendMail ? 'yes' : 'no';
|
||||||
|
$this->extraInfoAttributes['INFO.sendPasswordViaSms'] = $sendSms ? 'yes' : 'no';
|
||||||
if (!empty($input['sendMailAlternateAddress'])) {
|
if (!empty($input['sendMailAlternateAddress'])) {
|
||||||
$this->extraInfoAttributes['INFO.sendPasswordAlternateAddress'] = $input['sendMailAlternateAddress'];
|
$this->extraInfoAttributes['INFO.sendPasswordAlternateAddress'] = $input['sendMailAlternateAddress'];
|
||||||
}
|
}
|
||||||
|
@ -2106,6 +2113,14 @@ class accountContainer {
|
||||||
$this->sendPasswordViaMail = null;
|
$this->sendPasswordViaMail = null;
|
||||||
$this->sendPasswordViaMailAlternateAddress = 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) {
|
if (!$stopprocessing) {
|
||||||
// post modify actions
|
// post modify actions
|
||||||
foreach ($module as $singlemodule) {
|
foreach ($module as $singlemodule) {
|
||||||
|
|
|
@ -232,6 +232,11 @@ function passwordHandleInput(random, ajaxURL, tokenName, tokenValue, okText) {
|
||||||
if (lamPasswordChangeSendMailBox && lamPasswordChangeSendMailBox.checked) {
|
if (lamPasswordChangeSendMailBox && lamPasswordChangeSendMailBox.checked) {
|
||||||
sendMail = true;
|
sendMail = true;
|
||||||
}
|
}
|
||||||
|
let sendSms = false;
|
||||||
|
const lamPasswordChangeSendSmsBox = passwordDialog.querySelector('input[name=lamPasswordChangeSendSms]');
|
||||||
|
if (lamPasswordChangeSendSmsBox && lamPasswordChangeSendSmsBox.checked) {
|
||||||
|
sendSms = true;
|
||||||
|
}
|
||||||
|
|
||||||
let sendMailAlternateAddress = '';
|
let sendMailAlternateAddress = '';
|
||||||
const lamPasswordChangeMailAddress = passwordDialog.querySelector('[name=lamPasswordChangeMailAddress]');
|
const lamPasswordChangeMailAddress = passwordDialog.querySelector('[name=lamPasswordChangeMailAddress]');
|
||||||
|
@ -245,6 +250,7 @@ function passwordHandleInput(random, ajaxURL, tokenName, tokenValue, okText) {
|
||||||
"random": random,
|
"random": random,
|
||||||
"forcePasswordChange": forcePasswordChange,
|
"forcePasswordChange": forcePasswordChange,
|
||||||
"sendMail": sendMail,
|
"sendMail": sendMail,
|
||||||
|
"sendSms": sendSms,
|
||||||
"sendMailAlternateAddress": sendMailAlternateAddress
|
"sendMailAlternateAddress": sendMailAlternateAddress
|
||||||
};
|
};
|
||||||
let data = new FormData();
|
let data = new FormData();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue