From c0692ac303f0496c89d1fdee0ba333f5b8f383b9 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 24 May 2011 19:56:32 +0000 Subject: [PATCH] Allow to use search results as selection for export --- .../inc/class.calendar_export_csv.inc.php | 47 ++++++++++++------- calendar/setup/etemplates.inc.php | 4 +- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/calendar/inc/class.calendar_export_csv.inc.php b/calendar/inc/class.calendar_export_csv.inc.php index eaeab55a99..c8696c6c15 100644 --- a/calendar/inc/class.calendar_export_csv.inc.php +++ b/calendar/inc/class.calendar_export_csv.inc.php @@ -24,27 +24,41 @@ class calendar_export_csv implements importexport_iface_export_plugin { public function export( $_stream, importexport_definition $_definition) { $options = $_definition->plugin_options; $this->bo = new calendar_bo(); + $config = config::read('phpgwapi'); // Custom fields need to be specifically requested $cfs = array(); foreach($options['mapping'] as $key => $label) { if($key[0] == '#') $cfs[] = substr($key,1); } - $query = array( - 'start' => $options['selection']['start'], - 'end' => $options['selection']['end'], - 'categories' => $options['categories'] ? $options['categories'] : $options['selection']['categories'], - 'enum_recuring' => false, - 'daywise' => false, - 'users' => $options['selection']['owner'], - 'cfs' => $cfs // Otherwise we shouldn't get any custom fields - ); - $config = config::read('phpgwapi'); - if($config['export_limit']) { - $query['offset'] = 0; - $query['num_rows'] = (int)$config['export_limit']; + + if($options['select'] == 'criteria') { + $query = array( + 'start' => $options['selection']['start'], + 'end' => $options['selection']['end'], + 'categories' => $options['categories'] ? $options['categories'] : $options['selection']['categories'], + 'enum_recuring' => false, + 'daywise' => false, + 'users' => $options['selection']['owner'], + 'cfs' => $cfs // Otherwise we shouldn't get any custom fields + ); + if($config['export_limit']) { + $query['offset'] = 0; + $query['num_rows'] = (int)$config['export_limit']; + } + $events =& $this->bo->search($query); + } elseif ($options['select'] = 'search_results') { + $query = $GLOBALS['egw']->session->appsession('calendar_list','calendar'); + $query['num_rows'] = -1; // all + $query['start'] = 0; + $query['cfs'] = $cfs; + + if($config['export_limit']) { + $query['num_rows'] = (int)$config['export_limit']; + } + $ui = new calendar_uilist(); + $ui->get_rows($query, $events); } - $events =& $this->bo->search($query); $export_object = new importexport_export_csv($_stream, (array)$options); $export_object->set_mapping($options['mapping']); @@ -61,12 +75,10 @@ class calendar_export_csv implements importexport_iface_export_plugin { ), ); - // $options['selection'] is array of identifiers as this plugin doesn't - // support other selectors atm. $record = new calendar_egw_record(); foreach ($events as $event) { // Get rid of yearly recurring events that don't belong - if($event['start'] > $query['end'] || $event['end'] < $query['start']) continue; + if($options['selection']['select'] == 'criteria' && ($event['start'] > $query['end'] || $event['end'] < $query['start'])) continue; // Add in participants if($options['mapping']['participants']) { @@ -88,7 +100,6 @@ class calendar_export_csv implements importexport_iface_export_plugin { if(is_array($value)) $record->$key = implode(',', $value); } } - $export_object->export_record($record); } unset($record); diff --git a/calendar/setup/etemplates.inc.php b/calendar/setup/etemplates.inc.php index 679d89cca7..c2a8492d30 100644 --- a/calendar/setup/etemplates.inc.php +++ b/calendar/setup/etemplates.inc.php @@ -2,7 +2,7 @@ /** * EGroupware - eTemplates for Application calendar * http://www.egroupware.org - * generated by soetemplate::dump4setup() 2011-05-06 15:24 + * generated by soetemplate::dump4setup() 2011-05-24 13:56 * * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @package calendar @@ -45,7 +45,7 @@ $templ_data[] = array('name' => 'calendar.edit_series','template' => '','lang' = $templ_data[] = array('name' => 'calendar.export','template' => '','lang' => '','group' => '0','version' => '1.0.1.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:8:{i:0;a:2:{s:2:"h5";s:2:",1";s:2:"h1";s:6:",!@msg";}i:1;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:11:"all,message";s:4:"name";s:3:"msg";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:2;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"size";s:8:",,,start";s:5:"label";s:5:"Start";}s:1:"B";a:3:{s:4:"type";s:4:"date";s:4:"name";s:5:"start";s:4:"help";s:23:"Startdate of the export";}}i:3;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"size";s:6:",,,end";s:5:"label";s:3:"End";}s:1:"B";a:3:{s:4:"type";s:4:"date";s:4:"name";s:3:"end";s:4:"help";s:21:"Enddate of the export";}}i:4;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"size";s:7:",,,file";s:5:"label";s:8:"Filename";}s:1:"B";a:3:{s:4:"type";s:4:"text";s:4:"name";s:4:"file";s:4:"help";s:24:"Filename of the download";}}i:5;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"size";s:10:",,,version";s:5:"label";s:7:"Version";}s:1:"B";a:2:{s:4:"type";s:6:"select";s:4:"name";s:7:"version";}}i:6;a:2:{s:1:"A";a:1:{s:4:"type";s:5:"label";}s:1:"B";a:3:{s:4:"type";s:6:"button";s:5:"label";s:8:"Download";s:4:"name";s:8:"download";}}i:7;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:4:"span";s:3:"all";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:7;s:4:"cols";i:2;s:5:"align";s:6:"center";s:7:"options";a:0:{}}}','size' => '','style' => '','modified' => '1130738737',); -$templ_data[] = array('name' => 'calendar.export_csv_select','template' => '','lang' => '','group' => '0','version' => '1.9.002','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:6:{i:0;a:1:{s:2:"h1";s:6:",!@msg";}i:1;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:11:"all,message";s:4:"name";s:3:"msg";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:2;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"size";s:8:",,,start";s:5:"label";s:5:"Start";}s:1:"B";a:3:{s:4:"type";s:4:"date";s:4:"name";s:16:"selection[start]";s:4:"help";s:23:"Startdate of the export";}}i:3;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"size";s:6:",,,end";s:5:"label";s:3:"End";}s:1:"B";a:3:{s:4:"type";s:4:"date";s:4:"name";s:14:"selection[end]";s:4:"help";s:21:"Enddate of the export";}}i:4;a:2:{s:1:"A";a:4:{s:4:"type";s:14:"select-account";s:4:"span";s:3:"all";s:4:"name";s:16:"selection[owner]";s:4:"size";s:6:"5,both";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:5;a:2:{s:1:"A";a:1:{s:4:"type";s:5:"label";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:5;s:4:"cols";i:2;s:5:"align";s:6:"center";s:7:"options";a:0:{}}}','size' => '','style' => '','modified' => '1300135121',); +$templ_data[] = array('name' => 'calendar.export_csv_select','template' => '','lang' => '','group' => '0','version' => '1.9.002','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:8:{i:0;a:1:{s:2:"h1";s:6:",!@msg";}i:1;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:11:"all,message";s:4:"name";s:3:"msg";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:2;a:2:{s:1:"A";a:5:{s:4:"type";s:5:"radio";s:4:"size";s:14:"search_results";s:4:"span";s:3:"all";s:5:"label";s:18:"Use search results";s:4:"name";s:6:"select";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:3;a:2:{s:1:"A";a:5:{s:4:"type";s:5:"radio";s:4:"size";s:8:"criteria";s:4:"span";s:3:"all";s:5:"label";s:19:"Use given criteria:";s:4:"name";s:6:"select";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:4;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"size";s:8:",,,start";s:5:"label";s:5:"Start";}s:1:"B";a:3:{s:4:"type";s:4:"date";s:4:"name";s:16:"selection[start]";s:4:"help";s:23:"Startdate of the export";}}i:5;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"size";s:6:",,,end";s:5:"label";s:3:"End";}s:1:"B";a:3:{s:4:"type";s:4:"date";s:4:"name";s:14:"selection[end]";s:4:"help";s:21:"Enddate of the export";}}i:6;a:2:{s:1:"A";a:4:{s:4:"type";s:14:"select-account";s:4:"span";s:3:"all";s:4:"name";s:16:"selection[owner]";s:4:"size";s:6:"5,both";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:7;a:2:{s:1:"A";a:1:{s:4:"type";s:5:"label";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:7;s:4:"cols";i:2;s:5:"align";s:6:"center";s:7:"options";a:0:{}}}','size' => '','style' => '','modified' => '1300135121',); $templ_data[] = array('name' => 'calendar.freetimesearch','template' => '','lang' => '','group' => '0','version' => '1.3.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:7:{i:0;a:0:{}i:1;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:9:",size120b";s:5:"label";s:15:"Freetime Search";}s:1:"B";a:4:{s:4:"type";s:5:"label";s:4:"span";s:10:",redItalic";s:7:"no_lang";s:1:"1";s:4:"name";s:3:"msg";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:17:"Startdate / -time";}s:1:"B";a:3:{s:4:"type";s:9:"date-time";s:4:"name";s:5:"start";s:4:"help";s:33:"Startdate and -time of the search";}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:8:"Duration";}s:1:"B";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:6:{s:4:"type";s:6:"select";s:7:"no_lang";s:1:"1";s:4:"name";s:8:"duration";s:4:"help";s:23:"Duration of the meeting";s:8:"onchange";s:92:"set_style_by_class(\'table\',\'end_hide\',\'visibility\',this.value == \'\' ? \'visible\' : \'hidden\');";s:4:"size";s:12:"Use end date";}i:2;a:4:{s:4:"type";s:9:"date-time";s:4:"name";s:3:"end";s:4:"help";s:57:"Enddate / -time of the meeting, eg. for more then one day";s:4:"span";s:9:",end_hide";}}}i:4;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:9:"Timeframe";}s:1:"B";a:7:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"5";i:1;a:3:{s:4:"type";s:13:"date-houronly";s:4:"name";s:10:"start_time";s:4:"help";s:19:"Timeframe to search";}i:2;a:2:{s:4:"type";s:5:"label";s:5:"label";s:3:"til";}i:3;a:3:{s:4:"type";s:13:"date-houronly";s:4:"name";s:8:"end_time";s:4:"help";s:19:"Timeframe to search";}i:4;a:2:{s:4:"type";s:5:"label";s:5:"label";s:8:"Weekdays";}i:5;a:4:{s:4:"type";s:10:"select-dow";s:4:"size";s:1:"3";s:4:"name";s:8:"weekdays";s:4:"help";s:25:"Weekdays to use in search";}}}i:5;a:2:{s:1:"A";a:4:{s:4:"type";s:6:"button";s:5:"label";s:10:"New search";s:4:"name";s:6:"search";s:4:"help";s:36:"new search with the above parameters";}s:1:"B";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:4:{s:4:"type";s:6:"select";s:7:"no_lang";s:1:"1";s:4:"name";s:13:"search_window";s:4:"help";s:34:"how far to search (from startdate)";}i:2;a:5:{s:4:"type";s:6:"button";s:4:"name";s:6:"cancel";s:5:"label";s:6:"Cancel";s:4:"help";s:16:"Close the window";s:7:"onclick";s:15:"window.close();";}}}i:6;a:2:{s:1:"A";a:4:{s:4:"type";s:8:"template";s:4:"size";s:8:"freetime";s:4:"span";s:3:"all";s:4:"name";s:4:"rows";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:6;s:4:"cols";i:2;}}','size' => '','style' => '.size120b { text-size: 120%; font-weight: bold; } .redItalic { color: red; font-style: italic; }