allow to send password mail to alternate recipient
This commit is contained in:
parent
5932e0abc6
commit
1f49f941f6
|
@ -185,6 +185,8 @@ $helpArray = array (
|
||||||
"Text" => _("Here you can import PDF structures from other server profiles (overwrite existing).")),
|
"Text" => _("Here you can import PDF structures from other server profiles (overwrite existing).")),
|
||||||
"409" => array ("Headline" => _("Export PDF structure"),
|
"409" => array ("Headline" => _("Export PDF structure"),
|
||||||
"Text" => _("Here you can export PDF structures to other server profiles (overwrite existing). You may also export a structure to the global templates. In this case it will always be copied to all server profiles that do not yet have a structure with this name.")),
|
"Text" => _("Here you can export PDF structures to other server profiles (overwrite existing). You may also export a structure to the global templates. In this case it will always be copied to all server profiles that do not yet have a structure with this name.")),
|
||||||
|
"410" => array ("Headline" => _("Alternate recipient"),
|
||||||
|
"Text" => _("Here you can enter an alternative mail address for the password. To use the user's primary email address please leave the field blank.")),
|
||||||
// 500 - 599
|
// 500 - 599
|
||||||
// LAM Pro
|
// LAM Pro
|
||||||
"501" => array ("Headline" => _("LDAP suffix"),
|
"501" => array ("Headline" => _("LDAP suffix"),
|
||||||
|
|
|
@ -888,12 +888,16 @@ function extractDNSuffix($dn) {
|
||||||
*
|
*
|
||||||
* @param String $pwd new password
|
* @param String $pwd new password
|
||||||
* @param array $user LDAP attributes of user
|
* @param array $user LDAP attributes of user
|
||||||
|
* @param String $recipient recipient address (optional, $user['mail'][0] used by default)
|
||||||
* @return array list of arrays that can be used to create status messages
|
* @return array list of arrays that can be used to create status messages
|
||||||
*/
|
*/
|
||||||
function sendPasswordMail($pwd, $user) {
|
function sendPasswordMail($pwd, $user, $recipient = null) {
|
||||||
$user = array_change_key_case($user, CASE_LOWER);
|
$user = array_change_key_case($user, CASE_LOWER);
|
||||||
// read mail data
|
// read mail data
|
||||||
$mailTo = $user['mail'][0];
|
$mailTo = $user['mail'][0];
|
||||||
|
if (!empty($recipient)) {
|
||||||
|
$mailTo = $recipient;
|
||||||
|
}
|
||||||
$mailFrom = $_SESSION['config']->getLamProMailFrom();
|
$mailFrom = $_SESSION['config']->getLamProMailFrom();
|
||||||
$mailReplyTo = $_SESSION['config']->getLamProMailReplyTo();
|
$mailReplyTo = $_SESSION['config']->getLamProMailReplyTo();
|
||||||
$mailSubject = $_SESSION['config']->getLamProMailSubject();
|
$mailSubject = $_SESSION['config']->getLamProMailSubject();
|
||||||
|
|
|
@ -748,6 +748,8 @@ class accountContainer {
|
||||||
private $titleBarSubtitle = null;
|
private $titleBarSubtitle = null;
|
||||||
/** send password via mail */
|
/** send password via mail */
|
||||||
private $sendPasswordViaMail = null;
|
private $sendPasswordViaMail = null;
|
||||||
|
/** send password via mail to this alternate address */
|
||||||
|
private $sendPasswordViaMailAlternateAddress = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the account module with the given class name
|
* Returns the account module with the given class name
|
||||||
|
@ -1040,8 +1042,11 @@ class accountContainer {
|
||||||
$container->addElement(new htmlHelpLink('406'), true);
|
$container->addElement(new htmlHelpLink('406'), true);
|
||||||
}
|
}
|
||||||
if (isLAMProVersion() && isset($this->attributes_orig['mail'][0])) {
|
if (isLAMProVersion() && isset($this->attributes_orig['mail'][0])) {
|
||||||
$container->addElement(new htmlTableExtendedInputCheckbox('lamPasswordChangeSendMail', false, _('Send via mail')));
|
$pwdMailCheckbox = new htmlTableExtendedInputCheckbox('lamPasswordChangeSendMail', false, _('Send via mail'));
|
||||||
|
$pwdMailCheckbox->setTableRowsToShow(array('lamPasswordChangeSendMailAddress'));
|
||||||
|
$container->addElement($pwdMailCheckbox);
|
||||||
$container->addElement(new htmlHelpLink('407'), true);
|
$container->addElement(new htmlHelpLink('407'), true);
|
||||||
|
$container->addElement(new htmlTableExtendedInputField(_('Alternate recipient'), 'lamPasswordChangeSendMailAddress', '', '410'));
|
||||||
}
|
}
|
||||||
$container->addElement(new htmlSpacer(null, '10px'), true);
|
$container->addElement(new htmlSpacer(null, '10px'), true);
|
||||||
// password modules
|
// password modules
|
||||||
|
@ -1134,6 +1139,13 @@ class accountContainer {
|
||||||
}
|
}
|
||||||
if (isLAMProVersion() && $sendMail) {
|
if (isLAMProVersion() && $sendMail) {
|
||||||
$this->sendPasswordViaMail = $password1;
|
$this->sendPasswordViaMail = $password1;
|
||||||
|
if (!empty($input['sendMailAlternateAddress'])) {
|
||||||
|
if (!get_preg($input['sendMailAlternateAddress'], 'email')) {
|
||||||
|
$return['messages'] .= StatusMessage('ERROR', _('Alternate recipient'), _('Please enter a valid email address!'), array(), true);
|
||||||
|
$return['errorsOccured'] = 'true';
|
||||||
|
}
|
||||||
|
$this->sendPasswordViaMailAlternateAddress = $input['sendMailAlternateAddress'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($return['errorsOccured'] == 'false') {
|
if ($return['errorsOccured'] == 'false') {
|
||||||
$return['messages'] .= StatusMessage('INFO', _('The new password will be stored in the directory after you save this account.'), '', array(), true);
|
$return['messages'] .= StatusMessage('INFO', _('The new password will be stored in the directory after you save this account.'), '', array(), true);
|
||||||
|
@ -1780,7 +1792,7 @@ class accountContainer {
|
||||||
for ($i=0; $i<count($DNs); $i++) {
|
for ($i=0; $i<count($DNs); $i++) {
|
||||||
if (!$stopprocessing) {
|
if (!$stopprocessing) {
|
||||||
logNewMessage(LOG_DEBUG, 'Attribute changes for ' . $DNs[$i] . ":\n" . print_r($attributes[$DNs[$i]], true));
|
logNewMessage(LOG_DEBUG, 'Attribute changes for ' . $DNs[$i] . ":\n" . print_r($attributes[$DNs[$i]], true));
|
||||||
// modify attributes
|
// modify attributesabnahme
|
||||||
if (isset($attributes[$DNs[$i]]['modify']) && !$stopprocessing) {
|
if (isset($attributes[$DNs[$i]]['modify']) && !$stopprocessing) {
|
||||||
$success = @ldap_mod_replace($_SESSION['ldap']->server(), $DNs[$i], $attributes[$DNs[$i]]['modify']);
|
$success = @ldap_mod_replace($_SESSION['ldap']->server(), $DNs[$i], $attributes[$DNs[$i]]['modify']);
|
||||||
if (!$success) {
|
if (!$success) {
|
||||||
|
@ -1825,11 +1837,12 @@ class accountContainer {
|
||||||
}
|
}
|
||||||
// send password mail
|
// send password mail
|
||||||
if (!$stopprocessing && isLAMProVersion() && ($this->sendPasswordViaMail != null)) {
|
if (!$stopprocessing && isLAMProVersion() && ($this->sendPasswordViaMail != null)) {
|
||||||
$mailMessages = sendPasswordMail($this->sendPasswordViaMail, $prePostModifyAttributes);
|
$mailMessages = sendPasswordMail($this->sendPasswordViaMail, $prePostModifyAttributes, $this->sendPasswordViaMailAlternateAddress);
|
||||||
if (sizeof($mailMessages) > 0) {
|
if (sizeof($mailMessages) > 0) {
|
||||||
$errors = array_merge($errors, $mailMessages);
|
$errors = array_merge($errors, $mailMessages);
|
||||||
}
|
}
|
||||||
$this->sendPasswordViaMail = null;
|
$this->sendPasswordViaMail = null;
|
||||||
|
$this->sendPasswordViaMailAlternateAddress = null;
|
||||||
}
|
}
|
||||||
if (!$stopprocessing) {
|
if (!$stopprocessing) {
|
||||||
// post modify actions
|
// post modify actions
|
||||||
|
|
|
@ -248,13 +248,15 @@ function passwordHandleInput(random, ajaxURL) {
|
||||||
var pwd2 = jQuery('#passwordDialog').find('[name=newPassword2]').val();
|
var pwd2 = jQuery('#passwordDialog').find('[name=newPassword2]').val();
|
||||||
var forcePasswordChange = jQuery('input[name=lamForcePasswordChange]').prop('checked');
|
var forcePasswordChange = jQuery('input[name=lamForcePasswordChange]').prop('checked');
|
||||||
var sendMail = jQuery('input[name=lamPasswordChangeSendMail]').prop('checked');
|
var sendMail = jQuery('input[name=lamPasswordChangeSendMail]').prop('checked');
|
||||||
|
var sendMailAlternateAddress = jQuery('#passwordDialog').find('[name=lamPasswordChangeSendMailAddress]').val();
|
||||||
var pwdJSON = {
|
var pwdJSON = {
|
||||||
"modules": modules,
|
"modules": modules,
|
||||||
"password1": pwd1,
|
"password1": pwd1,
|
||||||
"password2": pwd2,
|
"password2": pwd2,
|
||||||
"random": random,
|
"random": random,
|
||||||
"forcePasswordChange": forcePasswordChange,
|
"forcePasswordChange": forcePasswordChange,
|
||||||
"sendMail": sendMail
|
"sendMail": sendMail,
|
||||||
|
"sendMailAlternateAddress": sendMailAlternateAddress
|
||||||
};
|
};
|
||||||
// make AJAX call
|
// make AJAX call
|
||||||
jQuery.post(ajaxURL, {jsonInput: pwdJSON}, function(data) {passwordHandleReply(data);}, 'json');
|
jQuery.post(ajaxURL, {jsonInput: pwdJSON}, function(data) {passwordHandleReply(data);}, 'json');
|
||||||
|
|
Loading…
Reference in New Issue