From 24bc2dca349163881710adfcabebe2570b510000 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sun, 23 Jul 2006 15:04:12 +0000 Subject: [PATCH] added more self service functions --- lam/lib/baseModule.inc | 26 +++++++++++++++++++++++++ lam/lib/selfService.inc | 43 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/lam/lib/baseModule.inc b/lam/lib/baseModule.inc index 9f1ec441..8294f865 100644 --- a/lam/lib/baseModule.inc +++ b/lam/lib/baseModule.inc @@ -675,6 +675,32 @@ class baseModule { if (isset($this->meta['selfServiceFieldSettings']) && is_array($this->meta['selfServiceFieldSettings'])) return $this->meta['selfServiceFieldSettings']; else return array(); } + + /** + * Returns the meta HTML code for each input field. + * format: array( => array(), ...) + * It is not possible to display help links. + * + * @param array $fields list of active fields + * @param array $attributes attributes of LDAP account (attribute names in lower case) + * @return array meta HTML + */ + function getSelfServiceOptions($fields, $attributes) { + // this function must be overwritten by subclasses. + return array(); + } + + /** + * Checks if all input values are correct and returns the LDAP commands which should be executed. + * + * @param string $fields input fields + * @param array $attributes LDAP attributes + * @return array messages and LDAP commands (array('messages' => array(), 'add' => array(), 'del' => array(), 'mod' => array())) + */ + function checkSelfServiceOptions($fields, $attributes) { + $return = array('messages' => array(), 'add' => array(), 'del' => array(), 'mod' => array()); + return $return; + } } diff --git a/lam/lib/selfService.inc b/lam/lib/selfService.inc index bf1e200b..e8f80e10 100644 --- a/lam/lib/selfService.inc +++ b/lam/lib/selfService.inc @@ -72,6 +72,49 @@ function getSelfServiceFieldSettings($scope) { } +/** + * Returns meta HTML code for each self service field. + * + * @param string $scope account type + * @param array $fields input fields (array( => array(, , ...))) + * @param array $attributes LDAP attributes (attribute names in lower case) + * @return array meta HTML code (array( => array( => array()))) + */ +function getSelfServiceOptions($scope, $fields, $attributes) { + $return = array(); + $modules = getAvailableModules($scope); + for ($i = 0; $i < sizeof($modules); $i++) { + $m = new $modules[$i]($scope); + $code = $m->getSelfServiceOptions($fields[$modules[$i]], $attributes); + if (sizeof($code) > 0) $return[$modules[$i]] = $code; + } + return $return; +} + + +/** + * Checks if all input values are correct and returns the LDAP commands which should be executed. + * + * @param string $scope account type + * @param string $fields input fields (array( => array(, , ...))) + * @param array $attributes LDAP attributes + * @return array messages and LDAP commands (array('messages' => array(), 'add' => array(), 'del' => array(), 'mod' => array())) + */ +function checkSelfServiceOptions($scope, $fields, $attributes) { + $return = array('messages' => array(), 'add' => array(), 'del' => array(), 'mod' => array()); + $modules = getAvailableModules($scope); + for ($i = 0; $i < sizeof($modules); $i++) { + $m = new $modules[$i]($scope); + $result = $m->checkSelfServiceOptions($fields[$modules[$i]], $attributes); + if (sizeof($result['messages']) > 0) $return['messages'] = array_merge($result['messages'], $return['messages']); + if (sizeof($result['add']) > 0) $return['add'] = array_merge($result['add'], $return['add']); + if (sizeof($result['del']) > 0) $return['del'] = array_merge($result['del'], $return['del']); + if (sizeof($result['mod']) > 0) $return['mod'] = array_merge($result['mod'], $return['mod']); + } + return $return; +} + + /** * Returns a list of all available self service profiles (without .conf) *