From 0cc31a4391bfdfeb2e7b00ce1c3b48e76b9af42c Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 15 Sep 2018 18:25:53 +0200 Subject: [PATCH] added checkbox to not stop on error --- lam/lib/import.inc | 9 ++++++++- lam/templates/tools/importexport.php | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lam/lib/import.inc b/lam/lib/import.inc index d96475f1..3c780c54 100644 --- a/lam/lib/import.inc +++ b/lam/lib/import.inc @@ -43,6 +43,7 @@ class Importer { const SESSION_KEY_TASKS = 'import_tasks'; const SESSION_KEY_COUNT = 'import_count'; + const SESSION_KEY_STOP_ON_ERROR = 'import_stop_on_error'; const STATUS = 'status'; const PROGRESS = 'progress'; const DATA = 'data'; @@ -118,6 +119,7 @@ class Importer { public function doImport() { $data = ''; $tasks = &$_SESSION[Importer::SESSION_KEY_TASKS]; + $stopOnError = $_SESSION[Importer::SESSION_KEY_STOP_ON_ERROR]; // check if any actions are needed at all if (empty($tasks)) { return $this->getStatus($data); @@ -129,7 +131,12 @@ class Importer { $data .= $task->run(); } catch (LAMException $e) { - return $this->stopImport($data, $e); + if ($stopOnError) { + return $this->stopImport($data, $e); + } + else { + $data .= Importer::formatMessage('ERROR', $e->getTitle(), $e->getMessage()); + } } } return $this->getStatus($data); diff --git a/lam/templates/tools/importexport.php b/lam/templates/tools/importexport.php index 8005b0b5..f5aa1ee1 100644 --- a/lam/templates/tools/importexport.php +++ b/lam/templates/tools/importexport.php @@ -74,6 +74,9 @@ if (isset($_SESSION[Importer::SESSION_KEY_TASKS])) { if (isset($_SESSION[Importer::SESSION_KEY_COUNT])) { unset($_SESSION[Importer::SESSION_KEY_COUNT]); } +if (isset($_SESSION[Importer::SESSION_KEY_STOP_ON_ERROR])) { + unset($_SESSION[Importer::SESSION_KEY_STOP_ON_ERROR]); +} include '../../lib/adminHeader.inc'; $tabindex = 1; @@ -142,6 +145,7 @@ function printImportTabContent(&$tabindex) { $container->addVerticalSpacer('1rem'); $container->add(new htmlResponsiveInputFileUpload('file', _('File'), '750'), 12); $container->add(new htmlResponsiveInputTextarea('text', '', '60', '20', _('LDIF data'), '750'), 12); + $container->add(new \htmlResponsiveInputCheckbox('noStop', false, _('Don\'t stop on errors')), 12); $container->addVerticalSpacer('3rem'); $button = new htmlButton('submitImport', _('Submit')); @@ -222,6 +226,7 @@ function checkImportData() { $tasks = $importer->getTasks($lines); $_SESSION[Importer::SESSION_KEY_TASKS] = $tasks; $_SESSION[Importer::SESSION_KEY_COUNT] = sizeof($tasks); + $_SESSION[Importer::SESSION_KEY_STOP_ON_ERROR] = (!isset($_POST['noStop']) || ($_POST['noStop'] != 'on')); } include '../../lib/adminFooter.inc';