allow messages in postModifyActions()
This commit is contained in:
parent
e8baa8d4fd
commit
236e582005
|
@ -4,6 +4,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15"><title>Upgrade notes</title>
|
||||
|
||||
|
||||
|
@ -20,7 +21,10 @@ This is a list of API changes for all LAM releases.
|
|||
|
||||
<br>
|
||||
|
||||
<h2>3.5.0 -> 3.6</h2>LAM now supports client-side validation (required + numeric fields). See htmlInputField::setValidationRule().<br>
|
||||
<h2>3.6 -> 3.7</h2>The module function <span style="font-weight: bold;">postModifyActions()</span> must return an array containing any messages to display.<br>
|
||||
<br>
|
||||
<h2>3.5.0 -> 3.6</h2>
|
||||
LAM now supports client-side validation (required + numeric fields). See htmlInputField::setValidationRule().<br>
|
||||
<br>
|
||||
<h2>3.4.0 -> 3.5.0</h2>
|
||||
The old meta HTML code is no longer supported. Please use the new solution based on htmlElement (see lib/html.inc).<br>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 "<div class=\"".$this->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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue