allow password reset mails in HTML format

This commit is contained in:
Roland Gruber 2011-05-22 15:02:14 +00:00
parent 2d70a55542
commit cd0e11e809
3 changed files with 38 additions and 1 deletions

View File

@ -192,6 +192,8 @@ $helpArray = array (
'<br><br><b>' . _('Format') . ': </b><ul>' .
'<li>' . _('You can use wildcards for LDAP attributes in the form @@attribute@@ (e.g. @@uid@@ for the user name).') . '</li>' .
'<li>' . _('The wildcard for the new password is @@newPassword@@.') . '</li>'),
"553" => array ("Headline" => _("HTML format"),
"Text" => _('Specifies if the mail should be sent as text or HTML.')),
// 600 - 699
// OU-editor, domain page
"601" => array ("Headline" => _("OU-Editor") . " - " . _("New organizational unit"),

View File

@ -260,6 +260,9 @@ class LAMConfig {
/** subject for password reset mails */
private $lamProMailSubject = '';
/** treat password reset mail body as HTML */
private $lamProMailIsHTML = 'false';
/** mail body for password reset mails */
private $lamProMailText = '';
@ -267,7 +270,8 @@ class LAMConfig {
private $settings = array("ServerURL", "useTLS", "Passwd", "Admins", "treesuffix",
"defaultLanguage", "scriptPath", "scriptServer", "scriptRights", "cachetimeout",
"modules", "activeTypes", "types", "accessLevel", 'loginMethod', 'loginSearchSuffix',
'loginSearchFilter', 'searchLimit', 'lamProMailFrom', 'lamProMailSubject', 'lamProMailText');
'loginSearchFilter', 'searchLimit', 'lamProMailFrom', 'lamProMailSubject',
'lamProMailText', 'lamProMailIsHTML');
/**
@ -420,6 +424,7 @@ class LAMConfig {
if (!in_array("loginSearchFilter", $saved)) array_push($file_array, "\n\n# Search filter for LAM login.\n" . "loginSearchFilter: " . $this->loginSearchFilter . "\n");
if (!in_array("lamProMailFrom", $saved)) array_push($file_array, "\n\n# Password mail from\n" . "lamProMailFrom: " . $this->lamProMailFrom . "\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("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);
@ -1072,6 +1077,24 @@ class LAMConfig {
$this->lamProMailSubject = $lamProMailSubject;
}
/**
* Returns if the password reset mail content should be treated as HTML.
*
* @return boolean HTML or text
*/
public function getLamProMailIsHTML() {
return $this->lamProMailIsHTML;
}
/**
* Sets if the password reset mail content should be treated as HTML.
*
* @param boolean $lamProMailIsHTML
*/
public function setLamProMailIsHTML($lamProMailIsHTML) {
$this->lamProMailIsHTML = $lamProMailIsHTML;
}
/**
* Returns the mail body for password reset mails.
*

View File

@ -317,6 +317,12 @@ if (isLAMProVersion()) {
$pwdMailSubject = new htmlTableExtendedInputField(_('Subject'), 'pwdResetMail_subject', $conf->getLamProMailSubject(), '551');
$pwdMailContent->addElement($pwdMailSubject, true);
$pwdMailIsHTML = false;
if ($conf->getLamProMailIsHTML() == 'true') {
$pwdMailIsHTML = true;
}
$pwdMailContent->addElement(new htmlTableExtendedInputCheckbox('pwdResetMail_isHTML',$pwdMailIsHTML , _('HTML format'), '553'), true);
$pwdMailBody = new htmlTableExtendedInputTextarea('pwdResetMail_body', $conf->getLamProMailText(), 50, 4, _('Text'), '552');
$pwdMailContent->addElement($pwdMailBody, true);
@ -413,6 +419,12 @@ function checkInput() {
$errors[] = array("ERROR", _("From address for password mails is invalid."), $_POST['pwdResetMail_from']);
}
$conf->setLamProMailSubject($_POST['pwdResetMail_subject']);
if (isset($_POST['pwdResetMail_isHTML']) && ($_POST['pwdResetMail_isHTML'] == 'on')) {
$conf->setLamProMailIsHTML('true');
}
else {
$conf->setLamProMailIsHTML('false');
}
$conf->setLamProMailText($_POST['pwdResetMail_body']);
}
$adminText = $_POST['admins'];