'; // get possible types and remove those which do not support file upload $types = $_SESSION['config']->get_ActiveTypes(); for ($i = 0; $i < sizeof($types); $i++) { $myType = new $types[$i](); if (!$myType->supportsFileUpload()) { unset($types[$i]); } } $types = array_values($types); // check if account specific page should be shown if (isset($_POST['type'])) { // get selected type $scope = $_POST['type']; // get selected modules $selectedModules = array(); $checkedBoxes = array_keys($_POST, 'on'); for ($i = 0; $i < sizeof($checkedBoxes); $i++) { if (strpos($checkedBoxes[$i], $scope . '_') === 0) { $selectedModules[] = substr($checkedBoxes[$i], strlen($scope) + 1); } } $deps = getModulesDependencies($scope); $depErrors = check_module_depends($selectedModules, $deps); if (is_array($depErrors) && (sizeof($depErrors) > 0)) { for ($i = 0; $i < sizeof($depErrors); $i++) { StatusMessage('ERROR', _("Unsolved dependency:") . ' ' . getModuleAlias($depErrors[$i][0], $scope) . " (" . getModuleAlias($depErrors[$i][1], $scope) . ")"); } } else { showMainPage($scope, $selectedModules); exit; } } // show start page echo "

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

\n"; echo "

 

\n"; echo "

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

\n"; echo "

 

\n"; echo ''; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo '' . _("Account type") . ':'; echo "\n"; echo "\n"; echo "
\n"; echo '' . _('Selected modules') . ':'; echo "\n"; // generate one DIV for each account type $counter = 0; foreach ($sortedTypes as $type => $label) { $style = 'style="display:none;"'; if ((!isset($_POST['type']) && ($counter == 0)) || (isset($_POST['type']) && ($_POST['type'] == $type))) { // show first account type or last selected one $style = ''; } echo "
\n"; echo ""; $modules = $_SESSION['config']->get_AccountModules($type); for ($m = 0; $m < sizeof($modules); $m++) { if ($m%3 == 0) { echo "\n"; } echo ""; if (($m%3 == 2) && ($m != (sizeof($modules) - 1))) { echo "\n"; } } echo ""; echo "
"; $module = new $modules[$m]($type); $iconImage = $module->getIcon(); echo '' . $iconImage . ''; echo "\n"; if (is_base_module($modules[$m], $type)) { echo ""; } else { $checked = 'checked'; if (isset($_POST['submit']) && !isset($_POST[$type . '_' . $modules[$m]])) { $checked = ''; } echo ""; } echo getModuleAlias($modules[$m], $type); echo "
\n"; echo "
\n"; $counter++; } echo "
\n"; echo "\n"; ?>
\n"; echo "
\n"; echo ''; include 'main_footer.php'; /** * Displays the acount type specific main page of the upload. * * @param string $scope account type * @param array $selectedModules list of selected account modules */ function showMainPage($scope, $selectedModules) { echo "

" . _("File upload") . "

"; 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 "
"; echo _("Check your input carefully. LAM will only do some basic checks on the upload data."); echo "

"; echo _("Hint: Format all cells as text in your spreadsheet program and turn off auto correction."); echo "

\n"; echo "

 

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

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

\n"; echo "
\n"; ?>  

\n"; echo _("Here is a list of possible columns. The red columns must be included in the CSV file and filled with data for all accounts."); 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"; // help link echo " "; printHelpLink(getHelp('', '361'), '361'); echo "
\n"; echo "
    \n"; echo "
  • " . _("Identifier") . ": " . "dn_suffix
  • \n"; echo "
  • " . _("Example value") . ": " . _("ou=accounts,dc=yourdomain,dc=org") . "
  • \n"; echo "
  • " . _("Default value") . ": " . $_SESSION['config']->get_Suffix($scope) . "
  • \n"; echo "
\n"; echo "
\n"; echo "" . _("RDN identifier") . "\n"; // help link echo " "; printHelpLink(getHelp('', '301'), '301'); echo "
\n"; echo "
    \n"; echo "
  • " . _("Identifier") . ": " . "dn_rdn
  • \n"; echo "
  • " . _("Possible values") . ": " . implode(", ", getRDNAttributes($scope, $selectedModules)) . "
  • \n"; echo "
\n"; echo "
\n"; echo "

\n"; // get input fields from modules $columns = getUploadColumns($scope, $selectedModules); // print input fields $modules = array_keys($columns); for ($m = 0; $m < sizeof($modules); $m++) { // skip modules without upload columns if (sizeof($columns[$modules[$m]]) < 1) { continue; } $icon = ''; $module = new $modules[$m]($scope); $iconImage = $module->getIcon(); if ($iconImage != null) { $icon = '' . $iconImage . ' '; } echo "
\n$icon" . 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], $scope); echo "\n"; showColumnData($modules[$m], $columns[$modules[$m]][$i], $scope); echo "\n"; showColumnData($modules[$m], $columns[$modules[$m]][$i], $scope); echo "
\n"; echo "

"; } // build sample CSV $sampleCSV_head = array(); $sampleCSV_row = array(); // DN attributes $sampleCSV_head[] = "\"dn_suffix\""; $sampleCSV_head[] = "\"dn_rdn\""; // module attributes 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'] . "\""; } } $RDNs = getRDNAttributes($scope, $selectedModules); // DN attributes $sampleCSV_row[] = "\"" . $_SESSION['config']->get_Suffix($scope) . "\""; $sampleCSV_row[] = "\"" . $RDNs[0] . "\""; // module attributes 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'] . "\""; } } $sampleCSV = implode(",", $sampleCSV_head) . "\n" . implode(",", $sampleCSV_row) . "\n"; $_SESSION['mass_csv'] = $sampleCSV; echo ''; include 'main_footer.php'; die; } /** * Prints the properties of one input field. * * @param string $module account module name * @param array $data field data from modules * @param string $scope account type */ function showColumnData($module, $data, $scope) { if (isset($data['required']) && ($data['required'] == true)) { echo "\n"; echo $data['description']; echo "\n"; } else { echo "\n"; echo $data['description']; echo "\n"; } // help link echo " "; printHelpLink(getHelp($module, $data['help'], $scope), $data['help'], $module, $scope); echo "
\n"; echo "\n"; } ?>