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).")),
|
||||
"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.")),
|
||||
"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
|
||||
// LAM Pro
|
||||
"501" => array ("Headline" => _("LDAP suffix"),
|
||||
|
|
|
@ -888,12 +888,16 @@ function extractDNSuffix($dn) {
|
|||
*
|
||||
* @param String $pwd new password
|
||||
* @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
|
||||
*/
|
||||
function sendPasswordMail($pwd, $user) {
|
||||
function sendPasswordMail($pwd, $user, $recipient = null) {
|
||||
$user = array_change_key_case($user, CASE_LOWER);
|
||||
// read mail data
|
||||
$mailTo = $user['mail'][0];
|
||||
if (!empty($recipient)) {
|
||||
$mailTo = $recipient;
|
||||
}
|
||||
$mailFrom = $_SESSION['config']->getLamProMailFrom();
|
||||
$mailReplyTo = $_SESSION['config']->getLamProMailReplyTo();
|
||||
$mailSubject = $_SESSION['config']->getLamProMailSubject();
|
||||
|
|
|
@ -748,6 +748,8 @@ class accountContainer {
|
|||
private $titleBarSubtitle = null;
|
||||
/** send password via mail */
|
||||
private $sendPasswordViaMail = null;
|
||||
/** send password via mail to this alternate address */
|
||||
private $sendPasswordViaMailAlternateAddress = null;
|
||||
|
||||
/**
|
||||
* Returns the account module with the given class name
|
||||
|
@ -1040,8 +1042,11 @@ class accountContainer {
|
|||
$container->addElement(new htmlHelpLink('406'), true);
|
||||
}
|
||||
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 htmlTableExtendedInputField(_('Alternate recipient'), 'lamPasswordChangeSendMailAddress', '', '410'));
|
||||
}
|
||||
$container->addElement(new htmlSpacer(null, '10px'), true);
|
||||
// password modules
|
||||
|
@ -1134,6 +1139,13 @@ class accountContainer {
|
|||
}
|
||||
if (isLAMProVersion() && $sendMail) {
|
||||
$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') {
|
||||
$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++) {
|
||||
if (!$stopprocessing) {
|
||||
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) {
|
||||
$success = @ldap_mod_replace($_SESSION['ldap']->server(), $DNs[$i], $attributes[$DNs[$i]]['modify']);
|
||||
if (!$success) {
|
||||
|
@ -1825,11 +1837,12 @@ class accountContainer {
|
|||
}
|
||||
// send password mail
|
||||
if (!$stopprocessing && isLAMProVersion() && ($this->sendPasswordViaMail != null)) {
|
||||
$mailMessages = sendPasswordMail($this->sendPasswordViaMail, $prePostModifyAttributes);
|
||||
$mailMessages = sendPasswordMail($this->sendPasswordViaMail, $prePostModifyAttributes, $this->sendPasswordViaMailAlternateAddress);
|
||||
if (sizeof($mailMessages) > 0) {
|
||||
$errors = array_merge($errors, $mailMessages);
|
||||
}
|
||||
$this->sendPasswordViaMail = null;
|
||||
$this->sendPasswordViaMailAlternateAddress = null;
|
||||
}
|
||||
if (!$stopprocessing) {
|
||||
// post modify actions
|
||||
|
|
|
@ -248,13 +248,15 @@ function passwordHandleInput(random, ajaxURL) {
|
|||
var pwd2 = jQuery('#passwordDialog').find('[name=newPassword2]').val();
|
||||
var forcePasswordChange = jQuery('input[name=lamForcePasswordChange]').prop('checked');
|
||||
var sendMail = jQuery('input[name=lamPasswordChangeSendMail]').prop('checked');
|
||||
var sendMailAlternateAddress = jQuery('#passwordDialog').find('[name=lamPasswordChangeSendMailAddress]').val();
|
||||
var pwdJSON = {
|
||||
"modules": modules,
|
||||
"password1": pwd1,
|
||||
"password2": pwd2,
|
||||
"random": random,
|
||||
"forcePasswordChange": forcePasswordChange,
|
||||
"sendMail": sendMail
|
||||
"sendMail": sendMail,
|
||||
"sendMailAlternateAddress": sendMailAlternateAddress
|
||||
};
|
||||
// make AJAX call
|
||||
jQuery.post(ajaxURL, {jsonInput: pwdJSON}, function(data) {passwordHandleReply(data);}, 'json');
|
||||
|
|
Loading…
Reference in New Issue