no longer allow integer results from process_..., updated documentation

This commit is contained in:
Roland Gruber 2005-09-07 12:58:34 +00:00
parent 4d769306f3
commit 4689680855
15 changed files with 171 additions and 122 deletions

View File

@ -747,18 +747,17 @@ is needed t interact with the user.<br>
<br>
This function processes user input. It checks user input. It also
saves changes in attributes.<br>
This functions can return two different variables. When 0 is returned
everything is ok. If it
returns an array the array contains status<br>
messages. First index is the attribute which has triggered a message.
Second index is an array containing status message arrays.<br>
This function must reset $this-&gt;triggered_messages when it wants to
display
status messages. This can be done with $this-&gt;triggered_messages =
array();<br>
It may
return an array which contains status messages. Each entry is an array
containing the status message parameters.<br>
<span style="font-weight: bold;">$post</span> is the $_POST
array.<br>
<br>
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br>
<br>
return array(0 =&gt; array('ERROR', 'Invalid input!', 'This is not
allowed here.'));<br>
<br>
<br>
<h3>2.2.14. process_*<br>
</h3>

View File

@ -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,13 +873,13 @@ 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; $i<count($this->order); $i++ )
else {
for ($i=1; $i<count($this->order); $i++ ) {
if (isset($post['form_main_'.$this->order[$i]])) {
if ($this->module[$this->order[$i]]->module_ready()) {
$this->current_page = $i;
@ -892,6 +892,8 @@ class accountContainer {
}
}
}
}
}
// Write HTML-Code
echo $_SESSION['header'];
echo "<title>";

View File

@ -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

View File

@ -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();

View File

@ -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;
}
}

View File

@ -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

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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,7 +430,6 @@ class sambaGroupMapping extends baseModule {
return $triggered_messages;
}
else $this->triggered_messages = array();
return 0;
}

View File

@ -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,20 +640,24 @@ 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; $i<count($workstations); $i++)
for ($i=0; $i<count($workstations); $i++) {
if ($workstations[$i]=='') unset($workstations[$i]);
}
$workstations = array_values($workstations);
// Add new // Add workstations
$workstations = array_merge($workstations, $post['availableSambaUserWorkstations']);
@ -663,14 +672,14 @@ class sambaSamAccount extends baseModule {
for ($i=1; $i<count($workstations); $i++) {
$this->attributes['sambaUserWorkstations'][0] = $this->attributes['sambaUserWorkstations'][0] . "," . $workstations[$i];
}
break;
}
if (isset($post['sambaUserWorkstations']) && isset($post['sambaUserWorkstations_remove'])) { // remove // Add workstations from list
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; $i<count($workstations); $i++)
for ($i=0; $i<count($workstations); $i++) {
if ($workstations[$i]=='') unset($workstations[$i]);
}
$workstations = array_values($workstations);
// Remove unwanted workstations from array
$workstations = array_delete($post['sambaUserWorkstations'], $workstations);
@ -679,18 +688,16 @@ class sambaSamAccount extends baseModule {
for ($i=1; $i<count($workstations); $i++) {
$this->attributes['sambaUserWorkstations'][0] = $this->attributes['sambaUserWorkstations'][0] . "," . $workstations[$i];
}
break;
}
} while(0);
}
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;

View File

@ -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;
}
/**