Beispiel #1
0
 public function init()
 {
     $rcmail = rcmail::get_instance();
     // the plugin might have been force-loaded so do some sanity check first
     if ($rcmail->output->type != 'html' || self::$ui_theme) {
         return;
     }
     $this->load_config();
     // include UI scripts
     $this->include_script("js/jquery-ui.min.js");
     // include UI stylesheet
     $skin = $rcmail->config->get('skin');
     $ui_map = $rcmail->config->get('jquery_ui_skin_map', array());
     $ui_theme = $ui_map[$skin] ?: $skin;
     self::$ui_theme = $ui_theme;
     if (file_exists($this->home . "/themes/{$ui_theme}/jquery-ui.css")) {
         $this->include_stylesheet("themes/{$ui_theme}/jquery-ui.css");
     } else {
         $this->include_stylesheet("themes/larry/jquery-ui.css");
     }
     if ($ui_theme == 'larry') {
         // patch dialog position function in order to fully fit the close button into the window
         $rcmail->output->add_script("jQuery.extend(jQuery.ui.dialog.prototype.options.position, {\n                using: function(pos) {\n                    var me = jQuery(this),\n                        offset = me.css(pos).offset(),\n                        topOffset = offset.top - 12;\n                    if (topOffset < 0)\n                        me.css('top', pos.top - topOffset);\n                    if (offset.left + me.outerWidth() + 12 > jQuery(window).width())\n                        me.css('left', pos.left - 12);\n                }\n            });", 'foot');
     }
     // jquery UI localization
     $jquery_ui_i18n = $rcmail->config->get('jquery_ui_i18n', array('datepicker'));
     if (count($jquery_ui_i18n) > 0) {
         $lang_l = str_replace('_', '-', substr($_SESSION['language'], 0, 5));
         $lang_s = substr($_SESSION['language'], 0, 2);
         foreach ($jquery_ui_i18n as $package) {
             if (file_exists($this->home . "/js/i18n/jquery.ui.{$package}-{$lang_l}.js")) {
                 $this->include_script("js/i18n/jquery.ui.{$package}-{$lang_l}.js");
             } else {
                 if (file_exists($this->home . "/js/i18n/jquery.ui.{$package}-{$lang_s}.js")) {
                     $this->include_script("js/i18n/jquery.ui.{$package}-{$lang_s}.js");
                 }
             }
         }
     }
     // Date format for datepicker
     $date_format = $rcmail->config->get('date_format', 'Y-m-d');
     $date_format = strtr($date_format, array('y' => 'y', 'Y' => 'yy', 'm' => 'mm', 'n' => 'm', 'd' => 'dd', 'j' => 'd'));
     $rcmail->output->set_env('date_format', $date_format);
 }
Beispiel #2
0
 /**
  * Handler for preferences_list hook.
  * Adds options blocks into Calendar settings sections in Preferences.
  *
  * @param array Original parameters
  * @return array Modified parameters
  */
 function preferences_list($p)
 {
     if ($p['section'] != 'calendar') {
         return $p;
     }
     $no_override = array_flip((array) $this->rc->config->get('dont_override'));
     $p['blocks']['view']['name'] = $this->gettext('mainoptions');
     if (!isset($no_override['calendar_default_view'])) {
         if (!$p['current']) {
             $p['blocks']['view']['content'] = true;
             return $p;
         }
         $field_id = 'rcmfd_default_view';
         $select = new html_select(array('name' => '_default_view', 'id' => $field_id));
         $select->add($this->gettext('day'), "agendaDay");
         $select->add($this->gettext('week'), "agendaWeek");
         $select->add($this->gettext('month'), "month");
         $select->add($this->gettext('agenda'), "table");
         $p['blocks']['view']['options']['default_view'] = array('title' => html::label($field_id, rcube::Q($this->gettext('default_view'))), 'content' => $select->show($this->rc->config->get('calendar_default_view', $this->defaults['calendar_default_view'])));
     }
     if (!isset($no_override['calendar_timeslots'])) {
         if (!$p['current']) {
             $p['blocks']['view']['content'] = true;
             return $p;
         }
         $field_id = 'rcmfd_timeslot';
         $choices = array('1', '2', '3', '4', '6');
         $select = new html_select(array('name' => '_timeslots', 'id' => $field_id));
         $select->add($choices);
         $p['blocks']['view']['options']['timeslots'] = array('title' => html::label($field_id, rcube::Q($this->gettext('timeslots'))), 'content' => $select->show(strval($this->rc->config->get('calendar_timeslots', $this->defaults['calendar_timeslots']))));
     }
     if (!isset($no_override['calendar_first_day'])) {
         if (!$p['current']) {
             $p['blocks']['view']['content'] = true;
             return $p;
         }
         $field_id = 'rcmfd_firstday';
         $select = new html_select(array('name' => '_first_day', 'id' => $field_id));
         $select->add($this->gettext('sunday'), '0');
         $select->add($this->gettext('monday'), '1');
         $select->add($this->gettext('tuesday'), '2');
         $select->add($this->gettext('wednesday'), '3');
         $select->add($this->gettext('thursday'), '4');
         $select->add($this->gettext('friday'), '5');
         $select->add($this->gettext('saturday'), '6');
         $p['blocks']['view']['options']['first_day'] = array('title' => html::label($field_id, rcube::Q($this->gettext('first_day'))), 'content' => $select->show(strval($this->rc->config->get('calendar_first_day', $this->defaults['calendar_first_day']))));
     }
     if (!isset($no_override['calendar_first_hour'])) {
         if (!$p['current']) {
             $p['blocks']['view']['content'] = true;
             return $p;
         }
         $time_format = $this->rc->config->get('time_format', libcalendaring::to_php_date_format($this->rc->config->get('calendar_time_format', $this->defaults['calendar_time_format'])));
         $select_hours = new html_select();
         for ($h = 0; $h < 24; $h++) {
             $select_hours->add(date($time_format, mktime($h, 0, 0)), $h);
         }
         $field_id = 'rcmfd_firsthour';
         $p['blocks']['view']['options']['first_hour'] = array('title' => html::label($field_id, rcube::Q($this->gettext('first_hour'))), 'content' => $select_hours->show($this->rc->config->get('calendar_first_hour', $this->defaults['calendar_first_hour']), array('name' => '_first_hour', 'id' => $field_id)));
     }
     if (!isset($no_override['calendar_work_start'])) {
         if (!$p['current']) {
             $p['blocks']['view']['content'] = true;
             return $p;
         }
         $field_id = 'rcmfd_workstart';
         $p['blocks']['view']['options']['workinghours'] = array('title' => html::label($field_id, rcube::Q($this->gettext('workinghours'))), 'content' => $select_hours->show($this->rc->config->get('calendar_work_start', $this->defaults['calendar_work_start']), array('name' => '_work_start', 'id' => $field_id)) . ' &mdash; ' . $select_hours->show($this->rc->config->get('calendar_work_end', $this->defaults['calendar_work_end']), array('name' => '_work_end', 'id' => $field_id)));
     }
     if (!isset($no_override['calendar_event_coloring'])) {
         if (!$p['current']) {
             $p['blocks']['view']['content'] = true;
             return $p;
         }
         $field_id = 'rcmfd_coloring';
         $select_colors = new html_select(array('name' => '_event_coloring', 'id' => $field_id));
         $select_colors->add($this->gettext('coloringmode0'), 0);
         $select_colors->add($this->gettext('coloringmode1'), 1);
         $select_colors->add($this->gettext('coloringmode2'), 2);
         $select_colors->add($this->gettext('coloringmode3'), 3);
         $p['blocks']['view']['options']['eventcolors'] = array('title' => html::label($field_id . 'value', rcube::Q($this->gettext('eventcoloring'))), 'content' => $select_colors->show($this->rc->config->get('calendar_event_coloring', $this->defaults['calendar_event_coloring'])));
     }
     // loading driver is expensive, don't do it if not needed
     $this->load_driver();
     if (!isset($no_override['calendar_default_alarm_type']) || !isset($no_override['calendar_default_alarm_offset'])) {
         if (!$p['current']) {
             $p['blocks']['view']['content'] = true;
             return $p;
         }
         $alarm_type = $alarm_offset = '';
         if (!isset($no_override['calendar_default_alarm_type'])) {
             $field_id = 'rcmfd_alarm';
             $select_type = new html_select(array('name' => '_alarm_type', 'id' => $field_id));
             $select_type->add($this->gettext('none'), '');
             foreach ($this->driver->alarm_types as $type) {
                 $select_type->add($this->rc->gettext(strtolower("alarm{$type}option"), 'libcalendaring'), $type);
             }
             $alarm_type = $select_type->show($this->rc->config->get('calendar_default_alarm_type', ''));
         }
         if (!isset($no_override['calendar_default_alarm_offset'])) {
             $field_id = 'rcmfd_alarm';
             $input_value = new html_inputfield(array('name' => '_alarm_value', 'id' => $field_id . 'value', 'size' => 3));
             $select_offset = new html_select(array('name' => '_alarm_offset', 'id' => $field_id . 'offset'));
             foreach (array('-M', '-H', '-D', '+M', '+H', '+D') as $trigger) {
                 $select_offset->add($this->rc->gettext('trigger' . $trigger, 'libcalendaring'), $trigger);
             }
             $preset = libcalendaring::parse_alarm_value($this->rc->config->get('calendar_default_alarm_offset', '-15M'));
             $alarm_offset = $input_value->show($preset[0]) . ' ' . $select_offset->show($preset[1]);
         }
         $p['blocks']['view']['options']['alarmtype'] = array('title' => html::label($field_id, rcube::Q($this->gettext('defaultalarmtype'))), 'content' => $alarm_type . ' ' . $alarm_offset);
     }
     if (!isset($no_override['calendar_default_calendar'])) {
         if (!$p['current']) {
             $p['blocks']['view']['content'] = true;
             return $p;
         }
         // default calendar selection
         $field_id = 'rcmfd_default_calendar';
         $select_cal = new html_select(array('name' => '_default_calendar', 'id' => $field_id, 'is_escaped' => true));
         foreach ((array) $this->driver->list_calendars(calendar_driver::FILTER_PERSONAL) as $id => $prop) {
             $select_cal->add($prop['name'], strval($id));
             if ($prop['default']) {
                 $default_calendar = $id;
             }
         }
         $p['blocks']['view']['options']['defaultcalendar'] = array('title' => html::label($field_id . 'value', rcube::Q($this->gettext('defaultcalendar'))), 'content' => $select_cal->show($this->rc->config->get('calendar_default_calendar', $default_calendar)));
     }
     $p['blocks']['itip']['name'] = $this->gettext('itipoptions');
     // Invitations handling
     if (!isset($no_override['calendar_itip_after_action'])) {
         if (!$p['current']) {
             $p['blocks']['itip']['content'] = true;
             return $p;
         }
         $field_id = 'rcmfd_after_action';
         $select = new html_select(array('name' => '_after_action', 'id' => $field_id, 'onchange' => "\$('#{$field_id}_select')[this.value == 4 ? 'show' : 'hide']()"));
         $select->add($this->gettext('afternothing'), '');
         $select->add($this->gettext('aftertrash'), 1);
         $select->add($this->gettext('afterdelete'), 2);
         $select->add($this->gettext('afterflagdeleted'), 3);
         $select->add($this->gettext('aftermoveto'), 4);
         $val = $this->rc->config->get('calendar_itip_after_action', $this->defaults['calendar_itip_after_action']);
         if ($val !== null && $val !== '' && !is_int($val)) {
             $folder = $val;
             $val = 4;
         }
         $folders = $this->rc->folder_selector(array('id' => $field_id . '_select', 'name' => '_after_action_folder', 'maxlength' => 30, 'folder_filter' => 'mail', 'folder_rights' => 'w', 'style' => $val !== 4 ? 'display:none' : ''));
         $p['blocks']['itip']['options']['after_action'] = array('title' => html::label($field_id, rcube::Q($this->gettext('afteraction'))), 'content' => $select->show($val) . $folders->show($folder));
     }
     // category definitions
     if (!$this->driver->nocategories && !isset($no_override['calendar_categories'])) {
         $p['blocks']['categories']['name'] = $this->gettext('categories');
         if (!$p['current']) {
             $p['blocks']['categories']['content'] = true;
             return $p;
         }
         $categories = (array) $this->driver->list_categories();
         $categories_list = '';
         foreach ($categories as $name => $color) {
             $key = md5($name);
             $field_class = 'rcmfd_category_' . str_replace(' ', '_', $name);
             $category_remove = new html_inputfield(array('type' => 'button', 'value' => 'X', 'class' => 'button', 'onclick' => '$(this).parent().remove()', 'title' => $this->gettext('remove_category')));
             $category_name = new html_inputfield(array('name' => "_categories[{$key}]", 'class' => $field_class, 'size' => 30, 'disabled' => $this->driver->categoriesimmutable));
             $category_color = new html_inputfield(array('name' => "_colors[{$key}]", 'class' => "{$field_class} colors", 'size' => 6));
             $hidden = $this->driver->categoriesimmutable ? html::tag('input', array('type' => 'hidden', 'name' => "_categories[{$key}]", 'value' => $name)) : '';
             $categories_list .= html::div(null, $hidden . $category_name->show($name) . '&nbsp;' . $category_color->show($color) . '&nbsp;' . $category_remove->show());
         }
         $p['blocks']['categories']['options']['category_' . $name] = array('content' => html::div(array('id' => 'calendarcategories'), $categories_list));
         $field_id = 'rcmfd_new_category';
         $new_category = new html_inputfield(array('name' => '_new_category', 'id' => $field_id, 'size' => 30));
         $add_category = new html_inputfield(array('type' => 'button', 'class' => 'button', 'value' => $this->gettext('add_category'), 'onclick' => "rcube_calendar_add_category()"));
         $p['blocks']['categories']['options']['categories'] = array('content' => $new_category->show('') . '&nbsp;' . $add_category->show());
         $this->rc->output->add_script('function rcube_calendar_add_category(){
       var name = $("#rcmfd_new_category").val();
       if (name.length) {
         var input = $("<input>").attr("type", "text").attr("name", "_categories[]").attr("size", 30).val(name);
         var color = $("<input>").attr("type", "text").attr("name", "_colors[]").attr("size", 6).addClass("colors").val("000000");
         var button = $("<input>").attr("type", "button").attr("value", "X").addClass("button").click(function(){ $(this).parent().remove() });
         $("<div>").append(input).append("&nbsp;").append(color).append("&nbsp;").append(button).appendTo("#calendarcategories");
         color.miniColors({ colorValues:(rcmail.env.mscolors || []) });
         $("#rcmfd_new_category").val("");
       }
     }');
         $this->rc->output->add_script('$("#rcmfd_new_category").keypress(function(event){
       if (event.which == 13) {
         rcube_calendar_add_category();
         event.preventDefault();
       }
     });
     ', 'docready');
         // load miniColors js/css files
         jqueryui::miniColors();
     }
     // virtual birthdays calendar
     if (!isset($no_override['calendar_contact_birthdays'])) {
         $p['blocks']['birthdays']['name'] = $this->gettext('birthdayscalendar');
         if (!$p['current']) {
             $p['blocks']['birthdays']['content'] = true;
             return $p;
         }
         $field_id = 'rcmfd_contact_birthdays';
         $input = new html_checkbox(array('name' => '_contact_birthdays', 'id' => $field_id, 'value' => 1, 'onclick' => '$(".calendar_birthday_props").prop("disabled",!this.checked)'));
         $p['blocks']['birthdays']['options']['contact_birthdays'] = array('title' => html::label($field_id, $this->gettext('displaybirthdayscalendar')), 'content' => $input->show($this->rc->config->get('calendar_contact_birthdays') ? 1 : 0));
         $input_attrib = array('class' => 'calendar_birthday_props', 'disabled' => !$this->rc->config->get('calendar_contact_birthdays'));
         $sources = array();
         $checkbox = new html_checkbox(array('name' => '_birthday_adressbooks[]') + $input_attrib);
         foreach ($this->rc->get_address_sources(false, true) as $source) {
             $active = in_array($source['id'], (array) $this->rc->config->get('calendar_birthday_adressbooks', array())) ? $source['id'] : '';
             $sources[] = html::label(null, $checkbox->show($active, array('value' => $source['id'])) . '&nbsp;' . rcube::Q($source['realname'] ?: $source['name']));
         }
         $p['blocks']['birthdays']['options']['birthday_adressbooks'] = array('title' => rcube::Q($this->gettext('birthdayscalendarsources')), 'content' => join(html::br(), $sources));
         $field_id = 'rcmfd_birthdays_alarm';
         $select_type = new html_select(array('name' => '_birthdays_alarm_type', 'id' => $field_id) + $input_attrib);
         $select_type->add($this->gettext('none'), '');
         foreach ($this->driver->alarm_types as $type) {
             $select_type->add($this->rc->gettext(strtolower("alarm{$type}option"), 'libcalendaring'), $type);
         }
         $input_value = new html_inputfield(array('name' => '_birthdays_alarm_value', 'id' => $field_id . 'value', 'size' => 3) + $input_attrib);
         $select_offset = new html_select(array('name' => '_birthdays_alarm_offset', 'id' => $field_id . 'offset') + $input_attrib);
         foreach (array('-M', '-H', '-D') as $trigger) {
             $select_offset->add($this->rc->gettext('trigger' . $trigger, 'libcalendaring'), $trigger);
         }
         $preset = libcalendaring::parse_alarm_value($this->rc->config->get('calendar_birthdays_alarm_offset', '-1D'));
         $p['blocks']['birthdays']['options']['birthdays_alarmoffset'] = array('title' => html::label($field_id . 'value', rcube::Q($this->gettext('showalarms'))), 'content' => $select_type->show($this->rc->config->get('calendar_birthdays_alarm_type', '')) . ' ' . $input_value->show($preset[0]) . '&nbsp;' . $select_offset->show($preset[1]));
     }
     return $p;
 }
 /**
  * Adds JS files to the page header
  */
 public function addJS()
 {
     $this->cal->include_script('calendar_ui.js');
     $this->cal->include_script('lib/js/fullcalendar.js');
     $this->rc->output->include_script('treelist.js');
     // include kolab folderlist widget if available
     if (in_array('libkolab', $this->cal->api->loaded_plugins())) {
         $this->cal->api->include_script('libkolab/js/folderlist.js');
     }
     jqueryui::miniColors();
 }
 /**
  * Register handler methods for the template engine
  */
 public function init_templates()
 {
     $this->plugin->register_handler('plugin.tasklists', array($this, 'tasklists'));
     $this->plugin->register_handler('plugin.tasklist_select', array($this, 'tasklist_select'));
     $this->plugin->register_handler('plugin.status_select', array($this, 'status_select'));
     $this->plugin->register_handler('plugin.searchform', array($this->rc->output, 'search_form'));
     $this->plugin->register_handler('plugin.quickaddform', array($this, 'quickadd_form'));
     $this->plugin->register_handler('plugin.tasks', array($this, 'tasks_resultview'));
     $this->plugin->register_handler('plugin.tagslist', array($this, 'tagslist'));
     $this->plugin->register_handler('plugin.tags_editline', array($this, 'tags_editline'));
     $this->plugin->register_handler('plugin.alarm_select', array($this, 'alarm_select'));
     $this->plugin->register_handler('plugin.recurrence_form', array($this->plugin->lib, 'recurrence_form'));
     $this->plugin->register_handler('plugin.attachments_form', array($this, 'attachments_form'));
     $this->plugin->register_handler('plugin.attachments_list', array($this, 'attachments_list'));
     $this->plugin->register_handler('plugin.filedroparea', array($this, 'file_drop_area'));
     $this->plugin->register_handler('plugin.attendees_list', array($this, 'attendees_list'));
     $this->plugin->register_handler('plugin.attendees_form', array($this, 'attendees_form'));
     $this->plugin->register_handler('plugin.identity_select', array($this, 'identity_select'));
     $this->plugin->register_handler('plugin.edit_attendees_notify', array($this, 'edit_attendees_notify'));
     $this->plugin->register_handler('plugin.task_rsvp_buttons', array($this->plugin->itip, 'itip_rsvp_buttons'));
     $this->plugin->register_handler('plugin.object_changelog_table', array('libkolab', 'object_changelog_table'));
     jqueryui::tagedit();
     $this->plugin->include_script('tasklist.js');
     $this->rc->output->include_script('treelist.js');
     // include kolab folderlist widget if available
     if (in_array('libkolab', $this->plugin->api->loaded_plugins())) {
         $this->plugin->api->include_script('libkolab/js/folderlist.js');
         $this->plugin->api->include_script('libkolab/js/audittrail.js');
     }
 }