mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-18 00:09:06 +01:00
LSformElement::password: fix multiple sent email in some cases
This commit is contained in:
parent
2d27a7049f
commit
d15fdc5d8e
1 changed files with 49 additions and 48 deletions
|
@ -307,62 +307,63 @@ class LSformElement_password extends LSformElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function send($params) {
|
public function send($params) {
|
||||||
if (is_array($this -> sendMail)) {
|
if (!is_array($this -> sendMail))
|
||||||
$mail = (String)$this -> sendMail['mail'];
|
return true;
|
||||||
self :: log_debug("send(): mail from params: '$mail'");
|
$mail = (String)$this -> sendMail['mail'];
|
||||||
if (!$mail) {
|
self :: log_debug("send(): mail from params: '$mail'");
|
||||||
$mail_attrs = ensureIsArray($this -> getMailAttrs());
|
if (!$mail) {
|
||||||
self :: log_debug('send(): mail attrs: '.varDump($mail_attrs));
|
$mail_attrs = ensureIsArray($this -> getMailAttrs());
|
||||||
$checkDomainsList = $this -> getParam('html_options.mail.domain');
|
self :: log_debug('send(): mail attrs: '.varDump($mail_attrs));
|
||||||
$checkDomain = $this -> getParam('html_options.mail.checkDomain', true, 'bool');
|
$checkDomainsList = $this -> getParam('html_options.mail.domain');
|
||||||
foreach($mail_attrs as $attr) {
|
$checkDomain = $this -> getParam('html_options.mail.checkDomain', true, 'bool');
|
||||||
$mail_attr = $this -> attr_html -> attribute -> ldapObject -> attrs[$attr];
|
foreach($mail_attrs as $attr) {
|
||||||
if ($mail_attr instanceOf LSattribute) {
|
$mail_attr = $this -> attr_html -> attribute -> ldapObject -> attrs[$attr];
|
||||||
$mail_values = ensureIsArray($mail_attr -> getValue());
|
if ($mail_attr instanceOf LSattribute) {
|
||||||
foreach($mail_values as $mail_value) {
|
$mail_values = ensureIsArray($mail_attr -> getValue());
|
||||||
if ($mail_value && checkEmail($mail_value, $checkDomainsList, $checkDomain)) {
|
foreach($mail_values as $mail_value) {
|
||||||
$mail = $mail_value;
|
if ($mail_value && checkEmail($mail_value, $checkDomainsList, $checkDomain)) {
|
||||||
break;
|
$mail = $mail_value;
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($mail)
|
|
||||||
break;
|
break;
|
||||||
else
|
}
|
||||||
self :: log_debug("send(): $attr attribute empty (or does not contain valid email)");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
self :: log_warning("send(): '$attr' attribute to send new password does not exists.");
|
|
||||||
}
|
}
|
||||||
|
if ($mail)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
self :: log_debug("send(): $attr attribute empty (or does not contain valid email)");
|
||||||
}
|
}
|
||||||
if (!$mail) {
|
else {
|
||||||
LSerror :: addErrorCode('LSformElement_password_01');
|
self :: log_warning("send(): '$attr' attribute to send new password does not exists.");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!$mail) {
|
||||||
self :: log_info(
|
LSerror :: addErrorCode('LSformElement_password_01');
|
||||||
$this -> attr_html -> attribute -> ldapObject -> getDn().": send new '".$this -> name."' to '$mail'."
|
|
||||||
);
|
|
||||||
$this -> attr_html -> attribute -> ldapObject -> registerOtherValue('password', $this -> sendMail['pwd']);
|
|
||||||
$msg = $this -> attr_html -> attribute -> ldapObject -> getDisplayFData($this -> sendMail['msg']);
|
|
||||||
$headers = $this -> getParam('html_options.mail.headers', array());
|
|
||||||
$bcc = $this -> getParam('html_options.mail.bcc');
|
|
||||||
if ($bcc)
|
|
||||||
$headers['Bcc'] = $bcc;
|
|
||||||
if (sendMail(
|
|
||||||
$mail,
|
|
||||||
$this -> sendMail['subject'],
|
|
||||||
$msg,
|
|
||||||
$headers
|
|
||||||
)) {
|
|
||||||
LSsession :: addInfo(_('Notice mail sent.'));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LSerror :: addErrorCode('LSformElement_password_02', $mail);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
|
self :: log_info(
|
||||||
|
$this -> attr_html -> attribute -> ldapObject -> getDn().": send new '".$this -> name."' to '$mail'."
|
||||||
|
);
|
||||||
|
$this -> attr_html -> attribute -> ldapObject -> registerOtherValue('password', $this -> sendMail['pwd']);
|
||||||
|
$msg = $this -> attr_html -> attribute -> ldapObject -> getDisplayFData($this -> sendMail['msg']);
|
||||||
|
$headers = $this -> getParam('html_options.mail.headers', array());
|
||||||
|
$bcc = $this -> getParam('html_options.mail.bcc');
|
||||||
|
if ($bcc)
|
||||||
|
$headers['Bcc'] = $bcc;
|
||||||
|
if (sendMail(
|
||||||
|
$mail,
|
||||||
|
$this -> sendMail['subject'],
|
||||||
|
$msg,
|
||||||
|
$headers
|
||||||
|
)) {
|
||||||
|
LSsession :: addInfo(_('Notice mail sent.'));
|
||||||
|
// Set $this -> sendMail to false to avoid potential multiple sent email
|
||||||
|
$this -> sendMail = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LSerror :: addErrorCode('LSformElement_password_02', $mail);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function ajax_verifyPassword(&$data) {
|
public static function ajax_verifyPassword(&$data) {
|
||||||
|
|
Loading…
Reference in a new issue