account upload\n"; echo "\n"; echo "\n"; echo "\n"; // check if account specific page should be shown if (isset($_POST['user'])) showMainPage('user'); elseif (isset($_POST['group'])) showMainPage('group'); elseif (isset($_POST['host'])) showMainPage('host'); // show start page else { echo "

" . _("Account creation via file upload") . "

\n"; echo "

 

\n"; echo "

 

\n"; echo "

\n"; echo "Here you can create multiple accounts by providing a CSV file."; echo "

\n"; echo "

 

\n"; echo "

\n"; echo _("Please select your account type:"); echo "

\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; } /** * Displays the acount type specific main page of the upload. * * @param string $scope account type */ function showMainPage($scope) { echo "

\n"; echo _("Please provide a CSV formated file with your account data. The cells in the first row must be filled with the column identifiers. The following rows represent one account for each row."); echo "

\n"; echo "

 

\n"; echo "
\n"; echo "

\n"; echo "" . _("CSV file:") . "   "; echo "\n"; echo "\n"; echo "

\n"; echo "
\n"; echo "

 

\n"; echo "" . _("Columns:") . "\n"; // DN options echo "
\n" . _("DN settings") . "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo "" . _("DN suffix") . "\n"; echo "
\n"; echo "
    \n"; echo "
  • " . _("Identifier") . ": " . "dn_suffix
  • \n"; echo "
  • " . _("Example value") . ": " . "ou=accounts,dc=yourdomain,dc=org
  • \n"; echo "
  • " . _("Default value") . ": " . call_user_func(array($_SESSION['config'], 'get_' . ucfirst($scope) . 'Suffix')) . "
  • \n"; echo "
  • \n"; echo "" . _("Help") . "\n"; echo "
  • \n"; echo "
\n"; echo "
\n"; echo "" . _("RDN identifier") . "\n"; echo "
\n"; echo "
    \n"; echo "
  • " . _("Identifier") . ": " . "dn_rdn
  • \n"; echo "
  • " . _("Possible values") . ": " . implode(", ", getRDNAttributes($scope)) . "
  • \n"; echo "
  • " . _("Example value") . ": " . "uid
  • \n"; echo "
  • \n"; echo "" . _("Help") . "\n"; echo "
  • \n"; echo "
\n"; echo "
\n"; echo "
\n"; // get input fields from modules $columns = getUploadColumns($scope); // print input fields $modules = array_keys($columns); for ($m = 0; $m < sizeof($modules); $m++) { if (sizeof($columns[$modules[$m]]) < 1) continue; echo "
\n" . getModuleAlias($modules[$m], $scope) . "\n"; echo "\n"; for ($i = 0; $i < sizeof($columns[$modules[$m]]); $i++) { echo "\n"; echo "\n"; $i++; if ($i < sizeof($columns[$modules[$m]])) { echo "\n"; $i++; if ($i < sizeof($columns[$modules[$m]])) { echo "\n"; } else echo ""; // empty cell if no more fields } else echo ""; // empty cell if no more fields echo "\n"; } echo "
\n"; showColumnData($modules[$m], $columns[$modules[$m]][$i]); echo "\n"; showColumnData($modules[$m], $columns[$modules[$m]][$i]); echo "\n"; showColumnData($modules[$m], $columns[$modules[$m]][$i]); echo "
\n"; echo "
"; } echo "

 

\n"; // print table example and build sample CSV $sampleCSV = ""; $sampleCSV_head = array(); $sampleCSV_row = array(); echo "" . _("This is an example how it would look in your spreadsheet program before you convert to CSV:") . "\n"; echo "\n"; echo "\n"; for ($m = 0; $m < sizeof($modules); $m++) { if (sizeof($columns[$modules[$m]]) < 1) continue; for ($i = 0; $i < sizeof($columns[$modules[$m]]); $i++) { $sampleCSV_head[] = "\"" . $columns[$modules[$m]][$i]['name'] . "\""; echo "\n"; } } echo "\n"; echo "\n"; for ($m = 0; $m < sizeof($modules); $m++) { if (sizeof($columns[$modules[$m]]) < 1) continue; for ($i = 0; $i < sizeof($columns[$modules[$m]]); $i++) { $sampleCSV_row[] = "\"" . $columns[$modules[$m]][$i]['example'] . "\""; echo "\n"; } } echo "\n"; echo "
\n"; echo $columns[$modules[$m]][$i]['name']; echo "
\n"; echo $columns[$modules[$m]][$i]['example']; echo "
\n"; $sampleCSV = implode(",", $sampleCSV_head) . "\n" . implode(",", $sampleCSV_row) . "\n"; $_SESSION['mass_csv'] = $sampleCSV; // link to CSV sample echo "

\n"; echo "

\n"; echo "" . _("Download sample CSV file") . "\n"; echo "

\n"; echo "

\n"; echo "\n"; echo "\n"; die; } /** * Prints the properties of one input field. * * @param string $module account module name * @param array $data field data from modules */ function showColumnData($module, $data) { if (isset($data['required']) && ($data['required'] == true)) { echo "\n"; echo $data['description']; echo "\n"; } else { echo "\n"; echo $data['description']; echo "\n"; } echo "
\n"; echo "

\n"; } ?>