mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 16:44:07 +01:00
If exporting a single record, name the download file accordingly
This commit is contained in:
parent
e75e112598
commit
4f59f282a0
@ -83,10 +83,7 @@ class addressbook_egw_record implements importexport_iface_egw_record
|
|||||||
*@return string tiltle
|
*@return string tiltle
|
||||||
*/
|
*/
|
||||||
public function get_title() {
|
public function get_title() {
|
||||||
if (empty($this->contact)) {
|
return $this->bocontacts->link_title(empty($this->contact) ? $this->identifier : $this->contact);
|
||||||
$this->get_record();
|
|
||||||
}
|
|
||||||
return $this->contact['fn'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,7 +33,7 @@ class addressbook_export_contacts_csv implements importexport_iface_export_plugi
|
|||||||
public function export( $_stream, importexport_definition $_definition) {
|
public function export( $_stream, importexport_definition $_definition) {
|
||||||
|
|
||||||
$options = $_definition->plugin_options;
|
$options = $_definition->plugin_options;
|
||||||
$export_object = new importexport_export_csv($_stream, (array)$options);
|
$this->export_object = $export_object = new importexport_export_csv($_stream, (array)$options);
|
||||||
|
|
||||||
$uicontacts = new addressbook_ui();
|
$uicontacts = new addressbook_ui();
|
||||||
$selection = array();
|
$selection = array();
|
||||||
@ -249,6 +249,19 @@ class addressbook_export_contacts_csv implements importexport_iface_export_plugi
|
|||||||
return 'text/csv';
|
return 'text/csv';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Suggest a file name for the downloaded file
|
||||||
|
* No suffix
|
||||||
|
*/
|
||||||
|
public function get_filename()
|
||||||
|
{
|
||||||
|
if(is_object($this->export_object) && $this->export_object->get_num_of_records() == 1)
|
||||||
|
{
|
||||||
|
return $this->export_object->record->get_title();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return html for options.
|
* return html for options.
|
||||||
* this way the plugin has all opertunities for options tab
|
* this way the plugin has all opertunities for options tab
|
||||||
|
@ -25,8 +25,8 @@ class addressbook_export_vcard implements importexport_iface_export_plugin {
|
|||||||
public function export( $_stream, importexport_definition $_definition) {
|
public function export( $_stream, importexport_definition $_definition) {
|
||||||
|
|
||||||
$options = $_definition->plugin_options;
|
$options = $_definition->plugin_options;
|
||||||
$uicontacts = new addressbook_ui();
|
$this->uicontacts = new addressbook_ui();
|
||||||
$selection = array();
|
$this->selection = array();
|
||||||
|
|
||||||
// Addressbook defines its own export imits
|
// Addressbook defines its own export imits
|
||||||
$limit_exception = bo_merge::is_export_limit_excepted();
|
$limit_exception = bo_merge::is_export_limit_excepted();
|
||||||
@ -46,24 +46,24 @@ class addressbook_export_vcard implements importexport_iface_export_plugin {
|
|||||||
$query['num_rows'] = -1; // all
|
$query['num_rows'] = -1; // all
|
||||||
$query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
|
$query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
|
||||||
if(!array_key_exists('filter',$query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id'];
|
if(!array_key_exists('filter',$query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id'];
|
||||||
$uicontacts->get_rows($query,$selection,$readonlys, true); // only return the ids
|
$this->uicontacts->get_rows($query,$this->selection,$readonlys, true); // only return the ids
|
||||||
}
|
}
|
||||||
elseif ( $options['selection'] == 'all_contacts' ) {
|
elseif ( $options['selection'] == 'all_contacts' ) {
|
||||||
if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) {
|
if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) {
|
||||||
$col_filter['account_id'] = null;
|
$col_filter['account_id'] = null;
|
||||||
}
|
}
|
||||||
$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$col_filter);
|
$this->selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$col_filter);
|
||||||
//$uicontacts->get_rows($query,$selection,$readonlys,true);
|
//$this->uicontacts->get_rows($query,$this->selection,$readonlys,true);
|
||||||
} else {
|
} else {
|
||||||
$selection = explode(',',$options['selection']);
|
$this->selection = explode(',',$options['selection']);
|
||||||
}
|
}
|
||||||
$GLOBALS['egw_info']['flags']['currentapp'] = $old_app;
|
$GLOBALS['egw_info']['flags']['currentapp'] = $old_app;
|
||||||
|
|
||||||
if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
|
if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
|
||||||
$selection = array_slice($selection, 0, $export_limit);
|
$this->selection = array_slice($this->selection, 0, $export_limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($selection as &$_contact) {
|
foreach ($this->selection as &$_contact) {
|
||||||
if(is_array($_contact) && ($_contact['id'] || $_contact['contact_id']))
|
if(is_array($_contact) && ($_contact['id'] || $_contact['contact_id']))
|
||||||
{
|
{
|
||||||
$_contact = $_contact[$_contact['id'] ? 'id' : 'contact_id'];
|
$_contact = $_contact[$_contact['id'] ? 'id' : 'contact_id'];
|
||||||
@ -74,7 +74,7 @@ class addressbook_export_vcard implements importexport_iface_export_plugin {
|
|||||||
$meta = stream_get_meta_data($_stream);
|
$meta = stream_get_meta_data($_stream);
|
||||||
|
|
||||||
$vcard = new addressbook_vcal();
|
$vcard = new addressbook_vcal();
|
||||||
$vcard->export($selection, $meta['uri']);
|
$vcard->export($this->selection, $meta['uri']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,6 +108,19 @@ class addressbook_export_vcard implements importexport_iface_export_plugin {
|
|||||||
return 'text/x-vcard';
|
return 'text/x-vcard';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Suggest a file name for the downloaded file
|
||||||
|
* No suffix
|
||||||
|
*/
|
||||||
|
public function get_filename()
|
||||||
|
{
|
||||||
|
if(is_array($this->selection) && count($this->selection) == 1)
|
||||||
|
{
|
||||||
|
return $this->uicontacts->link_title($this->selection[0]);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return html for options.
|
* return html for options.
|
||||||
* this way the plugin has all opertunities for options tab
|
* this way the plugin has all opertunities for options tab
|
||||||
|
@ -85,7 +85,7 @@ class infolog_egw_record implements importexport_iface_egw_record
|
|||||||
if (empty($this->record)) {
|
if (empty($this->record)) {
|
||||||
$this->get_record();
|
$this->get_record();
|
||||||
}
|
}
|
||||||
return $this->record['title'];
|
return self::$bo->link_title($this->record);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,8 +37,8 @@ class infolog_export_csv implements importexport_iface_export_plugin {
|
|||||||
$this->selects['info_priority'] = $this->bo->enums['priority'];
|
$this->selects['info_priority'] = $this->bo->enums['priority'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$export_object = new importexport_export_csv($_stream, (array)$options);
|
$this->export_object = new importexport_export_csv($_stream, (array)$options);
|
||||||
$export_object->set_mapping($options['mapping']);
|
$this->export_object->set_mapping($options['mapping']);
|
||||||
|
|
||||||
// do we need to query the cf's
|
// do we need to query the cf's
|
||||||
foreach($options['mapping'] as $field => $map) {
|
foreach($options['mapping'] as $field => $map) {
|
||||||
@ -77,18 +77,18 @@ class infolog_export_csv implements importexport_iface_export_plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->export_records($export_object, $options, $selection, $ids);
|
$this->export_records($this->export_object, $options, $selection, $ids);
|
||||||
$query['start'] += $query['num_rows'];
|
$query['start'] += $query['num_rows'];
|
||||||
} while($query['start'] < $query['total']);
|
} while($query['start'] < $query['total']);
|
||||||
|
|
||||||
return $export_object;
|
return $this->export_object;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$ids = $selection = explode(',',$options['selection']);
|
$ids = $selection = explode(',',$options['selection']);
|
||||||
$this->export_records($export_object, $options, $selection, $ids);
|
$this->export_records($this->export_object, $options, $selection, $ids);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $export_object;
|
return $this->export_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function export_records(&$export_object, $options, &$selection, $ids = array())
|
protected function export_records(&$export_object, $options, &$selection, $ids = array())
|
||||||
@ -182,6 +182,19 @@ class infolog_export_csv implements importexport_iface_export_plugin {
|
|||||||
return 'text/csv';
|
return 'text/csv';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Suggest a file name for the downloaded file
|
||||||
|
* No suffix
|
||||||
|
*/
|
||||||
|
public function get_filename()
|
||||||
|
{
|
||||||
|
if(is_object($this->export_object) && $this->export_object->get_num_of_records() == 1)
|
||||||
|
{
|
||||||
|
return $this->export_object->record->get_title();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return html for options.
|
* return html for options.
|
||||||
* this way the plugin has all opertunities for options tab
|
* this way the plugin has all opertunities for options tab
|
||||||
|
@ -38,16 +38,16 @@ class infolog_export_ical extends infolog_export_csv {
|
|||||||
case 'all':
|
case 'all':
|
||||||
$query['num_rows'] = $export_limit ? $export_limit : -1;
|
$query['num_rows'] = $export_limit ? $export_limit : -1;
|
||||||
$query['start'] = 0;
|
$query['start'] = 0;
|
||||||
$selection = $this->bo->search($query);
|
$this->selection = $this->bo->search($query);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$ids = $selection = explode(',',$options['selection']);
|
$ids = $this->selection = explode(',',$options['selection']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$boical = new infolog_ical();
|
$boical = new infolog_ical();
|
||||||
fwrite($_stream, $boical->exportvCalendar($selection));
|
fwrite($_stream, $boical->exportvCalendar($this->selection));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,6 +81,19 @@ class infolog_export_ical extends infolog_export_csv {
|
|||||||
return 'text/infolog';
|
return 'text/infolog';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Suggest a file name for the downloaded file
|
||||||
|
* No suffix
|
||||||
|
*/
|
||||||
|
public function get_filename()
|
||||||
|
{
|
||||||
|
if(is_array($this->selection) && count($this->selection) == 1)
|
||||||
|
{
|
||||||
|
return $this->bo->link_title(current($this->selection));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return html for options.
|
* return html for options.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user