From b7f1227dd6a4df789c79214dc1a167fc60689563 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Sat, 25 Apr 2009 18:23:26 +0200 Subject: [PATCH] =?utf8?q?Show=20possible=20event=20conflicts=20in=20iTip?= =?utf8?q?=20viewer=20(Request=20#3991,=20Gon=C3=A7alo=20Queir=C3=B3s=20).?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- imp/config/prefs.php.dist | 21 ++++++++++++++++++++ imp/docs/CHANGES | 2 ++ imp/lib/Mime/Viewer/Itip.php | 47 ++++++++++++++++++++++++++++++++++++++++++++ imp/themes/screen.css | 9 +++++++++ kronolith/lib/api.php | 16 ++++++++++++++- 5 files changed, 94 insertions(+), 1 deletion(-) diff --git a/imp/config/prefs.php.dist b/imp/config/prefs.php.dist index 69d25e397..b04cdfd00 100644 --- a/imp/config/prefs.php.dist +++ b/imp/config/prefs.php.dist @@ -175,6 +175,13 @@ $prefGroups['addressbooks'] = array( 'members' => array('save_recipients', 'display_contact', 'sourceselect') ); +$prefGroups['events'] = array( + 'column' => _("Other Options"), + 'label' => _("Event Requests"), + 'desc' => _("Customize how should be dealt with event or meeting requests."), + 'members' => array('conflict_interval') +); + if (isset($GLOBALS['conf']['utils']['gnupg'])) { $prefGroups['pgp'] = array( 'column' => _("Other Options"), @@ -1554,6 +1561,20 @@ $_prefs['add_source'] = array( // End Address book preferences +// Event preferences + +// Amount of minutes to consider a event as a non-conflicting one in iTip +$_prefs['conflict_interval'] = array( + 'value' => 30, + 'locked' => false, + 'shared' => false, + 'type' => 'number', + 'desc' => _("Minutes needed to consider a event as a non-conflicting one in iTip") +); + +// End Calendar preferences + + // PGP options // Activate PGP support? diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index 39c0ba2d6..27d2899a4 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,6 +2,8 @@ v5.0-git -------- +[jan] Show possible event conflicts in iTip viewer (Gonçalo Queirós + ). [mms] Move subfolders of special folders to lower folder display tree in DIMP (Bug #8127). [mms] Simplify quicksearch UI in DIMP. diff --git a/imp/lib/Mime/Viewer/Itip.php b/imp/lib/Mime/Viewer/Itip.php index 0a1fb154a..682e59388 100644 --- a/imp/lib/Mime/Viewer/Itip.php +++ b/imp/lib/Mime/Viewer/Itip.php @@ -787,6 +787,53 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver $html .= ''; } + if ($registry->hasMethod('calendar/getFbCalendars') && + $registry->hasMethod('calendar/listEvents') && + !is_a($calendars = $registry->call('calendar/getFbCalendars'), 'PEAR_Error')) { + + $vevent_allDay = true; + $vevent_start = new Horde_Date($start); + $vevent_end = new Horde_Date($end); + // Check if it's an all-day event. + if (is_array($start)) { + $vevent_end = $vevent_end->sub(1); + } else { + $vevent_allDay = false; + $time_span_start = new Horde_Date($start); + $time_span_start = $time_span_start->sub($prefs->getValue('conflict_interval') * 60); + $time_span_end = new Horde_Date($end); + $time_span_end = $time_span_end->add($prefs->getValue('conflict_interval') * 60); + } + $events = $registry->call('calendar/listEvents', array($start, $vevent_end, $calendars, false)); + + if (!is_a($events, 'PEAR_Error') && count($events)) { + $html .= '

' . _("Possible Conflicts") . '

'; + // TODO: Check if there are too many events to show. + foreach ($events as $calendar) { + foreach ($calendar as $event) { + if ($vevent_allDay || $event->isAllDay()) { + $html .= ''; + } else { + if ($event->end->compareDateTime($time_span_start) <= -1 || + $event->start->compareDateTime($time_span_end) >= 1) { + continue; + } + if ($event->end->compareDateTime($vevent_start) <= -1 || + $event->start->compareDateTime($vevent_end) >= 1) { + $html .= ''; + } else { + $html .= ''; + } + } + + $html .= ''; + } + } + $html .= '
'. $event->getTitle() . '' + . $event->getTimeRange() . '
'; + } + } + if ($_SESSION['imp']['view'] != 'imp') { return $html; } diff --git a/imp/themes/screen.css b/imp/themes/screen.css index 23d72e98c..09cc912cf 100644 --- a/imp/themes/screen.css +++ b/imp/themes/screen.css @@ -593,3 +593,12 @@ span.threadImg8 { .stripAtc { background-image: url("graphics/delete.png"); } + +#itipconflicts tr.itipcollision { + background-color: #f00; + color: #fff; +} + +#itipconflicts tr.itipnearcollision { + background-color: #ee0; +} diff --git a/kronolith/lib/api.php b/kronolith/lib/api.php index f3ac519a4..0f2c5700d 100644 --- a/kronolith/lib/api.php +++ b/kronolith/lib/api.php @@ -141,6 +141,11 @@ $_services['checkLocks'] = array( 'type' => 'string' ); +$_services['getFbCalendars'] = array( + 'args' => array(), + 'type' => '{urn:horde}stringArray' +); + /** * Returns a list of available permissions. * @@ -1516,4 +1521,13 @@ function _kronolith_checkLocks($calendar, $event = null) $share = &$GLOBALS['kronolith_shares']->getShare($calendar); return $share->checkLocks($event); -} \ No newline at end of file +} + +/** + * + * @return array A list of calendars used to display free/busy information + */ +function _kronolith_getFbCalendars() +{ + return (unserialize($GLOBALS['prefs']->getValue('fb_cals'))); +} -- 2.11.0