3 commits - plugins/calendar

Thomas Brüderli bruederli at kolabsys.com
Tue Oct 22 13:21:16 CEST 2013


 plugins/calendar/calendar.php                          |   17 +++-
 plugins/calendar/calendar_ui.js                        |   61 ++++++++++++++++-
 plugins/calendar/drivers/database/database_driver.php  |    2 
 plugins/calendar/lib/calendar_ui.php                   |   51 +++++++++++++-
 plugins/calendar/lib/js/fullcalendar.js                |    2 
 plugins/calendar/localization/de_CH.inc                |    3 
 plugins/calendar/localization/de_DE.inc                |    3 
 plugins/calendar/localization/en_US.inc                |    3 
 plugins/calendar/skins/classic/templates/calendar.html |    4 +
 plugins/calendar/skins/larry/calendar.css              |   15 ++--
 plugins/calendar/skins/larry/templates/calendar.html   |    4 +
 11 files changed, 150 insertions(+), 15 deletions(-)

New commits:
commit c2ebe32fda09370fe9b4bd4f1d2a9195368ac5c6
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Tue Oct 22 13:20:17 2013 +0200

    Show dialog for event export settings like start date and w/o attachments (#1712)

diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index 8314635..074f7bf 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 c367daf..693ff09 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 9ffb4ee..85e87f8 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()) .
@@ -573,6 +575,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
    */
   function attachments_form($attrib = array())
diff --git a/plugins/calendar/lib/js/fullcalendar.js b/plugins/calendar/lib/js/fullcalendar.js
index f790eea..4f0862a 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 de3def7..0cb7e66 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 11a8205..9e42874 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 9a631b2..5c41ed1 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 bb3e4b1..3c46cb7 100644
--- a/plugins/calendar/skins/classic/templates/calendar.html
+++ b/plugins/calendar/skins/classic/templates/calendar.html
@@ -146,6 +146,10 @@
   <roundcube:object name="plugin.events_import_form" id="events-import-form" uploadFieldSize="30" />
 </div>
 
+<div id="eventsexport" class="uidialog">
+  <roundcube:object name="plugin.events_export_form" id="events-export-form" />
+</div>
+
 <div id="calendarurlbox" class="uidialog">
   <p><roundcube:label name="calendar.showurldescription" /></p>
   <textarea id="calfeedurl" rows="2" readonly="readonly"></textarea>
diff --git a/plugins/calendar/skins/larry/templates/calendar.html b/plugins/calendar/skins/larry/templates/calendar.html
index 341632b..0d81289 100644
--- a/plugins/calendar/skins/larry/templates/calendar.html
+++ b/plugins/calendar/skins/larry/templates/calendar.html
@@ -161,6 +161,10 @@
 	<roundcube:object name="plugin.events_import_form" id="events-import-form" uploadFieldSize="30" />
 </div>
 
+<div id="eventsexport" class="uidialog">
+	<roundcube:object name="plugin.events_export_form" id="events-export-form" />
+</div>
+
 <div id="calendarurlbox" class="uidialog">
 	<p><roundcube:label name="calendar.showurldescription" /></p>
 	<textarea id="calfeedurl" rows="2" readonly="readonly"></textarea>


commit dcdc4299b14934623056f578ff3b293b9cf555a6
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Tue Oct 22 13:17:50 2013 +0200

    Give more space to toolbar buttons and labels

diff --git a/plugins/calendar/skins/larry/calendar.css b/plugins/calendar/skins/larry/calendar.css
index 3231436..4c5c6e3 100644
--- a/plugins/calendar/skins/larry/calendar.css
+++ b/plugins/calendar/skins/larry/calendar.css
@@ -31,7 +31,7 @@ body.attachmentwin #topnav .topright {
 	top: 0;
 	left: 10px;
 	bottom: 0;
-	width: 240px;
+	width: 250px;
 }
 
 #datepicker {
@@ -95,7 +95,7 @@ body.attachmentwin #topnav .topright {
 
 #calendarsidebartoggle {
 	position: absolute;
-	left: 254px;
+	left: 264px;
 	width: 8px;
 	top: 40px;
 	bottom: 0;
@@ -114,7 +114,7 @@ div.sidebarclosed {
 #calendar {
 	position: absolute;
 	top: 0;
-	left: 266px;
+	left: 276px;
 	right: 0;
 	bottom: 0;
 	padding-bottom: 28px;
@@ -280,21 +280,22 @@ pre {
 
 #calendartoolbar a.button {
 	background-image: url(images/toolbar.png);
+	padding-left: 0;
+	padding-right: 0;
+	min-width: 50px;
+	max-width: 60px;
 }
 
 #calendartoolbar a.button.addevent {
 	background-position: center 1px;
+	max-width: 70px;
 }
 
 #calendartoolbar a.button.export {
-	min-width: 50px;
-	max-width: 55px;
 	background-position: center -40px;
 }
 
 #calendartoolbar a.button.import {
-	min-width: 50px;
-	max-width: 55px;
 	background-position: center -440px;
 }
 


commit 4c85eeac3c845184f9ed406fdd89c09f130cb6f2
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Tue Oct 22 12:51:47 2013 +0200

    Fix typo

diff --git a/plugins/calendar/drivers/database/database_driver.php b/plugins/calendar/drivers/database/database_driver.php
index a2cb903..7896433 100644
--- a/plugins/calendar/drivers/database/database_driver.php
+++ b/plugins/calendar/drivers/database/database_driver.php
@@ -743,7 +743,7 @@ class database_driver extends calendar_driver
     }
     
     if (!$virtual)
-      $sql_arr .= ' AND e.recurrence_id = 0';
+      $sql_add .= ' AND e.recurrence_id = 0';
     
     if ($modifiedsince)
       $sql_add .= ' AND e.changed >= ' . $this->rc->db->quote(date('Y-m-d H:i:s', $modifiedsince));




More information about the commits mailing list