From: Jan Schneider Date: Thu, 12 Nov 2009 22:18:25 +0000 (+0100) Subject: Handle tasks separately from other timeobjects. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=ac1302dfc9ab8e048a2956b7cbfac3abdffa62e4;p=horde.git Handle tasks separately from other timeobjects. Fix toggling calendars. --- diff --git a/kronolith/ajax.php b/kronolith/ajax.php index 67c2605ec..646a0102e 100644 --- a/kronolith/ajax.php +++ b/kronolith/ajax.php @@ -26,6 +26,7 @@ function getDriver($cal) $driver = ''; break; case 'external': + case 'tasklists': $driver = 'Horde'; break; case 'remote': diff --git a/kronolith/js/kronolith.js b/kronolith/js/kronolith.js index c47ac69aa..e544c1ff6 100644 --- a/kronolith/js/kronolith.js +++ b/kronolith/js/kronolith.js @@ -755,6 +755,35 @@ KronolithCore = { $('kronolithSharedCalendars').hide(); } + my = 0; + shared = 0; + $H(Kronolith.conf.calendars.tasklists).each(function(cal) { + if (cal.value.owner) { + my++; + div = $('kronolithMyTasklists'); + div.insert(new Element('SPAN', { 'class': 'kronolithCalEdit' }) + .insert('›')); + } else { + shared++; + div = $('kronolithSharedTasklists'); + } + div.insert(new Element('DIV', { 'class': cal.value.show ? 'kronolithCalOn' : 'kronolithCalOff' }) + .store('calendar', cal.key) + .store('calendarclass', 'tasklists') + .setStyle({ backgroundColor: cal.value.bg, color: cal.value.fg }) + .update(cal.value.name.escapeHTML())); + }); + if (my) { + $('kronolithMyTasklists').show(); + } else { + $('kronolithMyTasklists').hide(); + } + if (shared) { + $('kronolithSharedTasklists').show(); + } else { + $('kronolithSharedTasklists').hide(); + } + $H(Kronolith.conf.calendars.external).each(function(cal) { var parts = cal.key.split('/'), api = parts.shift(); if (!ext.get(api)) { @@ -1438,11 +1467,10 @@ KronolithCore = { { if (Object.isUndefined(taskLists)) { taskLists = []; - // FIXME: Temporary hack to get the tasklists - $H(Kronolith.conf.calendars.external).each(function(cal) { - if (cal.key.startsWith('tasks') && cal.value.show) + $H(Kronolith.conf.calendars.tasklists).each(function(tasklist) { + if (tasklist.value.show) { - taskLists.push(cal.key.substring(6)); + taskLists.push(tasklist.key.substring(6)); } }); } @@ -2241,17 +2269,21 @@ KronolithCore = { } elt.toggleClassName('kronolithCalOn'); elt.toggleClassName('kronolithCalOff'); - if (calClass == 'remote' || calClass == 'external') { - if (calClass == 'external' && calendar.startsWith('tasks/')) { - var taskList = calendar.substr(6); - if (Object.isUndefined(this.tcache.get(taskList)) && - this.view == 'tasks') { - this._loadTasks(this.taskType,[taskList]); - } else { - $('kronolithViewTasksBody').select('tr').findAll(function(el) { return el.retrieve('taskList') == taskList; }).invoke('toggle'); - } + switch (calClass) { + case 'tasklists': + var taskList = calendar.substr(6); + if (Object.isUndefined(this.tcache.get(taskList)) && + this.view == 'tasks') { + this._loadTasks(this.taskType,[taskList]); + } else { + $('kronolithViewTasksBody').select('tr').findAll(function(el) { return el.retrieve('taskList') == taskList; }).invoke('toggle'); } + // Fall through. + case 'remote': + case 'external': + case 'holiday': calendar = calClass + '_' + calendar; + break; } this.doAction('SaveCalPref', { toggle_calendar: calendar }); } diff --git a/kronolith/lib/Kronolith.php b/kronolith/lib/Kronolith.php index 92979ea46..80aeae00e 100644 --- a/kronolith/lib/Kronolith.php +++ b/kronolith/lib/Kronolith.php @@ -150,6 +150,9 @@ class Kronolith // Turn debugging on? 'debug' => !empty($conf['js']['debug']), ); + + // Calendars + $has_tasks = $GLOBALS['registry']->hasInterface('tasks'); foreach (array(true, false) as $my) { foreach ($GLOBALS['all_calendars'] as $id => $calendar) { $owner = $calendar->get('owner') == Horde_Auth::getAuth(); @@ -161,12 +164,35 @@ class Kronolith 'fg' => self::foregroundColor($calendar), 'bg' => self::backgroundColor($calendar), 'show' => in_array($id, $GLOBALS['display_calendars']), - 'edit' => $calendar->hasPermission(Horde_Auth::getAuth(), PERMS_READ)); + 'edit' => $calendar->hasPermission(Horde_Auth::getAuth(), PERMS_EDIT)); + } + } + + // Tasklists + if (!$has_tasks) { + continue; + } + foreach ($GLOBALS['registry']->tasks->listTasklists($my, PERMS_SHOW) as $id => $tasklist) { + $owner = $tasklist->get('owner') == Horde_Auth::getAuth(); + if (($my && $owner) || (!$my && !$owner)) { + $code['conf']['calendars']['tasklists']['tasks/' . $id] = array( + 'name' => ($owner ? '' : '[' . Horde_Auth::convertUsername($tasklist->get('owner'), false) . '] ') + . $tasklist->get('name'), + 'owner' => $owner, + 'fg' => self::foregroundColor($tasklist), + 'bg' => self::backgroundColor($tasklist), + 'show' => in_array('tasks/' . $id, $GLOBALS['display_external_calendars']), + 'edit' => $tasklist->hasPermission(Horde_Auth::getAuth(), PERMS_EDIT)); } } } + + // Timeobjects foreach ($GLOBALS['all_external_calendars'] as $api => $categories) { foreach ($categories as $id => $name) { + if ($api == 'tasks') { + continue; + } $calendar = $api . '/' . $id; $code['conf']['calendars']['external'][$calendar] = array( 'name' => $name, @@ -176,6 +202,8 @@ class Kronolith 'show' => in_array($calendar, $GLOBALS['display_external_calendars'])); } } + + // Remote calendars foreach ($GLOBALS['all_remote_calendars'] as $calendar) { $code['conf']['calendars']['remote'][$calendar['url']] = array( 'name' => $calendar['name'], @@ -183,6 +211,8 @@ class Kronolith 'bg' => self::backgroundColor($calendar), 'show' => in_array($calendar['url'], $GLOBALS['display_remote_calendars'])); } + + // Holidays foreach ($GLOBALS['all_holidays'] as $holiday) { $code['conf']['calendars']['holiday'][$holiday['id']] = array( 'name' => $holiday['title'], @@ -794,16 +824,18 @@ class Kronolith } else { $GLOBALS['display_remote_calendars'][] = $calendarId; } - } elseif (strncmp($calendarId, 'external_', 9) === 0) { - $calendarId = substr($calendarId, 9); + } elseif ((strncmp($calendarId, 'external_', 9) === 0 && + $calendarId = substr($calendarId, 9)) || + (strncmp($calendarId, 'tasklists_', 10) === 0 && + $calendarId = substr($calendarId, 10))) { if (in_array($calendarId, $GLOBALS['display_external_calendars'])) { $key = array_search($calendarId, $GLOBALS['display_external_calendars']); unset($GLOBALS['display_external_calendars'][$key]); } else { $GLOBALS['display_external_calendars'][] = $calendarId; } - } elseif (strncmp($calendarId, 'holidays_', 9) === 0) { - $calendarId = substr($calendarId, 9); + } elseif (strncmp($calendarId, 'holiday_', 8) === 0) { + $calendarId = substr($calendarId, 8); if (in_array($calendarId, $GLOBALS['display_holidays'])) { $key = array_search($calendarId, $GLOBALS['display_holidays']); unset($GLOBALS['display_holidays'][$key]); diff --git a/kronolith/templates/index/index.inc b/kronolith/templates/index/index.inc index 56ca1f359..b0a141971 100644 --- a/kronolith/templates/index/index.inc +++ b/kronolith/templates/index/index.inc @@ -83,12 +83,28 @@

+ + +

+ + + +

+ +

+

+ + + +

+ + +