$('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)) {
{
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));
}
});
}
}
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 });
}
// 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();
'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,
'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'],
'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'],
} 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]);