- Use current view as filter for iCal export too

- Use preference for export selection parameter search results / given criteria
This commit is contained in:
Nathan Gray 2011-05-30 17:23:46 +00:00
parent 49e551e941
commit 82de8a636d
4 changed files with 86 additions and 19 deletions

View File

@ -32,7 +32,7 @@ class calendar_export_csv implements importexport_iface_export_plugin {
if($key[0] == '#') $cfs[] = substr($key,1);
}
if($options['select'] == 'criteria') {
if($options['selection']['select'] == 'criteria') {
$query = array(
'start' => $options['selection']['start'],
'end' => $options['selection']['end'],
@ -47,7 +47,7 @@ class calendar_export_csv implements importexport_iface_export_plugin {
$query['num_rows'] = (int)$config['export_limit'];
}
$events =& $this->bo->search($query);
} elseif ($options['select'] = 'search_results') {
} elseif ($options['selection']['select'] = 'search_results') {
$states = $GLOBALS['egw']->session->appsession('session_data','calendar');
if($states['view'] == 'listview') {
$query = $GLOBALS['egw']->session->appsession('calendar_list','calendar');
@ -175,14 +175,14 @@ class calendar_export_csv implements importexport_iface_export_plugin {
* return html for options.
*
*/
public function get_options_etpl() {
public function get_options_etpl($definition = null) {
}
/**
* returns selectors of this plugin
*
*/
public function get_selectors_etpl() {
public function get_selectors_etpl($definition = null) {
$states = $GLOBALS['egw']->session->appsession('session_data','calendar');
$start= new egw_time($states['date']);
@ -194,10 +194,12 @@ class calendar_export_csv implements importexport_iface_export_plugin {
$end = '+1 ' . $states['view'];
}
$prefs = unserialize($GLOBALS['egw_info']['user']['preferences']['importexport'][$definition->definition_id]);
return array(
'name' => 'calendar.export_csv_select',
'content' => array(
'plugin_override' => true, // Plugin overrides preferences
'select' => $prefs['selection']['select'] ? $prefs['selection']['select'] : 'criteria',
'start' => $start->format('ts'),
'end' => strtotime($end, $start->format('ts'))-1,
'owner' => $states['owner']
@ -209,7 +211,7 @@ class calendar_export_csv implements importexport_iface_export_plugin {
* Get additional query parameters used when in various views
* This stuff copied out of calendar_uiviews
*/
private function get_query_month($states)
public static function get_query_month($states)
{
$timespan = array(
'start' => mktime(0,0,0,$states['month'],1,$states['year']),
@ -218,14 +220,14 @@ class calendar_export_csv implements importexport_iface_export_plugin {
return $timespan;
}
public function get_query_week($states)
public static function get_query_week($states)
{
$query = array();
$days = $states['days'];
$ui = new calendar_uiviews($states);
if (!$days)
{
$days = isset($_GET['days']) ? $_GET['days'] : $this->cal_prefs['days_in_weekview'];
$days = isset($_GET['days']) ? $_GET['days'] : $ui->cal_prefs['days_in_weekview'];
if ($days != 5) $days = 7;
}
if ($days == 4) // next 4 days view

View File

@ -25,15 +25,76 @@ class calendar_export_ical extends calendar_export_csv {
$options = $_definition->plugin_options;
$this->bo = new calendar_bo();
$boical = new calendar_ical();
$events =& $this->bo->search(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'],
'date_format' => 'server',
));
// Custom fields need to be specifically requested
$cfs = array();
foreach($options['mapping'] as $key => $label) {
if($key[0] == '#') $cfs[] = substr($key,1);
}
if($options['selection']['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['selection']['select'] = 'search_results') {
$states = $GLOBALS['egw']->session->appsession('session_data','calendar');
if($states['view'] == 'listview') {
$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);
} else {
$query = $GLOBALS['egw']->session->appsession('session_data','calendar');
$query['users'] = explode(',', $query['owner']);
$query['num_rows'] = -1;
if($config['export_limit']) {
$query['num_rows'] = (int)$config['export_limit'];
}
$events = array();
switch($states['view']) {
case 'month':
$query += calendar_export_csv::get_query_month($states);
break;
case 'week':
$query += calendar_export_csv::get_query_week($states);
break;
case 'day':
$query += calendar_export_csv::get_query_day($states);
break;
default:
$ui = new calendar_uiviews($query);
$query += array(
'start' => is_array($ui->first) ? $this->bo->date2ts($ui->first) : $ui->first,
'end' => is_array($ui->last) ? $this->bo->date2ts($ui->last) : $ui->last
);
}
$bo = new calendar_boupdate();
$events = $bo->search($query + array(
'offset' => 0,
'order' => 'cal_start',
));
}
}
$ical =& $boical->exportVCal($events,'2.0','PUBLISH',false);
fwrite($_stream, $ical);
}

View File

@ -2,7 +2,7 @@
/**
* EGroupware - eTemplates for Application calendar
* http://www.egroupware.org
* generated by soetemplate::dump4setup() 2011-05-27 22:30
* generated by soetemplate::dump4setup() 2011-05-30 11:06
*
* @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: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.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:17:"selection[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:17:"selection[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; }

View File

@ -40,6 +40,7 @@
<entry type="string" name="begin_with_fieldnames">label</entry>
<entry type="string" name="convert">1</entry>
</entry>
<entry type="string" name="modified">2011-05-24 10:00:00</entry>
</entry>
<entry type="array" name="import-calendar-csv">
<entry type="string" name="name">import-calendar-csv</entry>
@ -98,6 +99,7 @@
</entry>
<entry type="string" name="field_conversion"/>
</entry>
<entry type="string" name="modified">2011-05-24 10:00:00</entry>
</entry>
<entry type="array" name="import-calendar-ical">
<entry type="string" name="name">import-calendar-ical</entry>
@ -105,9 +107,10 @@
<entry type="string" name="plugin">calendar_import_ical</entry>
<entry type="string" name="type">import</entry>
<entry type="array" name="allowed_users">
<entry type="string" name="0">Admins</entry>
<entry type="string" name="0">Default</entry>
</entry>
<entry type="string" name="plugin_options"/>
<entry type="string" name="modified">2011-05-24 10:00:00</entry>
</entry>
<entry type="array" name="export-calendar-ical">
<entry type="string" name="name">export-calendar-ical</entry>
@ -118,6 +121,7 @@
<entry type="string" name="0">Default</entry>
</entry>
<entry type="string" name="plugin_options"/>
<entry type="string" name="modified">2011-05-24 10:00:00</entry>
</entry>
</entry>
</entry>