getConfiguredTypes();
$count = sizeof($types);
for ($i = 0; $i < $count; $i++) {
$myType = $types[$i];
if (!$myType->getBaseType()->supportsFileUpload() || $myType->isHidden()
|| !checkIfNewEntriesAreAllowed($myType->getId()) || !checkIfWriteAccessIsAllowed($myType->getId())) {
unset($types[$i]);
}
}
$types = array_values($types);
// check if account specific page should be shown
if (isset($_POST['type'])) {
// get selected type
$typeId = htmlspecialchars($_POST['type']);
$type = $typeManager->getConfiguredType($typeId);
// get selected modules
$selectedModules = array();
$checkedBoxes = array_keys($_POST, 'on');
foreach ($checkedBoxes as $checkedBox) {
if (strpos($checkedBox, $typeId . '___') === 0) {
$selectedModules[] = substr($checkedBox, strlen($typeId) + strlen('___'));
}
}
$deps = getModulesDependencies($type->getScope());
$depErrors = check_module_depends($selectedModules, $deps);
if (is_array($depErrors) && (sizeof($depErrors) > 0)) {
foreach ($depErrors as $depError) {
StatusMessage('ERROR', _("Unsolved dependency:") . ' ' .
getModuleAlias($depError[0], $type->getScope()) . " (" .
getModuleAlias($depError[1], $type->getScope()) . ")");
}
}
else {
showMainPage($type, $selectedModules);
exit;
}
}
// show start page
$divClass = 'user';
if (isset($_REQUEST['type'])) {
$divClass = htmlspecialchars(\LAM\TYPES\getScopeFromTypeId($_REQUEST['type']));
}
echo '
';
echo "
';
include __DIR__ . '/../../lib/adminFooter.inc';
/**
* Displays the acount type specific main page of the upload.
*
* @param \LAM\TYPES\ConfiguredType $type account type
* @param array $selectedModules list of selected account modules
*/
function showMainPage(\LAM\TYPES\ConfiguredType $type, $selectedModules) {
$scope = $type->getScope();
echo '';
// get input fields from modules
$columns = getUploadColumns($type, $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\"";
$sampleCSV_head[] = "\"overwrite\"";
// module attributes
foreach ($modules as $moduleName) {
if (sizeof($columns[$moduleName]) < 1) {
continue;
}
foreach ($columns[$moduleName] as $column) {
$sampleCSV_head[] = "\"" . $column['name'] . "\"";
}
}
$RDNs = getRDNAttributes($type->getId(), $selectedModules);
// DN attributes
$sampleCSV_row[] = "\"" . $type->getSuffix() . "\"";
$sampleCSV_row[] = "\"" . $RDNs[0] . "\"";
$sampleCSV_row[] = "\"false\"";
// module attributes
foreach ($modules as $moduleName) {
if (sizeof($columns[$moduleName]) < 1) {
continue;
}
foreach ($columns[$moduleName] as $column) {
if (isset($column['example'])) {
$sampleCSV_row[] = '"' . $column['example'] . '"';
}
else {
$sampleCSV_row[] = '""';
}
}
}
$sampleCSV = implode(",", $sampleCSV_head) . "\n" . implode(",", $sampleCSV_row) . "\n";
$_SESSION['mass_csv'] = $sampleCSV;
echo '
';
include __DIR__ . '/../../lib/adminFooter.inc';
die;
}
?>