From 98f6c2bf84bf7e0b2c8a016ab581da908c78f6e0 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sun, 23 Sep 2018 10:05:06 +0200 Subject: [PATCH] export --- lam/templates/tools/importexport.php | 80 +++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 7 deletions(-) diff --git a/lam/templates/tools/importexport.php b/lam/templates/tools/importexport.php index a10a12f4..cf3ec4bf 100644 --- a/lam/templates/tools/importexport.php +++ b/lam/templates/tools/importexport.php @@ -85,12 +85,20 @@ if (isset($_SESSION[Importer::SESSION_KEY_STOP_ON_ERROR])) { } include '../../lib/adminHeader.inc'; - $tabindex = 1; +$tabindex = 1; +$activeTab = 0; +if (!empty($_GET['tab']) && ($_GET['tab'] === 'export')) { + $activeTab = 1; +} + ?> @@ -135,7 +143,7 @@ include '../../lib/adminHeader.inc'; * @param int $tabindex tabindex */ function printImportTabContent(&$tabindex) { - echo "
\n"; + echo "\n"; $container = new htmlResponsiveRow(); $container->add(new htmlTitle(_("Import")), 12); $sources = array( @@ -187,7 +195,7 @@ function printImportTabProcessing(&$tabindex) { printImportTabContent($tabindex); return; } - echo "\n"; + echo "\n"; $container = new htmlResponsiveRow(); $container->add(new htmlTitle(_("Import")), 12); @@ -249,13 +257,15 @@ function checkImportData() { * @param int $tabindex tabindex */ function printExportTabContent(&$tabindex) { - echo "\n"; + echo "\n"; $container = new htmlResponsiveRow(); $container->add(new htmlTitle(_("Export")), 12); - $container->addLabel(new htmlOutputText(_('Base DN'))); + $container->addLabel(new htmlOutputText(_('Base DN'), true, true)); $baseDnGroup = new htmlGroup(); - $baseDnGroup->addElement(new htmlInputField('baseDn', getDefaultBaseDn())); + $baseDnInput = new htmlInputField('baseDn', getDefaultBaseDn()); + $baseDnInput->setRequired(true); + $baseDnGroup->addElement($baseDnInput); $container->addField($baseDnGroup); $searchScopes = array( @@ -321,4 +331,60 @@ function getDefaultBaseDn() { return $baseDn; } +/** + * Prints the content area for the export tab during processing state. + * + * @param int $tabindex tabindex + */ +function printExportTabProcessing(&$tabindex) { + try { + checkExportData(); + } + catch (LAMException $e) { + $container = new htmlResponsiveRow(); + $container->add(new htmlStatusMessage('ERROR', $e->getTitle(), $e->getMessage()), 12); + parseHtml(null, $container, array(), false, $tabindex, 'user'); + printExportTabContent($tabindex); + return; + } + echo "\n"; + $container = new htmlResponsiveRow(); + $container->add(new htmlTitle(_("Export")), 12); + + $container->add(new htmlDiv('statusExportInprogress', new htmlOutputText(_('Status') . ': ' . _('in progress'))), 12); + $container->add(new htmlDiv('statusExportDone', new htmlOutputText(_('Status') . ': ' . _('done')), array('hidden')), 12); + $container->add(new htmlDiv('statusExportFailed', new htmlOutputText(_('Status') . ': ' . _('failed')), array('hidden')), 12); + $container->addVerticalSpacer('1rem'); + $container->add(new htmlDiv('progressbarExport', new htmlOutputText('')), 12); + $container->addVerticalSpacer('3rem'); + $button = new htmlButton('submitExportCancel', _('Cancel')); + $container->add($button, 12, 12, 12, 'text-center'); + + $newExportButton = new htmlLink(_('New export'), null, null, true); + $container->add($newExportButton, 12, 12, 12, 'text-center hidden newexport'); + + $container->addVerticalSpacer('3rem'); + + $container->add(new htmlDiv('exportResults', new htmlOutputText('')), 12); + $container->add(new htmlJavaScript( + 'window.lam.export.startExport(\'' . getSecurityTokenName() . '\', \'' . getSecurityTokenValue() . '\');' + ), 12); + + addSecurityTokenToMetaHTML($container); + + parseHtml(null, $container, array(), false, $tabindex, 'user'); + echo ("
\n"); +} + +/** + * Checks if the export data is ok. + * + * @throws LAMException error message if not valid + */ +function checkExportData() { + if (empty($_POST['baseDn'])) { + throw new LAMException(_('This field is required.'), _('Base DN')); + } +} + include '../../lib/adminFooter.inc';