diff --git a/lam/docs/devel/modules-specification.htm b/lam/docs/devel/modules-specification.htm index 86a895ad..b69c19ef 100644 --- a/lam/docs/devel/modules-specification.htm +++ b/lam/docs/devel/modules-specification.htm @@ -570,6 +570,83 @@ $fields: list of self service field names
    'mod' => array(),
    'del' => array(),
);
+
+ +
+

2.1.25. getSelfServiceSettings

+ + +
+ + + + + + + + + + +
function getSelfServiceSettings()
+
+ + +
+Returns a list of self service configuration settings.
+
+ + +The return value is an array +that contains meta HTML code.
+ +
+ +The type "fieldset" is not allowed here.
+ +The name 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.
+ +
+ + +

2.1.26. checkSelfServiceSettings

+ + +
+ + + + + + + + + + +
function checkSelfServiceSettings($options)
+
+ + +
+Checks if the self service settings are valid.
+ +
+ +$options: is an hash array +(option name => value) that contains the input. The option values +are all arrays containing one or more elements.
+
+If the input data is invalid the return value is an array that contains +arrays to build StatusMessages (0 => message type, 1 => message +head, 2 => message text, 3 => additional variables).
+ +If no errors occured the function returns an empty array.
+ +
+ +

diff --git a/lam/lib/baseModule.inc b/lam/lib/baseModule.inc index 2282c681..29e1107f 100644 --- a/lam/lib/baseModule.inc +++ b/lam/lib/baseModule.inc @@ -48,6 +48,9 @@ class baseModule { /** configuration settings of all modules */ var $moduleSettings; + /** self service settings of all modules */ + var $selfServiceSettings; + /** name of parent accountContainer ($_SESSION[$base]) */ var $base; @@ -69,7 +72,9 @@ class baseModule { $this->scope = $scope; $this->load_Messages(); $this->meta = $this->get_metaData(); + // load configuration 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; } + /** + * 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(); + } + } diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index 43959a9c..9cae134d 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -128,6 +128,17 @@ class posixAccount extends baseModule { $return['selfServiceSearchAttributes'] = array('uid'); // self service field settings $return['selfServiceFieldSettings'] = array('password' => _('Password')); + // self service configuration settings + $return['selfServiceSettings'] = array( + array( + 0 => array('kind' => 'text', 'text' => '' . _("Password hash type") . ':  '), + 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' => ' '), + 3 => array('kind' => 'text', 'value' => ' '), + 4 => array('kind' => 'text', 'value' => ' '), + 5 => array('kind' => 'help', 'value' => 'pwdHash')) + ); } // profile checks $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]; } 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']; } } diff --git a/lam/lib/selfService.inc b/lam/lib/selfService.inc index 4a920dc7..49f0afca 100644 --- a/lam/lib/selfService.inc +++ b/lam/lib/selfService.inc @@ -212,6 +212,40 @@ function saveSelfServiceProfile($name, $scope, $profile) { 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. @@ -249,6 +283,9 @@ class selfServiceProfile { * */ var $inputFields; + + /** configuration settings of modules */ + var $moduleSettings; /** * Constructor