From 630aab2df13e16a83352b040ad5c990b51496fd4 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sun, 29 Dec 2013 18:10:26 +0000 Subject: [PATCH] allow password mails for new accounts --- lam/lib/account.inc | 6 ++++++ lam/lib/modules.inc | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lam/lib/account.inc b/lam/lib/account.inc index 8d2c5e97..c449cbc3 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -989,6 +989,12 @@ function sendPasswordMail($pwd, $user, $recipient = null) { if (!empty($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(); $mailReplyTo = $_SESSION['config']->getLamProMailReplyTo(); $mailSubject = $_SESSION['config']->getLamProMailSubject(); diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index ab6b2381..3100875a 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -1056,7 +1056,7 @@ class accountContainer { $container->addElement(new htmlTableExtendedInputCheckbox('lamForcePasswordChange', false, _('Force password change'))); $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->setTableRowsToShow(array('lamPasswordChangeSendMailAddress')); $container->addElement($pwdMailCheckbox); @@ -1171,6 +1171,19 @@ class accountContainer { 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.