implemented configuration options for modules

This commit is contained in:
Roland Gruber 2004-07-24 17:14:39 +00:00
parent aa052ebf10
commit 3959293d09
6 changed files with 515 additions and 13 deletions

View File

@ -24,7 +24,7 @@ All module classes should extend the baseModule class.<br>
</h3>
<h3><br>
</h3>
<h3>2.1.1. can_manage</h3>
<h3>2.1.1. can_manage*</h3>
<br>
<table cellpadding="2" cellspacing="2" border="0"
style="text-align: left; width: 300px;">
@ -43,7 +43,7 @@ can manage accounts of the current type<span style="font-style: italic;"></span>
otherwise <span style="font-style: italic;">false</span>.<br>
<br>
<br>
<h3>2.1.2. get_alias</h3>
<h3>2.1.2. get_alias*</h3>
<br>
<table style="text-align: left; width: 300px;" border="0"
cellspacing="2" cellpadding="2">
@ -63,6 +63,8 @@ module selection of the configuration wizard.<br>
Please take care that your alias name is not too long. It may contain
any character but should not include parts that may be interpreted by
the browser (e.g. '&lt;' or '&gt;').<br>
If you use different aliases dependent on the account type please make
sure that there is a general alias for unknown types.<br>
<br>
<h3>2.1.3. is_base_module*</h3>
<br>
@ -118,7 +120,7 @@ The resulting LDAP filter will look like this:
is only used for base modules. Standard modules do not need to
implement it.</span><br>
<br>
<h3>2.1.5. get_dependencies</h3>
<h3>2.1.5. get_dependencies*</h3>
<br>
<table cellpadding="2" cellspacing="2" border="0"
style="text-align: left; width: 300px; font-weight: bold;">
@ -168,7 +170,92 @@ Returns an hash array including meta data for the baseModule.<br>
<span style="font-weight: bold;">Example: return array("is_base" =&gt;
true);</span><br style="font-weight: bold;">
<br>
<h3>2.1.7. get_scope()</h3>
<h3>2.1.7. get_configOptions()*</h3>
<br>
<table cellpadding="2" cellspacing="2" border="0"
style="text-align: left; width: 300px;">
<tbody>
<tr>
<td
style="vertical-align: top; background-color: rgb(204, 204, 204); text-align: center;"><span
style="font-weight: bold;">function get_configOptions($scopes)</span><br>
</td>
</tr>
</tbody>
</table>
<br>
Returns a list of configuration options.<br>
<span style="font-weight: bold;">$scopes</span> is a list of <span
style="font-style: italic;">account types</span> (user, group, host)
which are used.<br>
<span style="font-weight: bold;"></span><br>
The return value is an array
that contains <span style="font-weight: bold;">meta HTML code</span>.<br>
<br>
The type "fieldset" is not allowed here.<br>
The <span style="font-style: italic;">name</span> attributes are used
as keywords to load and save settings. We recommend to use the module
name as prefix for them (e.g. posixAccount_homeDirectory) to avoid
naming confilcts.<br>
<br>
<h3>2.1.8. get_configDescriptions()*</h3>
<br>
<table cellpadding="2" cellspacing="2" border="0"
style="text-align: left; width: 300px;">
<tbody>
<tr>
<td
style="vertical-align: top; background-color: rgb(204, 204, 204); text-align: center;"><span
style="font-weight: bold;">function get_configDescriptions()</span><br>
</td>
</tr>
</tbody>
</table>
<br>
Returns the description of every configuration option and the legend of
the module fieldset on the configuration page.<br>
<span style="font-weight: bold;"></span><br>
The <span style="font-style: italic;">return</span> value is a hash
array with this format:<br>
&nbsp;&nbsp;&nbsp; <br>
<span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; array( 'legend'
=&gt; 'Some general description for fieldset',</span><br
style="font-weight: bold;">
<span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 'descriptions' =&gt; array('option1'
=&gt; 'description1', ...))</span><br>
<br>
<h3>2.1.9. check_configOptions*</h3>
<br>
<table style="text-align: left; width: 400px; height: 30px;" border="0"
cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td
style="vertical-align: top; background-color: rgb(204, 204, 204); text-align: center;"><span
style="font-weight: bold;">function check_configOptions($scopes,
$options)</span><br>
</td>
</tr>
</tbody>
</table>
<br>
This function checks the input for module configuration settings.<br>
<br>
<span style="font-weight: bold;">$scopes</span> is a list of used
account types (user, group, host).<br>
<span style="font-weight: bold;"></span><span style="font-weight: bold;">$options</span>
is an hash array
(option name =&gt; value) that contains the input. The option values
are all arrays containing one or more elements.<br>
If the input data is invalid the return value is an array that contains
arrays to build StatusMessages (0 =&gt; message type, 1 =&gt; message
head, 2 =&gt; message text, 3 =&gt; additional variables).<br>
If no errors occured the function returns an empty array.<span
style="font-weight: bold;"></span><br>
<br style="font-weight: bold;">
<span style="font-weight: bold;"></span>
<h3>2.1.10. get_scope()</h3>
<br>
<table cellpadding="2" cellspacing="2" border="0"
style="text-align: left; width: 300px;">
@ -187,6 +274,8 @@ Returns the account type (user/group/host) of this module object.<br>
<span style="font-weight: bold;">This function is provided by the
baseModule and should not be overwritten.</span><br>
<br>
<br>
<br>
<h3>2.2. Class functions</h3>
<h3>2.2.1. init</h3>
<br>
@ -654,11 +743,51 @@ given</span><span style="font-weight: normal;"> (only if <span
<ul>
<li>&nbsp;array to build StatusMessages (0 =&gt; message type, 1
=&gt; message
head, 2 =&gt; message text, 3 =&gt; additional variables)<span
style="font-weight: bold;"><br>
</span></li>
head, 2 =&gt; message text, 3 =&gt; additional variables)</li>
</ul>
</ul>
<br>
<h3>6.7 get_configOptions()<br>
</h3>
&nbsp;&nbsp;&nbsp; "config_options" =&gt; array('user' =&gt; array,
'host' =&gt; array, 'all' =&gt; array)<br>
<br>
&nbsp;&nbsp;&nbsp; The values from <span style="font-weight: bold;">'all'</span>
are always returned, the other values only if they are inside the <span
style="font-style: italic;">$scopes</span> array.<br
style="font-weight: bold;">
<br style="font-weight: bold;">
<span style="font-weight: bold;">&nbsp;&nbsp; <span
style="font-style: italic;">Syntax for sub arrays is the same as for
the
return value of get_configOptions().<br>
<br>
</span></span>
<h3>6.8 get_configDescriptions()<br>
</h3>
&nbsp;&nbsp;&nbsp; "config_descriptions" =&gt; array<br>
<br>
<span style="font-weight: bold;">&nbsp;&nbsp; <span
style="font-style: italic;">Syntax for array is the same as for the
return value of get_configDescriptions().<br>
<br>
</span></span>
<h3>6.9 check_configOptions()<br>
</h3>
&nbsp;&nbsp;&nbsp; "config_checks" =&gt; array('user' =&gt; array,
'host' =&gt; 'array', 'all' =&gt; array)<br>
<br>
&nbsp;&nbsp;&nbsp; The values from 'all' are always used for checking,
the other values only if they are inside the <span
style="font-style: italic;">$scopes</span> array.<br>
<span style="font-weight: bold;"><br style="font-weight: bold;">
</span><span style="font-weight: bold;">&nbsp;&nbsp; <span
style="font-style: italic;">Syntax for sub arrays is the same as for
check_profileOptions().<br>
<br>
</span></span>
<h3><br>
</h3>
<span style="font-weight: bold;"></span><span style="font-weight: bold;"><span
style="font-style: italic;"></span></span><span
style="font-style: italic; font-weight: bold;"></span><span

View File

@ -141,7 +141,7 @@ class baseModule {
/**
* Checks input values of account profiles.
*
* @return profile elements
* @return array profile elements
*/
function check_profileOptions($options) {
$messages = array();
@ -204,6 +204,106 @@ class baseModule {
return $messages;
}
/**
* Returns a list of elements for the configuration.
*
* @param array $scopes account types (user, group, host)
* @return array configuration elements
*/
function get_configOptions($scopes) {
$return = array();
for ($i = 0; $i < sizeof($scopes); $i++) {
if (isset($this->meta['config_options'][$scopes[$i]])) $return = array_merge($return, $this->meta['config_options'][$scopes[$i]]);
}
if (isset($this->meta['config_options']['all'])) $return = array_merge($return, $this->meta['config_options']['all']);
return $return;
}
/**
* Returns an array containing descriptions shown on configuration pages.
*
* The returned array has the format array('legend' => '...', descriptions => array('option1' => '...', ...)).
* <br> The "legend" value is used as text for the fieldset, the descriptions are used when the configuration is printed.
*
* @return array configuration elements
*/
function get_configDescriptions() {
$return = array('legend' => 'no description', 'descriptions' => array());
if (isset($this->meta['config_descriptions'])) $return = $this->meta['config_descriptions'];
return $return;
}
/**
* Checks input values of module settings.
*
* @param array $scopes list of account types which are used
* @param array $options hash array containing the settings (array('option' => array('value')))
* @return array profile elements
*/
function check_configOptions($scopes, $options) {
$messages = array();
$scopes[] = 'all'; // add checks that are independent of scope
for ($s = 0; $s < sizeof($scopes); $s++) {
if (is_array($this->meta['config_checks'][$scopes[$s]])) {
$identifiers = array_keys($this->meta['config_checks'][$scopes[$s]]);
for ($i = 0; $i < sizeof($identifiers); $i++) {
// check if option is required
if ($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['required'] && ($options[$identifiers[$i]][0] == '')) {
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['required_message'];
}
// check by regular expression (case insensitive)
if ($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['type'] == 'regex_i') {
// ignore empty fileds
if ($options[$identifiers[$i]][0] == '') continue;
if (! eregi($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['regex'], $options[$identifiers[$i]][0])) {
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
}
}
// check by regular expression (case sensitive)
elseif ($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['type'] == 'regex') {
// ignore empty fileds
if ($options[$identifiers[$i]][0] == '') continue;
if (! ereg($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['regex'], $options[$identifiers[$i]][0])) {
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
}
}
// check by integer comparison (greater)
elseif ($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['type'] == 'int_greater') {
// ignore if both fields are empty
if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) continue;
// print error message if only one field is empty
if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') || ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) {
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
continue;
}
// compare
if (!(intval($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0]) > intval($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0]))) {
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
}
}
// check by integer comparison (greater or equal)
elseif ($this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['type'] == 'int_greaterOrEqual') {
// ignore if both fields are empty
if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) continue;
// print error message if only one field is empty
if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') || ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) {
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
continue;
}
// compare
if (!(intval($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0]) >= intval($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0]))) {
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
}
}
else {
StatusMessage("ERROR", "Unsupported type!", $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['type']);
}
}
}
}
return $messages;
}
// TODO implement missing interface
}

View File

@ -365,7 +365,15 @@ class Config {
echo "<b>" . _("Module settings") . ": </b><br>\n";
echo "<ul>\n";
$names = array_keys($this->moduleSettings);
for ($i = 0; $i < sizeof($names); $i++) echo "<li>" . $names[$i] . ": " . implode(", ", $this->moduleSettings[$names[$i]]) . "</li>\n";
$descriptions = getConfigDescriptions();
$descriptions = $descriptions['descriptions'];
for ($i = 0; $i < sizeof($names); $i++) {
echo "<li><b>";
// print description if available
if (isset($descriptions[$names[$i]])) echo $descriptions[$names[$i]];
else echo $names[$i];
echo ": </b>" . implode(", ", $this->moduleSettings[$names[$i]]) . "</li>\n";
}
echo "</ul>\n";
}

View File

@ -50,12 +50,12 @@ while ($stay<7) {
while ($entry = readdir($dir))
if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($relative.'lib/modules/'.$entry)) include_once ($relative.'lib/modules/'.$entry);
$stay=10;
}
}
else {
$stay++;
$relative .= '../';
}
}
}
/**
* Returns the alias name of a module
@ -131,7 +131,7 @@ function getModulesDependencies($scope) {
$return[$mods[$i]] = $module->get_dependencies();
}
return $return;
}
}
/**
@ -249,6 +249,61 @@ function checkProfileOptions($scope, $options) {
return $_SESSION["profile_account_$scope"]->checkProfileOptions($options);
}
/**
* Returns a hash array (module name => elements) of all module options for the configuration page.
*
* @param array $scopes hash array (module name => array(account types))
* @return array configuration options
*/
function getConfigOptions($scopes) {
$return = array();
$modules = array_keys($scopes);
for ($i = 0; $i < sizeof($modules); $i++) {
$m = new $modules[$i]('none');
$return[$modules[$i]] = $m->get_configOptions($scopes[$modules[$i]]);
}
return $return;
}
/**
* Returns a hash array (module name => descriptions) containing descriptions shown on configuration pages.
*
* The returned array has the format array('legend' => array('posixAccount' => '...', ...), descriptions => array('option1' => '...', ...)).
* <br> The "legend" value is used as text for the fieldset, the descriptions are used when the configuration is printed.
*
* @return array configuration descriptions
*/
function getConfigDescriptions() {
$return = array('legend' => array(), 'descriptions' => array());
$modules = array_merge(getAvailableModules('user'), getAvailableModules('group'), getAvailableModules('host'));
$modules = array_values(array_unique($modules));
for ($i = 0; $i < sizeof($modules); $i++) {
$m = new $modules[$i]('none');
$desc = $m->get_configDescriptions();
$return['legend'][$modules[$i]] = $desc['legend'];
$return['descriptions'] = array_merge($return['descriptions'], $desc['descriptions']);
}
return $return;
}
/**
* Checks if the configuration options are valid
*
* @param array $scopes hash array (module name => array(account types))
* @param array $options hash array containing all options (name => array(...))
* @return array list of error messages
*/
function checkConfigOptions($scopes, $options) {
$return = array();
$modules = array_keys($scopes);
for ($i = 0; $i < sizeof($modules); $i++) {
$m = new $modules[$i]('none');
$errors = $m->check_configOptions($scopes[$modules[$i]], $options);
$return = array_merge($return, $errors);
}
return $return;
}
/**
* Returns a help entry from an account module.
*

View File

@ -33,6 +33,9 @@ $Id$
/** Access to config functions */
include_once ("../../lib/config.inc");
/** access to module settings */
include_once ("../../lib/modules.inc");
// start session
session_save_path("../../sess");
@session_start();
@ -72,6 +75,8 @@ if ($_POST['back'] || $_POST['submitconf'] || $_POST['editmodules']){
$_SESSION['conf_groupmodules'] = explode(",", $_POST['groupmodules']);
$_SESSION['conf_hostmodules'] = explode(",", $_POST['hostmodules']);
$_SESSION['conf_filename'] = $_POST['filename'];
$modSettings = array_keys($_SESSION['config_types']);
for ($i = 0; $i < sizeof($modSettings); $i++) $_SESSION['config_moduleSettings'][$modSettings[$i]] = $_POST[$modSettings[$i]];
}
// go to final page
if ($_POST['submitconf']){
@ -212,7 +217,7 @@ echo ("<tr><td colspan=3>&nbsp</td></tr>");
// LDAP cache timeout
echo ("<tr><td align=\"right\"><b>".
_("Cache timeout") . " : </b></td>".
_("Cache timeout") . ": </b></td>".
"<td><select 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");
@ -244,6 +249,58 @@ echo ("</fieldset>");
echo ("<p></p>");
// module settings
// get list of scopes of modules
$scopes = array();
$mods = $conf->get_UserModules();
for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = 'user';
$mods = $conf->get_GroupModules();
for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = 'group';
$mods = $conf->get_HostModules();
for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = 'host';
// get module options
$options = getConfigOptions($scopes);
// get current setting
$old_options = $conf->get_moduleSettings();
// get module descriptions
$moduleDescriptions = getConfigDescriptions();
// save scopes
$_SESSION['config_scopes'] = $scopes;
// index for tab order (1 is LDAP suffix)
$tabindex = 2;
// display module boxes
$modules = array_keys($options);
for ($m = 0; $m < sizeof($modules); $m++) {
// ignore empty values
if (!is_array($options[$modules[$m]]) || (sizeof($options[$modules[$m]]) < 1)) continue;
echo "<fieldset>\n";
echo "<legend><b>" . $moduleDescriptions['legend'][$modules[$m]] . "</b></legend>\n";
echo "<table>\n";
for ($l = 0; $l < sizeof($options[$modules[$m]]); $l++) { // option lines
echo "<tr>\n";
for ($o = 0; $o < sizeof($options[$modules[$m]][$l]); $o++) { // line parts
echo "<td";
if (isset($options[$modules[$m]][$l][$o]['align'])) echo " align=\"" . $options[$modules[$m]][$l][$o]['align'] . "\"";
if (isset($options[$modules[$m]][$l][$o]['colspan'])) echo " colspan=\"" . $options[$modules[$m]][$l][$o]['colspan'] . "\"";
if (isset($options[$modules[$m]][$l][$o]['rowspan'])) echo " rowspan=\"" . $options[$modules[$m]][$l][$o]['rowspan'] . "\"";
echo ">";
print_option($options[$modules[$m]][$l][$o], $modules[$m], $old_options, $tabindex);
echo "</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
echo "</fieldset>\n";
echo "<br>";
}
echo ("<fieldset><legend><b>" . _("Ranges") . "</b></legend>");
echo ("<table border=0>");
@ -437,5 +494,110 @@ echo ("</form>\n");
echo ("</body>\n");
echo ("</html>\n");
/**
* prints out the row of a section table including the option name, values and help
*
* @param array $values an array formated as module option
* @param string $module_name the name of the module the options belong to
* @param array $old_options a hash array with the values from the loaded profile
* @param integer $tabindex current value for tabulator order
*/
function print_option($values, $modulename, $old_options, &$tabindex) {
switch ($values['kind']) {
// text value
case 'text':
echo $values['text'] . "\n";
break;
// help link
case 'help':
echo "<a href=../help.php?module=$modulename&amp;HelpNumber=" . $values['value'] . ">" . _('Help') . "</a>\n";
break;
// input field
case 'input':
if (($values['type'] == 'text') || ($values['type'] == 'checkbox')) {
if ($values['type'] == 'text') {
$output = "<input tabindex=\"$tabindex\" type=\"text\" name=\"" . $values['name'] . "\"";
if ($values['size']) $output .= " size=\"" . $values['size'] . "\"";
if ($values['maxlength']) $output .= " maxlength=\"" . $values['maxlength'] . "\"";
if (isset($old_options[$values['name']])) $output .= " value=\"" . $old_options[$values['name']][0] . "\"";
elseif ($values['value']) $output .= " value=\"" . $values['value'] . "\"";
if ($values['disabled']) $output .= " disabled";
$output .= ">\n";
echo $output;
$_SESSION['config_types'][$values['name']] = "text";
}
elseif ($values['type'] == 'checkbox') {
$output = "<input tabindex=\"$tabindex\" type=\"checkbox\" name=\"" . $values['name'] . "\"";
if ($values['size']) $output .= " size=\"" . $values['size'] . "\"";
if ($values['maxlength']) $output .= " maxlength=\"" . $values['maxlength'] . "\"";
if ($values['disabled']) $output .= " disabled";
if (isset($old_options[$values['name']]) && ($old_options[$values['name']][0] == 'true')) $output .= " checked";
elseif ($values['checked']) $output .= " checked";
$output .= ">\n";
echo $output;
$_SESSION['config_types'][$values['name']] = "checkbox";
}
$tabindex++;
}
break;
// select box
case 'select':
if (! is_numeric($values['size'])) $values['size'] = 1;// correct size if needed
if ($values['multiple']) {
echo "<select tabindex=\"$tabindex\" name=\"" . $values['name'] . "[]\" size=\"" . $values['size'] . "\" multiple>\n";
$_SESSION['config_types'][$values['name']] = "multiselect";
}
else {
echo "<select tabindex=\"$tabindex\" name=\"" . $values['name'] . "\" size=\"" . $values['size'] . "\">\n";
$_SESSION['config_types'][$values['name']] = "select";
}
// option values
for ($i = 0; $i < sizeof($values['options']); $i++) {
// use values from old profile if given
if (isset($old_options[$values['name']])) {
if (in_array($values['options'][$i], $old_options[$values['name']])) {
echo "<option selected>" . $values['options'][$i] . "</option>\n";
}
else {
echo "<option>" . $values['options'][$i] . "</option>\n";
}
}
// use default values if not in profile
else {
if (is_array($values['options_selected']) && in_array($values['options'][$i], $values['options_selected'])) {
echo "<option selected>" . $values['options'][$i] . "</option>\n";
}
else {
echo "<option>" . $values['options'][$i] . "</option>\n";
}
}
}
echo "</select>\n";
$tabindex++;
break;
// subtable
case 'table':
echo "<table>\n";
for ($l = 0; $l < sizeof($values['value']); $l++) { // option lines
echo "<tr>\n";
for ($o = 0; $o < sizeof($values['value'][$l]); $o++) { // line parts
echo "<td>";
print_option($values['value'][$l][$o], $values['value'], $old_options, $tabindex);
echo "</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
break;
// print error message for invalid types
default:
echo _("Unrecognized type") . ": " . $values['kind'] . "\n";
break;
}
}
?>

View File

@ -214,6 +214,54 @@ if (! $conf->set_HostModules($_SESSION['conf_hostmodules'])) {
exit;
}
// check module options
// create option array to check and save
$options = array();
$opt_keys = array_keys($_SESSION['config_types']);
foreach ($opt_keys as $element) {
// text fields
if ($_SESSION['config_types'][$element] == "text") {
$options[$element] = array($_SESSION['config_moduleSettings'][$element]);
}
// checkboxes
elseif ($_SESSION['config_types'][$element] == "checkbox") {
if ($_SESSION['config_moduleSettings'][$element] == "on") $options[$element] = array('true');
else $options[$element] = array('false');
}
// dropdownbox
elseif ($_SESSION['config_types'][$element] == "select") {
$options[$element] = array($_SESSION['config_moduleSettings'][$element]);
}
// multiselect
elseif ($_SESSION['config_types'][$element] == "multiselect") {
$options[$element] = $_SESSION['config_moduleSettings'][$element]; // value is already an array
}
}
// remove double slashes if magic quotes are on
if (get_magic_quotes_gpc() == 1) {
foreach ($opt_keys as $element) {
if (is_string($options[$element][0])) $options[$element][0] = stripslashes($options[$element][0]);
}
}
// check options
$errors = checkConfigOptions($_SESSION['config_scopes'], $options);
// print error messages if any
if (sizeof($errors) > 0) {
for ($i = 0; $i < sizeof($errors); $i++) {
if (sizeof($errors[$i]) > 3) { // messages with additional variables
StatusMessage($errors[$i][0], $errors[$i][1], $errors[$i][2], $errors[$i][3]);
}
else {
StatusMessage($errors[$i][0], $errors[$i][1], $errors[$i][2]);
}
}
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
// save module setting
$conf->set_moduleSettings($options);
// check if password was changed
if ($passwd1) {