diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index 83146357..074f7bfd 100644
--- a/plugins/calendar/calendar.php
+++ b/plugins/calendar/calendar.php
@@ -1060,11 +1060,20 @@ class calendar extends rcube_plugin
{
$start = get_input_value('start', RCUBE_INPUT_GET);
$end = get_input_value('end', RCUBE_INPUT_GET);
- if (!$start) $start = mktime(0, 0, 0, 1, date('n'), date('Y')-1);
- if (!$end) $end = mktime(0, 0, 0, 31, 12, date('Y')+10);
+ if (!isset($start))
+ $start = 'today -1 year';
+ if (!is_numeric($start))
+ $start = strtotime($start . ' 00:00:00');
+ if (!$end)
+ $end = 'today +10 years';
+ if (!is_numeric($end))
+ $end = strtotime($end . ' 23:59:59');
+
+ $attachments = get_input_value('attachments', RCUBE_INPUT_GET);
$calid = $calname = get_input_value('source', RCUBE_INPUT_GET);
+
$calendars = $this->driver->list_calendars();
-
+
if ($calendars[$calid]) {
$calname = $calendars[$calid]['name'] ? $calendars[$calid]['name'] : $calid;
$calname = preg_replace('/[^a-z0-9_.-]/i', '', html_entity_decode($calname)); // to 7bit ascii
@@ -1077,7 +1086,7 @@ class calendar extends rcube_plugin
header("Content-Type: text/calendar");
header("Content-Disposition: inline; filename=".$calname.'.ics');
- $this->get_ical()->export($events, '', true, array($this->driver, 'get_attachment_body'));
+ $this->get_ical()->export($events, '', true, $attachments ? array($this->driver, 'get_attachment_body') : null);
if ($terminate)
exit;
diff --git a/plugins/calendar/calendar_ui.js b/plugins/calendar/calendar_ui.js
index c367daf5..693ff09c 100644
--- a/plugins/calendar/calendar_ui.js
+++ b/plugins/calendar/calendar_ui.js
@@ -2021,6 +2021,63 @@ function rcube_calendar_ui(settings)
rcmail.display_message(p.message || rcmail.get_label('importerror', 'calendar'), 'error');
}
+ // open a dialog to select calendars for export
+ this.export_events = function(calendar)
+ {
+ // close show dialog first
+ var $dialog = $("#eventsexport"),
+ form = rcmail.gui_objects.exportform;
+
+ if ($dialog.is(':ui-dialog'))
+ $dialog.dialog('close');
+
+ if (calendar)
+ $('#event-export-calendar').val(calendar.id);
+
+ $('#event-export-range').change(function(e){
+ var custom = $('option:selected', this).val() == 'custom',
+ input = $('#event-export-startdate')
+ input.parent()[(custom?'show':'hide')]();
+ if (custom)
+ input.select();
+ })
+
+ var buttons = {};
+ buttons[rcmail.gettext('export', 'calendar')] = function() {
+ if (form) {
+ var start = 0, range = $('#event-export-range option:selected', this).val(),
+ source = $('#event-export-calendar option:selected').val(),
+ attachmt = $('#event-export-attachments').get(0).checked;
+
+ if (range == 'custom')
+ start = date2unixtime(parse_datetime('00:00', $('#event-export-startdate').val()));
+ else if (range > 0)
+ start = 'today -' + range + '^months';
+
+ rcmail.goto_url('export_events', { source:source, start:start, attachments:attachmt?1:0 });
+ }
+ };
+
+ buttons[rcmail.gettext('cancel', 'calendar')] = function() {
+ $dialog.dialog("close");
+ };
+
+ // open jquery UI dialog
+ $dialog.dialog({
+ modal: true,
+ resizable: false,
+ closeOnEscape: false,
+ title: rcmail.gettext('exporttitle', 'calendar'),
+ close: function() {
+ $('.ui-dialog-buttonpane button', $dialog.parent()).button('enable');
+ $dialog.dialog("destroy").hide();
+ },
+ buttons: buttons,
+ width: 520
+ }).show();
+
+ };
+
// show URL of the given calendar in a dialog box
this.showurl = function(calendar)
{
@@ -2693,6 +2750,8 @@ function rcube_calendar_ui(settings)
$('#edit-recurrence-enddate').datepicker(datepicker_settings).click(function(){ $("#edit-recurrence-repeat-until").prop('checked', true) });
$('#edit-recurrence-repeat-times').change(function(e){ $('#edit-recurrence-repeat-count').prop('checked', true); });
+ $('#event-export-startdate').datepicker(datepicker_settings);
+
// init attendees autocompletion
var ac_props;
// parallel autocompletion
@@ -2791,7 +2850,7 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
rcmail.register_command('calendar-showurl', function(){ cal.showurl(cal.calendars[cal.selected_calendar]); }, false);
// search and export events
- rcmail.register_command('export', function(){ rcmail.goto_url('export_events', { source:cal.selected_calendar }); }, true);
+ rcmail.register_command('export', function(){ cal.export_events(cal.calendars[cal.selected_calendar]); }, true);
rcmail.register_command('search', function(){ cal.quicksearch(); }, true);
rcmail.register_command('reset-search', function(){ cal.reset_quicksearch(); }, true);
diff --git a/plugins/calendar/lib/calendar_ui.php b/plugins/calendar/lib/calendar_ui.php
index 9ffb4ee7..85e87f82 100644
--- a/plugins/calendar/lib/calendar_ui.php
+++ b/plugins/calendar/lib/calendar_ui.php
@@ -90,6 +90,7 @@ class calendar_ui
$this->cal->register_handler('plugin.event_rsvp_buttons', array($this, 'event_rsvp_buttons'));
$this->cal->register_handler('plugin.angenda_options', array($this, 'angenda_options'));
$this->cal->register_handler('plugin.events_import_form', array($this, 'events_import_form'));
+ $this->cal->register_handler('plugin.events_export_form', array($this, 'events_export_form'));
$this->cal->register_handler('plugin.searchform', array($this->rc->output, 'search_form')); // use generic method from rcube_template
}
@@ -542,11 +543,12 @@ class calendar_ui
$select->add(array(
$this->cal->gettext('onemonthback'),
$this->cal->gettext(array('name' => 'nmonthsback', 'vars' => array('nr'=>2))),
+ $this->cal->gettext(array('name' => 'nmonthsback', 'vars' => array('nr'=>3))),
$this->cal->gettext(array('name' => 'nmonthsback', 'vars' => array('nr'=>6))),
$this->cal->gettext(array('name' => 'nmonthsback', 'vars' => array('nr'=>12))),
$this->cal->gettext('all'),
),
- array('1','2','6','12',0));
+ array('1','2','3','6','12',0));
$html .= html::div('form-section',
html::div(null, $input->show()) .
@@ -572,6 +574,53 @@ class calendar_ui
);
}
+ /**
+ * Form to select options for exporting events
+ */
+ function events_export_form($attrib = array())
+ {
+ if (!$attrib['id'])
+ $attrib['id'] = 'rcmExportForm';
+
+ $html .= html::div('form-section',
+ html::label('event-export-calendar', $this->cal->gettext('calendar')) .
+ $this->calendar_select(array('name' => 'calendar', 'id' => 'event-export-calendar'))
+ );
+
+ $select = new html_select(array('name' => 'range', 'id' => 'event-export-range'));
+ $select->add(array(
+ $this->cal->gettext('all'),
+ $this->cal->gettext('onemonthback'),
+ $this->cal->gettext(array('name' => 'nmonthsback', 'vars' => array('nr'=>2))),
+ $this->cal->gettext(array('name' => 'nmonthsback', 'vars' => array('nr'=>3))),
+ $this->cal->gettext(array('name' => 'nmonthsback', 'vars' => array('nr'=>6))),
+ $this->cal->gettext(array('name' => 'nmonthsback', 'vars' => array('nr'=>12))),
+ $this->cal->gettext('customdate'),
+ ),
+ array(0,'1','2','3','6','12','custom'));
+
+ $startdate = new html_inputfield(array('name' => 'start', 'size' => 11, 'id' => 'event-export-startdate'));
+
+ $html .= html::div('form-section',
+ html::label('event-export-range', $this->cal->gettext('exportrange')) .
+ $select->show(0) .
+ html::span(array('style'=>'display:none'), $startdate->show())
+ );
+
+ $checkbox = new html_checkbox(array('name' => 'attachments', 'id' => 'event-export-attachments', 'value' => 1));
+ $html .= html::div('form-section',
+ html::label('event-export-range', $this->cal->gettext('exportattachments')) .
+ $checkbox->show(1)
+ );
+
+ $this->rc->output->add_gui_object('exportform', $attrib['id']);
+
+ return html::tag('form', array('action' => $this->rc->url(array('task' => 'calendar', 'action' => 'export_events')),
+ 'method' => "post", 'id' => $attrib['id']),
+ $html
+ );
+ }
+
/**
* Generate the form for event attachments upload
*/
diff --git a/plugins/calendar/lib/js/fullcalendar.js b/plugins/calendar/lib/js/fullcalendar.js
index f790eeaa..4f0862a2 100644
--- a/plugins/calendar/lib/js/fullcalendar.js
+++ b/plugins/calendar/lib/js/fullcalendar.js
@@ -5913,5 +5913,5 @@ function TableView(element, calendar) {
}
}
-
+
})(jQuery);
diff --git a/plugins/calendar/localization/de_CH.inc b/plugins/calendar/localization/de_CH.inc
index de3def7a..0cb7e66e 100644
--- a/plugins/calendar/localization/de_CH.inc
+++ b/plugins/calendar/localization/de_CH.inc
@@ -40,6 +40,9 @@ $labels['description'] = 'Beschrieb';
$labels['all-day'] = 'ganztägig';
$labels['export'] = 'Exportieren';
$labels['exporttitle'] = 'Kalender als iCalendar exportieren';
+$labels['exportrange'] = 'Termine ab';
+$labels['exportattachments'] = 'Mit Anhängen';
+$labels['customdate'] = 'Eigenes Datum';
$labels['location'] = 'Ort';
$labels['date'] = 'Datum';
$labels['start'] = 'Beginn';
diff --git a/plugins/calendar/localization/de_DE.inc b/plugins/calendar/localization/de_DE.inc
index 11a82057..9e42874c 100644
--- a/plugins/calendar/localization/de_DE.inc
+++ b/plugins/calendar/localization/de_DE.inc
@@ -40,6 +40,9 @@ $labels['description'] = 'Beschreibung';
$labels['all-day'] = 'ganztägig';
$labels['export'] = 'Exportieren';
$labels['exporttitle'] = 'Kalender als iCalendar exportieren';
+$labels['exportrange'] = 'Termine ab';
+$labels['exportattachments'] = 'Mit Anhängen';
+$labels['customdate'] = 'Eigenes Datum';
$labels['location'] = 'Ort';
$labels['date'] = 'Datum';
$labels['start'] = 'Beginn';
diff --git a/plugins/calendar/localization/en_US.inc b/plugins/calendar/localization/en_US.inc
index 9a631b20..5c41ed11 100644
--- a/plugins/calendar/localization/en_US.inc
+++ b/plugins/calendar/localization/en_US.inc
@@ -46,6 +46,9 @@ $labels['description'] = 'Description';
$labels['all-day'] = 'all-day';
$labels['export'] = 'Export';
$labels['exporttitle'] = 'Export to iCalendar';
+$labels['exportrange'] = 'Events from';
+$labels['exportattachments'] = 'With attachments';
+$labels['customdate'] = 'Custom date';
$labels['location'] = 'Location';
$labels['url'] = 'URL';
$labels['date'] = 'Date';
diff --git a/plugins/calendar/skins/classic/templates/calendar.html b/plugins/calendar/skins/classic/templates/calendar.html
index bb3e4b19..3c46cb73 100644
--- a/plugins/calendar/skins/classic/templates/calendar.html
+++ b/plugins/calendar/skins/classic/templates/calendar.html
@@ -146,6 +146,10 @@