changed preModifyActions() return value

This commit is contained in:
Roland Gruber 2012-01-04 20:51:34 +00:00
parent 236e582005
commit 38bfc1c454
3 changed files with 18 additions and 8 deletions

View File

@ -5,6 +5,7 @@
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15"><title>Upgrade notes</title> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-15"><title>Upgrade notes</title>
@ -21,7 +22,13 @@ This is a list of API changes for all LAM releases.
<br> <br>
<h2>3.6 -&gt; 3.7</h2>The module function <span style="font-weight: bold;">postModifyActions()</span> must return an array containing any messages to display.<br> <h2>3.6 -&gt; 3.7</h2>Module interface:<br>
<ul>
<li><span style="font-weight: bold;">postModifyActions()</span>: Must return an array containing any messages to display</li>
<li><span style="font-weight: bold;">preModifyActions():</span> Changed return value from boolean to array of message arrays<br>
</li>
</ul>
<br> <br>
<h2>3.5.0 -&gt; 3.6</h2> <h2>3.5.0 -&gt; 3.6</h2>
LAM now supports client-side validation (required + numeric fields). See htmlInputField::setValidationRule().<br> LAM now supports client-side validation (required + numeric fields). See htmlInputField::setValidationRule().<br>

View File

@ -1034,14 +1034,14 @@ abstract class baseModule {
* *
* Calling this method requires the existence of an enclosing {@link accountContainer}.<br> * Calling this method requires the existence of an enclosing {@link accountContainer}.<br>
* <br> * <br>
* An error message should be printed if the function returns false. * The modification is aborted if an error message is returned.
* *
* @param boolean $newAccount new account * @param boolean $newAccount new account
* @param array $attributes LDAP attributes of this entry * @param array $attributes LDAP attributes of this entry
* @return boolean true, if no problems occured * @return array array which contains status messages. Each entry is an array containing the status message parameters.
*/ */
public function preModifyActions($newAccount, $attributes) { public function preModifyActions($newAccount, $attributes) {
return true; return array();
} }
/** /**

View File

@ -1636,12 +1636,15 @@ class accountContainer {
logNewMessage(LOG_DEBUG, 'Edit page pre/postModify attributes: ' . print_r($prePostModifyAttributes, true)); logNewMessage(LOG_DEBUG, 'Edit page pre/postModify attributes: ' . print_r($prePostModifyAttributes, true));
$preModifyOk = true; $preModifyOk = true;
foreach ($module as $singlemodule) { foreach ($module as $singlemodule) {
$result = $this->module[$singlemodule]->preModifyActions($this->isNewAccount, $prePostModifyAttributes); $preModifyMessages = $this->module[$singlemodule]->preModifyActions($this->isNewAccount, $prePostModifyAttributes);
if (!$result) { $errors = array_merge($errors, $preModifyMessages);
for ($i = 0; $i < sizeof($preModifyMessages); $i++) {
if ($preModifyMessages[$i][0] == 'ERROR') {
$preModifyOk = false; $preModifyOk = false;
break; break;
} }
} }
}
if (!$preModifyOk) { if (!$preModifyOk) {
$errors[] = array('ERROR', _('The operation was stopped because of the above errors.')); $errors[] = array('ERROR', _('The operation was stopped because of the above errors.'));
return $errors; return $errors;