fixed lamdaemon error handling

This commit is contained in:
Roland Gruber 2006-08-27 14:57:22 +00:00
parent 641af2270d
commit ec79d170b0
1 changed files with 28 additions and 21 deletions

View File

@ -813,6 +813,7 @@ class accountContainer {
* It prints the HTML code of each account page. * It prints the HTML code of each account page.
*/ */
function continue_main() { function continue_main() {
$result = array();
if ($this->subpage=='') $this->subpage='attributes'; if ($this->subpage=='') $this->subpage='attributes';
if (isset($_POST['form_main_reset'])) { if (isset($_POST['form_main_reset'])) {
$this->load_account($this->dn_orig); $this->load_account($this->dn_orig);
@ -820,7 +821,6 @@ class accountContainer {
else { else {
if ($this->current_page==0) { if ($this->current_page==0) {
if ($this->subpage=='attributes') { if ($this->subpage=='attributes') {
$result = 0;
// change dn // change dn
if (isset($_POST['suffix']) && ($_POST['suffix'] != '')) $this->dn = $_POST['suffix']; if (isset($_POST['suffix']) && ($_POST['suffix'] != '')) $this->dn = $_POST['suffix'];
// change RDN // change RDN
@ -840,13 +840,12 @@ class accountContainer {
if (isset($profile['ldap_suffix'][0])) { if (isset($profile['ldap_suffix'][0])) {
$this->dn = $profile['ldap_suffix'][0]; $this->dn = $profile['ldap_suffix'][0];
} }
$result = 0;
} }
// save account // save account
if (isset($_POST['create'])) { if (isset($_POST['create'])) {
$errors = $this->save_account(); $errors = $this->save_account();
if (is_array($errors)) { if (sizeof($errors) > 0) {
$result = array($errors); $result = $errors;
$stopProcessing = true; $stopProcessing = true;
} }
else $this->subpage = 'finish'; else $this->subpage = 'finish';
@ -1322,6 +1321,7 @@ class accountContainer {
* @return array list of status messages if any errors occured * @return array list of status messages if any errors occured
*/ */
function save_account() { function save_account() {
$errors = array();
$ldapUser = $_SESSION['ldap']->decrypt_login(); $ldapUser = $_SESSION['ldap']->decrypt_login();
$ldapUser = $ldapUser[0]; $ldapUser = $ldapUser[0];
$module = array_keys ($this->module); $module = array_keys ($this->module);
@ -1439,16 +1439,21 @@ class accountContainer {
// lamdaemon commands for the new account // lamdaemon commands for the new account
if (!$stopprocessing) { if (!$stopprocessing) {
$DN = $attributes[$this->dn]; $DN = $attributes[$this->dn];
if (is_array($DN['lamdaemon']['command'])) $result = lamdaemon($DN['lamdaemon']['command']); if (is_array($DN['lamdaemon']['command'])) {
// Error somewhere in lamdaemon $result = lamdaemon($DN['lamdaemon']['command']);
if (is_array($result)) { // Error somewhere in lamdaemon
foreach ($result as $singleresult) { if (is_array($result)) {
if (is_array($singleresult)) { foreach ($result as $singleresult) {
if ($singleresult[0] == 'ERROR') $stopprocessing = true; $singleresult = explode(",", $singleresult);
$temparray[0] = $singleresult[0]; if (is_array($singleresult)) {
$temparray[1] = _($singleresult[1]); if ($singleresult[0] == 'ERROR') {
$temparray[2] = _($singleresult[2]); $stopprocessing = true;
$errors[] = $temparray; $temparray[0] = $singleresult[0];
$temparray[1] = _($singleresult[1]);
$temparray[2] = _($singleresult[2]);
$errors[] = $temparray;
}
}
} }
} }
} }
@ -1505,12 +1510,15 @@ class accountContainer {
// Error somewhere in lamdaemon // Error somewhere in lamdaemon
if (isset($result) && is_array($result)) { if (isset($result) && is_array($result)) {
foreach ($result as $singleresult) { foreach ($result as $singleresult) {
$singleresult = explode(",", $singleresult);
if (is_array($singleresult)) { if (is_array($singleresult)) {
if ($singleresult[0] == 'ERROR') $stopprocessing = true; if ($singleresult[0] == 'ERROR') {
$temparray[0] = $singleresult[0]; $stopprocessing = true;
$temparray[1] = _($singleresult[1]); $temparray[0] = $singleresult[0];
$temparray[2] = _($singleresult[2]); $temparray[1] = _($singleresult[1]);
$errors[] = $temparray; $temparray[2] = _($singleresult[2]);
$errors[] = $temparray;
}
} }
} }
} }
@ -1518,8 +1526,7 @@ class accountContainer {
} }
} }
$_SESSION['cache']->refresh_cache(true); $_SESSION['cache']->refresh_cache(true);
if (count($errors)!=0) return $errors; return $errors;
return 0;
} }
/** /**