diff --git a/lam/docs/modules-specification.htm b/lam/docs/modules-specification.htm
index c94d5b3f..5141a39e 100644
--- a/lam/docs/modules-specification.htm
+++ b/lam/docs/modules-specification.htm
@@ -188,7 +188,7 @@ Returns the account type (user/group/host) of this module object.
baseModule and should not be overwritten.
2.2. Class functions
-2.2.1. Constructor
+2.2.1. init
@@ -196,13 +196,13 @@ baseModule and should not be overwritten.
function <module name> ($base)
+ style="font-weight: bold;">function init($base)
|
-Every module needs a constructor that has an account
container as argument $base.
With this account container you can interact with other modules and use
@@ -313,9 +313,8 @@ naming confilcts.
This function checks the input for a new or modified account profile.
-$scope is the account type
-("user", "group", "host" at this time).
-$options is an hash array
+$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
@@ -603,6 +602,18 @@ determines how to check input
regex_i: check with regular expression from regex variable, case insensitive
+ int_greater: integer value of cmp_name1 must be
+greater than the integer value from the option cmp_name2
+ int_greaterOrEqual: integer value of cmp_name1
+must be greater or equal than the integer value from the option cmp_name2
error_message: message that is displayed if input value
@@ -617,8 +628,19 @@ head, 2 => message text, 3 => additional variables) regular expression string (only if type is regex/regex_i)
-
+ style="font-style: italic;">regex_i)
+ cmp_name1:
+name of first input
+variable that is used for comparison (only if type is int_greater/int_greaterOrEqual)
+ cmp_name2: name of second input
+variable that is used for comparison (only if type is int_greater/int_greaterOrEqual)
+
required: true or false, if this input field must be
diff --git a/lam/lib/baseModule.inc b/lam/lib/baseModule.inc
index f23caaa8..6d45b4d5 100644
--- a/lam/lib/baseModule.inc
+++ b/lam/lib/baseModule.inc
@@ -152,20 +152,53 @@ class baseModule {
if ($this->meta['profile_checks'][$identifiers[$i]]['required'] && ($options[$identifiers[$i]][0] == '')) {
$messages[] = $this->meta['profile_checks'][$identifiers[$i]]['required_message'];
}
- // ignore empty fileds
- if ($options[$identifiers[$i]][0] == '') continue;
// check by regular expression (case insensitive)
if ($this->meta['profile_checks'][$identifiers[$i]]['type'] == 'regex_i') {
+ // ignore empty fileds
+ if ($options[$identifiers[$i]][0] == '') continue;
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') {
+ // ignore empty fileds
+ if ($options[$identifiers[$i]][0] == '') continue;
if (! ereg($this->meta['profile_checks'][$identifiers[$i]]['regex'], $options[$identifiers[$i]][0])) {
$messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message'];
}
}
+ // check by integer comparison (greater)
+ elseif ($this->meta['profile_checks'][$identifiers[$i]]['type'] == 'int_greater') {
+ // ignore if both fields are empty
+ if (($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0] == '')) continue;
+ // print error message if only one field is empty
+ if (($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0] == '') || ($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0] == '')) {
+ $messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message'];
+ continue;
+ }
+ // compare
+ if (!(intval($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0]) > intval($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0]))) {
+ $messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message'];
+ }
+ }
+ // check by integer comparison (greater or equal)
+ elseif ($this->meta['profile_checks'][$identifiers[$i]]['type'] == 'int_greaterOrEqual') {
+ // ignore if both fields are empty
+ if (($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0] == '')) continue;
+ // print error message if only one field is empty
+ if (($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0] == '') || ($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0] == '')) {
+ $messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message'];
+ continue;
+ }
+ // compare
+ if (!(intval($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0]) >= intval($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0]))) {
+ $messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message'];
+ }
+ }
+ else {
+ StatusMessage("ERROR", "Unsupported type!", $this->meta['profile_checks'][$identifiers[$i]]['type']);
+ }
}
}
return $messages;
diff --git a/lam/lib/modules/shadowAccount.inc b/lam/lib/modules/shadowAccount.inc
index ffe49094..42cb4772 100644
--- a/lam/lib/modules/shadowAccount.inc
+++ b/lam/lib/modules/shadowAccount.inc
@@ -124,6 +124,17 @@ class shadowAccount extends baseModule {
)),
2 => array('kind' => 'help', 'value' => 'TODO'))
);
+ // profile checks
+ $return['profile_checks']['shadowAccount_shadowMin'] = array('type' => 'regex', 'regex' => $this->regex_number,
+ 'error_message' => $this->messages['shadowMin']);
+ $return['profile_checks']['shadowAccount_shadowMax'] = array('type' => 'regex', 'regex' => $this->regex_number,
+ 'error_message' => $this->messages['shadowMax']);
+ $return['profile_checks']['shadowAccount_cmp'] = array('type' => 'int_greater', 'cmp_name1' => 'shadowAccount_shadowMax',
+ 'cmp_name2' => 'shadowAccount_shadowMin', 'error_message' => $this->messages['shadow_cmp']);
+ $return['profile_checks']['shadowAccount_shadowInactive'] = array('type' => 'regex', 'regex' => $this->regex_inactive,
+ 'error_message' => $this->messages['inactive']);
+ $return['profile_checks']['shadowAccount_shadowWarning'] = array('type' => 'regex', 'regex' => $this->regex_number,
+ 'error_message' => $this->messages['shadowWarning']);
return $return;
}
@@ -317,21 +328,6 @@ class shadowAccount extends baseModule {
return 0;
}
- /**
- * Checks input values of account profiles.
- *
- * @return profile elements
- */
- function check_profileOptions($options) {
- $errors = array();
- if (!ereg($this->regex_number, $options['shadowAccount_shadowMin'][0])) $errors[] = $this->messages['shadowMin'];
- if (!ereg($this->regex_number, $options['shadowAccount_shadowMax'][0])) $errors[] = $this->messages['shadowMax'];
- if ($options['shadowAccount_shadowMin'][0] > $options['shadowAccount_shadowMax'][0]) $errors[] = $this->messages['shadow_cmp'];
- if (!ereg($this->regex_inactive, $options['shadowAccount_shadowInactive'][0])) $errors[] = $this->messages['inactive'];
- if (!ereg($this->regex_number, $options['shadowAccount_shadowWarning'][0])) $errors[] = $this->messages['shadowWarning'];
- return $errors;
- }
-
function get_pdfFields($account_type="user") {
return array( 'shadowLastChange',
'shadowWarning',