added config options for self service

This commit is contained in:
Roland Gruber 2006-11-21 17:37:12 +00:00
parent fa27b504f0
commit e99a76a35d
4 changed files with 152 additions and 1 deletions

View File

@ -570,6 +570,83 @@ $fields:</span> list of self service field names<br>
<span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; 'mod' =&gt; array(),</span><br style="font-weight: bold;"> <span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; 'mod' =&gt; array(),</span><br style="font-weight: bold;">
<span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; 'del' =&gt; array(),</span><br style="font-weight: bold;"> <span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; 'del' =&gt; array(),</span><br style="font-weight: bold;">
<span style="font-weight: bold;">);</span><br style="font-weight: bold;"> <span style="font-weight: bold;">);</span><br style="font-weight: bold;">
<span style="font-weight: bold;"><br>
</span>
<h3>2.1.25. getSelfServiceSettings</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top; text-align: center;"><span style="font-weight: bold;">function getSelfServiceSettings()</span><br>
</td>
</tr>
</tbody>
</table>
<br>
Returns a list of self service configuration settings.<br>
<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>
<span style="font-weight: bold;"></span><br>
<h3>2.1.26. checkSelfServiceSettings</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top; text-align: center;"><span style="font-weight: bold;">function checkSelfServiceSettings($options)</span><br>
</td>
</tr>
</tbody>
</table>
<br>
Checks if the self service settings are valid.<br>
<br>
<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>
<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.<br>
<span style="font-weight: bold;"></span><br>
<span style="font-weight: bold;"><br> <span style="font-weight: bold;"><br>
<br> <br>
</span> </span>

View File

@ -48,6 +48,9 @@ class baseModule {
/** configuration settings of all modules */ /** configuration settings of all modules */
var $moduleSettings; var $moduleSettings;
/** self service settings of all modules */
var $selfServiceSettings;
/** name of parent accountContainer ($_SESSION[$base]) */ /** name of parent accountContainer ($_SESSION[$base]) */
var $base; var $base;
@ -69,7 +72,9 @@ class baseModule {
$this->scope = $scope; $this->scope = $scope;
$this->load_Messages(); $this->load_Messages();
$this->meta = $this->get_metaData(); $this->meta = $this->get_metaData();
// load configuration
if (isset($_SESSION['config'])) $this->moduleSettings = $_SESSION['config']->get_moduleSettings(); if (isset($_SESSION['config'])) $this->moduleSettings = $_SESSION['config']->get_moduleSettings();
if (isset($_SESSION['selfServiceProfile'])) $this->selfServiceSettings = $_SESSION['selfServiceProfile']->moduleSettings;
} }
/** /**
@ -686,6 +691,27 @@ class baseModule {
return $return; return $return;
} }
/**
* Returns a list of self service configuration settings.
*
* @return array settings
*/
function getSelfServiceSettings() {
if (isset($this->meta['selfServiceSettings']) && is_array($this->meta['selfServiceSettings'])) return $this->meta['selfServiceSettings'];
else return array();
}
/**
* Checks if the self service settings are valid.
*
* @param array $options settings
* @return array error messages
*/
function checkSelfServiceSettings($options) {
// needs to be implemented by the subclasses, if needed
return array();
}
} }

View File

@ -128,6 +128,17 @@ class posixAccount extends baseModule {
$return['selfServiceSearchAttributes'] = array('uid'); $return['selfServiceSearchAttributes'] = array('uid');
// self service field settings // self service field settings
$return['selfServiceFieldSettings'] = array('password' => _('Password')); $return['selfServiceFieldSettings'] = array('password' => _('Password'));
// self service configuration settings
$return['selfServiceSettings'] = array(
array(
0 => array('kind' => 'text', 'text' => '<b>' . _("Password hash type") . ': &nbsp;</b>'),
1 => array('kind' => 'select', 'name' => 'posixAccount_pwdHash', 'size' => '1',
'options' => array("CRYPT", "SHA", "SSHA", "MD5", "SMD5", "PLAIN"), 'options_selected' => array('SSHA')),
2 => array('kind' => 'text', 'value' => '&nbsp;'),
3 => array('kind' => 'text', 'value' => '&nbsp;'),
4 => array('kind' => 'text', 'value' => '&nbsp;'),
5 => array('kind' => 'help', 'value' => 'pwdHash'))
);
} }
// profile checks // profile checks
$return['profile_checks']['posixAccount_homeDirectory'] = array('type' => 'ext_preg', 'regex' => 'homeDirectory', $return['profile_checks']['posixAccount_homeDirectory'] = array('type' => 'ext_preg', 'regex' => 'homeDirectory',
@ -1530,7 +1541,7 @@ class posixAccount extends baseModule {
$return['messages'][] = $this->messages['userPassword'][1]; $return['messages'][] = $this->messages['userPassword'][1];
} }
else { else {
$return['mod']['userPassword'][0] = pwd_hash($_POST['posixAccount_password'], true, 'SSHA'); $return['mod']['userPassword'][0] = pwd_hash($_POST['posixAccount_password'], true, $this->selfServiceSettings['posixAccount_pwdHash'][0]);
$_SESSION['selfService_clientPasswordNew'] = $_POST['posixAccount_password']; $_SESSION['selfService_clientPasswordNew'] = $_POST['posixAccount_password'];
} }
} }

View File

@ -212,6 +212,40 @@ function saveSelfServiceProfile($name, $scope, $profile) {
return true; return true;
} }
/**
* Returns a hash array (module name => elements) of all module options for the configuration page.
*
* @param string $scope account type
* @return array configuration options
*/
function getSelfServiceSettings($scope) {
$return = array();
$modules = getAvailableModules($scope);
for ($i = 0; $i < sizeof($modules); $i++) {
$m = new $modules[$i]($scope);
$return[$modules[$i]] = $m->getSelfServiceSettings();
}
return $return;
}
/**
* Checks if the self service settings are valid
*
* @param string $scope account type
* @param array $options hash array containing all options (name => array(...))
* @return array list of error messages
*/
function checkSelfServiceSettings($scope, $options) {
$return = array();
$modules = getAvailableModules($scope);
for ($i = 0; $i < sizeof($modules); $i++) {
$m = new $modules[$i]($scope);
$errors = $m->checkSelfServiceSettings($options);
$return = array_merge($return, $errors);
}
return $return;
}
/** /**
* Includes all settings of a self service profile. * Includes all settings of a self service profile.
@ -249,6 +283,9 @@ class selfServiceProfile {
* *
*/ */
var $inputFields; var $inputFields;
/** configuration settings of modules */
var $moduleSettings;
/** /**
* Constructor * Constructor