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 = htmlspecialchars($_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 $divClass = 'user'; if (isset($_REQUEST['type'])) { $divClass = $_REQUEST['type']; } echo '
'; echo "
\n"; echo "

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

\n"; echo "
"; echo "

 

\n"; echo "

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

\n"; echo "

 

\n"; 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($_REQUEST['type']) && ($counter == 0)) || (isset($_REQUEST['type']) && ($_REQUEST['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 '
'; // get input fields from modules $columns = getUploadColumns($scope, $selectedModules); $modules = array_keys($columns); echo "
\n"; $container = new htmlTable(); // title $container->addElement(new htmlTitle(_("File upload")), true); $container->addElement(new htmlSpacer(null, '10px'), true); // instructions $container->addElement(new htmlOutputText(_("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.")), true); $container->addElement(new htmlOutputText(_("Check your input carefully. LAM will only do some basic checks on the upload data.")), true); $container->addElement(new htmlSpacer(null, '10px'), true); $container->addElement(new htmlOutputText(_("Hint: Format all cells as text in your spreadsheet program and turn off auto correction.")), true); $container->addElement(new htmlSpacer(null, '10px'), true); // upload elements $inputContainer = new htmlTable(); $inputContainer->addElement(new htmlOutputText(_("CSV file"))); $inputContainer->addElement(new htmlInputFileUpload('inputfile')); $inputContainer->addElement(new htmlSpacer('10px', null)); $inputContainer->addElement(new htmlLink(_("Download sample CSV file"), 'masscreate.php?getCSV=1')); $inputContainer->addElement(new htmlHiddenInput('scope', $scope)); $inputContainer->addElement(new htmlHiddenInput('selectedModules', implode(',', $selectedModules)), true); // PDF $createPDF = false; if (isset($_POST['createPDF']) && ($_POST['createPDF'] === '1')) { $createPDF = true; } $pdfCheckbox = new htmlTableExtendedInputCheckbox('createPDF', $createPDF, _('Create PDF files')); $pdfCheckbox->setTableRowsToShow(array('pdfStructure')); $inputContainer->addElement($pdfCheckbox, true); $pdfStructures = getPDFStructureDefinitions($scope); $pdfSelected = array(); if (isset($_POST['pdfStructure'])) { $pdfSelected = array($_POST['pdfStructure']); } else if (in_array('default', $pdfStructures)) { $pdfSelected = array('default'); } $inputContainer->addElement(new htmlTableExtendedSelect('pdfStructure', $pdfStructures, $pdfSelected, _('PDF structure')), true); $inputContainer->addElement(new htmlSpacer(null, '5px'), true); $inputContainer->addElement(new htmlButton('submitfile', _('Upload file and create accounts'))); $container->addElement($inputContainer, true); $container->addElement(new htmlSpacer(null, '10px'), true); // column list $columnSpacer = new htmlSpacer('10px', null); $container->addElement(new htmlTitle(_("Columns")), true); $columnContainer = new htmlTable(); $columnContainer->setCSSClasses($scope . 'list'); // DN options $dnTitle = new htmlSubTitle(_("DN settings"), '../graphics/logo32.png'); $dnTitle->colspan = 20; $columnContainer->addElement($dnTitle, true); $columnContainer->addElement($columnSpacer); $columnContainer->addElement(new htmlOutputText('')); $columnContainer->addElement($columnSpacer); $header0 = new htmlOutputText(_('Name')); $header0->alignment = htmlElement::ALIGN_LEFT; $columnContainer->addElement($header0, false, true); $columnContainer->addElement($columnSpacer); $header1 = new htmlOutputText(_("Identifier")); $header1->alignment = htmlElement::ALIGN_LEFT; $columnContainer->addElement($header1, false, true); $columnContainer->addElement($columnSpacer); $header2 = new htmlOutputText(_("Example value")); $header2->alignment = htmlElement::ALIGN_LEFT; $columnContainer->addElement($header2, false, true); $columnContainer->addElement($columnSpacer); $header3 = new htmlOutputText(_("Default value")); $header3->alignment = htmlElement::ALIGN_LEFT; $columnContainer->addElement($header3, false, true); $columnContainer->addElement($columnSpacer); $header4 = new htmlOutputText(_("Possible values")); $header4->alignment = htmlElement::ALIGN_LEFT; $columnContainer->addElement($header4, false, true); $dnSuffixRowCells = array(); $dnSuffixRowCells[] = $columnSpacer; $dnSuffixRowCells[] = new htmlHelpLink('361'); $dnSuffixRowCells[] = $columnSpacer; $dnSuffixRowCells[] = new htmlOutputText(_("DN suffix")); $dnSuffixRowCells[] = $columnSpacer; $dnSuffixRowCells[] = new htmlOutputText('dn_suffix'); $dnSuffixRowCells[] = $columnSpacer; $dnSuffixRowCells[] = new htmlOutputText($_SESSION['config']->get_Suffix($scope)); $dnSuffixRowCells[] = $columnSpacer; $dnSuffixRowCells[] = new htmlOutputText($_SESSION['config']->get_Suffix($scope)); $dnSuffixRowCells[] = $columnSpacer; $dnSuffixRowCells[] = new htmlOutputText(''); $dnSuffixRowCells[] = new htmlSpacer(null, '25px'); $dnSuffixRow = new htmlTableRow($dnSuffixRowCells); $dnSuffixRow->setCSSClasses($scope . 'list-dark'); $columnContainer->addElement($dnSuffixRow); $dnRDNRowCells = array(); $dnRDNRowCells[] = $columnSpacer; $dnRDNRowCells[] = new htmlHelpLink('301'); $dnRDNRowCells[] = $columnSpacer; $rdnText = new htmlOutputText(_("RDN identifier")); $rdnText->setMarkAsRequired(true); $dnRDNRowCells[] = $rdnText; $dnRDNRowCells[] = $columnSpacer; $dnRDNRowCells[] = new htmlOutputText('dn_rdn'); $dnRDNRowCells[] = $columnSpacer; $rdnAttributes = getRDNAttributes($scope, $selectedModules); $dnRDNRowCells[] = new htmlOutputText($rdnAttributes[0]); $dnRDNRowCells[] = $columnSpacer; $dnRDNRowCells[] = new htmlOutputText(''); $dnRDNRowCells[] = $columnSpacer; $dnRDNRowCells[] = new htmlOutputText(implode(", ", $rdnAttributes)); $dnRDNRowCells[] = new htmlSpacer(null, '25px'); $dnRDNRow = new htmlTableRow($dnRDNRowCells); $dnRDNRow->setCSSClasses($scope . 'list-bright'); $columnContainer->addElement($dnRDNRow); // module options for ($m = 0; $m < sizeof($modules); $m++) { // skip modules without upload columns if (sizeof($columns[$modules[$m]]) < 1) { continue; } $columnContainer->addElement(new htmlSpacer(null, '10px'), true); $icon = ''; $module = new $modules[$m]($scope); $iconImage = $module->getIcon(); if ($iconImage != null) { $icon = '../graphics/' . $iconImage; } $moduleTitle = new htmlSubTitle(getModuleAlias($modules[$m], $scope), $icon); $moduleTitle->colspan = 20; $columnContainer->addElement($moduleTitle, true); $columnContainer->addElement(new htmlOutputText('')); $columnContainer->addElement(new htmlOutputText('')); $columnContainer->addElement(new htmlOutputText('')); $nameOut = new htmlOutputText(_('Name')); $nameOut->alignment = htmlElement::ALIGN_LEFT; $columnContainer->addElement($nameOut, false, true); $columnContainer->addElement(new htmlOutputText('')); $idOut = new htmlOutputText(_('Identifier')); $idOut->alignment = htmlElement::ALIGN_LEFT; $columnContainer->addElement($idOut, false, true); $columnContainer->addElement(new htmlOutputText('')); $exampleOut = new htmlOutputText(_('Example value')); $exampleOut->alignment = htmlElement::ALIGN_LEFT; $columnContainer->addElement($exampleOut, false, true); $columnContainer->addElement(new htmlOutputText('')); $defaultOut = new htmlOutputText(_('Default value')); $defaultOut->alignment = htmlElement::ALIGN_LEFT; $columnContainer->addElement($defaultOut, false, true); $columnContainer->addElement(new htmlOutputText('')); $possibleOut = new htmlOutputText(_('Possible values')); $possibleOut->alignment = htmlElement::ALIGN_LEFT; $columnContainer->addElement($possibleOut, false, true); $odd = true; for ($i = 0; $i < sizeof($columns[$modules[$m]]); $i++) { $required = false; if (isset($columns[$modules[$m]][$i]['required']) && ($columns[$modules[$m]][$i]['required'] == true)) { $required = true; } $rowCells = array(); $rowCells[] = $columnSpacer; $rowCells[] = new htmlHelpLink($columns[$modules[$m]][$i]['help'], $modules[$m], $scope); $rowCells[] = $columnSpacer; $descriptionText = new htmlOutputText($columns[$modules[$m]][$i]['description']); $descriptionText->setMarkAsRequired($required); $descriptionText->setNoWrap(true); $rowCells[] = $descriptionText; $rowCells[] = $columnSpacer; $rowCells[] = new htmlOutputText($columns[$modules[$m]][$i]['name']); $rowCells[] = $columnSpacer; $example = ''; if (isset($columns[$modules[$m]][$i]['example'])) { $example = $columns[$modules[$m]][$i]['example']; } $rowCells[] = new htmlOutputText($example); $rowCells[] = $columnSpacer; if (isset($columns[$modules[$m]][$i]['default'])) { $rowCells[] = new htmlOutputText($columns[$modules[$m]][$i]['default']); } else { $rowCells[] = new htmlOutputText(''); } $rowCells[] = $columnSpacer; if (isset($columns[$modules[$m]][$i]['values'])) { $rowCells[] = new htmlOutputText($columns[$modules[$m]][$i]['values']); } else { $rowCells[] = new htmlOutputText(''); } $rowCells[] = new htmlSpacer(null, '25px'); $row = new htmlTableRow($rowCells); if ($odd) { $row->setCSSClasses($scope . 'list-dark'); } else { $row->setCSSClasses($scope . 'list-bright'); } $odd = !$odd; $columnContainer->addElement($row); } } $container->addElement($columnContainer, true); $tabindex = 1; parseHtml(null, $container, array(), false, $tabindex, $scope); echo "
\n"; // 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++) { if (isset($columns[$modules[$m]][$i]['example'])) { $sampleCSV_row[] = '"' . $columns[$modules[$m]][$i]['example'] . '"'; } else { $sampleCSV_row[] = '""'; } } } $sampleCSV = implode(",", $sampleCSV_head) . "\n" . implode(",", $sampleCSV_row) . "\n"; $_SESSION['mass_csv'] = $sampleCSV; echo '
'; include 'main_footer.php'; die; } ?>