added LAM Pro mail settings

This commit is contained in:
Roland Gruber 2010-08-29 16:02:51 +00:00
parent 3f5d113f3c
commit 2ead13206a
4 changed files with 147 additions and 42 deletions

View File

@ -68,3 +68,9 @@ types: suffix_smbDomain: dc=my-domain,dc=com
types: attr_smbDomain: sambaDomainName:Domain name;sambaSID:Domain SID
types: modules_smbDomain: sambaDomain
# Password mail subject
lamProMailSubject: Your password was reset
# Password mail text
lamProMailText: Dear @@givenName@@ @@sn@@,+::++::+your password was reset to: @@newPassword@@+::++::++::+Best regards+::++::+deskside support+::+

View File

@ -45,10 +45,7 @@ for ($i = 0; $i < sizeof($types); $i++) {
}
$helpArray = array (
// 0 - 99
// any developer
// 200 - 299
// Roland Gruber
// configuration wizard
// configuration login
// config profile management
@ -147,7 +144,6 @@ $helpArray = array (
"250" => array ("Headline" => _("Filter"),
"Text" => _("Here you can input simple filter expressions (e.g. 'value' or 'v*'). The filter is case-sensitive.")),
// 300 - 399
// Roland Gruber
// profile editor, file upload
"301" => array ("Headline" => _("RDN identifier"),
"Text" => _("This is the identifier for the relative DN value. It must be one of the given allowed LDAP attributes (e.g. user accounts usually use \"uid\" while groups use \"cn\").")),
@ -164,7 +160,6 @@ $helpArray = array (
"404" => array ("Headline" => _("Password"),
"Text" => _("Please enter the password which you want to set for this account. You may also generate a random password (12 characters) which will be displayed on your screen.")),
// 500 - 599
// Roland Gruber
// LAM Pro
"501" => array ("Headline" => _("LDAP suffix"),
"Text" => _("LAM will search for accounts in this part of the LDAP tree.")),
@ -194,8 +189,16 @@ $helpArray = array (
'<li>' . _('All following lines form the mail body.') . '</li>' .
'<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>'),
"550" => array ("Headline" => _("From address"),
"Text" => _("This email address will be set as sender address of all password mails. If empty the system default (php.ini) will be used.")),
"551" => array ("Headline" => _("Subject"),
"Text" => _('The subject of all password mails. If empty the first line of "config/passwordMailTemplate.txt" will be used.')),
"552" => array ("Headline" => _("Text"),
"Text" => _('The mail text of all password mails. If empty the content of "config/passwordMailTemplate.txt" starting at the second line will be used.') .
'<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>'),
// 600 - 699
// Roland Gruber
// OU-editor, domain page
"601" => array ("Headline" => _("OU-Editor") . " - " . _("New organizational unit"),
"Text" => _("This will create a new organizational unit under the selected one.")),

View File

@ -175,6 +175,9 @@ class LAMConfig {
/* login method: predefined list or LDAP search */
const LOGIN_LIST = 'list';
const LOGIN_SEARCH = 'search';
/** line separator */
const LINE_SEPARATOR = '+::+';
/** Server address (e.g. ldap://127.0.0.1:389) */
private $ServerURL;
@ -244,12 +247,21 @@ class LAMConfig {
/** search filter for login */
private $loginSearchFilter = 'uid=%USER%';
/** email address for sender of password reset mails */
private $lamProMailFrom = '';
/** subject for password reset mails */
private $lamProMailSubject = '';
/** mail body for password reset mails */
private $lamProMailText = '';
/** List of all settings in config file */
private $settings = array("ServerURL", "useTLS", "Passwd", "Admins", "treesuffix",
"defaultLanguage", "scriptPath", "scriptServer", "scriptRights", "cachetimeout",
"modules", "activeTypes", "types", "accessLevel", 'loginMethod', 'loginSearchSuffix',
'loginSearchFilter', 'searchLimit');
'loginSearchFilter', 'searchLimit', 'lamProMailFrom', 'lamProMailSubject', 'lamProMailText');
/**
@ -290,7 +302,7 @@ class LAMConfig {
if (strtolower(substr($line, 0, $keylen + 2)) == "modules: ") {
$option = substr($line, $keylen + 2, strlen($line) - $keylen - 2);
$pos = strpos($option, ":");
$this->moduleSettings[substr($option, 0, $pos)] = explode("+::+", substr($option, $pos + 2));
$this->moduleSettings[substr($option, 0, $pos)] = explode(LAMConfig::LINE_SEPARATOR, substr($option, $pos + 2));
}
// type settings
elseif (strtolower(substr($line, 0, $keylen + 2)) == "types: ") {
@ -357,7 +369,7 @@ class LAMConfig {
$pos = strpos($option, ":");
$name = substr($option, 0, $pos);
if (!isset($this->moduleSettings[$name])) continue;
$file_array[$i] = "modules: " . $name . ": " . implode("+::+", $this->moduleSettings[$name]) . "\n";
$file_array[$i] = "modules: " . $name . ": " . implode(LAMConfig::LINE_SEPARATOR, $this->moduleSettings[$name]) . "\n";
$mod_saved[] = $name; // mark keyword as saved
}
// type settings
@ -398,11 +410,14 @@ class LAMConfig {
if (!in_array("loginMethod", $saved)) array_push($file_array, "\n\n# Login method.\n" . "loginMethod: " . $this->loginMethod . "\n");
if (!in_array("loginSearchSuffix", $saved)) array_push($file_array, "\n\n# Search suffix for LAM login.\n" . "loginSearchSuffix: " . $this->loginSearchSuffix . "\n");
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("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);
for ($i = 0; $i < sizeof($m_settings); $i++) {
if (!in_array($m_settings[$i], $mod_saved)) {
array_push($file_array, "modules: " . $m_settings[$i] . ": " . implode("+::+", $this->moduleSettings[$m_settings[$i]]) . "\n");
array_push($file_array, "modules: " . $m_settings[$i] . ": " . implode(LAMConfig::LINE_SEPARATOR, $this->moduleSettings[$m_settings[$i]]) . "\n");
}
}
// check if all type settings were added
@ -1003,6 +1018,65 @@ class LAMConfig {
public function setLoginSearchSuffix($loginSearchSuffix) {
$this->loginSearchSuffix = $loginSearchSuffix;
}
/**
* Returns the sender address for password reset mails.
*
* @return String mail address
*/
public function getLamProMailFrom() {
return $this->lamProMailFrom;
}
/**
* Sets the sender address for password reset mails.
*
* @param String $lamProMailFrom mail address
* @return boolean true if address is valid
*/
public function setLamProMailFrom($lamProMailFrom) {
$this->lamProMailFrom = $lamProMailFrom;
if (($lamProMailFrom != '') && !get_preg($lamProMailFrom, 'email')) {
return false;
}
return true;
}
/**
* Returns the subject for password reset mails.
*
* @return String subject
*/
public function getLamProMailSubject() {
return $this->lamProMailSubject;
}
/**
* Sets the subject for password reset mails.
*
* @param String $lamProMailSubject subject
*/
public function setLamProMailSubject($lamProMailSubject) {
$this->lamProMailSubject = $lamProMailSubject;
}
/**
* Returns the mail body for password reset mails.
*
* @return String body
*/
public function getLamProMailText() {
return implode("\r\n", explode(LAMConfig::LINE_SEPARATOR, $this->lamProMailText));
}
/**
* Sets the mail body for password reset mails.
*
* @param String $lamProMailText body
*/
public function setLamProMailText($lamProMailText) {
$this->lamProMailText = implode(LAMConfig::LINE_SEPARATOR, explode("\r\n", $lamProMailText));
}
}

View File

@ -230,10 +230,10 @@ jQuery(document).ready(function() {
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom">
<?php
echo ("<fieldset><legend><img align=\"middle\" src=\"../../graphics/profiles.png\" alt=\"profiles.png\"> <b>" . _("Server settings") . "</b></legend><br>\n");
echo ("<fieldset><legend><img align=\"middle\" src=\"../../graphics/profiles.png\" alt=\"profiles.png\"> " . _("Server settings") . "</legend><br>\n");
echo ("<table border=0>");
// serverURL
echo ("<tr><td align=\"right\"><b>" . _("Server address") . " *: </b></td>".
echo ("<tr><td align=\"right\">" . _("Server address") . " * </td>".
"<td align=\"left\">".
"<input tabindex=\"$tabindex\" size=50 type=\"text\" name=\"serverurl\" value=\"" . $conf->get_ServerURL() . "\">".
"</td>\n");
@ -242,7 +242,7 @@ printHelpLink(getHelp('', '201'), '201');
echo "</td></tr>\n";
$tabindex++;
// use TLS
echo "<tr><td align=\"right\"><b>" . _("Activate TLS") . ": </b></td>\n";
echo "<tr><td align=\"right\">" . _("Activate TLS") . " </td>\n";
echo "<td align=\"left\">\n";
echo "<select tabindex=\"$tabindex\" size=1 name=\"useTLS\">";
$useTLS = $conf->getUseTLS();
@ -265,8 +265,8 @@ $tabindex++;
echo ("<tr><td colspan=3>&nbsp;</td></tr>");
// tree suffix
echo ("<tr><td align=\"right\"><b>".
_("Tree suffix") . ": </b></td>".
echo ("<tr><td align=\"right\">".
_("Tree suffix") . " </td>".
"<td><input tabindex=\"$tabindex\" size=50 type=\"text\" name=\"sufftree\" value=\"" . $conf->get_Suffix('tree') . "\"></td>\n");
echo "<td>";
printHelpLink(getHelp('', '203'), '203');
@ -277,8 +277,8 @@ $tabindex++;
echo ("<tr><td colspan=3>&nbsp;</td></tr>");
// LDAP cache timeout
echo ("<tr><td align=\"right\"><b>".
_("Cache timeout") . ": </b></td>".
echo ("<tr><td align=\"right\">".
_("Cache timeout") . " </td>".
"<td><select tabindex=\"$tabindex\" name=\"cachetimeout\">\n<option selected>".$conf->get_cacheTimeout()."</option>\n");
if ($conf->get_cacheTimeout() != 0) echo("<option>0</option>\n");
if ($conf->get_cacheTimeout() != 1) echo("<option>1</option>\n");
@ -298,8 +298,8 @@ array(0, '-'), array(100, 100), array(500, 500),
array(1000, 1000), array(5000, 5000), array(10000, 10000),
array(50000, 50000), array(100000, 100000)
);
echo ("<tr><td align=\"right\"><b>".
_("LDAP search limit") . ": </b></td>".
echo ("<tr><td align=\"right\">".
_("LDAP search limit") . " </td>".
"<td><select tabindex=\"$tabindex\" name=\"searchLimit\">\n");
for ($i = 0; $i < sizeof($searchLimitOptions); $i++) {
$selected = "";
@ -320,8 +320,8 @@ if (isLAMProVersion()) {
echo ("<tr><td colspan=3>&nbsp;</td></tr>");
// access level
echo ("<tr><td align=\"right\"><b>".
_("Access level") . ": </b></td>".
echo ("<tr><td align=\"right\">".
_("Access level") . " </td>".
"<td><select tabindex=\"$tabindex\" name=\"accessLevel\">\n");
if ($conf->getAccessLevel() == LAMConfig::ACCESS_ALL) {
echo("<option selected value=" . LAMConfig::ACCESS_ALL . ">" . _('Write access') . "</option>\n");
@ -353,12 +353,12 @@ echo ("</fieldset>");
echo ("<br>");
echo ("<fieldset><legend><img align=\"middle\" src=\"../../graphics/language.png\" alt=\"language.png\"> <b>" . _("Language settings") . "</b></legend><br>\n");
echo ("<fieldset><legend><img align=\"middle\" src=\"../../graphics/language.png\" alt=\"language.png\"> " . _("Language settings") . "</legend><br>\n");
echo ("<table border=0>\n");
// language
echo ("<tr>");
echo ("<td><b>" . _("Default language") . ":</b></td><td>\n");
echo ("<td>" . _("Default language") . "</td><td>\n");
// read available languages
$languagefile = "../../config/language";
if(is_file($languagefile))
@ -398,24 +398,24 @@ echo ("</fieldset>\n");
echo ("<br>\n");
// lamdaemon settings
echo ("<fieldset><legend><img align=\"middle\" src=\"../../graphics/lamdaemon.png\" alt=\"lamdaemon.png\"> <b>" . _("Lamdaemon settings") . "</b></legend><br>\n");
echo ("<fieldset><legend><img align=\"middle\" src=\"../../graphics/lamdaemon.png\" alt=\"lamdaemon.png\"> " . _("Lamdaemon settings") . "</legend><br>\n");
echo ("<table border=0>\n");
echo ("<tr><td align=\"right\"><b>".
_("Server list") . ": </b></td>".
echo ("<tr><td align=\"right\">".
_("Server list") . " </td>".
"<td><input tabindex=\"$tabindex\" size=50 type=\"text\" name=\"scriptservers\" value=\"" . $conf->get_scriptServers(false) . "\"></td>\n");
$tabindex++;
echo "<td>";
printHelpLink(getHelp('', '218'), '218');
echo "</td></tr>\n";
echo ("<tr><td align=\"right\"><b>".
_("Path to external script") . ": </b></td>".
echo ("<tr><td align=\"right\">".
_("Path to external script") . " </td>".
"<td><input tabindex=\"$tabindex\" size=50 type=\"text\" name=\"scriptpath\" value=\"" . $conf->get_scriptPath() . "\"></td>\n");
$tabindex++;
echo "<td>";
printHelpLink(getHelp('', '210'), '210');
echo "</td></tr>\n";
echo "<tr><td align=\"right\"><b>". _("Rights for the home directory") . ": </b></td>\n";
echo "<tr><td align=\"right\">". _("Rights for the home directory") . " </td>\n";
$owr = "";
$oww = "";
$owe = "";
@ -464,12 +464,32 @@ echo ("</fieldset>\n");
echo ("<br>\n");
// LAM Pro settings
if (isLAMProVersion()) {
$pwdMailContent = new htmlTable();
$pwdMailFrom = new htmlTableExtendedInputField(_('From address'), 'pwdResetMail_from', $conf->getLamProMailFrom(), '550');
$pwdMailContent->addElement($pwdMailFrom, true);
$pwdMailSubject = new htmlTableExtendedInputField(_('Subject'), 'pwdResetMail_subject', $conf->getLamProMailSubject(), '551');
$pwdMailContent->addElement($pwdMailSubject, true);
$pwdMailBody = new htmlTableExtendedInputTextarea('pwdResetMail_body', $conf->getLamProMailText(), 50, 4, _('Text'), '552');
$pwdMailContent->addElement($pwdMailBody, true);
$pwdMailFieldset = new htmlFieldset($pwdMailContent, _("Password mail settings"), '../../graphics/mailBig.png');
parseHtml(null, $pwdMailFieldset, array(), true, $tabindex, 'config');
echo ("<br>\n");
}
// security setings
echo ("<fieldset><legend><img align=\"middle\" src=\"../../graphics/security.png\" alt=\"security.png\"> <b>" . _("Security settings") . "</b></legend><br>\n");
echo ("<fieldset><legend><img align=\"middle\" src=\"../../graphics/security.png\" alt=\"security.png\"> " . _("Security settings") . "</legend><br>\n");
echo ("<table border=0>\n");
// login method
echo ("<tr><td align=\"right\"><b>".
_("Login method") . ": </b></td>".
echo ("<tr><td align=\"right\">".
_("Login method") . " </td>".
"<td><select tabindex=\"$tabindex\" name=\"loginMethod\" onchange=\"configLoginMethodChanged()\">\n");
if ($conf->getLoginMethod() == LAMConfig::LOGIN_LIST) {
echo("<option selected value=" . LAMConfig::LOGIN_LIST . ">" . _('Fixed list') . "</option>\n");
@ -491,8 +511,7 @@ echo "</td></tr>\n";
// admin list
$adminText = implode("\n", explode(";", $conf->get_Adminstring()));
echo "<tr id=\"trAdminList\"><td align=\"right\">\n";
echo "<b>".
_("List of valid users") . " *: </b></td>".
echo _("List of valid users") . " * </td>".
"<td><textarea tabindex=\"$tabindex\" name=\"admins\" cols=75 rows=3>" . $adminText . "</textarea></td>\n";
echo "<td>";
printHelpLink(getHelp('', '207'), '207');
@ -500,8 +519,7 @@ echo "</td></tr>\n";
$tabindex++;
// login search suffix
echo "<tr id=\"trLoginSearchSuffix\"><td align=\"right\">\n";
echo "<b>".
_("LDAP suffix") . " *: </b></td>".
echo _("LDAP suffix") . " * </td>".
"<td><input type=\"text\" tabindex=\"$tabindex\" name=\"loginSearchSuffix\" value=\"" . $conf->getLoginSearchSuffix() . "\" size=50></td>\n";
echo "<td>";
printHelpLink(getHelp('', '221'), '221');
@ -509,8 +527,7 @@ echo "</td></tr>\n";
$tabindex++;
// login search filter
echo "<tr id=\"trLoginSearchFilter\"><td align=\"right\">\n";
echo "<b>".
_("LDAP filter") . " *: </b></td>".
echo _("LDAP filter") . " * </td>".
"<td><input type=\"text\" tabindex=\"$tabindex\" name=\"loginSearchFilter\" value=\"" . $conf->getLoginSearchFilter() . "\" size=50></td>\n";
echo "<td>";
printHelpLink(getHelp('', '221'), '221');
@ -520,16 +537,16 @@ $tabindex++;
echo ("<tr><td colspan=3>&nbsp;</td></tr>\n");
// new password
echo ("<tr><td align=\"right\"><font color=\"red\"><b>".
_("New password") . ": </b></font></td>".
echo ("<tr><td align=\"right\"><font color=\"red\">".
_("New password") . " </font></td>".
"<td align=\"left\"><input tabindex=\"$tabindex\" type=\"password\" name=\"passwd1\"></td>\n");
$tabindex++;
echo "<td rowspan=2>";
printHelpLink(getHelp('', '212'), '212');
echo "</td></tr>\n";
// reenter password
echo ("<tr><td align=\"right\"><font color=\"red\"><b>".
_("Reenter password") . ": </b></font></td>".
echo ("<tr><td align=\"right\"><font color=\"red\">".
_("Reenter password") . " </font></td>".
"<td align=\"left\"><input tabindex=\"$tabindex\" type=\"password\" name=\"passwd2\"></td></tr>\n");
$tabindex++;
echo ("</table>\n");
@ -570,6 +587,11 @@ function checkInput() {
$conf->set_searchLimit($_POST['searchLimit']);
if (isLAMProVersion()) {
$conf->setAccessLevel($_POST['accessLevel']);
if (!$conf->setLamProMailFrom($_POST['pwdResetMail_from'])) {
$errors[] = array("ERROR", _("From address for password mails is invalid."), $_POST['pwdResetMail_from']);
}
$conf->setLamProMailSubject($_POST['pwdResetMail_subject']);
$conf->setLamProMailText($_POST['pwdResetMail_body']);
}
$adminText = $_POST['admins'];
$adminText = explode("\n", $adminText);