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,23 +170,29 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
$accounts[$i]['dn'] = $account_dn; $accounts[$i]['dn'] = $account_dn;
} }
} }
// store accounts in session // print errors if DN could not be built
$_SESSION['mass_accounts'] = $_SESSION['ldap']->encrypt(serialize($accounts)); if (sizeof($errors) > 0) {
$_SESSION['mass_counter'] = 0; for ($i = 0; $i < sizeof($errors); $i++) StatusMessage("ERROR", $errors[$i][0], $errors[$i][1], $errors[$i][2]);
$_SESSION['mass_errors'] = array(); }
// show links for upload and LDIF export else {
echo "<h1 align=\"center\">" . _("LAM has checked your input and is now ready to create the accounts.") . "</h1>\n"; // store accounts in session
echo "<p>&nbsp;</p>\n"; $_SESSION['mass_accounts'] = $_SESSION['ldap']->encrypt(serialize($accounts));
echo "<p align=\"center\">\n"; $_SESSION['mass_counter'] = 0;
echo "<table align=\"center\" width=\"80%\"><tr>\n"; $_SESSION['mass_errors'] = array();
echo "<td align=\"center\" width=\"50%\">\n"; // show links for upload and LDIF export
echo "<a href=\"massDoUpload.php\"><b>" . _("Upload accounts to LDAP") . "</b></a>"; echo "<h1 align=\"center\">" . _("LAM has checked your input and is now ready to create the accounts.") . "</h1>\n";
echo "</td>\n"; echo "<p>&nbsp;</p>\n";
echo "<td align=\"center\" width=\"50%\">\n"; echo "<p align=\"center\">\n";
echo "<a href=\"massBuildAccounts.php?showldif=true\"><b>" . _("Show LDIF file") . "</b></a>"; echo "<table align=\"center\" width=\"80%\"><tr>\n";
echo "</td>\n"; echo "<td align=\"center\" width=\"50%\">\n";
echo "</tr></table>\n"; echo "<a href=\"massDoUpload.php\"><b>" . _("Upload accounts to LDAP") . "</b></a>";
echo "</p>\n"; echo "</td>\n";
echo "<td align=\"center\" width=\"50%\">\n";
echo "<a href=\"massBuildAccounts.php?showldif=true\"><b>" . _("Show LDIF file") . "</b></a>";
echo "</td>\n";
echo "</tr></table>\n";
echo "</p>\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";