Use static convert from importexport to handle human values, custom fields

This commit is contained in:
Nathan Gray 2011-05-12 18:01:34 +00:00
parent 59a0fc75ad
commit 450b380de1
3 changed files with 11 additions and 7 deletions

View File

@ -22,6 +22,12 @@ class addressbook_egw_record implements importexport_iface_egw_record
private $contact = array();
private $bocontacts;
// Used in conversions
static $types = array(
'select-account' => array('owner','creator','modifier'),
'date-time' => array('modified','created','last_event','next_event'),
'select-cat' => array('cat_id'),
);
/**

View File

@ -16,12 +16,6 @@
*/
class addressbook_export_contacts_csv implements importexport_iface_export_plugin {
// Used in conversions
static $types = array(
'select-account' => array('owner','creator','modifier'),
'date-time' => array('modified','created','last_event','next_event'),
'select-cat' => array('cat_id'),
);
/**
* Constants used for exploding categories & multi-selectboxes into seperate fields
@ -195,7 +189,7 @@ class addressbook_export_contacts_csv implements importexport_iface_export_plugi
// Some conversion
$this->convert($contact, $options);
if($options['convert']) {
importexport_export_csv::convert($contact, self::$types, 'addressbook');
importexport_export_csv::convert($contact, addressbook_egw_record::$types, 'addressbook');
} else {
// Implode arrays, so they don't say 'Array'
foreach($contact->get_record_array() as $key => $value) {

View File

@ -133,6 +133,8 @@ class addressbook_import_contacts_csv implements importexport_iface_import_plugi
$import_csv->skip_records(1);
}
$_lookups = array();
// set eventOwner
$_definition->plugin_options['contact_owner'] = isset( $_definition->plugin_options['contact_owner'] ) ?
$_definition->plugin_options['contact_owner'] : $this->user;
@ -150,6 +152,8 @@ class addressbook_import_contacts_csv implements importexport_iface_import_plugi
// don't import empty contacts
if( count( array_unique( $record ) ) < 2 ) continue;
importexport_import_csv::convert($record, addressbook_egw_record::$types, 'addressbook', $_lookups);
// Set owner, unless it's supposed to come from CSV file
if($_definition->plugin_options['owner_from_csv']) {
if($record['owner'] && !is_numeric($record['owner'])) {