mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-21 15:33:23 +01:00
Import/Export - change signature of method that gets options to allow definition-specific values
Do export too, for consistency
This commit is contained in:
parent
85a3b3e027
commit
8451836a92
@ -349,9 +349,19 @@ class addressbook_export_contacts_csv implements importexport_iface_export_plugi
|
||||
* return html for options.
|
||||
* this way the plugin has all opertunities for options tab
|
||||
*
|
||||
* @return string html
|
||||
* @param $definition Specific definition
|
||||
*
|
||||
* @return array (
|
||||
* name => string,
|
||||
* content => array,
|
||||
* sel_options => array,
|
||||
* readonlys => array,
|
||||
* preserv => array,
|
||||
* )
|
||||
*/
|
||||
public function get_options_etpl() {
|
||||
public function get_options_etpl(importexport_definition &$definition = NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,8 @@ use EGroupware\Api;
|
||||
/**
|
||||
* export addressbook contacts as vcard
|
||||
*/
|
||||
class addressbook_export_vcard implements importexport_iface_export_plugin {
|
||||
class addressbook_export_vcard implements importexport_iface_export_plugin
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
@ -24,7 +25,8 @@ class addressbook_export_vcard implements importexport_iface_export_plugin {
|
||||
*
|
||||
* @param egw_record $_definition
|
||||
*/
|
||||
public function export( $_stream, importexport_definition $_definition) {
|
||||
public function export( $_stream, importexport_definition $_definition)
|
||||
{
|
||||
|
||||
$options = $_definition->plugin_options;
|
||||
$this->uicontacts = new addressbook_ui();
|
||||
@ -33,7 +35,8 @@ class addressbook_export_vcard implements importexport_iface_export_plugin {
|
||||
// Addressbook defines its own export imits
|
||||
$limit_exception = Api\Storage\Merge::is_export_limit_excepted();
|
||||
$export_limit = Api\Storage\Merge::getExportLimit($app='addressbook');
|
||||
if($export_limit == 'no' && !$limit_exception) {
|
||||
if($export_limit == 'no' && !$limit_exception)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@ -41,7 +44,8 @@ class addressbook_export_vcard implements importexport_iface_export_plugin {
|
||||
$old_app = $GLOBALS['egw_info']['flags']['currentapp'];
|
||||
$GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook';
|
||||
|
||||
if ($options['selection'] == 'search') {
|
||||
if ($options['selection'] == 'search')
|
||||
{
|
||||
// uicontacts selection with checkbox 'use_all'
|
||||
$query = Api\Cache::getSession('addressbook', 'index');
|
||||
$query['num_rows'] = -1; // all
|
||||
@ -50,22 +54,28 @@ class addressbook_export_vcard implements importexport_iface_export_plugin {
|
||||
$readonlys = null;
|
||||
$this->uicontacts->get_rows($query,$this->selection,$readonlys, true); // only return the ids
|
||||
}
|
||||
elseif ( $options['selection'] == 'all' ) {
|
||||
if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1') {
|
||||
elseif ( $options['selection'] == 'all' )
|
||||
{
|
||||
if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1')
|
||||
{
|
||||
$col_filter['account_id'] = null;
|
||||
}
|
||||
$this->selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$col_filter);
|
||||
//$this->uicontacts->get_rows($query,$this->selection,$readonlys,true);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->selection = explode(',',$options['selection']);
|
||||
}
|
||||
$GLOBALS['egw_info']['flags']['currentapp'] = $old_app;
|
||||
|
||||
if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) {
|
||||
if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception)
|
||||
{
|
||||
$this->selection = array_slice($this->selection, 0, $export_limit);
|
||||
}
|
||||
|
||||
foreach ($this->selection as &$_contact) {
|
||||
foreach ($this->selection as &$_contact)
|
||||
{
|
||||
if(is_array($_contact) && ($_contact['id'] || $_contact['contact_id']))
|
||||
{
|
||||
$_contact = $_contact[$_contact['id'] ? 'id' : 'contact_id'];
|
||||
@ -86,7 +96,8 @@ class addressbook_export_vcard implements importexport_iface_export_plugin {
|
||||
*
|
||||
* @return string name
|
||||
*/
|
||||
public static function get_name() {
|
||||
public static function get_name()
|
||||
{
|
||||
return lang('Addressbook vCard export');
|
||||
}
|
||||
|
||||
@ -95,7 +106,8 @@ class addressbook_export_vcard implements importexport_iface_export_plugin {
|
||||
*
|
||||
* @return string descriprion
|
||||
*/
|
||||
public static function get_description() {
|
||||
public static function get_description()
|
||||
{
|
||||
return lang("Exports contacts from your Addressbook into a vCard File.");
|
||||
}
|
||||
|
||||
@ -104,11 +116,13 @@ class addressbook_export_vcard implements importexport_iface_export_plugin {
|
||||
*
|
||||
* @return string suffix
|
||||
*/
|
||||
public static function get_filesuffix() {
|
||||
public static function get_filesuffix()
|
||||
{
|
||||
return 'vcf';
|
||||
}
|
||||
|
||||
public static function get_mimetype() {
|
||||
public static function get_mimetype()
|
||||
{
|
||||
return 'text/x-vcard';
|
||||
}
|
||||
|
||||
@ -126,19 +140,29 @@ class addressbook_export_vcard implements importexport_iface_export_plugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* return html for options.
|
||||
* this way the plugin has all opertunities for options tab
|
||||
* Return array of settings for export dialog
|
||||
*
|
||||
* @return string html
|
||||
* @param $definition Specific definition
|
||||
*
|
||||
* @return array (
|
||||
* name => string,
|
||||
* content => array,
|
||||
* sel_options => array,
|
||||
* readonlys => array,
|
||||
* preserv => array,
|
||||
* )
|
||||
*/
|
||||
public function get_options_etpl() {
|
||||
public function get_options_etpl(importexport_definition &$definition = NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns slectors of this plugin via xajax
|
||||
*
|
||||
*/
|
||||
public function get_selectors_etpl() {
|
||||
public function get_selectors_etpl()
|
||||
{
|
||||
return array(
|
||||
'name' => 'addressbook.export_vcard_selectors',
|
||||
'content' => 'all',
|
||||
|
@ -222,13 +222,23 @@ class calendar_export_csv implements importexport_iface_export_plugin {
|
||||
{
|
||||
return 'text/csv';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* return html for options.
|
||||
* Return array of settings for export dialog
|
||||
*
|
||||
* @param $definition Specific definition
|
||||
*
|
||||
* @return array (
|
||||
* name => string,
|
||||
* content => array,
|
||||
* sel_options => array,
|
||||
* readonlys => array,
|
||||
* preserv => array,
|
||||
* )
|
||||
*/
|
||||
public function get_options_etpl($definition = null)
|
||||
public function get_options_etpl(importexport_definition &$definition = NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -124,13 +124,23 @@ class calendar_export_ical extends calendar_export_csv {
|
||||
}
|
||||
|
||||
/**
|
||||
* return html for options.
|
||||
* Return array of settings for export dialog
|
||||
*
|
||||
* @param $definition Specific definition
|
||||
*
|
||||
* @return array (
|
||||
* name => string,
|
||||
* content => array,
|
||||
* sel_options => array,
|
||||
* readonlys => array,
|
||||
* preserv => array,
|
||||
* )
|
||||
*/
|
||||
public function get_options_etpl($definition = null) {
|
||||
unset($definition); // not used, but required by function signature
|
||||
public function get_options_etpl(importexport_definition &$definition = NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* returns selectors of this plugin
|
||||
*
|
||||
|
@ -251,10 +251,19 @@ class infolog_export_csv implements importexport_iface_export_plugin
|
||||
* return html for options.
|
||||
* this way the plugin has all opertunities for options tab
|
||||
*
|
||||
* @return string html
|
||||
* @param $definition Specific definition
|
||||
*
|
||||
* @return array (
|
||||
* name => string,
|
||||
* content => array,
|
||||
* sel_options => array,
|
||||
* readonlys => array,
|
||||
* preserv => array,
|
||||
* )
|
||||
*/
|
||||
public function get_options_etpl()
|
||||
public function get_options_etpl(importexport_definition &$definition = NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,10 +97,21 @@ class infolog_export_ical extends infolog_export_csv {
|
||||
}
|
||||
|
||||
/**
|
||||
* return html for options.
|
||||
* return array for options.
|
||||
*
|
||||
* @param $definition Specific definition
|
||||
*
|
||||
* @return array (
|
||||
* name => string,
|
||||
* content => array,
|
||||
* sel_options => array,
|
||||
* readonlys => array,
|
||||
* preserv => array,
|
||||
* )
|
||||
*/
|
||||
public function get_options_etpl() {
|
||||
public function get_options_etpl(importexport_definition &$definition = NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,8 @@ use EGroupware\Api\Acl;
|
||||
/**
|
||||
* export resources to CSV
|
||||
*/
|
||||
class resources_export_csv implements importexport_iface_export_plugin {
|
||||
class resources_export_csv implements importexport_iface_export_plugin
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -31,11 +32,13 @@ class resources_export_csv implements importexport_iface_export_plugin {
|
||||
*
|
||||
* @param egw_record $_definition
|
||||
*/
|
||||
public function export( $_stream, importexport_definition $_definition) {
|
||||
public function export( $_stream, importexport_definition $_definition)
|
||||
{
|
||||
$options = $_definition->plugin_options;
|
||||
|
||||
$selection = array();
|
||||
if ($options['selection'] == 'search') {
|
||||
if ($options['selection'] == 'search')
|
||||
{
|
||||
// ui selection with checkbox 'selected'
|
||||
$query = Api\Cache::getSession('resources', 'get_rows');
|
||||
$query['num_rows'] = -1; // all
|
||||
@ -43,13 +46,14 @@ class resources_export_csv implements importexport_iface_export_plugin {
|
||||
$query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
|
||||
$this->bo->get_rows($query,$selection,$readonlys);
|
||||
}
|
||||
elseif ( $options['selection'] == 'all' || $options['selection'] == 'filter') {
|
||||
elseif ( $options['selection'] == 'all' || $options['selection'] == 'filter')
|
||||
{
|
||||
$query = array(
|
||||
'num_rows' => -1,
|
||||
'filter2' => -3, // Accessories & resources
|
||||
'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session
|
||||
); // all
|
||||
|
||||
|
||||
if($options['selection'] == 'filter')
|
||||
{
|
||||
$filter = $_definition->filter;
|
||||
@ -75,9 +79,11 @@ class resources_export_csv implements importexport_iface_export_plugin {
|
||||
unset($query['col_filter'][$field]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->bo->get_rows($query,$selection,$readonlys);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$selection = explode(',',$options['selection']);
|
||||
}
|
||||
|
||||
@ -86,27 +92,35 @@ class resources_export_csv implements importexport_iface_export_plugin {
|
||||
|
||||
// Check if we need to load the custom fields
|
||||
$need_custom = false;
|
||||
foreach(Api\Storage\Customfields::get('resources') as $field => $settings) {
|
||||
if($options['mapping']['#'.$field]) {
|
||||
foreach(Api\Storage\Customfields::get('resources') as $field => $settings)
|
||||
{
|
||||
if($options['mapping']['#'.$field])
|
||||
{
|
||||
$need_custom = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($selection as $record) {
|
||||
foreach ($selection as $record)
|
||||
{
|
||||
if(!is_array($record) || !$record['res_id']) continue;
|
||||
|
||||
if($need_custom) {
|
||||
if($need_custom)
|
||||
{
|
||||
$record = $this->bo->read($record['res_id']);
|
||||
}
|
||||
$resource = new resources_egw_record();
|
||||
$resource->set_record($record);
|
||||
$resource->long_description = strip_tags($resource->long_description);
|
||||
if($options['convert']) {
|
||||
if($options['convert'])
|
||||
{
|
||||
importexport_export_csv::convert($resource, resources_egw_record::$types, 'resources', $this->selects);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Implode arrays, so they don't say 'Array'
|
||||
foreach($resource->get_record_array() as $key => $value) {
|
||||
foreach($resource->get_record_array() as $key => $value)
|
||||
{
|
||||
if(is_array($value)) $resource->$key = implode(',', $value);
|
||||
}
|
||||
}
|
||||
@ -122,7 +136,8 @@ class resources_export_csv implements importexport_iface_export_plugin {
|
||||
*
|
||||
* @return string name
|
||||
*/
|
||||
public static function get_name() {
|
||||
public static function get_name()
|
||||
{
|
||||
return lang('Resources CSV export');
|
||||
}
|
||||
|
||||
@ -131,7 +146,8 @@ class resources_export_csv implements importexport_iface_export_plugin {
|
||||
*
|
||||
* @return string descriprion
|
||||
*/
|
||||
public static function get_description() {
|
||||
public static function get_description()
|
||||
{
|
||||
return lang("Exports a list of resources to a CSV File.");
|
||||
}
|
||||
|
||||
@ -140,27 +156,40 @@ class resources_export_csv implements importexport_iface_export_plugin {
|
||||
*
|
||||
* @return string suffix
|
||||
*/
|
||||
public static function get_filesuffix() {
|
||||
public static function get_filesuffix()
|
||||
{
|
||||
return 'csv';
|
||||
}
|
||||
|
||||
public static function get_mimetype() {
|
||||
public static function get_mimetype()
|
||||
{
|
||||
return 'text/csv';
|
||||
}
|
||||
|
||||
/**
|
||||
* return html for options.
|
||||
* this way the plugin has all opportunities for options tab
|
||||
* Return array of settings for export dialog
|
||||
*
|
||||
* @param $definition Specific definition
|
||||
*
|
||||
* @return array (
|
||||
* name => string,
|
||||
* content => array,
|
||||
* sel_options => array,
|
||||
* readonlys => array,
|
||||
* preserv => array,
|
||||
* )
|
||||
*/
|
||||
public function get_options_etpl() {
|
||||
public function get_options_etpl(importexport_definition &$definition = NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns selectors information
|
||||
*
|
||||
*/
|
||||
public function get_selectors_etpl() {
|
||||
public function get_selectors_etpl()
|
||||
{
|
||||
return array(
|
||||
'name' => 'importexport.export_csv_selectors',
|
||||
);
|
||||
@ -170,9 +199,9 @@ class resources_export_csv implements importexport_iface_export_plugin {
|
||||
* Get selectbox values
|
||||
*/
|
||||
protected function get_selects()
|
||||
{
|
||||
{
|
||||
$this->selects = array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Customize automatically generated filter fields
|
||||
|
@ -16,7 +16,8 @@ use EGroupware\Api;
|
||||
/**
|
||||
* export plugin of addressbook
|
||||
*/
|
||||
class timesheet_export_csv implements importexport_iface_export_plugin {
|
||||
class timesheet_export_csv implements importexport_iface_export_plugin
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -29,18 +30,22 @@ class timesheet_export_csv implements importexport_iface_export_plugin {
|
||||
*
|
||||
* @param egw_record $_definition
|
||||
*/
|
||||
public function export( $_stream, importexport_definition $_definition) {
|
||||
public function export( $_stream, importexport_definition $_definition)
|
||||
{
|
||||
$options = $_definition->plugin_options;
|
||||
|
||||
$this->ui = new timesheet_ui();
|
||||
$selection = array();
|
||||
|
||||
if($options['selection'] == 'search') {
|
||||
if($options['selection'] == 'search')
|
||||
{
|
||||
$query = Api\Cache::getSession(TIMESHEET_APP, 'index');
|
||||
$query['num_rows'] = -1; // all records
|
||||
$query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
|
||||
$this->ui->get_rows($query,$selection,$readonlys,true); // true = only return the id's
|
||||
} elseif($options['selection'] == 'all') {
|
||||
}
|
||||
elseif($options['selection'] == 'all')
|
||||
{
|
||||
$query = array(
|
||||
'num_rows' => -1,
|
||||
'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session
|
||||
@ -83,13 +88,18 @@ class timesheet_export_csv implements importexport_iface_export_plugin {
|
||||
|
||||
// $options['selection'] is array of identifiers as this plugin doesn't
|
||||
// support other selectors atm.
|
||||
foreach ($selection as $identifier) {
|
||||
foreach ($selection as $identifier)
|
||||
{
|
||||
$record = new timesheet_egw_record($identifier);
|
||||
if($options['convert']) {
|
||||
if($options['convert'])
|
||||
{
|
||||
importexport_export_csv::convert($record, timesheet_egw_record::$types, 'timesheet', $this->selects);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Implode arrays, so they don't say 'Array'
|
||||
foreach($record->get_record_array() as $key => $value) {
|
||||
foreach($record->get_record_array() as $key => $value)
|
||||
{
|
||||
if(is_array($value)) $record->$key = implode(',', $value);
|
||||
}
|
||||
}
|
||||
@ -104,7 +114,8 @@ class timesheet_export_csv implements importexport_iface_export_plugin {
|
||||
*
|
||||
* @return string name
|
||||
*/
|
||||
public static function get_name() {
|
||||
public static function get_name()
|
||||
{
|
||||
return lang('Timesheet CSV export');
|
||||
}
|
||||
|
||||
@ -113,7 +124,8 @@ class timesheet_export_csv implements importexport_iface_export_plugin {
|
||||
*
|
||||
* @return string descriprion
|
||||
*/
|
||||
public static function get_description() {
|
||||
public static function get_description()
|
||||
{
|
||||
return lang("Exports entries from your Timesheet into a CSV File. ");
|
||||
}
|
||||
|
||||
@ -122,21 +134,31 @@ class timesheet_export_csv implements importexport_iface_export_plugin {
|
||||
*
|
||||
* @return string suffix
|
||||
*/
|
||||
public static function get_filesuffix() {
|
||||
public static function get_filesuffix()
|
||||
{
|
||||
return 'csv';
|
||||
}
|
||||
|
||||
public static function get_mimetype() {
|
||||
return 'text/csv';
|
||||
}
|
||||
public static function get_mimetype()
|
||||
{
|
||||
return 'text/csv';
|
||||
}
|
||||
|
||||
/**
|
||||
* return html for options.
|
||||
* this way the plugin has all opportunities for options tab
|
||||
* Return array of settings for export dialog
|
||||
*
|
||||
* @return string html
|
||||
* @param $definition Specific definition
|
||||
*
|
||||
* @return array (
|
||||
* name => string,
|
||||
* content => array,
|
||||
* sel_options => array,
|
||||
* readonlys => array,
|
||||
* preserv => array,
|
||||
* )
|
||||
*/
|
||||
public function get_options_etpl() {
|
||||
public function get_options_etpl(importexport_definition &$definition = NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -144,7 +166,8 @@ class timesheet_export_csv implements importexport_iface_export_plugin {
|
||||
* returns slectors of this plugin via xajax
|
||||
*
|
||||
*/
|
||||
public function get_selectors_etpl() {
|
||||
public function get_selectors_etpl()
|
||||
{
|
||||
return array(
|
||||
'name' => 'importexport.export_csv_selectors',
|
||||
);
|
||||
@ -155,7 +178,8 @@ class timesheet_export_csv implements importexport_iface_export_plugin {
|
||||
$this->selects = array(
|
||||
'ts_status' => $this->ui->status_labels+array(lang('No status'))
|
||||
);
|
||||
foreach($this->selects['ts_status'] as &$status) {
|
||||
foreach($this->selects['ts_status'] as &$status)
|
||||
{
|
||||
$status = str_replace(' ','',$status); // Remove
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user