diff --git a/lam/docs/devel/upgrade.htm b/lam/docs/devel/upgrade.htm index d13f9217..98dc8c30 100644 --- a/lam/docs/devel/upgrade.htm +++ b/lam/docs/devel/upgrade.htm @@ -3,6 +3,7 @@ + Upgrade notes @@ -20,7 +21,10 @@ This is a list of API changes for all LAM releases.
-

3.5.0 -> 3.6

LAM now supports client-side validation (required + numeric fields). See htmlInputField::setValidationRule().
+

3.6 -> 3.7

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

3.5.0 -> 3.6

+LAM now supports client-side validation (required + numeric fields). See htmlInputField::setValidationRule().

3.4.0 -> 3.5.0

The old meta HTML code is no longer supported. Please use the new solution based on htmlElement (see lib/html.inc).
diff --git a/lam/lib/baseModule.inc b/lam/lib/baseModule.inc index def03148..23afdff6 100644 --- a/lam/lib/baseModule.inc +++ b/lam/lib/baseModule.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2003 - 2011 Roland Gruber + Copyright (C) 2003 - 2012 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1051,9 +1051,10 @@ abstract class baseModule { * * @param boolean $newAccount new account * @param array $attributes LDAP attributes of this entry + * @return array array which contains status messages. Each entry is an array containing the status message parameters. */ public function postModifyActions($newAccount, $attributes) { - return; + return array(); } /** diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 30813843..2392880b 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -820,13 +820,19 @@ class accountContainer { } else { // save account - $errors = $this->save_account(); - if (sizeof($errors) > 0) { - $result = $errors; + $saveMessages = $this->save_account(); + $saveOk = true; + for ($i = 0; $i < sizeof($saveMessages); $i++) { + if ($saveMessages[$i][0] == 'ERROR') { + $saveOk = false; + } + } + if (!$saveOk) { + $result = $saveMessages; $stopProcessing = true; } else { - $this->printSuccessPage(); + $this->printSuccessPage($saveMessages); return; } } @@ -1178,8 +1184,9 @@ class accountContainer { /** * Prints the HTML code to notify the user about the successful saving. * + * @param array $messages array which contains status messages. Each entry is an array containing the status message parameters. */ - private function printSuccessPage() { + private function printSuccessPage($messages) { $this->printPageHeader(); // Show success message if ($this->dn_orig == '') { @@ -1191,6 +1198,19 @@ class accountContainer { echo "
type."list-bright smallPaddingContent\">"; $container = new htmlTable(); + // show messages + for ($i = 0; $i < sizeof($messages); $i++) { + if (sizeof($messages[$i]) == 2) { + $message = new htmlStatusMessage($messages[$i][0], $messages[$i][1]); + $message->colspan = 10; + $container->addElement($message, true); + } + else { + $message = new htmlStatusMessage($messages[$i][0], $messages[$i][1], $messages[$i][2]); + $message->colspan = 10; + $container->addElement($message, true); + } + } $message = new htmlStatusMessage('INFO', _('LDAP operation successful.'), $text); $message->colspan = 10; $container->addElement($message, true); @@ -1533,7 +1553,7 @@ class accountContainer { /** * This function will save an account to the LDAP database. * - * @return array list of status messages if any errors occured + * @return array list of status messages */ function save_account() { if (!checkIfWriteAccessIsAllowed()) { @@ -1712,7 +1732,8 @@ class accountContainer { if (!$stopprocessing) { // post modify actions foreach ($module as $singlemodule) { - $this->module[$singlemodule]->postModifyActions($this->isNewAccount, $prePostModifyAttributes); + $postMessages = $this->module[$singlemodule]->postModifyActions($this->isNewAccount, $prePostModifyAttributes); + $errors = array_merge($errors, $postMessages); } } return $errors; diff --git a/lam/lib/modules/fixed_ip.inc b/lam/lib/modules/fixed_ip.inc index 414c093c..5ba23581 100644 --- a/lam/lib/modules/fixed_ip.inc +++ b/lam/lib/modules/fixed_ip.inc @@ -4,7 +4,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2008 Thomas Manninger - 2008 - 2011 Roland Gruber + 2008 - 2012 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -444,6 +444,7 @@ class fixed_ip extends baseModule { * * @param boolean $newAccount * @param array $attributes LDAP attributes of this entry + * @return array array which contains status messages. Each entry is an array containing the status message parameters. */ public function postModifyActions($newAccount, $attributes) { if ($this->getAccountContainer()->dn_orig!=$_SESSION['config']->get_suffix('dhcp')) { @@ -507,6 +508,7 @@ class fixed_ip extends baseModule { ldap_add($_SESSION['ldap']->server(),'cn='.$add[$id]['cn'].',cn='.$this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0].','.$_SESSION['config']->get_suffix('dhcp'),$attr); } } + return array(); } /** diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index 055b4b1e..3885dd02 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -4,7 +4,7 @@ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2003 - 2006 Tilo Lutz - Copyright (C) 2005 - 2011 Roland Gruber + Copyright (C) 2005 - 2012 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -573,8 +573,10 @@ class posixAccount extends baseModule implements passwordService { * * @param boolean $newAccount * @param array $attributes LDAP attributes of this entry + * @return array array which contains status messages. Each entry is an array containing the status message parameters. */ public function postModifyActions($newAccount, $attributes) { + $messages = array(); // create home directories if needed if (sizeof($this->lamdaemonServers) > 0) { $server = null; @@ -607,10 +609,10 @@ class posixAccount extends baseModule implements passwordService { if (is_array($result)) { $singleresult = explode(",", $result[0]); if (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'INFO') || ($singleresult[0] == 'WARN')) { - call_user_func_array('StatusMessage', $singleresult); + $messages[] = $singleresult; } else { - StatusMessage('ERROR', $result[0]); + $messages[] = array('ERROR', $result[0]); } } } @@ -631,7 +633,7 @@ class posixAccount extends baseModule implements passwordService { $success = @ldap_mod_add($_SESSION['ldap']->server(), $toAdd[$i], array($attrName => array($this->getAccountContainer()->finalDN))); if (!$success) { logNewMessage(LOG_ERR, '[' . $ldapUser .'] Unable to add attributes to DN: ' . $toAdd[$i] . ' (' . ldap_err2str(ldap_errno($_SESSION['ldap']->server())) . ').'); - StatusMessage('ERROR', sprintf(_('Was unable to add attributes to DN: %s.'), $toAdd[$i]), ldap_error($_SESSION['ldap']->server())); + $messages[] = array('ERROR', sprintf(_('Was unable to add attributes to DN: %s.'), $toAdd[$i]), ldap_error($_SESSION['ldap']->server())); } } } @@ -644,11 +646,12 @@ class posixAccount extends baseModule implements passwordService { $success = @ldap_mod_del($_SESSION['ldap']->server(), $toRem[$i], array($attrName => array($this->getAccountContainer()->dn_orig))); if (!$success) { logNewMessage(LOG_ERR, '[' . $ldapUser .'] Unable to delete attributes from DN: ' . $toRem[$i] . ' (' . ldap_err2str(ldap_errno($_SESSION['ldap']->server())) . ').'); - StatusMessage('ERROR', sprintf(_('Was unable to remove attributes from DN: %s.'), $toRem[$i]), ldap_error($_SESSION['ldap']->server())); + $messages[] = array('ERROR', sprintf(_('Was unable to remove attributes from DN: %s.'), $toRem[$i]), ldap_error($_SESSION['ldap']->server())); } } } } + return $messages; } /** diff --git a/lam/lib/modules/quota.inc b/lam/lib/modules/quota.inc index db0bb170..b272beb4 100644 --- a/lam/lib/modules/quota.inc +++ b/lam/lib/modules/quota.inc @@ -4,7 +4,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2003 - 2006 Tilo Lutz - 2007 - 2010 Roland Gruber + 2007 - 2012 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -236,9 +236,11 @@ class quota extends baseModule { * * @param boolean $newAccount * @param array $attributes LDAP attributes of this entry + * @return array array which contains status messages. Each entry is an array containing the status message parameters. */ public function postModifyActions($newAccount, $attributes) { - if (!isset($this->quota) || !is_array($this->quota)) return; + $messages = array(); + if (!isset($this->quota) || !is_array($this->quota)) return $messages; // determine if this is a user or group account if ($this->get_scope()=='user') { $attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes(); @@ -267,6 +269,7 @@ class quota extends baseModule { } lamdaemon(implode(quota::$SPLIT_DELIMITER, array($id, "quota", "set", $this->get_scope(), "$quotastring\n")), $server); } + return $messages; } /**