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 "
';
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";
// 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;
}
?>