mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-18 14:03:19 +01:00
fixed default-records
This commit is contained in:
parent
15ad7469de
commit
c1a2bd342f
@ -147,8 +147,9 @@ class bodefinitions {
|
|||||||
*/
|
*/
|
||||||
public static function import( $_import_file )
|
public static function import( $_import_file )
|
||||||
{
|
{
|
||||||
|
$translation = CreateObject('phpgwapi.translation');
|
||||||
if ( !is_file( $_import_file ) ) {
|
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 ) );
|
$data = arrayxml::xml2array( file_get_contents( $_import_file ) );
|
||||||
@ -158,10 +159,10 @@ class bodefinitions {
|
|||||||
unset ( $data );
|
unset ( $data );
|
||||||
|
|
||||||
// convert charset into internal used charset
|
// convert charset into internal used charset
|
||||||
$definitions = $GLOBALS['egw']->translation->convert(
|
$definitions = $translation->convert(
|
||||||
$definitions,
|
$definitions,
|
||||||
$metainfo['charset'],
|
$metainfo['charset'],
|
||||||
$GLOBALS['egw']->translation->charset()
|
$translation->charset()
|
||||||
);
|
);
|
||||||
|
|
||||||
// save definition(s) into internal table
|
// save definition(s) into internal table
|
||||||
|
@ -96,6 +96,11 @@ class definition implements iface_egw_record {
|
|||||||
if (isset($identifiers[1])) {
|
if (isset($identifiers[1])) {
|
||||||
throw new Exception('Error: Definition: "'.$_name. '" is not unique! Can\'t convert to identifier');
|
throw new Exception('Error: Definition: "'.$_name. '" is not unique! Can\'t convert to identifier');
|
||||||
}
|
}
|
||||||
|
if ( empty( $identifiers[0] ) ) {
|
||||||
|
// 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'];
|
return $identifiers[0]['definition_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class import_export_helper_functions {
|
|||||||
$account_ids[] = $account_id;
|
$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
|
} // end of member function account_lid2id
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ class import_export_helper_functions {
|
|||||||
$account_lids[] = $account_lid;
|
$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
|
} // end of member function account_id2lid
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,7 +66,7 @@ class import_export_helper_functions {
|
|||||||
foreach ( $cat_ids as $cat_id ) {
|
foreach ( $cat_ids as $cat_id ) {
|
||||||
$cat_names[] = $cats->id2name( (int)$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
|
} // end of member function category_id2name
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,7 +92,7 @@ class import_export_helper_functions {
|
|||||||
}
|
}
|
||||||
$cat_ids[] = $cat_id;
|
$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
|
} // 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. '/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
|
// 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 (
|
$appnames = array (
|
||||||
'addressbook',
|
'addressbook',
|
||||||
);
|
);
|
||||||
@ -23,7 +31,7 @@ foreach ($appnames as $appname) {
|
|||||||
|
|
||||||
// step through each file in appdir
|
// step through each file in appdir
|
||||||
while (false !== ($entry = $d->read())) {
|
while (false !== ($entry = $d->read())) {
|
||||||
$file = $appdir. '/'. $entry;
|
$file = $defdir. '/'. $entry;
|
||||||
list( $filename, $extension) = explode('.',$entry);
|
list( $filename, $extension) = explode('.',$entry);
|
||||||
if ( $extension != 'xml' ) continue;
|
if ( $extension != 'xml' ) continue;
|
||||||
bodefinitions::import( $file );
|
bodefinitions::import( $file );
|
||||||
|
Loading…
Reference in New Issue
Block a user