From 3b2862a63b2a4b92edc71a966c39dd7ba01c1fb9 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 20 Dec 2011 19:01:16 +0000 Subject: [PATCH] Hold on to import file while doing dry run, so user can just click import again --- .../inc/class.importexport_import_ui.inc.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/importexport/inc/class.importexport_import_ui.inc.php b/importexport/inc/class.importexport_import_ui.inc.php index a2f4e61b60..d744774699 100644 --- a/importexport/inc/class.importexport_import_ui.inc.php +++ b/importexport/inc/class.importexport_import_ui.inc.php @@ -56,15 +56,31 @@ $content['delimiter'] == 'other' ? $content['other_delimiter'] : $content['delimiter']; $definition_obj->plugin_options = $options; } + $plugin = new $definition_obj->plugin; $file = fopen($content['file']['tmp_name'], 'r'); // Some of the translation, conversion, etc look here $GLOBALS['egw_info']['flags']['currentapp'] = $appname; + // Destination if we need to hold the file + $cachefile = new egw_cache_files(array()); + $dst_file = $cachefile->filename(egw_cache::keys(egw_cache::INSTANCE, 'importexport', + 'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id']), true),true); if($content['dry-run']) { echo $this->preview($file, $definition_obj); + // Keep file + if($dst_file) + { + if(copy($content['file']['tmp_name'],$dst_file)) { + $preserve['file']['tmp_name'] = $dst_file; + } + } + } elseif ($dst_file && $content['file']['tmp_name'] == $dst_file) { + // Remove file + $cachefile->delete(egw_cache::keys(egw_cache::INSTANCE, 'importexport', + 'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id']))); } $count = $plugin->import($file, $definition_obj);