Try to set some default values for export definitions

This commit is contained in:
Nathan Gray 2011-03-16 17:07:32 +00:00
parent 2e752e17b6
commit 83bbea7669
4 changed files with 32 additions and 9 deletions

View File

@ -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');
}
}
}

View File

@ -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');
}
}
}

View File

@ -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');

View File

@ -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';
}