allow password mails for new accounts

This commit is contained in:
Roland Gruber 2013-12-29 18:10:26 +00:00
parent 0c4c2c4cf6
commit 630aab2df1
2 changed files with 20 additions and 1 deletions

View File

@ -989,6 +989,12 @@ function sendPasswordMail($pwd, $user, $recipient = null) {
if (!empty($recipient)) { if (!empty($recipient)) {
$mailTo = $recipient; $mailTo = $recipient;
} }
if (empty($mailTo)) {
logNewMessage(LOG_ERR, 'Unable to send password mail, no TO address set.');
return array(
array('ERROR', _('Unable to send mail!'))
);
}
$mailFrom = $_SESSION['config']->getLamProMailFrom(); $mailFrom = $_SESSION['config']->getLamProMailFrom();
$mailReplyTo = $_SESSION['config']->getLamProMailReplyTo(); $mailReplyTo = $_SESSION['config']->getLamProMailReplyTo();
$mailSubject = $_SESSION['config']->getLamProMailSubject(); $mailSubject = $_SESSION['config']->getLamProMailSubject();

View File

@ -1056,7 +1056,7 @@ class accountContainer {
$container->addElement(new htmlTableExtendedInputCheckbox('lamForcePasswordChange', false, _('Force password change'))); $container->addElement(new htmlTableExtendedInputCheckbox('lamForcePasswordChange', false, _('Force password change')));
$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]) || $this->anyModuleManagesMail())) {
$pwdMailCheckbox = new htmlTableExtendedInputCheckbox('lamPasswordChangeSendMail', false, _('Send via mail')); $pwdMailCheckbox = new htmlTableExtendedInputCheckbox('lamPasswordChangeSendMail', false, _('Send via mail'));
$pwdMailCheckbox->setTableRowsToShow(array('lamPasswordChangeSendMailAddress')); $pwdMailCheckbox->setTableRowsToShow(array('lamPasswordChangeSendMailAddress'));
$container->addElement($pwdMailCheckbox); $container->addElement($pwdMailCheckbox);
@ -1171,6 +1171,19 @@ class accountContainer {
return $return; return $return;
} }
/**
* Returns if any module manages the mail attribute.
*
* @return boolean mail is managed
*/
private function anyModuleManagesMail() {
foreach ($this->module as $mod) {
if (in_array('mail', $mod->getManagedAttributes())) {
return true;
}
}
return false;
}
/** /**
* Prints common controls like the save button and the ou selection. * Prints common controls like the save button and the ou selection.