diff --git a/lam/docs/devel/modules-specification.htm b/lam/docs/devel/modules-specification.htm index 2ac70e0c..3f3e2c77 100644 --- a/lam/docs/devel/modules-specification.htm +++ b/lam/docs/devel/modules-specification.htm @@ -747,18 +747,17 @@ is needed t interact with the user.

This function processes user input. It checks user input. It also saves changes in attributes.
-This functions can return two different variables. When 0 is returned -everything is ok. If it -returns an array the array contains status
-messages. First index is the attribute which has triggered a message. -Second index is an array containing status message arrays.
-This function must reset $this->triggered_messages when it wants to -display -status messages. This can be done with $this->triggered_messages = -array();
+It may +return an array which contains status messages. Each entry is an array +containing the status message parameters.
$post is the $_POST array.

+Example:
+
+return array(0 => array('ERROR', 'Invalid input!', 'This is not +allowed here.'));
+

2.2.14. process_*

diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index e682dca4..7921c948 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -861,8 +861,8 @@ class accountContainer { } } } - // go to subpage of current module if (!$errorsOccured) { + // go to subpage of current module $postKeys = array_keys($post); for ($p = 0; $p < sizeof($postKeys); $p++) { if (is_string($postKeys[$p]) && (strpos($postKeys[$p], 'form_subpage_' . $this->order[$this->current_page]) === 0)) { @@ -873,24 +873,26 @@ class accountContainer { } } } - } - if (is_int($result) || !$errorsOccured) { // numeric return value means to change to another module + // change module page if requested if ($post['form_main_main']) { $this->current_page = 0; $this->subpage='attributes'; } - else for ($i=1; $iorder); $i++ ) - if (isset($post['form_main_'.$this->order[$i]])) { - if ($this->module[$this->order[$i]]->module_ready()) { - $this->current_page = $i; - $this->subpage='attributes'; - } - else { - StatusMessage('ERROR', _('The module %s is not yet ready.'), - _('Please enter the account information on the other pages first.'), - array($this->module[$this->order[$i]]->get_alias())); + else { + for ($i=1; $iorder); $i++ ) { + if (isset($post['form_main_'.$this->order[$i]])) { + if ($this->module[$this->order[$i]]->module_ready()) { + $this->current_page = $i; + $this->subpage='attributes'; + } + else { + StatusMessage('ERROR', _('The module %s is not yet ready.'), + _('Please enter the account information on the other pages first.'), + array($this->module[$this->order[$i]]->get_alias())); + } } } + } } // Write HTML-Code echo $_SESSION['header']; diff --git a/lam/lib/modules/account.inc b/lam/lib/modules/account.inc index 4cff8571..d5c2819b 100644 --- a/lam/lib/modules/account.inc +++ b/lam/lib/modules/account.inc @@ -183,7 +183,12 @@ class account extends baseModule { return $return; } - /* Write variables into object and do some regexp checks + /** + * Processes user input of the primary module page. + * It checks if all input values are correct and updates the associated LDAP attributes. + * + * @param array $post HTTP-POST values + * @return array list of info/error messages */ function process_attributes(&$post) { // Load attributes @@ -195,7 +200,6 @@ class account extends baseModule { if (!get_preg($this->attributes['uid'][0], '!upper')) $triggered_messages['uid'][] = $this->messages['uid'][2]; if (!get_preg($this->attributes['uid'][0], 'username')) $triggered_messages['uid'][] = $this->messages['uid'][3]; } - return 0; } /* This function will create the html-page diff --git a/lam/lib/modules/ieee802device.inc b/lam/lib/modules/ieee802device.inc index 84225b4f..e5c93532 100644 --- a/lam/lib/modules/ieee802device.inc +++ b/lam/lib/modules/ieee802device.inc @@ -157,9 +157,11 @@ class ieee802Device extends baseModule { } /** - * Write variables into object and do some regex checks + * Processes user input of the primary module page. + * It checks if all input values are correct and updates the associated LDAP attributes. * * @param array $post HTTP-POST values + * @return array list of info/error messages */ function process_attributes(&$post) { $this->triggered_messages = array(); diff --git a/lam/lib/modules/inetLocalMailRecipient.inc b/lam/lib/modules/inetLocalMailRecipient.inc index 62e129cb..ad1d42ef 100644 --- a/lam/lib/modules/inetLocalMailRecipient.inc +++ b/lam/lib/modules/inetLocalMailRecipient.inc @@ -219,9 +219,11 @@ class inetLocalMailRecipient extends baseModule { } /** - * Write variables into object and do some regex checks + * Processes user input of the primary module page. + * It checks if all input values are correct and updates the associated LDAP attributes. * * @param array $post HTTP-POST values + * @return array list of info/error messages */ function process_attributes(&$post) { $this->triggered_messages = array(); @@ -286,7 +288,6 @@ class inetLocalMailRecipient extends baseModule { } else { $this->inputCorrect = true; - return 0; } } diff --git a/lam/lib/modules/inetOrgPerson.inc b/lam/lib/modules/inetOrgPerson.inc index 4931a263..2edfe40f 100644 --- a/lam/lib/modules/inetOrgPerson.inc +++ b/lam/lib/modules/inetOrgPerson.inc @@ -413,6 +413,13 @@ class inetOrgPerson extends baseModule { return $return; } + /** + * Processes user input of the primary module page. + * It checks if all input values are correct and updates the associated LDAP attributes. + * + * @param array $post HTTP-POST values + * @return array list of info/error messages + */ function process_attributes(&$post) { // Load attributes $this->attributes['description'][0] = $post['description']; @@ -498,8 +505,6 @@ class inetOrgPerson extends baseModule { } // Return error-messages if (is_array($triggered_messages)) return $triggered_messages; - if ($post['changepass']) return 'password'; - return 0; } /* This function will create the html-page diff --git a/lam/lib/modules/kolabUser.inc b/lam/lib/modules/kolabUser.inc index 160a78f6..7f401ade 100644 --- a/lam/lib/modules/kolabUser.inc +++ b/lam/lib/modules/kolabUser.inc @@ -433,9 +433,11 @@ class kolabUser extends baseModule { } /** - * Write variables into object and do some regex checks + * Processes user input of the primary module page. + * It checks if all input values are correct and updates the associated LDAP attributes. * * @param array $post HTTP-POST values + * @return array list of info/error messages */ function process_attributes(&$post) { if ($post['form_subpage_kolabUser_deleteUser_open']) return; @@ -582,7 +584,6 @@ class kolabUser extends baseModule { } else { $this->inputCorrect = true; - return 0; } } diff --git a/lam/lib/modules/nisMailAlias.inc b/lam/lib/modules/nisMailAlias.inc index cebf7677..1282bd2f 100644 --- a/lam/lib/modules/nisMailAlias.inc +++ b/lam/lib/modules/nisMailAlias.inc @@ -191,9 +191,11 @@ class nisMailAlias extends baseModule { } /** - * Write variables into object and do some regex checks + * Processes user input of the primary module page. + * It checks if all input values are correct and updates the associated LDAP attributes. * * @param array $post HTTP-POST values + * @return array list of info/error messages */ function process_attributes(&$post) { $this->triggered_messages = array(); @@ -242,7 +244,6 @@ class nisMailAlias extends baseModule { } else { $this->inputCorrect = true; - return 0; } } diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index 02b3dd3a..6ffac0b6 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -615,7 +615,12 @@ class posixAccount extends baseModule { return $return; } - /* Write variables into object and do some regexp checks + /** + * Processes user input of the primary module page. + * It checks if all input values are correct and updates the associated LDAP attributes. + * + * @param array $post HTTP-POST values + * @return array list of info/error messages */ function process_attributes(&$post) { $triggered_messages = array(); @@ -828,31 +833,31 @@ class posixAccount extends baseModule { return $triggered_messages; } else $this->triggered_messages = array(); - return 0; - } - - /* Write variables into object and do some regexp checks - */ - function process_group(&$post) { - do { // X-Or, only one if() can be true - if (isset($post['addgroups']) && isset($post['addgroups_button'])) { // Add groups to list - // Add new group - $this->groups = @array_merge($this->groups, $post['addgroups']); - break; - } - if (isset($post['removegroups']) && isset($post['removegroups_button'])) { // remove groups from list - $this->groups = array_delete($post['removegroups'], $this->groups); - break; - } - } while(0); - if (isset($post['addgroups_button']) || isset($post['removegroups_button'])) return 'group'; - return 0; } /** - * Sets a new password. + * Processes user input of the group selection page. + * It checks if all input values are correct and updates the associated LDAP attributes. * - * @param $post HTTP POST + * @param array $post HTTP-POST values + * @return array list of info/error messages + */ + function process_group(&$post) { + if (isset($post['addgroups']) && isset($post['addgroups_button'])) { // Add groups to list + // Add new group + $this->groups = @array_merge($this->groups, $post['addgroups']); + } + elseif (isset($post['removegroups']) && isset($post['removegroups_button'])) { // remove groups from list + $this->groups = array_delete($post['removegroups'], $this->groups); + } + } + + /** + * Processes user input of the password page. + * It checks if all input values are correct and updates the associated LDAP attributes. + * + * @param array $post HTTP-POST values + * @return array list of info/error messages */ function process_password(&$post) { if ($post['form_subpage_posixAccount_attributes_back']) return; diff --git a/lam/lib/modules/posixGroup.inc b/lam/lib/modules/posixGroup.inc index 551d8fdc..f6858afd 100644 --- a/lam/lib/modules/posixGroup.inc +++ b/lam/lib/modules/posixGroup.inc @@ -529,7 +529,12 @@ class posixGroup extends baseModule { } - /* Write variables into object and do some regexp checks + /** + * Processes user input of the primary module page. + * It checks if all input values are correct and updates the associated LDAP attributes. + * + * @param array $post HTTP-POST values + * @return array list of info/error messages */ function process_attributes(&$post) { $this->attributes['description'][0] = $post['description']; @@ -672,15 +677,15 @@ class posixGroup extends baseModule { return $triggered_messages; } else $this->triggered_messages = array(); - return 0; } /** - * Processes input data and adds or removes users from current group. + * Processes user input of the user selection page. + * It checks if all input values are correct and updates the associated LDAP attributes. * - * @param array $post HTTP-POST - * @return string name of next page + * @param array $post HTTP-POST values + * @return array list of info/error messages */ function process_user(&$post) { if (isset($post['addusers']) && isset($post['addusers_button'])) { // Add users to list @@ -696,14 +701,15 @@ class posixGroup extends baseModule { elseif (isset($post['removeusers']) && isset($post['removeusers_button'])) { // remove users from list $this->attributes['memberUid'] = array_delete($post['removeusers'], $this->attributes['memberUid']); } - return 0; } /** - * Sets a new password. + * Processes user input of the password page. + * It checks if all input values are correct and updates the associated LDAP attributes. * - * @param $post HTTP POST + * @param array $post HTTP-POST values + * @return array list of info/error messages */ function process_password(&$post) { if ($post['form_subpage_posixGroup_attributes_back']) return; diff --git a/lam/lib/modules/quota.inc b/lam/lib/modules/quota.inc index c0a12cfe..89ebcb2c 100644 --- a/lam/lib/modules/quota.inc +++ b/lam/lib/modules/quota.inc @@ -272,7 +272,12 @@ class quota extends baseModule { return $return; } - /* Write variables into object and do some regexp checks + /** + * Processes user input of the primary module page. + * It checks if all input values are correct and updates the associated LDAP attributes. + * + * @param array $post HTTP-POST values + * @return array list of info/error messages */ function process_attributes(&$post) { // Write all general values into $account_new @@ -304,8 +309,6 @@ class quota extends baseModule { return $triggered_messages; } else $this->triggered_messages = array(); - // Go to additional group page when no error did ocour and button was pressed - return 0; } /* This function will create the html-page diff --git a/lam/lib/modules/sambaAccount.inc b/lam/lib/modules/sambaAccount.inc index b78d38b7..869c85b5 100644 --- a/lam/lib/modules/sambaAccount.inc +++ b/lam/lib/modules/sambaAccount.inc @@ -493,7 +493,12 @@ class sambaAccount extends baseModule { return $return; } - /* Write variables into object and do some regexp checks + /** + * Processes user input of the primary module page. + * It checks if all input values are correct and updates the associated LDAP attributes. + * + * @param array $post HTTP-POST values + * @return array list of info/error messages */ function process_attributes(&$post) { $this->attributes['domain'][0] = $post['domain']; @@ -626,10 +631,14 @@ class sambaAccount extends baseModule { return $triggered_messages; } else $this->triggered_messages = array(); - return 0; - } + } - /* Write variables into object and do some regexp checks + /** + * Processes user input of the workstation selection page. + * It checks if all input values are correct and updates the associated LDAP attributes. + * + * @param array $post HTTP-POST values + * @return array list of info/error messages */ function process_userWorkstations(&$post) { // Load attributes @@ -672,7 +681,6 @@ class sambaAccount extends baseModule { } } } - return 0; } /* This function will create the html-page diff --git a/lam/lib/modules/sambaGroupMapping.inc b/lam/lib/modules/sambaGroupMapping.inc index 428619a7..04f5fa3a 100644 --- a/lam/lib/modules/sambaGroupMapping.inc +++ b/lam/lib/modules/sambaGroupMapping.inc @@ -386,7 +386,12 @@ class sambaGroupMapping extends baseModule { } - /* Write variables into object and do some regexp checks + /** + * Processes user input of the primary module page. + * It checks if all input values are correct and updates the associated LDAP attributes. + * + * @param array $post HTTP-POST values + * @return array list of info/error messages */ function process_attributes(&$post) { // Save attributes @@ -425,8 +430,7 @@ class sambaGroupMapping extends baseModule { return $triggered_messages; } else $this->triggered_messages = array(); - return 0; - } + } /* This function returns an array with 3 entries: diff --git a/lam/lib/modules/sambaSamAccount.inc b/lam/lib/modules/sambaSamAccount.inc index 938702bd..536dc307 100644 --- a/lam/lib/modules/sambaSamAccount.inc +++ b/lam/lib/modules/sambaSamAccount.inc @@ -486,7 +486,12 @@ class sambaSamAccount extends baseModule { return $return; } - /* Write variables into object and do some regexp checks + /** + * Processes user input of the primary module page. + * It checks if all input values are correct and updates the associated LDAP attributes. + * + * @param array $post HTTP-POST values + * @return array list of info/error messages */ function process_attributes(&$post) { // Save attributes @@ -635,62 +640,64 @@ class sambaSamAccount extends baseModule { return $triggered_messages; } else $this->triggered_messages = array(); - return 0; } - /* Write variables into object and do some regexp checks + /** + * Processes user input of the primary module page. + * It checks if all input values are correct and updates the associated LDAP attributes. + * + * @param array $post HTTP-POST values + * @return array list of info/error messages */ function process_sambaUserWorkstations(&$post) { // Load attributes if ($_SESSION[$this->base]->type=='user') { - do { // X-Or, only one if() can be true - if (isset($post['availableSambaUserWorkstations']) && isset($post['sambaUserWorkstations_add'])) { // Add workstations to list - $temp = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]); - $workstations = explode (',', $temp); - for ($i=0; $iattributes['sambaUserWorkstations'][0] = $workstations[0]; - for ($i=1; $iattributes['sambaUserWorkstations'][0] = $this->attributes['sambaUserWorkstations'][0] . "," . $workstations[$i]; - } - break; + if (isset($post['availableSambaUserWorkstations']) && isset($post['sambaUserWorkstations_add'])) { // Add workstations to list + $temp = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]); + $workstations = explode (',', $temp); + for ($i=0; $iattributes['sambaUserWorkstations'][0] = $workstations[0]; + for ($i=1; $iattributes['sambaUserWorkstations'][0] = $this->attributes['sambaUserWorkstations'][0] . "," . $workstations[$i]; } - if (isset($post['sambaUserWorkstations']) && isset($post['sambaUserWorkstations_remove'])) { // remove // Add workstations from list - // Put all workstations in array - $temp = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]); - $workstations = explode (',', $temp); - for ($i=0; $iattributes['sambaUserWorkstations'][0] = $workstations[0]; - for ($i=1; $iattributes['sambaUserWorkstations'][0] = $this->attributes['sambaUserWorkstations'][0] . "," . $workstations[$i]; - } - break; - } - } while(0); + } + elseif (isset($post['sambaUserWorkstations']) && isset($post['sambaUserWorkstations_remove'])) { // remove // Add workstations from list + // Put all workstations in array + $temp = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]); + $workstations = explode (',', $temp); + for ($i=0; $iattributes['sambaUserWorkstations'][0] = $workstations[0]; + for ($i=1; $iattributes['sambaUserWorkstations'][0] = $this->attributes['sambaUserWorkstations'][0] . "," . $workstations[$i]; + } } - return 0; + } } /** - * Save logon hours + * Processes user input of the logon hours page. + * It checks if all input values are correct and updates the associated LDAP attributes. * - * @param array $post HTTP POST variables - * @return string next page name (attributes or logonHours) + * @param array $post HTTP-POST values + * @return array list of info/error messages */ function process_logonHours(&$post) { if ($post['form_subpage_sambaSamAccount_attributes_abort']) return; diff --git a/lam/lib/modules/shadowAccount.inc b/lam/lib/modules/shadowAccount.inc index ce4a9ac9..37d34b6e 100644 --- a/lam/lib/modules/shadowAccount.inc +++ b/lam/lib/modules/shadowAccount.inc @@ -235,9 +235,11 @@ class shadowAccount extends baseModule { } /** - * Checks user input and saves it in LDAP attributes. + * Processes user input of the primary module page. + * It checks if all input values are correct and updates the associated LDAP attributes. * - * @param array $post HTTP POST data + * @param array $post HTTP-POST values + * @return array list of info/error messages */ function process_attributes(&$post) { // Load attributes @@ -256,7 +258,6 @@ class shadowAccount extends baseModule { return $triggered_messages; } else $this->triggered_messages = array(); - return 0; } /**