enhanced password mail sending

This commit is contained in:
Roland Gruber 2014-02-10 19:16:37 +00:00
parent 400b66f647
commit 6926b7cbde
7 changed files with 62 additions and 5 deletions

View File

@ -1286,6 +1286,21 @@ Have fun!
the script is located. The default rights for new home directories
can be set, too.</para>
<screenshot>
<mediaobject>
<imageobject>
<imagedata fileref="images/configProfiles9.png" />
</imageobject>
</mediaobject>
</screenshot>
<para>LAM Pro users can send out changed passwords to their users.
Here you can specify the options for these mails.</para>
<para>If you select "Allow alternate address" then password mails
can be sent to any address (e.g. a secondary address if the user
account is also bound to the mailbox).</para>
<screenshot>
<mediaobject>
<imageobject>

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -250,6 +250,8 @@ $helpArray = array (
"Text" => _('Specifies if the mail should be sent as text or HTML.')),
"554" => array ("Headline" => _("Reply-to address"),
"Text" => _("This email address will be set as reply-to address of all password mails.")),
"555" => array ("Headline" => _("Allow alternate address"),
"Text" => _('Specifies if password mails may be sent to mail addresses other than the user\'s LDAP mail address.')),
// 600 - 699
// OU-editor, domain page
"601" => array ("Headline" => _("OU-Editor") . " - " . _("New organisational unit"),

View File

@ -407,6 +407,9 @@ class LAMConfig {
/** treat password reset mail body as HTML */
private $lamProMailIsHTML = 'false';
/** allow sending mails to an alternative address */
private $lamProMailAllowAlternateAddress = 'true';
/** mail body for password reset mails */
private $lamProMailText = '';
@ -415,7 +418,8 @@ class LAMConfig {
"defaultLanguage", "scriptPath", "scriptServer", "scriptRights", "cachetimeout",
"modules", "activeTypes", "types", "tools", "accessLevel", 'loginMethod', 'loginSearchSuffix',
'loginSearchFilter', 'searchLimit', 'lamProMailFrom', 'lamProMailReplyTo', 'lamProMailSubject',
'lamProMailText', 'lamProMailIsHTML', 'httpAuthentication', 'loginSearchDN', 'loginSearchPassword');
'lamProMailText', 'lamProMailIsHTML', 'lamProMailAllowAlternateAddress', 'httpAuthentication', 'loginSearchDN',
'loginSearchPassword');
/**
@ -603,6 +607,7 @@ class LAMConfig {
if (!in_array("lamProMailReplyTo", $saved)) array_push($file_array, "\n\n# Password mail reply-to\n" . "lamProMailReplyTo: " . $this->lamProMailReplyTo . "\n");
if (!in_array("lamProMailSubject", $saved)) array_push($file_array, "\n\n# Password mail subject\n" . "lamProMailSubject: " . $this->lamProMailSubject . "\n");
if (!in_array("lamProMailIsHTML", $saved)) array_push($file_array, "\n\n# Password mail is HTML\n" . "lamProMailIsHTML: " . $this->lamProMailIsHTML . "\n");
if (!in_array("lamProMailAllowAlternateAddress", $saved)) array_push($file_array, "\n\n# Allow alternate address\n" . "lamProMailAllowAlternateAddress: " . $this->lamProMailAllowAlternateAddress . "\n");
if (!in_array("lamProMailText", $saved)) array_push($file_array, "\n\n# Password mail text\n" . "lamProMailText: " . $this->lamProMailText . "\n");
// check if all module settings were added
$m_settings = array_keys($this->moduleSettings);
@ -1402,12 +1407,30 @@ class LAMConfig {
/**
* Sets if the password reset mail content should be treated as HTML.
*
* @param boolean $lamProMailIsHTML
* @param boolean $lamProMailIsHTML true if HTML
*/
public function setLamProMailIsHTML($lamProMailIsHTML) {
$this->lamProMailIsHTML = $lamProMailIsHTML;
}
/**
* Returns if sending to an alternate address is allowed.
*
* @return boolean alternate address allowed
*/
public function getLamProMailAllowAlternateAddress() {
return $this->lamProMailAllowAlternateAddress;
}
/**
* Sets if sending to an alternate address is allowed.
*
* @param boolean $lamProMailAllowAlternateAddress alternate address allowed
*/
public function setLamProMailAllowAlternateAddress($lamProMailAllowAlternateAddress) {
$this->lamProMailAllowAlternateAddress = $lamProMailAllowAlternateAddress;
}
/**
* Returns the mail body for password reset mails.
*

View File

@ -1061,8 +1061,10 @@ class accountContainer {
$pwdMailCheckbox->setTableRowsToShow(array('lamPasswordChangeSendMailAddress'));
$container->addElement($pwdMailCheckbox);
$container->addElement(new htmlHelpLink('407'), true);
if (($_SESSION['config']->getLamProMailAllowAlternateAddress() != 'false')) {
$container->addElement(new htmlTableExtendedInputField(_('Alternate recipient'), 'lamPasswordChangeSendMailAddress', '', '410'));
}
}
$container->addElement(new htmlSpacer(null, '10px'), true);
// password modules
$moduleContainer = new htmlTable();
@ -1157,7 +1159,7 @@ class accountContainer {
}
if (isLAMProVersion() && $sendMail) {
$this->sendPasswordViaMail = $password1;
if (!empty($input['sendMailAlternateAddress'])) {
if (($_SESSION['config']->getLamProMailAllowAlternateAddress() != 'false') && !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';

View File

@ -355,6 +355,12 @@ if (isLAMProVersion()) {
}
$pwdMailContent->addElement(new htmlTableExtendedInputCheckbox('pwdResetMail_isHTML',$pwdMailIsHTML , _('HTML format'), '553'), true);
$pwdMailAllowAlternate = true;
if ($conf->getLamProMailAllowAlternateAddress() == 'false') {
$pwdMailAllowAlternate = false;
}
$pwdMailContent->addElement(new htmlTableExtendedInputCheckbox('pwdResetMail_allowAlternate',$pwdMailAllowAlternate , _('Allow alternate address'), '555'), true);
$pwdMailBody = new htmlTableExtendedInputTextarea('pwdResetMail_body', $conf->getLamProMailText(), 50, 4, _('Text'), '552');
$pwdMailContent->addElement($pwdMailBody, true);
@ -522,6 +528,12 @@ function checkInput() {
else {
$conf->setLamProMailIsHTML('false');
}
if (isset($_POST['pwdResetMail_allowAlternate']) && ($_POST['pwdResetMail_allowAlternate'] == 'on')) {
$conf->setLamProMailAllowAlternateAddress('true');
}
else {
$conf->setLamProMailAllowAlternateAddress('false');
}
$conf->setLamProMailText($_POST['pwdResetMail_body']);
}
$adminText = $_POST['admins'];

View File

@ -253,7 +253,10 @@ 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 sendMailAlternateAddress = '';
if (jQuery('#passwordDialog').find('[name=lamPasswordChangeSendMailAddress]')) {
sendMailAlternateAddress = jQuery('#passwordDialog').find('[name=lamPasswordChangeSendMailAddress]').val();
}
var pwdJSON = {
"modules": modules,
"password1": pwd1,