Branch 'roundcubemail-plugins-kolab-3.1' - 2 commits - plugins/calendar

Thomas Brüderli bruederli at kolabsys.com
Mon Mar 17 12:48:12 CET 2014


 plugins/calendar/calendar.php                          |   19 +++--
 plugins/calendar/calendar_ui.js                        |   61 ++++++++++++++++-
 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/calendar.css            |    8 ++
 plugins/calendar/skins/classic/images/toolbar.png      |binary
 plugins/calendar/skins/classic/templates/calendar.html |    6 +
 plugins/calendar/skins/larry/calendar.css              |    9 ++
 plugins/calendar/skins/larry/images/toolbar.png        |binary
 plugins/calendar/skins/larry/templates/calendar.html   |    6 +
 13 files changed, 161 insertions(+), 10 deletions(-)

New commits:
commit 1f2c9088715e52e0940c38d8da398fab9344de7b
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Thu Oct 17 17:28:28 2013 +0200

    Move button for event import to the toolbar in order to make the UI consistent with the address book (#1655)

diff --git a/plugins/calendar/skins/classic/calendar.css b/plugins/calendar/skins/classic/calendar.css
index 7182b5d..77308c2 100644
--- a/plugins/calendar/skins/classic/calendar.css
+++ b/plugins/calendar/skins/classic/calendar.css
@@ -253,6 +253,14 @@ pre {
   background-position: -64px -32px;
 }
 
+#calendartoolbar a.import {
+	background-position: -168px 0;
+}
+
+#calendartoolbar a.importSel {
+	background-position: -168px -32px;
+}
+
 #calendartoolbar a.export {
 	background-position: -128px 0;
 }
diff --git a/plugins/calendar/skins/classic/images/toolbar.png b/plugins/calendar/skins/classic/images/toolbar.png
index 94beddb..d49162a 100644
Binary files a/plugins/calendar/skins/classic/images/toolbar.png and b/plugins/calendar/skins/classic/images/toolbar.png differ
diff --git a/plugins/calendar/skins/classic/templates/calendar.html b/plugins/calendar/skins/classic/templates/calendar.html
index d9f0283..da77999 100644
--- a/plugins/calendar/skins/classic/templates/calendar.html
+++ b/plugins/calendar/skins/classic/templates/calendar.html
@@ -36,7 +36,6 @@
     <li><roundcube:button command="calendar-edit" label="calendar.edit" classAct="active" /></li>
     <li><roundcube:button command="calendar-remove" label="calendar.remove" classAct="active" /></li>
     <li><roundcube:button command="calendar-showurl" label="calendar.showurl" classAct="active" /></li>
-    <li><roundcube:button command="events-import" label="calendar.importevents" classAct="active" /></li>
     <roundcube:if condition="env:calendar_driver == 'kolab'" />
     <li class="separator_above"><roundcube:button command="folders" task="settings" type="link" label="managefolders" classAct="active" /></li>
     <roundcube:endif />
@@ -163,6 +162,7 @@
 <div id="calendartoolbar">
   <roundcube:button command="addevent" type="link" class="buttonPas addevent" classAct="button addevent" classSel="button addeventSel" title="calendar.new_event" content=" " />
   <roundcube:button command="print" type="link" class="buttonPas print" classAct="button print" classSel="button printSel" title="calendar.print" content=" " />
+  <roundcube:button command="events-import" type="link" class="buttonPas import" classAct="button import" classSel="button importSel" title="calendar.importevents" content=" " />
   <roundcube:button command="export" type="link" class="buttonPas export" classAct="button export" classSel="button exportSel" title="calendar.export" content=" " />
   <roundcube:container name="toolbar" id="calendartoolbar" />
 </div>
diff --git a/plugins/calendar/skins/larry/calendar.css b/plugins/calendar/skins/larry/calendar.css
index ea88ffe..aa5345d 100644
--- a/plugins/calendar/skins/larry/calendar.css
+++ b/plugins/calendar/skins/larry/calendar.css
@@ -276,6 +276,7 @@ pre {
 	top: -6px;
 	left: 0;
 	height: 40px;
+	white-space: nowrap;
 }
 
 #calendartoolbar a.button {
@@ -287,9 +288,17 @@ pre {
 }
 
 #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;
+}
+
 #calendartoolbar a.button.print {
 	background-position: center -80px;
 }
diff --git a/plugins/calendar/skins/larry/images/toolbar.png b/plugins/calendar/skins/larry/images/toolbar.png
index 16ce444..f829837 100644
Binary files a/plugins/calendar/skins/larry/images/toolbar.png and b/plugins/calendar/skins/larry/images/toolbar.png differ
diff --git a/plugins/calendar/skins/larry/templates/calendar.html b/plugins/calendar/skins/larry/templates/calendar.html
index 8c39a00..910df17 100644
--- a/plugins/calendar/skins/larry/templates/calendar.html
+++ b/plugins/calendar/skins/larry/templates/calendar.html
@@ -14,6 +14,7 @@
 		<div id="calendartoolbar" class="toolbar">
 			<roundcube:button command="addevent" type="link" class="button addevent disabled" classAct="button addevent" classSel="button addevent pressed" label="calendar.new_event" title="calendar.new_event" />
 			<roundcube:button command="print" type="link" class="button print disabled" classAct="button print" classSel="button print pressed" label="calendar.print" title="calendar.printtitle" />
+			<roundcube:button command="events-import" type="link" class="button import disabled" classAct="button import" classSel="button import pressed" label="import" title="calendar.importevents" />
 			<roundcube:button command="export" type="link" class="button export disabled" classAct="button export" classSel="button export pressed" label="calendar.export" title="calendar.exporttitle" />
 			<roundcube:container name="toolbar" id="calendartoolbar" />
 		</div>
@@ -50,7 +51,6 @@
 		<li><roundcube:button command="calendar-edit" label="calendar.edit" classAct="active" /></li>
 		<li><roundcube:button command="calendar-remove" label="calendar.remove" classAct="active" /></li>
 		<li><roundcube:button command="calendar-showurl" label="calendar.showurl" classAct="active" /></li>
-		<li><roundcube:button command="events-import" label="calendar.importevents" classAct="active" /></li>
 		<roundcube:if condition="env:calendar_driver == 'kolab'" />
 		<li class="separator_above"><roundcube:button command="folders" task="settings" type="link" label="managefolders" classAct="active" /></li>
 		<roundcube:endif />


commit d1b8949998cdd1b68819e99c1986d158b8a77cb4
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 9f02289..5bf5fdb 100644
--- a/plugins/calendar/calendar.php
+++ b/plugins/calendar/calendar.php
@@ -1083,11 +1083,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(true);
-    
+
+    $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
@@ -1100,7 +1109,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 7d53e99..adafb3b 100644
--- a/plugins/calendar/calendar_ui.js
+++ b/plugins/calendar/calendar_ui.js
@@ -2039,6 +2039,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)
     {
@@ -2712,6 +2769,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
@@ -2810,7 +2869,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 b580fc2..2360be5 100644
--- a/plugins/calendar/localization/de_CH.inc
+++ b/plugins/calendar/localization/de_CH.inc
@@ -46,6 +46,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 60e6ad2..f8227e8 100644
--- a/plugins/calendar/localization/de_DE.inc
+++ b/plugins/calendar/localization/de_DE.inc
@@ -46,6 +46,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 af66629..d9f0283 100644
--- a/plugins/calendar/skins/classic/templates/calendar.html
+++ b/plugins/calendar/skins/classic/templates/calendar.html
@@ -147,6 +147,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 6748741..8c39a00 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>




More information about the commits mailing list