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> <br>
This function processes user input. It checks user input. It also This function processes user input. It checks user input. It also
saves changes in attributes.<br> saves changes in attributes.<br>
This functions can return two different variables. When 0 is returned It may
everything is ok. If it return an array which contains status messages. Each entry is an array
returns an array the array contains status<br> containing the status message parameters.<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>
<span style="font-weight: bold;">$post</span> is the $_POST <span style="font-weight: bold;">$post</span> is the $_POST
array.<br> array.<br>
<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> <br>
<h3>2.2.14. process_*<br> <h3>2.2.14. process_*<br>
</h3> </h3>

View File

@ -861,8 +861,8 @@ class accountContainer {
} }
} }
} }
// go to subpage of current module
if (!$errorsOccured) { if (!$errorsOccured) {
// go to subpage of current module
$postKeys = array_keys($post); $postKeys = array_keys($post);
for ($p = 0; $p < sizeof($postKeys); $p++) { for ($p = 0; $p < sizeof($postKeys); $p++) {
if (is_string($postKeys[$p]) && (strpos($postKeys[$p], 'form_subpage_' . $this->order[$this->current_page]) === 0)) { if (is_string($postKeys[$p]) && (strpos($postKeys[$p], 'form_subpage_' . $this->order[$this->current_page]) === 0)) {
@ -873,24 +873,26 @@ class accountContainer {
} }
} }
} }
} // change module page if requested
if (is_int($result) || !$errorsOccured) { // numeric return value means to change to another module
if ($post['form_main_main']) { if ($post['form_main_main']) {
$this->current_page = 0; $this->current_page = 0;
$this->subpage='attributes'; $this->subpage='attributes';
} }
else for ($i=1; $i<count($this->order); $i++ ) else {
if (isset($post['form_main_'.$this->order[$i]])) { for ($i=1; $i<count($this->order); $i++ ) {
if ($this->module[$this->order[$i]]->module_ready()) { if (isset($post['form_main_'.$this->order[$i]])) {
$this->current_page = $i; if ($this->module[$this->order[$i]]->module_ready()) {
$this->subpage='attributes'; $this->current_page = $i;
} $this->subpage='attributes';
else { }
StatusMessage('ERROR', _('The module %s is not yet ready.'), else {
_('Please enter the account information on the other pages first.'), StatusMessage('ERROR', _('The module %s is not yet ready.'),
array($this->module[$this->order[$i]]->get_alias())); _('Please enter the account information on the other pages first.'),
array($this->module[$this->order[$i]]->get_alias()));
}
} }
} }
}
} }
// Write HTML-Code // Write HTML-Code
echo $_SESSION['header']; echo $_SESSION['header'];

View File

@ -183,7 +183,12 @@ class account extends baseModule {
return $return; 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) { function process_attributes(&$post) {
// Load attributes // 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], '!upper')) $triggered_messages['uid'][] = $this->messages['uid'][2];
if (!get_preg($this->attributes['uid'][0], 'username')) $triggered_messages['uid'][] = $this->messages['uid'][3]; if (!get_preg($this->attributes['uid'][0], 'username')) $triggered_messages['uid'][] = $this->messages['uid'][3];
} }
return 0;
} }
/* This function will create the html-page /* 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 * @param array $post HTTP-POST values
* @return array list of info/error messages
*/ */
function process_attributes(&$post) { function process_attributes(&$post) {
$this->triggered_messages = array(); $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 * @param array $post HTTP-POST values
* @return array list of info/error messages
*/ */
function process_attributes(&$post) { function process_attributes(&$post) {
$this->triggered_messages = array(); $this->triggered_messages = array();
@ -286,7 +288,6 @@ class inetLocalMailRecipient extends baseModule {
} }
else { else {
$this->inputCorrect = true; $this->inputCorrect = true;
return 0;
} }
} }

View File

@ -413,6 +413,13 @@ class inetOrgPerson extends baseModule {
return $return; 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) { function process_attributes(&$post) {
// Load attributes // Load attributes
$this->attributes['description'][0] = $post['description']; $this->attributes['description'][0] = $post['description'];
@ -498,8 +505,6 @@ class inetOrgPerson extends baseModule {
} }
// Return error-messages // Return error-messages
if (is_array($triggered_messages)) return $triggered_messages; if (is_array($triggered_messages)) return $triggered_messages;
if ($post['changepass']) return 'password';
return 0;
} }
/* This function will create the html-page /* 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 * @param array $post HTTP-POST values
* @return array list of info/error messages
*/ */
function process_attributes(&$post) { function process_attributes(&$post) {
if ($post['form_subpage_kolabUser_deleteUser_open']) return; if ($post['form_subpage_kolabUser_deleteUser_open']) return;
@ -582,7 +584,6 @@ class kolabUser extends baseModule {
} }
else { else {
$this->inputCorrect = true; $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 * @param array $post HTTP-POST values
* @return array list of info/error messages
*/ */
function process_attributes(&$post) { function process_attributes(&$post) {
$this->triggered_messages = array(); $this->triggered_messages = array();
@ -242,7 +244,6 @@ class nisMailAlias extends baseModule {
} }
else { else {
$this->inputCorrect = true; $this->inputCorrect = true;
return 0;
} }
} }

View File

@ -615,7 +615,12 @@ class posixAccount extends baseModule {
return $return; 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) { function process_attributes(&$post) {
$triggered_messages = array(); $triggered_messages = array();
@ -828,31 +833,31 @@ class posixAccount extends baseModule {
return $triggered_messages; return $triggered_messages;
} }
else $this->triggered_messages = array(); 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) { function process_password(&$post) {
if ($post['form_subpage_posixAccount_attributes_back']) return; 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) { function process_attributes(&$post) {
$this->attributes['description'][0] = $post['description']; $this->attributes['description'][0] = $post['description'];
@ -672,15 +677,15 @@ class posixGroup extends baseModule {
return $triggered_messages; return $triggered_messages;
} }
else $this->triggered_messages = array(); 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 * @param array $post HTTP-POST values
* @return string name of next page * @return array list of info/error messages
*/ */
function process_user(&$post) { function process_user(&$post) {
if (isset($post['addusers']) && isset($post['addusers_button'])) { // Add users to list 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 elseif (isset($post['removeusers']) && isset($post['removeusers_button'])) { // remove users from list
$this->attributes['memberUid'] = array_delete($post['removeusers'], $this->attributes['memberUid']); $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) { function process_password(&$post) {
if ($post['form_subpage_posixGroup_attributes_back']) return; if ($post['form_subpage_posixGroup_attributes_back']) return;

View File

@ -272,7 +272,12 @@ class quota extends baseModule {
return $return; 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) { function process_attributes(&$post) {
// Write all general values into $account_new // Write all general values into $account_new
@ -304,8 +309,6 @@ class quota extends baseModule {
return $triggered_messages; return $triggered_messages;
} }
else $this->triggered_messages = array(); 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 /* This function will create the html-page

View File

@ -493,7 +493,12 @@ class sambaAccount extends baseModule {
return $return; 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) { function process_attributes(&$post) {
$this->attributes['domain'][0] = $post['domain']; $this->attributes['domain'][0] = $post['domain'];
@ -626,10 +631,14 @@ class sambaAccount extends baseModule {
return $triggered_messages; return $triggered_messages;
} }
else $this->triggered_messages = array(); 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) { function process_userWorkstations(&$post) {
// Load attributes // Load attributes
@ -672,7 +681,6 @@ class sambaAccount extends baseModule {
} }
} }
} }
return 0;
} }
/* This function will create the html-page /* 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) { function process_attributes(&$post) {
// Save attributes // Save attributes
@ -425,8 +430,7 @@ class sambaGroupMapping extends baseModule {
return $triggered_messages; return $triggered_messages;
} }
else $this->triggered_messages = array(); else $this->triggered_messages = array();
return 0; }
}
/* This function returns an array with 3 entries: /* This function returns an array with 3 entries:

View File

@ -486,7 +486,12 @@ class sambaSamAccount extends baseModule {
return $return; 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) { function process_attributes(&$post) {
// Save attributes // Save attributes
@ -635,62 +640,64 @@ class sambaSamAccount extends baseModule {
return $triggered_messages; return $triggered_messages;
} }
else $this->triggered_messages = array(); 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) { function process_sambaUserWorkstations(&$post) {
// Load attributes // Load attributes
if ($_SESSION[$this->base]->type=='user') { 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
if (isset($post['availableSambaUserWorkstations']) && isset($post['sambaUserWorkstations_add'])) { // Add workstations to list $temp = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]);
$temp = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]); $workstations = explode (',', $temp);
$workstations = explode (',', $temp); for ($i=0; $i<count($workstations); $i++) {
for ($i=0; $i<count($workstations); $i++) if ($workstations[$i]=='') unset($workstations[$i]);
if ($workstations[$i]=='') unset($workstations[$i]); }
$workstations = array_values($workstations); $workstations = array_values($workstations);
// Add new // Add workstations // Add new // Add workstations
$workstations = array_merge($workstations, $post['availableSambaUserWorkstations']); $workstations = array_merge($workstations, $post['availableSambaUserWorkstations']);
// remove doubles // remove doubles
$workstations = array_flip($workstations); $workstations = array_flip($workstations);
array_unique($workstations); array_unique($workstations);
$workstations = array_flip($workstations); $workstations = array_flip($workstations);
// sort workstations // sort workstations
sort($workstations); sort($workstations);
// Recreate workstation string // Recreate workstation string
$this->attributes['sambaUserWorkstations'][0] = $workstations[0]; $this->attributes['sambaUserWorkstations'][0] = $workstations[0];
for ($i=1; $i<count($workstations); $i++) { for ($i=1; $i<count($workstations); $i++) {
$this->attributes['sambaUserWorkstations'][0] = $this->attributes['sambaUserWorkstations'][0] . "," . $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 }
// Put all workstations in array elseif (isset($post['sambaUserWorkstations']) && isset($post['sambaUserWorkstations_remove'])) { // remove // Add workstations from list
$temp = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]); // Put all workstations in array
$workstations = explode (',', $temp); $temp = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]);
for ($i=0; $i<count($workstations); $i++) $workstations = explode (',', $temp);
if ($workstations[$i]=='') unset($workstations[$i]); for ($i=0; $i<count($workstations); $i++) {
$workstations = array_values($workstations); if ($workstations[$i]=='') unset($workstations[$i]);
// Remove unwanted workstations from array }
$workstations = array_delete($post['sambaUserWorkstations'], $workstations); $workstations = array_values($workstations);
// Recreate workstation string // Remove unwanted workstations from array
$this->attributes['sambaUserWorkstations'][0] = $workstations[0]; $workstations = array_delete($post['sambaUserWorkstations'], $workstations);
for ($i=1; $i<count($workstations); $i++) { // Recreate workstation string
$this->attributes['sambaUserWorkstations'][0] = $this->attributes['sambaUserWorkstations'][0] . "," . $workstations[$i]; $this->attributes['sambaUserWorkstations'][0] = $workstations[0];
} for ($i=1; $i<count($workstations); $i++) {
break; $this->attributes['sambaUserWorkstations'][0] = $this->attributes['sambaUserWorkstations'][0] . "," . $workstations[$i];
} }
} 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 * @param array $post HTTP-POST values
* @return string next page name (attributes or logonHours) * @return array list of info/error messages
*/ */
function process_logonHours(&$post) { function process_logonHours(&$post) {
if ($post['form_subpage_sambaSamAccount_attributes_abort']) return; 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) { function process_attributes(&$post) {
// Load attributes // Load attributes
@ -256,7 +258,6 @@ class shadowAccount extends baseModule {
return $triggered_messages; return $triggered_messages;
} }
else $this->triggered_messages = array(); else $this->triggered_messages = array();
return 0;
} }
/** /**