removed $scope from profile functions,
added meta data for profile options and checks
This commit is contained in:
parent
a7862e4dab
commit
c92674a95a
|
@ -271,7 +271,7 @@ It must return the help entry as array for the submitted help
|
||||||
identifier. The format of the array to be returned is described in
|
identifier. The format of the array to be returned is described in
|
||||||
section 4. "Help entry syntax".<br>
|
section 4. "Help entry syntax".<br>
|
||||||
<br>
|
<br>
|
||||||
<h3>2.2.5. get_profileOptions</h3>
|
<h3>2.2.5. get_profileOptions*</h3>
|
||||||
<br>
|
<br>
|
||||||
<table cellpadding="2" cellspacing="2" border="0"
|
<table cellpadding="2" cellspacing="2" border="0"
|
||||||
style="text-align: left; width: 300px; height: 30px;">
|
style="text-align: left; width: 300px; height: 30px;">
|
||||||
|
@ -279,7 +279,7 @@ section 4. "Help entry syntax".<br>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td
|
||||||
style="vertical-align: top; background-color: rgb(204, 204, 204); text-align: center;"><span
|
style="vertical-align: top; background-color: rgb(204, 204, 204); text-align: center;"><span
|
||||||
style="font-weight: bold;">function get_profileOptions($scope)</span><br>
|
style="font-weight: bold;">function get_profileOptions()</span><br>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -288,10 +288,8 @@ section 4. "Help entry syntax".<br>
|
||||||
This function defines what attributes will be used in the account
|
This function defines what attributes will be used in the account
|
||||||
profiles and their appearance in the profile editor.<br>
|
profiles and their appearance in the profile editor.<br>
|
||||||
<br>
|
<br>
|
||||||
<span style="font-weight: bold;">$scope</span> is the account type
|
<span style="font-weight: bold;"></span>The return value is an array
|
||||||
("user", "group", "host" at this time).<br>
|
that contains <span style="font-weight: bold;">meta HTML code</span>.<br>
|
||||||
The return value is an array that contains <span
|
|
||||||
style="font-weight: bold;">meta HTML code</span>.<br>
|
|
||||||
<br>
|
<br>
|
||||||
The type "fieldset" is not allowed here.<br>
|
The type "fieldset" is not allowed here.<br>
|
||||||
The <span style="font-style: italic;">name</span> attributes are used
|
The <span style="font-style: italic;">name</span> attributes are used
|
||||||
|
@ -299,7 +297,7 @@ as keywords to load and save profiles. We recommend to use the module
|
||||||
name as prefix for them (e.g. posixAccount_homeDirectory) to avoid
|
name as prefix for them (e.g. posixAccount_homeDirectory) to avoid
|
||||||
naming confilcts.<br>
|
naming confilcts.<br>
|
||||||
<br>
|
<br>
|
||||||
<h3>2.2.6. check_profileOptions</h3>
|
<h3>2.2.6. check_profileOptions*</h3>
|
||||||
<br>
|
<br>
|
||||||
<table style="text-align: left; width: 400px; height: 30px;" border="0"
|
<table style="text-align: left; width: 400px; height: 30px;" border="0"
|
||||||
cellspacing="2" cellpadding="2">
|
cellspacing="2" cellpadding="2">
|
||||||
|
@ -307,8 +305,7 @@ naming confilcts.<br>
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td
|
||||||
style="vertical-align: top; background-color: rgb(204, 204, 204); text-align: center;"><span
|
style="vertical-align: top; background-color: rgb(204, 204, 204); text-align: center;"><span
|
||||||
style="font-weight: bold;">function check_profileOptions($scope,
|
style="font-weight: bold;">function check_profileOptions($options)</span><br>
|
||||||
$options)</span><br>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -576,8 +573,74 @@ array("user", "host")</span><br style="font-weight: bold;">
|
||||||
style="font-weight: bold; font-style: italic;">"depends"
|
style="font-weight: bold; font-style: italic;">"depends"
|
||||||
=> array("posixAccount", array("qmail", "sendmail")), "conflicts"
|
=> array("posixAccount", array("qmail", "sendmail")), "conflicts"
|
||||||
=> array("exim")</span></span><span
|
=> array("exim")</span></span><span
|
||||||
style="font-style: italic; font-weight: bold;">)</span><span
|
style="font-style: italic; font-weight: bold;">)<br>
|
||||||
style="font-style: italic; font-weight: bold;"><br>
|
</span><br>
|
||||||
|
<h3>6.5 get_profileOptions()<br>
|
||||||
|
</h3>
|
||||||
|
"profile_options" => array<br>
|
||||||
|
<br>
|
||||||
|
<span style="font-weight: bold;"> <span
|
||||||
|
style="font-style: italic;">Syntax for array is the same as for the
|
||||||
|
return value of get_profileOptions().<br>
|
||||||
|
<br>
|
||||||
|
</span></span>
|
||||||
|
<h3>6.6 check_profileOptions()<br>
|
||||||
|
</h3>
|
||||||
|
"profile_checks" => array<br>
|
||||||
|
<br>
|
||||||
|
<span style="font-weight: bold;"> The keys of the array are
|
||||||
|
the names of the option identifiers.<br>
|
||||||
|
Each array element is an array containing these values:<br>
|
||||||
|
<br>
|
||||||
</span>
|
</span>
|
||||||
|
<ul>
|
||||||
|
<li style="font-weight: bold;">type:<span style="font-weight: normal;">
|
||||||
|
determines how to check input</span></li>
|
||||||
|
<ul>
|
||||||
|
<li style="font-weight: bold;">regex:<span
|
||||||
|
style="font-weight: normal;"> check with regular expression from <span
|
||||||
|
style="font-style: italic;">regex</span> variable, case sensitive</span></li>
|
||||||
|
<li style="font-weight: bold;">regex_i:<span
|
||||||
|
style="font-weight: normal;"> check with regular expression from <span
|
||||||
|
style="font-style: italic;">regex</span> variable, case insensitive</span></li>
|
||||||
|
</ul>
|
||||||
|
<li style="font-weight: bold;">error_message:<span
|
||||||
|
style="font-weight: normal;"> message that is displayed if input value
|
||||||
|
was syntactically incorrect</span></li>
|
||||||
|
<ul>
|
||||||
|
<li style="font-weight: bold;"><span style="font-weight: normal;">array
|
||||||
|
to build StatusMessages (0 => message type, 1 => message
|
||||||
|
head, 2 => message text, 3 => additional variables)</span><span
|
||||||
|
style="font-weight: normal;"></span></li>
|
||||||
|
</ul>
|
||||||
|
<li style="font-weight: bold;">regex:<span
|
||||||
|
style="font-weight: normal;"> regular expression string (only if <span
|
||||||
|
style="font-style: italic;">type</span> is <span
|
||||||
|
style="font-style: italic;">regex</span>/<span
|
||||||
|
style="font-style: italic;">regex_i</span>)</span><br>
|
||||||
|
</li>
|
||||||
|
<li><span style="font-weight: bold;">required:</span> <span
|
||||||
|
style="font-style: italic;">true</span> or <span
|
||||||
|
style="font-style: italic;">false</span>, if this input field must be
|
||||||
|
filled set to true (optional)<span style="font-weight: bold;"><br>
|
||||||
|
</span></li>
|
||||||
|
<li><span style="font-weight: bold;">required_message:</span> message<span
|
||||||
|
style="font-weight: normal;"> that is displayed if no input value was
|
||||||
|
given</span><span style="font-weight: normal;"> (only if <span
|
||||||
|
style="font-style: italic;">required</span> == true)</span><span
|
||||||
|
style="font-weight: bold;"></span></li>
|
||||||
|
<ul>
|
||||||
|
<li> array to build StatusMessages (0 => message type, 1
|
||||||
|
=> message
|
||||||
|
head, 2 => message text, 3 => additional variables)<span
|
||||||
|
style="font-weight: bold;"><br>
|
||||||
|
</span></li>
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
<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
|
||||||
|
style="font-style: italic; font-weight: bold;"></span><span
|
||||||
|
style="font-style: italic; font-weight: bold;"></span>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -128,6 +128,47 @@ class baseModule {
|
||||||
else return array('depends' => array(), 'conflicts' => array());
|
else return array('depends' => array(), 'conflicts' => array());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of elements for the account profiles.
|
||||||
|
*
|
||||||
|
* @return profile elements
|
||||||
|
*/
|
||||||
|
function get_profileOptions() {
|
||||||
|
if (isset($this->meta['profile_options'])) return $this->meta['profile_options'];
|
||||||
|
else return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks input values of account profiles.
|
||||||
|
*
|
||||||
|
* @return profile elements
|
||||||
|
*/
|
||||||
|
function check_profileOptions($options) {
|
||||||
|
$messages = array();
|
||||||
|
if (is_array($this->meta['profile_checks'])) {
|
||||||
|
$identifiers = array_keys($this->meta['profile_checks']);
|
||||||
|
for ($i = 0; $i < sizeof($identifiers); $i++) {
|
||||||
|
// check if option is required
|
||||||
|
if ($this->meta['profile_checks'][$identifiers[$i]]['required'] && ($options[$identifiers[$i]][0] == '')) {
|
||||||
|
$messages[] = $this->meta['profile_checks'][$identifiers[$i]]['required_message'];
|
||||||
|
}
|
||||||
|
// check by regular expression (case insensitive)
|
||||||
|
if ($this->meta['profile_checks'][$identifiers[$i]]['type'] == 'regex_i') {
|
||||||
|
if (! eregi($this->meta['profile_checks'][$identifiers[$i]]['regex'], $options[$identifiers[$i]][0])) {
|
||||||
|
$messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check by regular expression (case sensitive)
|
||||||
|
elseif ($this->meta['profile_checks'][$identifiers[$i]]['type'] == 'regex') {
|
||||||
|
if (! ereg($this->meta['profile_checks'][$identifiers[$i]]['regex'], $options[$identifiers[$i]][0])) {
|
||||||
|
$messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $messages;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO implement missing interface
|
// TODO implement missing interface
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -240,13 +240,13 @@ function getProfileOptions($scope) {
|
||||||
* @return array list of error messages
|
* @return array list of error messages
|
||||||
*/
|
*/
|
||||||
function checkProfileOptions($scope, $options) {
|
function checkProfileOptions($scope, $options) {
|
||||||
$return = array();
|
// create new account container if needed
|
||||||
$modules = getAvailableModules($scope);
|
if (! isset($_SESSION["profile_account_$scope"])) {
|
||||||
for ($i = 0; $i < sizeof($modules); $i++) {
|
$_SESSION["profile_account_$scope"] = new accountContainer($scope, "profile_account_$scope");
|
||||||
$errors = call_user_func(array($modules[$i], "check_profileOptions"), $scope, $options);
|
$_SESSION["profile_account_$scope"]->new_account();
|
||||||
$return = array_merge($return, $errors);
|
|
||||||
}
|
}
|
||||||
return $return;
|
// get options
|
||||||
|
return $_SESSION["profile_account_$scope"]->checkProfileOptions($options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -808,6 +808,22 @@ class accountContainer {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the input values of an account profile.
|
||||||
|
*
|
||||||
|
* @param array $options list of input values
|
||||||
|
* @return array list of error messages
|
||||||
|
*/
|
||||||
|
function checkProfileOptions($options) {
|
||||||
|
$return = array();
|
||||||
|
$modules = array_keys($this->module);
|
||||||
|
foreach ($modules as $singlemodule) {
|
||||||
|
$temp = $this->module[$singlemodule]->check_profileOptions($options);
|
||||||
|
$return = array_merge($return, $temp);
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO remove this function?
|
// TODO remove this function?
|
||||||
function proccess_profile($post) {
|
function proccess_profile($post) {
|
||||||
$return = array();
|
$return = array();
|
||||||
|
|
|
@ -196,17 +196,6 @@ class account extends baseModule {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_profileOptions() {
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
// checks if the values of a new or modified profile are valid
|
|
||||||
// $scope: the account type (user, group, host, ...)
|
|
||||||
// $options: a hash array (name => value) containing the options
|
|
||||||
function check_profileOptions($scope, $options) {
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_pdfFields($account_type="user") {
|
function get_pdfFields($account_type="user") {
|
||||||
return array( 'description');
|
return array( 'description');
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,6 @@ class inetOrgPerson extends baseModule {
|
||||||
* Creates a new inetOrgPerson object.
|
* Creates a new inetOrgPerson object.
|
||||||
*/
|
*/
|
||||||
function inetOrgPerson($scope) {
|
function inetOrgPerson($scope) {
|
||||||
parent::baseModule($scope);
|
|
||||||
// error messages for input checks
|
// error messages for input checks
|
||||||
$this->messages['host'] = array('ERROR', _('Unix workstations'), _('Unix workstations is invalid.'));
|
$this->messages['host'] = array('ERROR', _('Unix workstations'), _('Unix workstations is invalid.'));
|
||||||
$this->messages['givenName'] = array('ERROR', _('Given name'), _('Given name contains invalid characters'));
|
$this->messages['givenName'] = array('ERROR', _('Given name'), _('Given name contains invalid characters'));
|
||||||
|
@ -56,6 +55,8 @@ class inetOrgPerson extends baseModule {
|
||||||
$this->messages['postalCode'] = array('ERROR', _('Postal code'), _('Please enter a valid postal code!'));
|
$this->messages['postalCode'] = array('ERROR', _('Postal code'), _('Please enter a valid postal code!'));
|
||||||
$this->messages['title'] = array('ERROR', _('Title'), _('Please enter a valid title!'));
|
$this->messages['title'] = array('ERROR', _('Title'), _('Please enter a valid title!'));
|
||||||
$this->messages['employeeType'] = array('ERROR', _('Employee type'), _('Please enter a valid employee type!'));
|
$this->messages['employeeType'] = array('ERROR', _('Employee type'), _('Please enter a valid employee type!'));
|
||||||
|
// call parent constructor
|
||||||
|
parent::baseModule($scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,6 +72,22 @@ class inetOrgPerson extends baseModule {
|
||||||
$return["alias"] = _('Personal');
|
$return["alias"] = _('Personal');
|
||||||
// module dependencies
|
// module dependencies
|
||||||
$return['dependencies'] = array('depends' => array('posixAccount'), 'conflicts' => array('account'));
|
$return['dependencies'] = array('depends' => array('posixAccount'), 'conflicts' => array('account'));
|
||||||
|
// profile elements
|
||||||
|
$return['profile_options'] = array(
|
||||||
|
array(
|
||||||
|
0 => array('kind' => 'text', 'text' => _('Job title') . ":"),
|
||||||
|
1 => array('kind' => 'input', 'name' => 'inetOrgPerson_title', 'type' => 'text', 'size' => '30', 'maxlength' => '255'),
|
||||||
|
2 => array('kind' => 'help', 'value' => 'TODO')),
|
||||||
|
array(
|
||||||
|
0 => array('kind' => 'text', 'text' => _('Employee type') . ":"),
|
||||||
|
1 => array('kind' => 'input', 'name' => 'inetOrgPerson_employeeType', 'type' => 'text', 'size' => '30', 'maxlength' => '255'),
|
||||||
|
2 => array('kind' => 'help', 'value' => 'TODO'))
|
||||||
|
);
|
||||||
|
// profile checks
|
||||||
|
$return['profile_checks']['inetOrgPerson_title'] = array('type' => 'regex_i', 'regex' => $this->regex_title,
|
||||||
|
'error_message' => $this->messages['title']);
|
||||||
|
$return['profile_checks']['inetOrgPerson_employeeType'] = array('type' => 'regex_i',
|
||||||
|
'regex' => $this->regex_employeeType, 'error_message' => $this->messages['employeeType']);
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,9 +294,9 @@ class inetOrgPerson extends baseModule {
|
||||||
'maxlength' => '255', 'value' => $hostvalues ),
|
'maxlength' => '255', 'value' => $hostvalues ),
|
||||||
2 => array ('kind' => 'help', 'value' => 'host'));
|
2 => array ('kind' => 'help', 'value' => 'host'));
|
||||||
}
|
}
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Title') ),
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Job title') ),
|
||||||
1 => array ( 'kind' => 'input', 'name' => 'title', 'type' => 'text', 'size' => '10',
|
1 => array ( 'kind' => 'input', 'name' => 'title', 'type' => 'text', 'size' => '10',
|
||||||
'maxlength' => '10', 'value' => $this->attributes['title'][0] ),
|
'value' => $this->attributes['title'][0] ),
|
||||||
2 => array ('kind' => 'help', 'value' => 'title'));
|
2 => array ('kind' => 'help', 'value' => 'title'));
|
||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('First name').'*' ),
|
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('First name').'*' ),
|
||||||
|
@ -332,17 +349,6 @@ class inetOrgPerson extends baseModule {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_profileOptions() {
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
// checks if the values of a new or modified profile are valid
|
|
||||||
// $scope: the account type (user, group, host, ...)
|
|
||||||
// $options: a hash array (name => value) containing the options
|
|
||||||
function check_profileOptions($scope, $options) {
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_pdfFields($account_type = "user") {
|
function get_pdfFields($account_type = "user") {
|
||||||
return array( 'description',
|
return array( 'description',
|
||||||
'host',
|
'host',
|
||||||
|
|
|
@ -707,7 +707,7 @@ class posixAccount extends baseModule {
|
||||||
// checks if the values of a new or modified profile are valid
|
// checks if the values of a new or modified profile are valid
|
||||||
// $scope: the account type (user, group, host, ...)
|
// $scope: the account type (user, group, host, ...)
|
||||||
// $options: a hash array (name => value) containing the options
|
// $options: a hash array (name => value) containing the options
|
||||||
function check_profileOptions($scope, $options) {
|
function check_profileOptions($options) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -591,7 +591,7 @@ class posixGroup extends baseModule {
|
||||||
// checks if the values of a new or modified profile are valid
|
// checks if the values of a new or modified profile are valid
|
||||||
// $scope: the account type (user, group, host, ...)
|
// $scope: the account type (user, group, host, ...)
|
||||||
// $options: a hash array (name => value) containing the options
|
// $options: a hash array (name => value) containing the options
|
||||||
function check_profileOptions($scope, $options) {
|
function check_profileOptions($options) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -335,7 +335,7 @@ class quota extends baseModule {
|
||||||
// checks if the values of a new or modified profile are valid
|
// checks if the values of a new or modified profile are valid
|
||||||
// $scope: the account type (user, group, host, ...)
|
// $scope: the account type (user, group, host, ...)
|
||||||
// $options: a hash array (name => value) containing the options
|
// $options: a hash array (name => value) containing the options
|
||||||
function check_profileOptions($scope, $options) {
|
function check_profileOptions($options) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -687,7 +687,7 @@ class sambaAccount extends baseModule {
|
||||||
// checks if the values of a new or modified profile are valid
|
// checks if the values of a new or modified profile are valid
|
||||||
// $scope: the account type (user, group, host, ...)
|
// $scope: the account type (user, group, host, ...)
|
||||||
// $options: a hash array (name => value) containing the options
|
// $options: a hash array (name => value) containing the options
|
||||||
function check_profileOptions($scope, $options) {
|
function check_profileOptions($options) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -323,7 +323,7 @@ class sambaGroupMapping extends baseModule {
|
||||||
// checks if the values of a new or modified profile are valid
|
// checks if the values of a new or modified profile are valid
|
||||||
// $scope: the account type (user, group, host, ...)
|
// $scope: the account type (user, group, host, ...)
|
||||||
// $options: a hash array (name => value) containing the options
|
// $options: a hash array (name => value) containing the options
|
||||||
function check_profileOptions($scope, $options) {
|
function check_profileOptions($options) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -713,7 +713,7 @@ class sambaSamAccount extends baseModule {
|
||||||
// checks if the values of a new or modified profile are valid
|
// checks if the values of a new or modified profile are valid
|
||||||
// $scope: the account type (user, group, host, ...)
|
// $scope: the account type (user, group, host, ...)
|
||||||
// $options: a hash array (name => value) containing the options
|
// $options: a hash array (name => value) containing the options
|
||||||
function check_profileOptions($scope, $options) {
|
function check_profileOptions($options) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -296,7 +296,7 @@ class shadowAccount extends baseModule {
|
||||||
// checks if the values of a new or modified profile are valid
|
// checks if the values of a new or modified profile are valid
|
||||||
// $scope: the account type (user, group, host, ...)
|
// $scope: the account type (user, group, host, ...)
|
||||||
// $options: a hash array (name => value) containing the options
|
// $options: a hash array (name => value) containing the options
|
||||||
function check_profileOptions($scope, $options) {
|
function check_profileOptions($options) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue