mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:38 +01:00
fixed defautl-records
This commit is contained in:
parent
10225ce9d8
commit
e004216f15
@ -147,8 +147,9 @@ class bodefinitions {
|
||||
*/
|
||||
public static function import( $_import_file )
|
||||
{
|
||||
$translation = CreateObject('phpgwapi.translation');
|
||||
if ( !is_file( $_import_file ) ) {
|
||||
throw new Exception("'$_import_file' is not a valid file" );
|
||||
throw new Exception("'$_import_file' does not exist or is not readable" );
|
||||
}
|
||||
|
||||
$data = arrayxml::xml2array( file_get_contents( $_import_file ) );
|
||||
@ -158,10 +159,10 @@ class bodefinitions {
|
||||
unset ( $data );
|
||||
|
||||
// convert charset into internal used charset
|
||||
$definitions = $GLOBALS['egw']->translation->convert(
|
||||
$definitions = $translation->convert(
|
||||
$definitions,
|
||||
$metainfo['charset'],
|
||||
$GLOBALS['egw']->translation->charset()
|
||||
$translation->charset()
|
||||
);
|
||||
|
||||
// save definition(s) into internal table
|
||||
@ -170,7 +171,7 @@ class bodefinitions {
|
||||
// convert allowed_user
|
||||
$definition_data['allowed_users'] = import_export_helper_functions::account_name2id( $definition_data['allowed_users'] );
|
||||
$definition_data['owner'] = import_export_helper_functions::account_name2id( $definition_data['owner'] );
|
||||
|
||||
|
||||
$definition = new definition( $definition_data['name'] );
|
||||
$definition_id = $definition->get_identifier() ? $definition->get_identifier() : NULL;
|
||||
|
||||
|
@ -97,7 +97,9 @@ class definition implements iface_egw_record {
|
||||
throw new Exception('Error: Definition: "'.$_name. '" is not unique! Can\'t convert to identifier');
|
||||
}
|
||||
if ( empty( $identifiers[0] ) ) {
|
||||
throw new Exception('Error: No such definition :"'.$_name.'"!');
|
||||
// not a good idea, till we don't have different exceptions so far
|
||||
// throw new Exception('Error: No such definition :"'.$_name.'"!');
|
||||
$identifiers = array( array( 'definition_id' => 0 ) );
|
||||
}
|
||||
return $identifiers[0]['definition_id'];
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class import_export_helper_functions {
|
||||
$account_ids[] = $account_id;
|
||||
}
|
||||
}
|
||||
return is_array( $_account_lids ) ? $account_ids : implode( ',', $account_ids );
|
||||
return is_array( $_account_lids ) ? $account_ids : implode( ',', (array)$account_ids );
|
||||
|
||||
} // end of member function account_lid2id
|
||||
|
||||
@ -50,7 +50,7 @@ class import_export_helper_functions {
|
||||
$account_lids[] = $account_lid;
|
||||
}
|
||||
}
|
||||
return is_array( $_account_id ) ? $account_lids : implode( ',', $account_lids );
|
||||
return is_array( $_account_id ) ? $account_lids : implode( ',', (array)$account_lids );
|
||||
} // end of member function account_id2lid
|
||||
|
||||
/**
|
||||
@ -66,7 +66,7 @@ class import_export_helper_functions {
|
||||
foreach ( $cat_ids as $cat_id ) {
|
||||
$cat_names[] = $cats->id2name( (int)$cat_id );
|
||||
}
|
||||
return is_array( $_cat_ids ) ? $cat_names : implode(',',$cat_names);
|
||||
return is_array( $_cat_ids ) ? $cat_names : implode(',',(array)$cat_names);
|
||||
} // end of member function category_id2name
|
||||
|
||||
/**
|
||||
@ -92,7 +92,7 @@ class import_export_helper_functions {
|
||||
}
|
||||
$cat_ids[] = $cat_id;
|
||||
}
|
||||
return is_array( $_cat_names ) ? $cat_ids : implode( ',', $cat_ids );
|
||||
return is_array( $_cat_names ) ? $cat_ids : implode( ',', (array)$cat_ids );
|
||||
|
||||
} // end of member function category_name2id
|
||||
|
||||
|
@ -10,8 +10,16 @@
|
||||
*/
|
||||
|
||||
require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.bodefinitions.inc.php');
|
||||
require_once(EGW_INCLUDE_ROOT. '/phpgwapi/inc/class.accounts.inc.php');
|
||||
require_once(EGW_INCLUDE_ROOT. '/phpgwapi/inc/class.translation.inc.php');
|
||||
|
||||
// some globals we need
|
||||
if ( !is_object($GLOBALS['egw']->accounts) ) $GLOBALS['egw']->accounts = new accounts();
|
||||
if ( !is_object($GLOBALS['egw']->translation) ) $GLOBALS['egw']->translation = new translation();
|
||||
if ( !is_object($GLOBALS['egw']->db)) $GLOBALS['egw']->db = $GLOBALS['egw_setup']->db;
|
||||
|
||||
// apps, whose definitions should be installed automatically
|
||||
// i don't know how to ask setup which apps are / ore are going to be installed.
|
||||
$appnames = array (
|
||||
'addressbook',
|
||||
);
|
||||
@ -23,7 +31,7 @@ foreach ($appnames as $appname) {
|
||||
|
||||
// step through each file in appdir
|
||||
while (false !== ($entry = $d->read())) {
|
||||
$file = $appdir. '/'. $entry;
|
||||
$file = $defdir. '/'. $entry;
|
||||
list( $filename, $extension) = explode('.',$entry);
|
||||
if ( $extension != 'xml' ) continue;
|
||||
bodefinitions::import( $file );
|
||||
|
Loading…
Reference in New Issue
Block a user