Add last date & next date as exportable fields

This commit is contained in:
Nathan Gray 2015-03-03 22:26:21 +00:00
parent 4295d84746
commit d8ffcb1d74
3 changed files with 39 additions and 3 deletions

View File

@ -13,7 +13,11 @@
/**
* class addressbook_egw_record
* compability layer for iface_egw_record needet for importexport
* compability layer for iface_egw_record needed for importexport
*
* Note that last_event and next_event are not automatically loaded by
* addressbook_bo->read(), so if you need them use:
* addressbook_bo->read_calendar();
*/
class addressbook_egw_record implements importexport_iface_egw_record
{

View File

@ -241,6 +241,24 @@ class addressbook_export_contacts_csv implements importexport_iface_export_plugi
}
$export_object->set_mapping($options['mapping']);
// Add in last/next event, if needed
if($options['mapping']['last_date'] || $options['mapping']['next_date'])
{
$contact_ids = array();
foreach($selection as $_contact)
{
if(is_array($_contact) && $_contact['id'])
{
$contact_ids[] = $_contact['id'];
}
else
{
$contact_ids[] = $contact;
}
}
$events = $this->ui->read_calendar($contact_ids, false);
}
// $options['selection'] is array of identifiers as this plugin doesn't
// support other selectors atm.
@ -257,6 +275,14 @@ class addressbook_export_contacts_csv implements importexport_iface_export_plugi
} else {
$contact = new addressbook_egw_record($_contact);
}
if($events && $events[$contact->id])
{
// NB: last_date and next_date are used instead of last_event & next_event
// to avoid automatic conversion - we want to export link title, not date-time
$contact->last_date = $events[$contact->id]['last_link']['title'];
$contact->next_date = $events[$contact->id]['next_link']['title'];
}
// Some conversion
$this->convert($contact, $options);
if($options['convert']) {
@ -400,12 +426,12 @@ class addressbook_export_contacts_csv implements importexport_iface_export_plugi
* Adjust automatically generated filter fields
*/
public function get_filter_fields(Array &$filters)
{
{
unset($filters['last_event']);
unset($filters['next_event']);
foreach($filters as $field_name => &$settings)
{
if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
}
$filters['owner'] = array(
'name' => 'owner',

View File

@ -24,6 +24,12 @@ class addressbook_wizard_export_contacts_csv extends importexport_wizard_basic_e
$this->export_fields['#'.$name] = $data['label'];
}
unset($this->export_fields['jpegphoto']); // can't cvs export that
// Add in last/next appointments
// NB: last_date and next_date are used instead of last_event & next_event
// to avoid automatic conversion - we want to export link title, not date-time
$this->export_fields['last_date'] = lang('Last date');
$this->export_fields['next_date'] = lang('Next date');
}
/**