mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 00:54:50 +01:00
Some data conversions from internal to something with more meaning:
Dates, times, User IDs, Category IDs
This commit is contained in:
parent
82793d32b0
commit
b93ad4c5f1
@ -42,7 +42,7 @@ class addressbook_egw_record implements importexport_iface_egw_record
|
||||
* @param string $_attribute_name
|
||||
*/
|
||||
public function __get($_attribute_name) {
|
||||
|
||||
return $this->contact[$_attribute_name];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,7 +52,7 @@ class addressbook_egw_record implements importexport_iface_egw_record
|
||||
* @param data $data
|
||||
*/
|
||||
public function __set($_attribute_name, $data) {
|
||||
|
||||
$this->contact[$_attribute_name] = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,6 +16,13 @@
|
||||
*/
|
||||
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'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Exports records as defined in $_definition
|
||||
*
|
||||
@ -46,6 +53,9 @@ class addressbook_export_contacts_csv implements importexport_iface_export_plugi
|
||||
// support other selectors atm.
|
||||
foreach ($selection as $identifier) {
|
||||
$contact = new addressbook_egw_record($identifier);
|
||||
|
||||
// Some conversion
|
||||
$this->convert($contact);
|
||||
$export_object->export_record($contact);
|
||||
unset($contact);
|
||||
}
|
||||
@ -99,4 +109,42 @@ class addressbook_export_contacts_csv implements importexport_iface_export_plugi
|
||||
public function get_selectors_etpl() {
|
||||
return 'addressbook.export_csv_selectors';
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert some internal data to something with more meaning
|
||||
*
|
||||
* Dates, times, user IDs, category IDs
|
||||
*/
|
||||
public static function convert(addressbook_egw_record &$record) {
|
||||
$custom = config::get_customfields('addressbook');
|
||||
foreach($custom as $name => $c_field) {
|
||||
$name = '#' . $name;
|
||||
if($c_field['type'] == 'date') {
|
||||
self::$types['date-time'][] = $name;
|
||||
} elseif ($c_field['type'] == 'select-account') {
|
||||
self::$types['select-account'][] = $name;
|
||||
}
|
||||
}
|
||||
foreach(self::$types['select-account'] as $name) {
|
||||
if ($record->$name) {
|
||||
$record->$name = $GLOBALS['egw']->common->grab_owner_name($record->$name);
|
||||
} elseif ($name == 'owner') {
|
||||
$record->$name = lang('Accounts');
|
||||
}
|
||||
}
|
||||
foreach(self::$types['date-time'] as $name) {
|
||||
if ($record->$name) $record->$name = date('Y-m-d H:i:s',$record->$name);
|
||||
}
|
||||
if ($record->tel_prefer) {
|
||||
$field = $record->tel_prefer;
|
||||
$record->tel_prefer = $record->$field;
|
||||
}
|
||||
|
||||
$cats = array();
|
||||
foreach(explode(',',$record->cat_id) as $n => $cat_id) {
|
||||
if ($cat_id) $cats[] = $GLOBALS['egw']->categories->id2name($cat_id);
|
||||
}
|
||||
|
||||
$record->cat_id = implode(', ',$cats);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user