new type API for upload
This commit is contained in:
parent
9355b55982
commit
cdaa9a8a12
|
@ -6,7 +6,7 @@ use accountContainer;
|
|||
$Id$
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||
Copyright (C) 2016 Roland Gruber
|
||||
Copyright (C) 2016 - 2017 Roland Gruber
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -46,7 +46,7 @@ class Uploader {
|
|||
|
||||
private $accounts = null;
|
||||
private $data = null;
|
||||
private $scope = null;
|
||||
private $type = null;
|
||||
private $endTime;
|
||||
|
||||
const TIME_LIMIT = 10;
|
||||
|
@ -61,11 +61,13 @@ class Uploader {
|
|||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \LAM\TYPES\ConfiguredType $type account type
|
||||
*/
|
||||
public function __construct($scope) {
|
||||
public function __construct($type) {
|
||||
$this->accounts = unserialize(lamDecrypt($_SESSION['mass_accounts']));
|
||||
$this->data = unserialize(lamDecrypt($_SESSION['mass_data']));
|
||||
$this->scope = $scope;
|
||||
$this->type = $type;
|
||||
$startTime = time();
|
||||
$maxTime = get_cfg_var('max_execution_time') - 5;
|
||||
if ($maxTime > Uploader::TIME_LIMIT) $maxTime = Uploader::TIME_LIMIT;
|
||||
|
@ -131,7 +133,7 @@ class Uploader {
|
|||
$preAttributes[$key] = &$attrs[$key];
|
||||
}
|
||||
$preAttributes['dn'] = &$dn;
|
||||
$preMessages = doUploadPreActions($this->scope, $_SESSION['mass_selectedModules'], $preAttributes);
|
||||
$preMessages = doUploadPreActions($this->type->getScope(), $_SESSION['mass_selectedModules'], $preAttributes);
|
||||
$preActionOk = true;
|
||||
for ($i = 0; $i < sizeof($preMessages); $i++) {
|
||||
if (($preMessages[$i][0] == 'ERROR') || ($preMessages[$i][0] == 'WARN')) {
|
||||
|
@ -202,7 +204,7 @@ class Uploader {
|
|||
'pdfFinished' => $pdfFinished,
|
||||
'allDone' => $allDone,
|
||||
'errorHtml' => $errorHtml,
|
||||
'scope' => $this->scope
|
||||
'typeId' => $this->type->getId()
|
||||
);
|
||||
return json_encode($status);
|
||||
}
|
||||
|
@ -211,10 +213,10 @@ class Uploader {
|
|||
* Checks for security violations and stops processing if needed.
|
||||
*/
|
||||
private function securityCheck() {
|
||||
if (!isLoggedIn() || empty($this->scope)
|
||||
|| isAccountTypeHidden($this->scope)
|
||||
|| !checkIfNewEntriesAreAllowed($this->scope)
|
||||
|| !checkIfWriteAccessIsAllowed($this->scope)) {
|
||||
if (!isLoggedIn() || empty($this->type)
|
||||
|| $this->type->isHidden()
|
||||
|| !checkIfNewEntriesAreAllowed($this->type->getId())
|
||||
|| !checkIfWriteAccessIsAllowed($this->type->getId())) {
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
@ -229,7 +231,7 @@ class Uploader {
|
|||
while (!isset($_SESSION['mass_postActions']['finished']) && ($this->endTime > time())) {
|
||||
$return = $this->runModulePostActions();
|
||||
}
|
||||
$title = _("Additional tasks for module:") . ' ' . getModuleAlias($return['module'], $this->scope);
|
||||
$title = _("Additional tasks for module:") . ' ' . getModuleAlias($return['module'], $this->type->getScope());
|
||||
$progress = round($return['progress'], 2);
|
||||
$finished = isset($_SESSION['mass_postActions']['finished']);
|
||||
return $this->buildUploadStatus(100, true, $title, $progress, $finished);
|
||||
|
@ -241,7 +243,7 @@ class Uploader {
|
|||
* @return array status array
|
||||
*/
|
||||
private function runModulePostActions() {
|
||||
$return = doUploadPostActions($this->scope, $this->data, $_SESSION['mass_ids'], $_SESSION['mass_failed'], $_SESSION['mass_selectedModules'], $this->accounts);
|
||||
$return = doUploadPostActions($this->type->getScope(), $this->data, $_SESSION['mass_ids'], $_SESSION['mass_failed'], $_SESSION['mass_selectedModules'], $this->accounts);
|
||||
if ($return['status'] == 'finished') {
|
||||
$_SESSION['mass_postActions']['finished'] = true;
|
||||
}
|
||||
|
@ -284,7 +286,7 @@ class Uploader {
|
|||
}
|
||||
// load account
|
||||
$typeManager = new \LAM\TYPES\TypeManager();
|
||||
$_SESSION['mass_pdfAccount'] = new accountContainer($typeManager->getConfiguredType($this->scope), 'mass_pdfAccount');
|
||||
$_SESSION['mass_pdfAccount'] = new accountContainer($this->type, 'mass_pdfAccount');
|
||||
$pdfErrors = $_SESSION['mass_pdfAccount']->load_account($dn, $infoAttributes);
|
||||
if (sizeof($pdfErrors) > 0) {
|
||||
$_SESSION['mass_errors'] = array_merge($_SESSION['mass_errors'], $pdfErrors);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
$Id$
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||
Copyright (C) 2003 - 2016 Roland Gruber
|
||||
Copyright (C) 2003 - 2017 Roland Gruber
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -757,6 +757,6 @@ window.lam.upload.uploadDone = function(jsonData) {
|
|||
jQuery('#uploadContent').html(htmlOut);
|
||||
}
|
||||
else {
|
||||
top.location.href = '../lists/list.php?type=' + jsonData.scope + '&uploadAllOk';
|
||||
top.location.href = '../lists/list.php?type=' + jsonData.typeId + '&uploadAllOk';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
$Id$
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||
Copyright (C) 2011 - 2016 Roland Gruber
|
||||
Copyright (C) 2011 - 2017 Roland Gruber
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -90,7 +90,8 @@ class lamAjax {
|
|||
}
|
||||
elseif ($function == 'upload') {
|
||||
include_once('../../lib/upload.inc');
|
||||
$uploader = new LAM\UPLOAD\Uploader($_GET['scope']);
|
||||
$typeManager = new \LAM\TYPES\TypeManager();
|
||||
$uploader = new LAM\UPLOAD\Uploader($typeManager->getConfiguredType($_GET['typeId']));
|
||||
ob_start();
|
||||
$jsonOut = $uploader->doUpload();
|
||||
ob_end_clean();
|
||||
|
|
|
@ -1,9 +1,17 @@
|
|||
<?php
|
||||
namespace LAM\UPLOAD;
|
||||
use \htmlTable;
|
||||
use \htmlSpacer;
|
||||
use \htmlStatusMessage;
|
||||
use \htmlLink;
|
||||
use \htmlTitle;
|
||||
use \htmlButton;
|
||||
use \htmlHiddenInput;
|
||||
/*
|
||||
$Id$
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||
Copyright (C) 2004 - 2016 Roland Gruber
|
||||
Copyright (C) 2004 - 2017 Roland Gruber
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -89,20 +97,22 @@ if (isset($_GET['showldif'])) {
|
|||
}
|
||||
|
||||
include '../main_header.php';
|
||||
$scope = htmlspecialchars($_POST['scope']);
|
||||
$typeId = htmlspecialchars($_POST['typeId']);
|
||||
$typeManager = new \LAM\TYPES\TypeManager();
|
||||
$type = $typeManager->getConfiguredType($typeId);
|
||||
|
||||
// check if account type is ok
|
||||
if (isAccountTypeHidden($scope)) {
|
||||
logNewMessage(LOG_ERR, 'User tried to access hidden upload: ' . $scope);
|
||||
if ($type->isHidden()) {
|
||||
logNewMessage(LOG_ERR, 'User tried to access hidden upload: ' . $type->getId());
|
||||
die();
|
||||
}
|
||||
if (!checkIfNewEntriesAreAllowed($scope) || !checkIfWriteAccessIsAllowed($scope)) {
|
||||
logNewMessage(LOG_ERR, 'User tried to access forbidden upload: ' . $scope);
|
||||
if (!checkIfNewEntriesAreAllowed($type->getId()) || !checkIfWriteAccessIsAllowed($type->getId())) {
|
||||
logNewMessage(LOG_ERR, 'User tried to access forbidden upload: ' . $type->getId());
|
||||
die();
|
||||
}
|
||||
|
||||
echo '<form enctype="multipart/form-data" action="masscreate.php" method="post">';
|
||||
echo '<div class="' . $scope . '-bright smallPaddingContent">';
|
||||
echo '<div class="' . $type->getScope() . '-bright smallPaddingContent">';
|
||||
$container = new htmlTable();
|
||||
|
||||
$selectedModules = explode(',', $_POST['selectedModules']);
|
||||
|
@ -111,7 +121,7 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
|
|||
$data = array(); // input values without first row
|
||||
$ids = array(); // <column name> => <column number for $data>
|
||||
// get input fields from modules
|
||||
$columns = getUploadColumns($scope, $selectedModules);
|
||||
$columns = getUploadColumns($type->getScope(), $selectedModules);
|
||||
// read input file
|
||||
$handle = fopen ($_FILES['inputfile']['tmp_name'], "r");
|
||||
if (($head = fgetcsv($handle, 2000)) !== false ) { // head row
|
||||
|
@ -184,15 +194,15 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
|
|||
$container->addElement(new htmlStatusMessage("ERROR", $errors[$i][0], $errors[$i][1]), true);
|
||||
}
|
||||
$container->addElement(new htmlSpacer(null, '10px'), true);
|
||||
massPrintBackButton($scope, $selectedModules, $container);
|
||||
massPrintBackButton($type->getId(), $selectedModules, $container);
|
||||
}
|
||||
|
||||
// let modules build accounts
|
||||
else {
|
||||
$accounts = buildUploadAccounts($scope, $data, $ids, $selectedModules);
|
||||
$accounts = buildUploadAccounts($type->getId(), $data, $ids, $selectedModules);
|
||||
if ($accounts != false) {
|
||||
$rdnList = getRDNAttributes($scope, $selectedModules);
|
||||
$suffix = $_SESSION['config']->get_Suffix($scope);
|
||||
$rdnList = getRDNAttributes($type->getId(), $selectedModules);
|
||||
$suffix = $type->getSuffix();
|
||||
// set DN
|
||||
foreach ($accounts as $i => $account) {
|
||||
// check against list of possible RDN attributes
|
||||
|
@ -220,7 +230,7 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
|
|||
$_SESSION['mass_postActions'] = array();
|
||||
$_SESSION['mass_data'] = lamEncrypt(serialize($data));
|
||||
$_SESSION['mass_ids'] = $ids;
|
||||
$_SESSION['mass_scope'] = $scope;
|
||||
$_SESSION['mass_typeId'] = $type->getId();
|
||||
$_SESSION['mass_selectedModules'] = $selectedModules;
|
||||
if (isset($_SESSION['mass_pdf'])) {
|
||||
unset($_SESSION['mass_pdf']);
|
||||
|
@ -240,25 +250,25 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
|
|||
$buttonContainer->addElement(new htmlLink(_("Upload accounts to LDAP"), 'massDoUpload.php', '../../graphics/up.gif', true));
|
||||
$buttonContainer->addElement(new htmlLink(_("Show LDIF file"), 'massBuildAccounts.php?showldif=true', '../../graphics/edit.png', true));
|
||||
$buttonContainer->addElement(new htmlSpacer('10px', null));
|
||||
massPrintBackButton($scope, $selectedModules, $buttonContainer);
|
||||
massPrintBackButton($type->getId(), $selectedModules, $buttonContainer);
|
||||
$container->addElement($buttonContainer, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$container->addElement(new htmlSpacer(null, '10px'), true);
|
||||
massPrintBackButton($scope, $selectedModules, $container);
|
||||
massPrintBackButton($type->getId(), $selectedModules, $container);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$container->addElement(new htmlStatusMessage('ERROR', _('Please provide a file to upload.')), true);
|
||||
$container->addElement(new htmlSpacer(null, '10px'), true);
|
||||
massPrintBackButton($scope, $selectedModules, $container);
|
||||
massPrintBackButton($type->getId(), $selectedModules, $container);
|
||||
}
|
||||
|
||||
addSecurityTokenToMetaHTML($container);
|
||||
$tabindex = 1;
|
||||
parseHtml(null, $container, array(), false, $tabindex, $scope);
|
||||
parseHtml(null, $container, array(), false, $tabindex, $type->getScope());
|
||||
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
@ -267,15 +277,15 @@ include '../main_footer.php';
|
|||
/**
|
||||
* Prints a back button to the page where the user enters a file to upload.
|
||||
*
|
||||
* @param String $scope account type (e.g. user)
|
||||
* @param String $typeId account type (e.g. user)
|
||||
* @param array $selectedModules selected modules for upload
|
||||
* @param htmlTable $container table container
|
||||
*/
|
||||
function massPrintBackButton($scope, $selectedModules, &$container) {
|
||||
function massPrintBackButton($typeId, $selectedModules, &$container) {
|
||||
$backButton = new htmlButton('submit', _('Back'));
|
||||
$backButton->setIconClass('backButton');
|
||||
$container->addElement($backButton);
|
||||
$container->addElement(new htmlHiddenInput('type', $scope));
|
||||
$container->addElement(new htmlHiddenInput('type', $typeId));
|
||||
$createPDF = 0;
|
||||
if (isset($_POST['createPDF']) && ($_POST['createPDF'] == 'on')) {
|
||||
$createPDF = 1;
|
||||
|
@ -283,7 +293,7 @@ function massPrintBackButton($scope, $selectedModules, &$container) {
|
|||
$container->addElement(new htmlHiddenInput('createPDF', $createPDF));
|
||||
$container->addElement(new htmlHiddenInput('pdfStructure', $_POST['pdfStructure']));
|
||||
for ($i = 0; $i < sizeof($selectedModules); $i++) {
|
||||
$container->addElement(new htmlHiddenInput($scope . '_' . $selectedModules[$i], 'on'));
|
||||
$container->addElement(new htmlHiddenInput($typeId . '___' . $selectedModules[$i], 'on'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
namespace LAM\UPLOAD;
|
||||
/*
|
||||
$Id$
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||
Copyright (C) 2004 - 2013 Roland Gruber
|
||||
Copyright (C) 2004 - 2017 Roland Gruber
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -61,24 +62,26 @@ if (!isLoggedIn()) {
|
|||
setlanguage();
|
||||
|
||||
include '../main_header.php';
|
||||
$scope = htmlspecialchars($_SESSION['mass_scope']);
|
||||
$typeId = htmlspecialchars($_SESSION['mass_typeId']);
|
||||
$typeManager = new \LAM\TYPES\TypeManager();
|
||||
$type = $typeManager->getConfiguredType($typeId);
|
||||
|
||||
// check if account type is ok
|
||||
if (isAccountTypeHidden($scope)) {
|
||||
logNewMessage(LOG_ERR, 'User tried to access hidden upload: ' . $scope);
|
||||
if ($type->isHidden()) {
|
||||
logNewMessage(LOG_ERR, 'User tried to access hidden upload: ' . $type->getId());
|
||||
die();
|
||||
}
|
||||
if (!checkIfNewEntriesAreAllowed($scope) || !checkIfWriteAccessIsAllowed($scope)) {
|
||||
logNewMessage(LOG_ERR, 'User tried to access forbidden upload: ' . $scope);
|
||||
if (!checkIfNewEntriesAreAllowed($type->getId()) || !checkIfWriteAccessIsAllowed($type->getId())) {
|
||||
logNewMessage(LOG_ERR, 'User tried to access forbidden upload: ' . $type->getId());
|
||||
die();
|
||||
}
|
||||
|
||||
echo '<div id="uploadContent" class="' . $scope . '-bright smallPaddingContent">';
|
||||
echo '<div id="uploadContent" class="' . $type->getScope() . '-bright smallPaddingContent">';
|
||||
$tokenPrefix = '?' . getSecurityTokenName() . '=' . getSecurityTokenValue();
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function(){
|
||||
window.lam.upload.continueUpload('../misc/ajax.php' + '<?php echo $tokenPrefix; ?>' + '&function=upload&scope=' + '<?php echo $scope ?>');
|
||||
window.lam.upload.continueUpload('../misc/ajax.php' + '<?php echo $tokenPrefix; ?>' + '&function=upload&typeId=' + '<?php echo $type->getId() ?>');
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,9 +1,28 @@
|
|||
<?php
|
||||
namespace LAM\UPLOAD;
|
||||
use \htmlTable;
|
||||
use \htmlTableExtendedSelect;
|
||||
use \htmlSpacer;
|
||||
use \htmlOutputText;
|
||||
use \htmlGroup;
|
||||
use \htmlElement;
|
||||
use \htmlImage;
|
||||
use \htmlTableExtendedInputCheckbox;
|
||||
use \htmlDiv;
|
||||
use \htmlHiddenInput;
|
||||
use \htmlButton;
|
||||
use \htmlTitle;
|
||||
use \htmlInputFileUpload;
|
||||
use \htmlLink;
|
||||
use \htmlSubTitle;
|
||||
use \htmlHelpLink;
|
||||
use \htmlTableRow;
|
||||
use \moduleCache;
|
||||
/*
|
||||
$Id$
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||
Copyright (C) 2004 - 2016 Roland Gruber
|
||||
Copyright (C) 2004 - 2017 Roland Gruber
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -74,17 +93,18 @@ if (isset($_GET['getCSV'])) {
|
|||
exit;
|
||||
}
|
||||
|
||||
LAM\UPLOAD\Uploader::cleanSession();
|
||||
Uploader::cleanSession();
|
||||
|
||||
include '../main_header.php';
|
||||
|
||||
// get possible types and remove those which do not support file upload
|
||||
$types = $_SESSION['config']->get_ActiveTypes();
|
||||
$typeManager = new \LAM\TYPES\TypeManager();
|
||||
$types = $typeManager->getConfiguredTypes();
|
||||
$count = sizeof($types);
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$myType = new $types[$i]();
|
||||
if (!$myType->supportsFileUpload() || isAccountTypeHidden($types[$i])
|
||||
|| !checkIfNewEntriesAreAllowed($types[$i]) || !checkIfWriteAccessIsAllowed($types[$i])) {
|
||||
$myType = $types[$i];
|
||||
if (!$myType->getBaseType()->supportsFileUpload() || $myType->isHidden()
|
||||
|| !checkIfNewEntriesAreAllowed($myType->getId()) || !checkIfWriteAccessIsAllowed($myType->getId())) {
|
||||
unset($types[$i]);
|
||||
}
|
||||
}
|
||||
|
@ -93,26 +113,27 @@ $types = array_values($types);
|
|||
// check if account specific page should be shown
|
||||
if (isset($_POST['type'])) {
|
||||
// get selected type
|
||||
$scope = htmlspecialchars($_POST['type']);
|
||||
$typeId = htmlspecialchars($_POST['type']);
|
||||
$type = $typeManager->getConfiguredType($typeId);
|
||||
// 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);
|
||||
if (strpos($checkedBoxes[$i], $typeId . '___') === 0) {
|
||||
$selectedModules[] = substr($checkedBoxes[$i], strlen($typeId) + strlen('___'));
|
||||
}
|
||||
}
|
||||
$deps = getModulesDependencies($scope);
|
||||
$deps = getModulesDependencies($type->getScope());
|
||||
$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) . ")");
|
||||
getModuleAlias($depErrors[$i][0], $type->getScope()) . " (" .
|
||||
getModuleAlias($depErrors[$i][1], $type->getScope()) . ")");
|
||||
}
|
||||
}
|
||||
else {
|
||||
showMainPage($scope, $selectedModules);
|
||||
showMainPage($type, $selectedModules);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +141,7 @@ if (isset($_POST['type'])) {
|
|||
// show start page
|
||||
$divClass = 'user';
|
||||
if (isset($_REQUEST['type'])) {
|
||||
$divClass = $_REQUEST['type'];
|
||||
$divClass = \LAM\TYPES\getScopeFromTypeId($_REQUEST['type']);
|
||||
}
|
||||
echo '<div class="' . $divClass . '-bright smallPaddingContent">';
|
||||
echo "<div class=\"title\">\n";
|
||||
|
@ -141,15 +162,15 @@ $table = new htmlTable();
|
|||
|
||||
// account type
|
||||
$typeList = array();
|
||||
for ($i = 0; $i < sizeof($types); $i++) {
|
||||
$typeList[LAM\TYPES\getTypeAlias($types[$i])] = $types[$i];
|
||||
foreach ($types as $type) {
|
||||
$typeList[$type->getAlias()] = $type->getId();
|
||||
}
|
||||
$selectedType = array();
|
||||
if (isset($_REQUEST['type'])) {
|
||||
$selectedType[] = $_REQUEST['type'];
|
||||
}
|
||||
elseif (!empty($types)) {
|
||||
$selectedType[] = $types[0];
|
||||
$selectedType[] = $types[0]->getId();
|
||||
}
|
||||
$typeSelect = new htmlTableExtendedSelect('type', $typeList, $selectedType, _("Account type"));
|
||||
$typeSelect->setHasDescriptiveElements(true);
|
||||
|
@ -162,32 +183,32 @@ $moduleLabel = new htmlOutputText(_('Selected modules'));
|
|||
$moduleLabel->alignment = htmlElement::ALIGN_TOP;
|
||||
$table->addElement($moduleLabel);
|
||||
$moduleGroup = new htmlGroup();
|
||||
for ($i = 0; $i < sizeof($types); $i++) {
|
||||
foreach ($types as $type) {
|
||||
$divClasses = array('typeOptions');
|
||||
if ((!isset($_REQUEST['type']) && ($i != 0)) || (isset($_REQUEST['type']) && ($_REQUEST['type'] != $types[$i]))) {
|
||||
if ((!isset($_REQUEST['type']) && ($i != 0)) || (isset($_REQUEST['type']) && ($_REQUEST['type'] != $type->getId()))) {
|
||||
$divClasses[] = 'hidden';
|
||||
}
|
||||
$innerTable = new htmlTable();
|
||||
$modules = $_SESSION['config']->get_AccountModules($types[$i]);
|
||||
$modules = $_SESSION['config']->get_AccountModules($type->getId());
|
||||
for ($m = 0; $m < sizeof($modules); $m++) {
|
||||
if (($m != 0) && ($m%3 == 0)) {
|
||||
echo $innerTable->addNewLine();
|
||||
}
|
||||
$module = moduleCache::getModule($modules[$m], $types[$i]);
|
||||
$module = moduleCache::getModule($modules[$m], $type->getScope());
|
||||
$iconImage = $module->getIcon();
|
||||
if (!is_null($iconImage) && !(strpos($iconImage, 'http') === 0) && !(strpos($iconImage, '/') === 0)) {
|
||||
$iconImage = '../../graphics/' . $iconImage;
|
||||
}
|
||||
$innerTable->addElement(new htmlImage($iconImage));
|
||||
$enabled = true;
|
||||
if (is_base_module($modules[$m], $types[$i])) {
|
||||
if (is_base_module($modules[$m], $type->getScope())) {
|
||||
$enabled = false;
|
||||
}
|
||||
$checked = true;
|
||||
if (isset($_POST['submit']) && !isset($_POST[$types[$i] . '_' . $modules[$m]])) {
|
||||
if (isset($_POST['submit']) && !isset($_POST[$type->getId() . '___' . $modules[$m]])) {
|
||||
$checked = false;
|
||||
}
|
||||
$checkbox = new htmlTableExtendedInputCheckbox($types[$i] . '_' . $modules[$m], $checked, getModuleAlias($modules[$m], $types[$i]), null, false);
|
||||
$checkbox = new htmlTableExtendedInputCheckbox($type->getId() . '___' . $modules[$m], $checked, getModuleAlias($modules[$m], $type->getScope()), null, false);
|
||||
$checkbox->setIsEnabled($enabled);
|
||||
if ($enabled) {
|
||||
$innerTable->addElement($checkbox);
|
||||
|
@ -196,12 +217,12 @@ for ($i = 0; $i < sizeof($types); $i++) {
|
|||
$boxGroup = new htmlGroup();
|
||||
$boxGroup->addElement($checkbox);
|
||||
// add hidden field to fake disabled checkbox value
|
||||
$boxGroup->addElement(new htmlHiddenInput($types[$i] . '_' . $modules[$m], 'on'));
|
||||
$boxGroup->addElement(new htmlHiddenInput($type->getId() . '___' . $modules[$m], 'on'));
|
||||
$innerTable->addElement($boxGroup);
|
||||
}
|
||||
$innerTable->addElement(new htmlSpacer('10px', null));
|
||||
}
|
||||
$typeDiv = new htmlDiv($types[$i], $innerTable);
|
||||
$typeDiv = new htmlDiv($type->getId(), $innerTable);
|
||||
$typeDiv->setCSSClasses($divClasses);
|
||||
$moduleGroup->addElement($typeDiv);
|
||||
}
|
||||
|
@ -231,10 +252,11 @@ include '../main_footer.php';
|
|||
/**
|
||||
* Displays the acount type specific main page of the upload.
|
||||
*
|
||||
* @param string $scope account type
|
||||
* @param \LAM\TYPES\ConfiguredType $type account type
|
||||
* @param array $selectedModules list of selected account modules
|
||||
*/
|
||||
function showMainPage($scope, $selectedModules) {
|
||||
function showMainPage($type, $selectedModules) {
|
||||
$scope = $type->getScope();
|
||||
echo '<div class="' . $scope . '-bright smallPaddingContent">';
|
||||
// get input fields from modules
|
||||
$columns = getUploadColumns($scope, $selectedModules);
|
||||
|
@ -257,7 +279,7 @@ function showMainPage($scope, $selectedModules) {
|
|||
$inputContainer->addElement(new htmlInputFileUpload('inputfile'));
|
||||
$inputContainer->addElement(new htmlSpacer('10px', null));
|
||||
$inputContainer->addElement(new htmlLink(_("Download sample CSV file"), 'masscreate.php?getCSV=1', '../../graphics/save.png', true));
|
||||
$inputContainer->addElement(new htmlHiddenInput('scope', $scope));
|
||||
$inputContainer->addElement(new htmlHiddenInput('typeId', $type->getId()));
|
||||
$inputContainer->addElement(new htmlHiddenInput('selectedModules', implode(',', $selectedModules)), true);
|
||||
// PDF
|
||||
$createPDF = false;
|
||||
|
@ -267,7 +289,7 @@ function showMainPage($scope, $selectedModules) {
|
|||
$pdfCheckbox = new htmlTableExtendedInputCheckbox('createPDF', $createPDF, _('Create PDF files'));
|
||||
$pdfCheckbox->setTableRowsToShow(array('pdfStructure'));
|
||||
$inputContainer->addElement($pdfCheckbox, true);
|
||||
$pdfStructures = \LAM\PDF\getPDFStructures($scope);
|
||||
$pdfStructures = \LAM\PDF\getPDFStructures($type->getId());
|
||||
$pdfSelected = array();
|
||||
if (isset($_POST['pdfStructure'])) {
|
||||
$pdfSelected = array($_POST['pdfStructure']);
|
||||
|
@ -321,9 +343,9 @@ function showMainPage($scope, $selectedModules) {
|
|||
$dnSuffixRowCells[] = $columnSpacer;
|
||||
$dnSuffixRowCells[] = new htmlOutputText('dn_suffix');
|
||||
$dnSuffixRowCells[] = $columnSpacer;
|
||||
$dnSuffixRowCells[] = new htmlOutputText($_SESSION['config']->get_Suffix($scope));
|
||||
$dnSuffixRowCells[] = new htmlOutputText($type->getSuffix());
|
||||
$dnSuffixRowCells[] = $columnSpacer;
|
||||
$dnSuffixRowCells[] = new htmlOutputText($_SESSION['config']->get_Suffix($scope));
|
||||
$dnSuffixRowCells[] = new htmlOutputText($type->getSuffix());
|
||||
$dnSuffixRowCells[] = $columnSpacer;
|
||||
$dnSuffixRowCells[] = new htmlOutputText('');
|
||||
$dnSuffixRowCells[] = new htmlSpacer(null, '25px');
|
||||
|
@ -340,7 +362,7 @@ function showMainPage($scope, $selectedModules) {
|
|||
$dnRDNRowCells[] = $columnSpacer;
|
||||
$dnRDNRowCells[] = new htmlOutputText('dn_rdn');
|
||||
$dnRDNRowCells[] = $columnSpacer;
|
||||
$rdnAttributes = getRDNAttributes($scope, $selectedModules);
|
||||
$rdnAttributes = getRDNAttributes($type->getId(), $selectedModules);
|
||||
$dnRDNRowCells[] = new htmlOutputText($rdnAttributes[0]);
|
||||
$dnRDNRowCells[] = $columnSpacer;
|
||||
$dnRDNRowCells[] = new htmlOutputText('');
|
||||
|
@ -456,9 +478,9 @@ function showMainPage($scope, $selectedModules) {
|
|||
$sampleCSV_head[] = "\"" . $columns[$modules[$m]][$i]['name'] . "\"";
|
||||
}
|
||||
}
|
||||
$RDNs = getRDNAttributes($scope, $selectedModules);
|
||||
$RDNs = getRDNAttributes($type->getId(), $selectedModules);
|
||||
// DN attributes
|
||||
$sampleCSV_row[] = "\"" . $_SESSION['config']->get_Suffix($scope) . "\"";
|
||||
$sampleCSV_row[] = "\"" . $type->getSuffix() . "\"";
|
||||
$sampleCSV_row[] = "\"" . $RDNs[0] . "\"";
|
||||
// module attributes
|
||||
for ($m = 0; $m < sizeof($modules); $m++) {
|
||||
|
|
Loading…
Reference in New Issue