fixed error handling, updated to changed specification

This commit is contained in:
Roland Gruber 2004-10-10 11:16:34 +00:00
parent e34312a75e
commit 4f1b9681ce
2 changed files with 26 additions and 20 deletions

View File

@ -108,7 +108,7 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
$checkcolumns = array(); $checkcolumns = array();
$columns = call_user_func_array('array_merge', $columns); $columns = call_user_func_array('array_merge', $columns);
for ($i = 0; $i < sizeof($columns); $i++) { for ($i = 0; $i < sizeof($columns); $i++) {
if ($columns[$i]['required'] == true) { if (isset($columns[$i]['required']) && ($columns[$i]['required'] == true)) {
if (isset($ids[$columns[$i]['name']])) $checkcolumns[] = $ids[$columns[$i]['name']]; if (isset($ids[$columns[$i]['name']])) $checkcolumns[] = $ids[$columns[$i]['name']];
else $errors[] = array(_("A required column is missing in your CSV file."), $columns[$i]['name']); else $errors[] = array(_("A required column is missing in your CSV file."), $columns[$i]['name']);
} }
@ -161,7 +161,7 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
if ($accounts != false) { if ($accounts != false) {
// set DN // set DN
for ($i = 0; $i < sizeof($accounts); $i++) { for ($i = 0; $i < sizeof($accounts); $i++) {
if (!isset($accounts[$i][$data[$i][$ids['dn_rdn']]])) $errors[] = array(_("Data field for RDN is empty for account $i!"), ""); if (!isset($accounts[$i][$data[$i][$ids['dn_rdn']]])) $errors[] = array(_('Account %s: dn_rdn'), _("Data field for RDN is empty!"), array($i));
// TODO check against list of possible RDN attributes // TODO check against list of possible RDN attributes
else { else {
$account_dn = $data[$i][$ids['dn_rdn']] . "=" . $accounts[$i][$data[$i][$ids['dn_rdn']]] . ","; $account_dn = $data[$i][$ids['dn_rdn']] . "=" . $accounts[$i][$data[$i][$ids['dn_rdn']]] . ",";
@ -170,6 +170,11 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
$accounts[$i]['dn'] = $account_dn; $accounts[$i]['dn'] = $account_dn;
} }
} }
// print errors if DN could not be built
if (sizeof($errors) > 0) {
for ($i = 0; $i < sizeof($errors); $i++) StatusMessage("ERROR", $errors[$i][0], $errors[$i][1], $errors[$i][2]);
}
else {
// store accounts in session // store accounts in session
$_SESSION['mass_accounts'] = $_SESSION['ldap']->encrypt(serialize($accounts)); $_SESSION['mass_accounts'] = $_SESSION['ldap']->encrypt(serialize($accounts));
$_SESSION['mass_counter'] = 0; $_SESSION['mass_counter'] = 0;
@ -190,6 +195,7 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
} }
} }
} }
}
echo "</body>\n"; echo "</body>\n";
echo "</html>\n"; echo "</html>\n";

View File

@ -225,7 +225,7 @@ function showMainPage($scope) {
* @param array $data field data from modules * @param array $data field data from modules
*/ */
function showColumnData($module, $data) { function showColumnData($module, $data) {
if ($data['required']) { if (isset($data['required']) && ($data['required'] == true)) {
echo "<font color=\"red\"><b>\n"; echo "<font color=\"red\"><b>\n";
echo $data['description']; echo $data['description'];
echo "</b></font>\n"; echo "</b></font>\n";