From 38bfc1c454d16afdada62f49dee64d2ad7979126 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Wed, 4 Jan 2012 20:51:34 +0000 Subject: [PATCH] changed preModifyActions() return value --- lam/docs/devel/upgrade.htm | 9 ++++++++- lam/lib/baseModule.inc | 6 +++--- lam/lib/modules.inc | 11 +++++++---- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lam/docs/devel/upgrade.htm b/lam/docs/devel/upgrade.htm index 98dc8c30..92f7cf5d 100644 --- a/lam/docs/devel/upgrade.htm +++ b/lam/docs/devel/upgrade.htm @@ -4,6 +4,7 @@ + Upgrade notes @@ -21,7 +22,13 @@ This is a list of API changes for all LAM releases.
-

3.6 -> 3.7

The module function postModifyActions() must return an array containing any messages to display.
+

3.6 -> 3.7

Module interface:
+ +

3.5.0 -> 3.6

LAM now supports client-side validation (required + numeric fields). See htmlInputField::setValidationRule().
diff --git a/lam/lib/baseModule.inc b/lam/lib/baseModule.inc index 23afdff6..5b2738c5 100644 --- a/lam/lib/baseModule.inc +++ b/lam/lib/baseModule.inc @@ -1034,14 +1034,14 @@ abstract class baseModule { * * Calling this method requires the existence of an enclosing {@link accountContainer}.
*
- * 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 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) { - return true; + return array(); } /** diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 2392880b..1019261b 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -1636,10 +1636,13 @@ class accountContainer { logNewMessage(LOG_DEBUG, 'Edit page pre/postModify attributes: ' . print_r($prePostModifyAttributes, true)); $preModifyOk = true; foreach ($module as $singlemodule) { - $result = $this->module[$singlemodule]->preModifyActions($this->isNewAccount, $prePostModifyAttributes); - if (!$result) { - $preModifyOk = false; - break; + $preModifyMessages = $this->module[$singlemodule]->preModifyActions($this->isNewAccount, $prePostModifyAttributes); + $errors = array_merge($errors, $preModifyMessages); + for ($i = 0; $i < sizeof($preModifyMessages); $i++) { + if ($preModifyMessages[$i][0] == 'ERROR') { + $preModifyOk = false; + break; + } } } if (!$preModifyOk) {