From 83bbea7669b838ecb36428fb82ceedee15527ed5 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 16 Mar 2011 17:07:32 +0000 Subject: [PATCH] Try to set some default values for export definitions --- .../class.importexport_definitions_bo.inc.php | 8 -------- importexport/setup/default_records.inc.php | 11 ++++++++++ importexport/setup/setup.inc.php | 2 +- importexport/setup/tables_update.inc.php | 20 +++++++++++++++++++ 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/importexport/inc/class.importexport_definitions_bo.inc.php b/importexport/inc/class.importexport_definitions_bo.inc.php index b1d65a6cee..eed39ca10d 100644 --- a/importexport/inc/class.importexport_definitions_bo.inc.php +++ b/importexport/inc/class.importexport_definitions_bo.inc.php @@ -175,14 +175,6 @@ class importexport_definitions_bo { $definition->set_record( $definition_data ); $definition->save( $definition_id ); } - - // Set as default definition for the app, if there is no site default yet - if($definition->type == 'export' && $definition->name == 'export-'.$definition->application && - !$GLOBALS['egw']->preferences->default[$definition->application]['nextmatch-export-definition']) - { - $GLOBALS['egw']->preferences->add($definition->application, 'nextmatch-export-definition', $definition->name, 'default'); - $GLOBALS['egw']->preferences->save_repository(true, 'default'); - } } } diff --git a/importexport/setup/default_records.inc.php b/importexport/setup/default_records.inc.php index 1479c4f674..03ae567509 100644 --- a/importexport/setup/default_records.inc.php +++ b/importexport/setup/default_records.inc.php @@ -33,4 +33,15 @@ while (false !== ($appdir = $egwdir->read())) { if ( $extension != 'xml' ) continue; importexport_definitions_bo::import( $file ); } + + // Set as default definition for the app, if there is no site default yet + if(!$GLOBALS['egw']->preferences->default[$appdir]['nextmatch-export-definition']) { + $bo = new importexport_definitions_bo(array('name' => "export-$appdir")); + $definitions = $bo->get_definitions(); + if($definitions[0]) { + $definition = $definition[0]; + $GLOBALS['egw']->preferences->add($appdir, 'nextmatch-export-definition', "export-$appdir", 'default'); + $GLOBALS['egw']->preferences->save_repository(true, 'default'); + } + } } diff --git a/importexport/setup/setup.inc.php b/importexport/setup/setup.inc.php index 6207345c4c..6280cca651 100644 --- a/importexport/setup/setup.inc.php +++ b/importexport/setup/setup.inc.php @@ -10,7 +10,7 @@ */ $setup_info['importexport']['name'] = 'importexport'; -$setup_info['importexport']['version'] = '1.9.001'; +$setup_info['importexport']['version'] = '1.9.002'; $setup_info['importexport']['app_order'] = 2; $setup_info['importexport']['enable'] = 2; $setup_info['importexport']['tables'] = array('egw_importexport_definitions'); diff --git a/importexport/setup/tables_update.inc.php b/importexport/setup/tables_update.inc.php index eb207dd26e..5dd8dddabb 100755 --- a/importexport/setup/tables_update.inc.php +++ b/importexport/setup/tables_update.inc.php @@ -55,3 +55,23 @@ function importexport_upgrade1_8() return $GLOBALS['setup_info']['importexport']['currentver'] = '1.9.001'; } +function importexport_upgrade1_9_001() +{ + $egwdir = dir(EGW_INCLUDE_ROOT); + while (false !== ($appdir = $egwdir->read())) { + $defdir = EGW_INCLUDE_ROOT. "/$appdir/setup/"; + if ( !is_dir( $defdir ) ) continue; + + // Set as default definition for the app, if there is no site default yet + if(!$GLOBALS['egw']->preferences->default[$appdir]['nextmatch-export-definition']) { + $bo = new importexport_definitions_bo(array('name' => "export-$appdir*")); + $definitions = $bo->get_definitions(); + if($definitions[0]) { + $definition = $bo->read($definitions[0]); + $GLOBALS['egw']->preferences->add($appdir, 'nextmatch-export-definition', $definition['name'], 'default'); + } + } + } + $GLOBALS['egw']->preferences->save_repository(true, 'default'); + return $GLOBALS['setup_info']['importexport']['currentver'] = '1.9.002'; +}