2011-05-20 19:04:25 +02:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
+-------------------------------------------------------------------------+
|
|
|
|
| User Interface for the Calendar Plugin |
|
|
|
|
| Version 0.3 beta |
|
|
|
|
| |
|
|
|
|
| This program is free software; you can redistribute it and/or modify |
|
|
|
|
| it under the terms of the GNU General Public License version 2 |
|
|
|
|
| as published by the Free Software Foundation. |
|
|
|
|
| |
|
|
|
|
| This program is distributed in the hope that it will be useful, |
|
|
|
|
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
|
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
|
|
| GNU General Public License for more details. |
|
|
|
|
| |
|
|
|
|
| You should have received a copy of the GNU General Public License along |
|
|
|
|
| with this program; if not, write to the Free Software Foundation, Inc., |
|
|
|
|
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
|
|
|
| |
|
|
|
|
+-------------------------------------------------------------------------+
|
|
|
|
| Author: Lazlo Westerhof <hello@lazlo.me> |
|
|
|
|
+-------------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
class calendar_ui
|
|
|
|
{
|
|
|
|
private $rc;
|
|
|
|
private $calendar;
|
2011-07-29 09:19:18 +02:00
|
|
|
private $ready = false;
|
2011-07-26 09:38:44 +02:00
|
|
|
public $screen;
|
2011-05-20 19:04:25 +02:00
|
|
|
|
|
|
|
function __construct($calendar)
|
|
|
|
{
|
|
|
|
$this->calendar = $calendar;
|
|
|
|
$this->rc = $calendar->rc;
|
2011-07-26 09:38:44 +02:00
|
|
|
$this->screen = $this->rc->task == 'calendar' ? ($this->rc->action ? $this->rc->action: 'calendar') : 'other';
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calendar UI initialization and requests handlers
|
|
|
|
*/
|
|
|
|
public function init()
|
|
|
|
{
|
2011-07-29 09:19:18 +02:00
|
|
|
if ($this->ready) // already done
|
|
|
|
return;
|
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
// add taskbar button
|
|
|
|
$this->calendar->add_button(array(
|
|
|
|
'name' => 'calendar',
|
|
|
|
'class' => 'button-calendar',
|
|
|
|
'label' => 'calendar.calendar',
|
|
|
|
'href' => './?_task=calendar',
|
|
|
|
), 'taskbar');
|
2011-06-19 17:56:23 -06:00
|
|
|
|
|
|
|
// load basic client script (which - unfortunately - requires fullcalendar)
|
|
|
|
$this->calendar->include_script('lib/js/fullcalendar.js');
|
|
|
|
$this->calendar->include_script('calendar_base.js');
|
2011-07-16 16:11:10 +02:00
|
|
|
|
|
|
|
$skin = $this->rc->config->get('skin');
|
|
|
|
$this->calendar->include_stylesheet('skins/' . $skin . '/calendar.css');
|
2011-07-29 09:19:18 +02:00
|
|
|
|
|
|
|
$this->ready = true;
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds CSS stylesheets to the page header
|
|
|
|
*/
|
|
|
|
public function addCSS()
|
|
|
|
{
|
|
|
|
$skin = $this->rc->config->get('skin');
|
|
|
|
$this->calendar->include_stylesheet('skins/' . $skin . '/fullcalendar.css');
|
2011-07-16 16:11:10 +02:00
|
|
|
$this->calendar->include_stylesheet('skins/' . $skin . '/jquery.miniColors.css');
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds JS files to the page header
|
|
|
|
*/
|
|
|
|
public function addJS()
|
|
|
|
{
|
2011-06-19 17:56:23 -06:00
|
|
|
$this->calendar->include_script('calendar_ui.js');
|
|
|
|
$this->calendar->include_script('lib/js/jquery.miniColors.min.js');
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|
2011-07-16 16:11:10 +02:00
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2011-07-16 16:11:10 +02:00
|
|
|
function calendar_css($attrib = array())
|
2011-05-20 19:04:25 +02:00
|
|
|
{
|
|
|
|
$categories = $this->rc->config->get('calendar_categories', array());
|
|
|
|
|
|
|
|
$css = "\n";
|
|
|
|
|
|
|
|
foreach ((array)$categories as $class => $color) {
|
|
|
|
$class = 'cat-' . asciiwords($class, true);
|
|
|
|
$css .= "." . $class . ",\n";
|
|
|
|
$css .= ".fc-event-" . $class . ",\n";
|
|
|
|
$css .= "." . $class . " a {\n";
|
|
|
|
$css .= "color: #" . $color . ";\n";
|
|
|
|
$css .= "border-color: #" . $color . ";\n";
|
|
|
|
$css .= "}\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$calendars = $this->calendar->driver->list_calendars();
|
|
|
|
foreach ((array)$calendars as $id => $prop) {
|
|
|
|
if (!$prop['color'])
|
|
|
|
continue;
|
|
|
|
$color = $prop['color'];
|
|
|
|
$class = 'cal-' . asciiwords($id, true);
|
|
|
|
$css .= "li." . $class . ", ";
|
|
|
|
$css .= "#eventshow ." . $class . " { ";
|
|
|
|
$css .= "color: #" . $color . " }\n";
|
|
|
|
$css .= ".fc-event-" . $class . ", ";
|
|
|
|
$css .= ".fc-event-" . $class . " .fc-event-inner, ";
|
|
|
|
$css .= ".fc-event-" . $class . " .fc-event-time {\n";
|
2011-07-16 16:11:10 +02:00
|
|
|
if (!$attrib['printmode'])
|
|
|
|
$css .= "background-color: #" . $color . ";\n";
|
2011-05-20 19:04:25 +02:00
|
|
|
$css .= "border-color: #" . $color . ";\n";
|
|
|
|
$css .= "}\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
return html::tag('style', array('type' => 'text/css'), $css);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function calendar_list($attrib = array())
|
|
|
|
{
|
|
|
|
$calendars = $this->calendar->driver->list_calendars();
|
2011-06-03 18:23:17 +02:00
|
|
|
$hidden = explode(',', $this->rc->config->get('hidden_calendars', ''));
|
2011-05-20 19:04:25 +02:00
|
|
|
|
|
|
|
$li = '';
|
|
|
|
foreach ((array)$calendars as $id => $prop) {
|
2011-07-16 16:11:10 +02:00
|
|
|
if ($attrib['activeonly'] && in_array($id, $hidden))
|
|
|
|
continue;
|
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
unset($prop['user_id']);
|
2011-05-22 17:29:09 +02:00
|
|
|
$prop['alarms'] = $this->calendar->driver->alarms;
|
2011-05-20 19:04:25 +02:00
|
|
|
$prop['attendees'] = $this->calendar->driver->attendees;
|
2011-07-26 08:38:13 +02:00
|
|
|
$prop['freebusy'] = $this->calendar->driver->freebusy;
|
2011-05-20 19:04:25 +02:00
|
|
|
$prop['attachments'] = $this->calendar->driver->attachments;
|
|
|
|
$jsenv[$id] = $prop;
|
2011-06-28 13:05:58 +02:00
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
$html_id = html_identifier($id);
|
2011-06-28 13:05:58 +02:00
|
|
|
$class = 'cal-' . asciiwords($id, true);
|
|
|
|
|
|
|
|
if ($prop['readonly'])
|
|
|
|
$class .= ' readonly';
|
|
|
|
if ($prop['class_name'])
|
|
|
|
$class .= ' '.$prop['class_name'];
|
|
|
|
|
|
|
|
$li .= html::tag('li', array('id' => 'rcmlical' . $html_id, 'class' => $class),
|
2011-06-03 18:23:17 +02:00
|
|
|
html::tag('input', array('type' => 'checkbox', 'name' => '_cal[]', 'value' => $id, 'checked' => !in_array($id, $hidden)), '') . html::span(null, Q($prop['name'])));
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->rc->output->set_env('calendars', $jsenv);
|
|
|
|
$this->rc->output->add_gui_object('folderlist', $attrib['id']);
|
2011-06-28 13:05:58 +02:00
|
|
|
|
2011-07-16 16:11:10 +02:00
|
|
|
return html::tag('ul', $attrib, $li, html::$common_attrib);
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render a HTML select box for calendar selection
|
|
|
|
*/
|
|
|
|
function calendar_select($attrib = array())
|
|
|
|
{
|
|
|
|
$attrib['name'] = 'calendar';
|
|
|
|
$select = new html_select($attrib);
|
|
|
|
foreach ((array)$this->calendar->driver->list_calendars() as $id => $prop) {
|
2011-06-11 14:10:49 -06:00
|
|
|
if (!$prop['readonly'])
|
|
|
|
$select->add($prop['name'], $id);
|
2011-05-20 19:04:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $select->show(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render a HTML select box to select an event category
|
|
|
|
*/
|
|
|
|
function category_select($attrib = array())
|
|
|
|
{
|
|
|
|
$attrib['name'] = 'categories';
|
|
|
|
$select = new html_select($attrib);
|
|
|
|
$select->add('---', '');
|
|
|
|
foreach ((array)$this->calendar->driver->list_categories() as $cat => $color) {
|
|
|
|
$select->add($cat, $cat);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $select->show(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render a HTML select box for free/busy/out-of-office property
|
|
|
|
*/
|
|
|
|
function freebusy_select($attrib = array())
|
|
|
|
{
|
|
|
|
$attrib['name'] = 'freebusy';
|
|
|
|
$select = new html_select($attrib);
|
|
|
|
$select->add($this->calendar->gettext('free'), 'free');
|
|
|
|
$select->add($this->calendar->gettext('busy'), 'busy');
|
|
|
|
$select->add($this->calendar->gettext('outofoffice'), 'outofoffice');
|
2011-06-14 14:52:20 +03:00
|
|
|
$select->add($this->calendar->gettext('tentative'), 'tentative');
|
2011-05-20 19:04:25 +02:00
|
|
|
return $select->show(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render a HTML select for event priorities
|
|
|
|
*/
|
|
|
|
function priority_select($attrib = array())
|
|
|
|
{
|
|
|
|
$attrib['name'] = 'priority';
|
|
|
|
$select = new html_select($attrib);
|
|
|
|
$select->add($this->calendar->gettext('normal'), '1');
|
|
|
|
$select->add($this->calendar->gettext('low'), '0');
|
|
|
|
$select->add($this->calendar->gettext('high'), '2');
|
|
|
|
return $select->show(null);
|
|
|
|
}
|
|
|
|
|
2011-05-27 18:41:01 +02:00
|
|
|
/**
|
|
|
|
* Render HTML input for sensitivity selection
|
|
|
|
*/
|
|
|
|
function sensitivity_select($attrib = array())
|
|
|
|
{
|
|
|
|
$attrib['name'] = 'sensitivity';
|
|
|
|
$select = new html_select($attrib);
|
|
|
|
$select->add($this->calendar->gettext('public'), '0');
|
|
|
|
$select->add($this->calendar->gettext('private'), '1');
|
|
|
|
$select->add($this->calendar->gettext('confidential'), '2');
|
|
|
|
return $select->show(null);
|
|
|
|
}
|
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
/**
|
|
|
|
* Render HTML form for alarm configuration
|
|
|
|
*/
|
|
|
|
function alarm_select($attrib = array())
|
|
|
|
{
|
|
|
|
unset($attrib['name']);
|
|
|
|
$select_type = new html_select(array('name' => 'alarmtype[]', 'class' => 'edit-alarm-type'));
|
2011-05-25 23:16:13 +02:00
|
|
|
$select_type->add($this->calendar->gettext('none'), '');
|
|
|
|
foreach ($this->calendar->driver->alarm_types as $type)
|
|
|
|
$select_type->add($this->calendar->gettext(strtolower("alarm{$type}option")), $type);
|
2011-05-20 19:04:25 +02:00
|
|
|
|
|
|
|
$input_value = new html_inputfield(array('name' => 'alarmvalue[]', 'class' => 'edit-alarm-value', 'size' => 3));
|
|
|
|
$input_date = new html_inputfield(array('name' => 'alarmdate[]', 'class' => 'edit-alarm-date', 'size' => 10));
|
|
|
|
$input_time = new html_inputfield(array('name' => 'alarmtime[]', 'class' => 'edit-alarm-time', 'size' => 6));
|
|
|
|
|
|
|
|
$select_offset = new html_select(array('name' => 'alarmoffset[]', 'class' => 'edit-alarm-offset'));
|
2011-05-22 18:45:04 +02:00
|
|
|
foreach (array('-M','-H','-D','+M','+H','+D','@') as $trigger)
|
|
|
|
$select_offset->add($this->calendar->gettext('trigger' . $trigger), $trigger);
|
2011-05-20 19:04:25 +02:00
|
|
|
|
2011-05-22 22:27:56 +02:00
|
|
|
// pre-set with default values from user settings
|
|
|
|
$preset = calendar::parse_alaram_value($this->rc->config->get('calendar_default_alarm_offset', '-15M'));
|
2011-05-20 19:04:25 +02:00
|
|
|
$hidden = array('style' => 'display:none');
|
|
|
|
$html = html::span('edit-alarm-set',
|
2011-05-22 22:27:56 +02:00
|
|
|
$select_type->show($this->rc->config->get('calendar_default_alarm_type', '')) . ' ' .
|
2011-05-20 19:04:25 +02:00
|
|
|
html::span(array('class' => 'edit-alarm-values', 'style' => 'display:none'),
|
2011-05-22 22:27:56 +02:00
|
|
|
$input_value->show($preset[0]) . ' ' .
|
|
|
|
$select_offset->show($preset[1]) . ' ' .
|
2011-05-20 19:04:25 +02:00
|
|
|
$input_date->show('', $hidden) . ' ' .
|
|
|
|
$input_time->show('', $hidden)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// TODO: support adding more alarms
|
|
|
|
#$html .= html::a(array('href' => '#', 'id' => 'edit-alam-add', 'title' => $this->calendar->gettext('addalarm')),
|
|
|
|
# $attrib['addicon'] ? html::img(array('src' => $attrib['addicon'], 'alt' => 'add')) : '(+)');
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
2011-05-25 23:16:13 +02:00
|
|
|
function snooze_select($attrib = array())
|
|
|
|
{
|
|
|
|
$steps = array(
|
|
|
|
5 => 'repeatinmin',
|
|
|
|
10 => 'repeatinmin',
|
|
|
|
15 => 'repeatinmin',
|
|
|
|
20 => 'repeatinmin',
|
|
|
|
30 => 'repeatinmin',
|
|
|
|
60 => 'repeatinhr',
|
|
|
|
120 => 'repeatinhrs',
|
|
|
|
1440 => 'repeattomorrow',
|
|
|
|
10080 => 'repeatinweek',
|
|
|
|
);
|
|
|
|
|
|
|
|
$items = array();
|
|
|
|
foreach ($steps as $n => $label) {
|
|
|
|
$items[] = html::tag('li', null, html::a(array('href' => "#" . ($n * 60), 'class' => 'active'),
|
|
|
|
$this->calendar->gettext(array('name' => $label, 'vars' => array('min' => $n % 60, 'hrs' => intval($n / 60))))));
|
|
|
|
}
|
|
|
|
|
2011-07-19 17:51:15 +02:00
|
|
|
return html::tag('ul', $attrib, join("\n", $items), html::$common_attrib);
|
2011-05-25 23:16:13 +02:00
|
|
|
}
|
2011-07-27 18:55:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function edit_attendees_notify($attrib = array())
|
|
|
|
{
|
|
|
|
$checkbox = new html_checkbox(array('name' => 'notify', 'id' => 'edit-attendees-donotify', 'value' => 1));
|
|
|
|
return html::div($attrib, html::label(null, $checkbox->show(1) . ' ' . $this->calendar->gettext('sendnotifications')));
|
|
|
|
}
|
2011-05-25 23:16:13 +02:00
|
|
|
|
2011-06-01 18:35:10 +02:00
|
|
|
/**
|
|
|
|
* Generate the form for recurrence settings
|
|
|
|
*/
|
|
|
|
function recurring_event_warning($attrib = array())
|
|
|
|
{
|
|
|
|
$attrib['id'] = 'edit-recurring-warning';
|
|
|
|
|
|
|
|
$radio = new html_radiobutton(array('name' => 'savemode', 'class' => 'edit-recurring-savemode'));
|
|
|
|
$form = html::label(null, $radio->show('', array('value' => 'current')) . $this->calendar->gettext('currentevent')) . ' ' .
|
|
|
|
html::label(null, $radio->show('', array('value' => 'future')) . $this->calendar->gettext('futurevents')) . ' ' .
|
|
|
|
html::label(null, $radio->show('all', array('value' => 'all')) . $this->calendar->gettext('allevents')) . ' ' .
|
|
|
|
html::label(null, $radio->show('', array('value' => 'new')) . $this->calendar->gettext('saveasnew'));
|
|
|
|
|
|
|
|
return html::div($attrib, html::div('message', html::span('ui-icon ui-icon-alert', '') . $this->calendar->gettext('changerecurringeventwarning')) . html::div('savemode', $form));
|
|
|
|
}
|
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
/**
|
|
|
|
* Generate the form for recurrence settings
|
|
|
|
*/
|
|
|
|
function recurrence_form($attrib = array())
|
|
|
|
{
|
|
|
|
switch ($attrib['part']) {
|
|
|
|
// frequency selector
|
|
|
|
case 'frequency':
|
|
|
|
$select = new html_select(array('name' => 'frequency', 'id' => 'edit-recurrence-frequency'));
|
|
|
|
$select->add($this->calendar->gettext('never'), '');
|
|
|
|
$select->add($this->calendar->gettext('daily'), 'DAILY');
|
|
|
|
$select->add($this->calendar->gettext('weekly'), 'WEEKLY');
|
|
|
|
$select->add($this->calendar->gettext('monthly'), 'MONTHLY');
|
2011-06-29 19:42:56 +02:00
|
|
|
$select->add($this->calendar->gettext('yearly'), 'YEARLY');
|
2011-05-20 19:04:25 +02:00
|
|
|
$html = html::label('edit-frequency', $this->calendar->gettext('frequency')) . $select->show('');
|
|
|
|
break;
|
|
|
|
|
|
|
|
// daily recurrence
|
|
|
|
case 'daily':
|
|
|
|
$select = $this->interval_selector(array('name' => 'interval', 'class' => 'edit-recurrence-interval', 'id' => 'edit-recurrence-interval-daily'));
|
|
|
|
$html = html::div($attrib, html::label(null, $this->calendar->gettext('every')) . $select->show(1) . html::span('label-after', $this->calendar->gettext('days')));
|
|
|
|
break;
|
|
|
|
|
|
|
|
// weekly recurrence form
|
|
|
|
case 'weekly':
|
|
|
|
$select = $this->interval_selector(array('name' => 'interval', 'class' => 'edit-recurrence-interval', 'id' => 'edit-recurrence-interval-weekly'));
|
|
|
|
$html = html::div($attrib, html::label(null, $this->calendar->gettext('every')) . $select->show(1) . html::span('label-after', $this->calendar->gettext('weeks')));
|
|
|
|
// weekday selection
|
|
|
|
$daymap = array('sun','mon','tue','wed','thu','fri','sat');
|
|
|
|
$checkbox = new html_checkbox(array('name' => 'byday', 'class' => 'edit-recurrence-weekly-byday'));
|
|
|
|
$first = $this->rc->config->get('calendar_first_day', 1);
|
|
|
|
for ($weekdays = '', $j = $first; $j <= $first+6; $j++) {
|
|
|
|
$d = $j % 7;
|
|
|
|
$weekdays .= html::label(array('class' => 'weekday'), $checkbox->show('', array('value' => strtoupper(substr($daymap[$d], 0, 2)))) . $this->calendar->gettext($daymap[$d])) . ' ';
|
|
|
|
}
|
|
|
|
$html .= html::div($attrib, html::label(null, $this->calendar->gettext('bydays')) . $weekdays);
|
|
|
|
break;
|
|
|
|
|
|
|
|
// monthly recurrence form
|
|
|
|
case 'monthly':
|
|
|
|
$select = $this->interval_selector(array('name' => 'interval', 'class' => 'edit-recurrence-interval', 'id' => 'edit-recurrence-interval-monthly'));
|
|
|
|
$html = html::div($attrib, html::label(null, $this->calendar->gettext('every')) . $select->show(1) . html::span('label-after', $this->calendar->gettext('months')));
|
2011-07-04 13:57:01 +02:00
|
|
|
|
2011-06-29 19:42:56 +02:00
|
|
|
/* multiple month selection is not supported by Kolab
|
2011-06-18 14:39:58 +03:00
|
|
|
$checkbox = new html_radiobutton(array('name' => 'bymonthday', 'class' => 'edit-recurrence-monthly-bymonthday'));
|
2011-05-20 19:04:25 +02:00
|
|
|
for ($monthdays = '', $d = 1; $d <= 31; $d++) {
|
|
|
|
$monthdays .= html::label(array('class' => 'monthday'), $checkbox->show('', array('value' => $d)) . $d);
|
|
|
|
$monthdays .= $d % 7 ? ' ' : html::br();
|
|
|
|
}
|
2011-06-29 19:42:56 +02:00
|
|
|
*/
|
2011-05-20 19:04:25 +02:00
|
|
|
// rule selectors
|
|
|
|
$radio = new html_radiobutton(array('name' => 'repeatmode', 'class' => 'edit-recurrence-monthly-mode'));
|
|
|
|
$table = new html_table(array('cols' => 2, 'border' => 0, 'cellpadding' => 0, 'class' => 'formtable'));
|
2011-06-29 19:42:56 +02:00
|
|
|
$table->add('label', html::label(null, $radio->show('BYMONTHDAY', array('value' => 'BYMONTHDAY')) . ' ' . $this->calendar->gettext('onsamedate'))); // $this->calendar->gettext('each')
|
2011-05-20 19:04:25 +02:00
|
|
|
$table->add(null, $monthdays);
|
|
|
|
$table->add('label', html::label(null, $radio->show('', array('value' => 'BYDAY')) . ' ' . $this->calendar->gettext('onevery')));
|
|
|
|
$table->add(null, $this->rrule_selectors($attrib['part']));
|
|
|
|
|
|
|
|
$html .= html::div($attrib, $table->show());
|
2011-06-29 19:42:56 +02:00
|
|
|
|
2011-05-20 19:04:25 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
// annually recurrence form
|
|
|
|
case 'yearly':
|
|
|
|
$select = $this->interval_selector(array('name' => 'interval', 'class' => 'edit-recurrence-interval', 'id' => 'edit-recurrence-interval-yearly'));
|
|
|
|
$html = html::div($attrib, html::label(null, $this->calendar->gettext('every')) . $select->show(1) . html::span('label-after', $this->calendar->gettext('years')));
|
|
|
|
// month selector
|
|
|
|
$monthmap = array('','jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec');
|
2011-06-29 19:42:56 +02:00
|
|
|
$boxtype = is_a($this->calendar->driver, 'kolab_driver') ? 'radio' : 'checkbox';
|
|
|
|
$checkbox = new html_inputfield(array('type' => $boxtype, 'name' => 'bymonth', 'class' => 'edit-recurrence-yearly-bymonth'));
|
2011-05-20 19:04:25 +02:00
|
|
|
for ($months = '', $m = 1; $m <= 12; $m++) {
|
2011-06-29 19:42:56 +02:00
|
|
|
$months .= html::label(array('class' => 'month'), $checkbox->show(null, array('value' => $m)) . $this->calendar->gettext($monthmap[$m]));
|
2011-05-20 19:04:25 +02:00
|
|
|
$months .= $m % 4 ? ' ' : html::br();
|
|
|
|
}
|
|
|
|
$html .= html::div($attrib + array('id' => 'edit-recurrence-yearly-bymonthblock'), $months);
|
|
|
|
|
|
|
|
// day rule selection
|
|
|
|
$html .= html::div($attrib, html::label(null, $this->calendar->gettext('onevery')) . $this->rrule_selectors($attrib['part'], '---'));
|
|
|
|
break;
|
|
|
|
|
|
|
|
// end of recurrence form
|
|
|
|
case 'until':
|
|
|
|
$radio = new html_radiobutton(array('name' => 'repeat', 'class' => 'edit-recurrence-until'));
|
|
|
|
$select = $this->interval_selector(array('name' => 'times', 'id' => 'edit-recurrence-repeat-times'));
|
|
|
|
$input = new html_inputfield(array('name' => 'untildate', 'id' => 'edit-recurrence-enddate', 'size' => "10"));
|
|
|
|
|
|
|
|
$table = new html_table(array('cols' => 2, 'border' => 0, 'cellpadding' => 0, 'class' => 'formtable'));
|
|
|
|
|
2011-05-31 17:12:59 +02:00
|
|
|
$table->add('label', ucfirst($this->calendar->gettext('recurrencend')));
|
2011-05-20 19:04:25 +02:00
|
|
|
$table->add(null, html::label(null, $radio->show('', array('value' => '', 'id' => 'edit-recurrence-repeat-forever')) . ' ' .
|
|
|
|
$this->calendar->gettext('forever')));
|
|
|
|
|
|
|
|
$table->add('label', '');
|
|
|
|
$table->add(null, html::label(null, $radio->show('', array('value' => 'count', 'id' => 'edit-recurrence-repeat-count')) . ' ' .
|
|
|
|
$this->calendar->gettext(array(
|
|
|
|
'name' => 'forntimes',
|
|
|
|
'vars' => array('nr' => $select->show(1)))
|
|
|
|
)));
|
|
|
|
|
|
|
|
$table->add('label', '');
|
|
|
|
$table->add(null, $radio->show('', array('value' => 'until', 'id' => 'edit-recurrence-repeat-until')) . ' ' .
|
|
|
|
$this->calendar->gettext('until') . ' ' . $input->show(''));
|
|
|
|
$html = $table->show();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Input field for interval selection
|
|
|
|
*/
|
|
|
|
private function interval_selector($attrib)
|
|
|
|
{
|
|
|
|
$select = new html_select($attrib);
|
|
|
|
$select->add(range(1,30), range(1,30));
|
|
|
|
return $select;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Drop-down menus for recurrence rules like "each last sunday of"
|
|
|
|
*/
|
|
|
|
private function rrule_selectors($part, $noselect = null)
|
|
|
|
{
|
|
|
|
// rule selectors
|
|
|
|
$select_prefix = new html_select(array('name' => 'bydayprefix', 'id' => "edit-recurrence-$part-prefix"));
|
|
|
|
if ($noselect) $select_prefix->add($noselect, '');
|
|
|
|
$select_prefix->add(array(
|
|
|
|
$this->calendar->gettext('first'),
|
|
|
|
$this->calendar->gettext('second'),
|
|
|
|
$this->calendar->gettext('third'),
|
2011-06-29 19:42:56 +02:00
|
|
|
$this->calendar->gettext('fourth')
|
2011-05-20 19:04:25 +02:00
|
|
|
),
|
2011-06-29 19:42:56 +02:00
|
|
|
array(1, 2, 3, 4));
|
|
|
|
|
|
|
|
// Kolab doesn't support 'last' but others do.
|
|
|
|
if (!is_a($this->calendar->driver, 'kolab_driver'))
|
|
|
|
$select_prefix->add($this->calendar->gettext('last'), -1);
|
2011-05-20 19:04:25 +02:00
|
|
|
|
|
|
|
$select_wday = new html_select(array('name' => 'byday', 'id' => "edit-recurrence-$part-byday"));
|
|
|
|
if ($noselect) $select_wday->add($noselect, '');
|
|
|
|
|
|
|
|
$daymap = array('sunday','monday','tuesday','wednesday','thursday','friday','saturday');
|
|
|
|
$first = $this->rc->config->get('calendar_first_day', 1);
|
|
|
|
for ($j = $first; $j <= $first+6; $j++) {
|
|
|
|
$d = $j % 7;
|
|
|
|
$select_wday->add($this->calendar->gettext($daymap[$d]), strtoupper(substr($daymap[$d], 0, 2)));
|
|
|
|
}
|
|
|
|
if ($part == 'monthly')
|
|
|
|
$select_wday->add($this->calendar->gettext('dayofmonth'), '');
|
|
|
|
|
|
|
|
return $select_prefix->show() . ' ' . $select_wday->show();
|
|
|
|
}
|
2011-07-01 21:08:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate the form for event attachments upload
|
|
|
|
*/
|
|
|
|
function attachments_form($attrib = array())
|
|
|
|
{
|
|
|
|
// add ID if not given
|
|
|
|
if (!$attrib['id'])
|
|
|
|
$attrib['id'] = 'rcmUploadForm';
|
|
|
|
|
2011-07-04 13:57:01 +02:00
|
|
|
// Enable upload progress bar
|
|
|
|
rcube_upload_progress_init();
|
|
|
|
|
2011-07-01 21:08:12 +02:00
|
|
|
// find max filesize value
|
|
|
|
$max_filesize = parse_bytes(ini_get('upload_max_filesize'));
|
|
|
|
$max_postsize = parse_bytes(ini_get('post_max_size'));
|
|
|
|
if ($max_postsize && $max_postsize < $max_filesize)
|
|
|
|
$max_filesize = $max_postsize;
|
|
|
|
|
|
|
|
$this->rc->output->set_env('max_filesize', $max_filesize);
|
|
|
|
|
|
|
|
$max_filesize = show_bytes($max_filesize);
|
|
|
|
|
|
|
|
$button = new html_inputfield(array('type' => 'button'));
|
|
|
|
$input = new html_inputfield(array(
|
|
|
|
'type' => 'file', 'name' => '_attachments[]',
|
|
|
|
'multiple' => 'multiple', 'size' => $attrib['attachmentfieldsize']));
|
|
|
|
|
|
|
|
return html::div($attrib,
|
|
|
|
html::div(null, $input->show()) .
|
|
|
|
html::div('buttons', $button->show(rcube_label('upload'), array('class' => 'button mainaction',
|
|
|
|
'onclick' => JS_OBJECT_NAME . ".upload_file(this.form)"))) .
|
|
|
|
html::div('hint', rcube_label(array('name' => 'maxuploadsize', 'vars' => array('size' => $max_filesize))))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate HTML element for attachments list
|
|
|
|
*/
|
|
|
|
function attachments_list($attrib = array())
|
|
|
|
{
|
|
|
|
if (!$attrib['id'])
|
|
|
|
$attrib['id'] = 'rcmAttachmentList';
|
|
|
|
|
|
|
|
$skin_path = $this->rc->config->get('skin_path');
|
|
|
|
if ($attrib['deleteicon']) {
|
|
|
|
$_SESSION['calendar_deleteicon'] = $skin_path . $attrib['deleteicon'];
|
|
|
|
$this->rc->output->set_env('deleteicon', $skin_path . $attrib['deleteicon']);
|
|
|
|
}
|
|
|
|
if ($attrib['cancelicon'])
|
|
|
|
$this->rc->output->set_env('cancelicon', $skin_path . $attrib['cancelicon']);
|
|
|
|
if ($attrib['loadingicon'])
|
|
|
|
$this->rc->output->set_env('loadingicon', $skin_path . $attrib['loadingicon']);
|
|
|
|
|
|
|
|
$this->rc->output->add_gui_object('attachmentlist', $attrib['id']);
|
|
|
|
|
|
|
|
return html::tag('ul', $attrib, '', html::$common_attrib);
|
|
|
|
}
|
|
|
|
|
2011-07-06 09:43:42 +02:00
|
|
|
function attachment_controls($attrib = array())
|
|
|
|
{
|
|
|
|
$table = new html_table(array('cols' => 3));
|
|
|
|
|
|
|
|
if (!empty($this->calendar->attachment['name'])) {
|
|
|
|
$table->add('title', Q(rcube_label('filename')));
|
|
|
|
$table->add(null, Q($this->calendar->attachment['name']));
|
|
|
|
$table->add(null, '[' . html::a('?'.str_replace('_frame=', '_download=', $_SERVER['QUERY_STRING']), Q(rcube_label('download'))) . ']');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($this->calendar->attachment['size'])) {
|
|
|
|
$table->add('title', Q(rcube_label('filesize')));
|
|
|
|
$table->add(null, Q(show_bytes($this->calendar->attachment['size'])));
|
|
|
|
}
|
|
|
|
|
|
|
|
return $table->show($attrib);
|
|
|
|
}
|
|
|
|
|
2011-07-06 22:01:54 +02:00
|
|
|
/**
|
2011-07-26 13:13:04 +02:00
|
|
|
* Handler for calendar form template.
|
|
|
|
* The form content could be overriden by the driver
|
2011-07-06 22:01:54 +02:00
|
|
|
*/
|
|
|
|
function calendar_editform($action, $calendar = array())
|
|
|
|
{
|
2011-07-27 13:15:15 +02:00
|
|
|
// compose default calendar form fields
|
2011-07-27 11:20:27 +02:00
|
|
|
$input_name = new html_inputfield(array('name' => 'name', 'id' => 'calendar-name', 'size' => 20));
|
|
|
|
$input_color = new html_inputfield(array('name' => 'color', 'id' => 'calendar-color', 'size' => 6));
|
|
|
|
|
2011-07-27 13:15:15 +02:00
|
|
|
$formfields = array(
|
|
|
|
'name' => array(
|
|
|
|
'label' => $this->calendar->gettext('name'),
|
|
|
|
'value' => $input_name->show($name),
|
|
|
|
'id' => 'calendar-name',
|
|
|
|
),
|
|
|
|
'color' => array(
|
|
|
|
'label' => $this->calendar->gettext('color'),
|
|
|
|
'value' => $input_color->show($calendar['color']),
|
|
|
|
'id' => 'calendar-color',
|
|
|
|
),
|
|
|
|
);
|
2011-07-27 11:20:27 +02:00
|
|
|
|
|
|
|
// allow driver to extend or replace the form content
|
2011-07-27 13:15:15 +02:00
|
|
|
return html::tag('form', array('action' => "#", 'method' => "get", 'id' => 'calendarpropform'),
|
|
|
|
$this->calendar->driver->calendar_form($action, $calendar, $formfields)
|
|
|
|
);
|
2011-07-06 22:01:54 +02:00
|
|
|
}
|
2011-07-26 13:13:04 +02:00
|
|
|
|
2011-07-08 17:29:22 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function attendees_list($attrib = array())
|
|
|
|
{
|
|
|
|
$table = new html_table(array('cols' => 5, 'border' => 0, 'cellpadding' => 0, 'class' => 'rectable'));
|
|
|
|
$table->add_header('role', $this->calendar->gettext('role'));
|
|
|
|
$table->add_header('name', $this->calendar->gettext('attendee'));
|
|
|
|
$table->add_header('availability', $this->calendar->gettext('availability'));
|
|
|
|
$table->add_header('confirmstate', $this->calendar->gettext('confirmstate'));
|
|
|
|
$table->add_header('options', '');
|
|
|
|
|
|
|
|
return $table->show($attrib);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function attendees_form($attrib = array())
|
|
|
|
{
|
|
|
|
$input = new html_inputfield(array('name' => 'participant', 'id' => 'edit-attendee-name', 'size' => 30));
|
2011-07-27 18:55:51 +02:00
|
|
|
$checkbox = new html_checkbox(array('name' => 'invite', 'id' => 'edit-attendees-invite', 'value' => 1));
|
2011-07-08 17:29:22 +02:00
|
|
|
|
2011-07-20 14:46:38 +02:00
|
|
|
return html::div($attrib,
|
|
|
|
html::div(null, $input->show() . " " .
|
|
|
|
html::tag('input', array('type' => 'button', 'class' => 'button', 'id' => 'edit-attendee-add', 'value' => $this->calendar->gettext('addattendee'))) . " " .
|
|
|
|
html::tag('input', array('type' => 'button', 'class' => 'button', 'id' => 'edit-attendee-schedule', 'value' => $this->calendar->gettext('scheduletime').'...'))) .
|
2011-07-27 18:55:51 +02:00
|
|
|
html::p('attendees-invitebox', html::label(null, $checkbox->show(1) . $this->calendar->gettext('sendinvitations')))
|
2011-07-20 14:46:38 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function attendees_freebusy_table($attrib = array())
|
|
|
|
{
|
|
|
|
$table = new html_table(array('cols' => 2, 'border' => 0, 'cellspacing' => 0));
|
|
|
|
$table->add('attendees',
|
|
|
|
html::tag('h3', 'boxtitle', $this->calendar->gettext('tabattendees')) .
|
|
|
|
html::div('timesheader', ' ') .
|
2011-07-24 12:46:54 +02:00
|
|
|
html::div(array('id' => 'schedule-attendees-list', 'class' => 'attendees-list'), '')
|
2011-07-20 14:46:38 +02:00
|
|
|
);
|
|
|
|
$table->add('times',
|
2011-07-23 17:08:31 +02:00
|
|
|
html::div('scroll',
|
|
|
|
html::tag('table', array('id' => 'schedule-freebusy-times', 'border' => 0, 'cellspacing' => 0), html::tag('thead') . html::tag('tbody')) .
|
|
|
|
html::div(array('id' => 'schedule-event-time', 'style' => 'display:none'), ' ')
|
|
|
|
)
|
2011-07-20 14:46:38 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
return $table->show($attrib);
|
2011-07-08 17:29:22 +02:00
|
|
|
}
|
2011-07-06 22:01:54 +02:00
|
|
|
|
2011-07-01 21:08:12 +02:00
|
|
|
}
|