diff --git a/plugins/calendar/drivers/caldav/caldav_calendar.php b/plugins/calendar/drivers/caldav/caldav_calendar.php index 46b0278e..ac0d8b41 100644 --- a/plugins/calendar/drivers/caldav/caldav_calendar.php +++ b/plugins/calendar/drivers/caldav/caldav_calendar.php @@ -61,7 +61,7 @@ class caldav_calendar extends kolab_storage_dav_folder $this->storage = $folder_or_id; } else { - // $this->storage = kolab_storage_dav::get_folder($folder_or_id); + // $this->storage = kolab_storage_dav::get_folder($folder_or_id, 'event'); } $this->cal = $calendar; @@ -368,8 +368,8 @@ class caldav_calendar extends kolab_storage_dav_folder // $config = kolab_storage_config::get_instance(); // $config->apply_links($events); - // avoid session race conditions that will loose temporary subscriptions - $this->cal->rc->session->nowrite = true; + // Avoid session race conditions that will loose temporary subscriptions + // $this->cal->rc->session->nowrite = true; return $events; } diff --git a/plugins/calendar/drivers/caldav/caldav_driver.php b/plugins/calendar/drivers/caldav/caldav_driver.php index f7e1638f..b26c2f23 100644 --- a/plugins/calendar/drivers/caldav/caldav_driver.php +++ b/plugins/calendar/drivers/caldav/caldav_driver.php @@ -125,6 +125,7 @@ class caldav_driver extends kolab_driver $folders = $this->filter_calendars($filter); $calendars = []; + $prefs = $this->rc->config->get('kolab_calendars', []); // include virtual folders for a full folder tree /* @@ -181,11 +182,11 @@ class caldav_driver extends kolab_driver 'color' => $cal->get_color(), 'editable' => $cal->editable, 'group' => $is_user ? 'other user' : $cal->get_namespace(), - 'active' => $cal->is_active(), + 'active' => !isset($prefs[$cal->id]['active']) || !empty($prefs[$cal->id]['active']), 'owner' => $cal->get_owner(), 'removable' => !$cal->default, // extras to hide some elements in the UI - 'subscriptions' => false, + 'subscriptions' => $cal->subscriptions, 'driver' => 'caldav', ]; @@ -306,10 +307,8 @@ class caldav_driver extends kolab_driver */ public function create_calendar($prop) { - $prop['type'] = 'event'; - $prop['active'] = true; // TODO - $prop['subscribed'] = true; - $prop['alarms'] = !empty($prop['showalarms']); + $prop['type'] = 'event'; + $prop['alarms'] = !empty($prop['showalarms']); $id = $this->storage->folder_update($prop); @@ -317,6 +316,10 @@ class caldav_driver extends kolab_driver return false; } + $prefs['kolab_calendars'] = $this->rc->config->get('kolab_calendars', []); + $prefs['kolab_calendars'][$id]['active'] = true; + + $this->rc->user->save_prefs($prefs); return $id; } @@ -362,48 +365,19 @@ class caldav_driver extends kolab_driver */ public function subscribe_calendar($prop) { - if (!empty($prop['id']) && ($cal = $this->get_calendar($prop['id'])) && !empty($cal->storage)) { - $ret = false; - if (isset($prop['permanent'])) { - $ret |= $cal->storage->subscribe(intval($prop['permanent'])); - } - if (isset($prop['active'])) { - $ret |= $cal->storage->activate(intval($prop['active'])); - } - - // apply to child folders, too - if (!empty($prop['recursive'])) { - foreach ((array) $this->storage->list_folders($cal->storage->name, '*', 'event') as $subfolder) { - if (isset($prop['permanent'])) { - if ($prop['permanent']) { - $this->storage->folder_subscribe($subfolder); - } - else { - $this->storage->folder_unsubscribe($subfolder); - } - } - - if (isset($prop['active'])) { - if ($prop['active']) { - $this->storage->folder_activate($subfolder); - } - else { - $this->storage->folder_deactivate($subfolder); - } - } - } - } - return $ret; + if (empty($prop['id'])) { + return false; } - else { - // save state in local prefs + + // save state in local prefs + if (isset($prop['active'])) { $prefs['kolab_calendars'] = $this->rc->config->get('kolab_calendars', []); $prefs['kolab_calendars'][$prop['id']]['active'] = !empty($prop['active']); + $this->rc->user->save_prefs($prefs); - return true; } - return false; + return true; } /** diff --git a/plugins/calendar/lib/calendar_ui.php b/plugins/calendar/lib/calendar_ui.php index 1d4daef2..83779834 100644 --- a/plugins/calendar/lib/calendar_ui.php +++ b/plugins/calendar/lib/calendar_ui.php @@ -352,7 +352,7 @@ class calendar_ui $color = !empty($prop['color']) ? $prop['color'] : 'f00'; $actions = ''; - if (!EMPTY($prop['removable'])) { + if (!empty($prop['removable'])) { $actions .= html::a([ 'href' => '#', 'class' => 'remove', @@ -370,28 +370,28 @@ class calendar_ui ], '' ); - if (!empty($prop['subscribed'])) { - $actions .= html::a([ - 'href' => '#', - 'class' => 'subscribed', - 'title' => $this->cal->gettext('calendarsubscribe'), - 'role' => 'checkbox', - 'aria-checked' => !empty($prop['subscribed']) ? 'true' : 'false' - ], ' ' - ); + if (!isset($prop['subscriptions']) || $prop['subscriptions'] !== false) { + if (!empty($prop['subscribed'])) { + $actions .= html::a([ + 'href' => '#', + 'class' => 'subscribed', + 'title' => $this->cal->gettext('calendarsubscribe'), + 'role' => 'checkbox', + 'aria-checked' => !empty($prop['subscribed']) ? 'true' : 'false' + ], ' ' + ); + } } - if (!isset($prop['subscriptions']) || $prop['subscriptions'] !== false) { - $content .= html::tag('input', [ - 'type' => 'checkbox', - 'name' => '_cal[]', - 'value' => $id, - 'checked' => !empty($prop['active']), - 'aria-labelledby' => $label_id - ]) - . html::span('actions', $actions) - . html::span(['class' => 'handle', 'style' => "background-color: #$color"], ' '); - } + $content .= html::tag('input', [ + 'type' => 'checkbox', + 'name' => '_cal[]', + 'value' => $id, + 'checked' => !empty($prop['active']), + 'aria-labelledby' => $label_id + ]) + . html::span('actions', $actions) + . html::span(['class' => 'handle', 'style' => "background-color: #$color"], ' '); } $content = html::div(join(' ', $classes), $content); diff --git a/plugins/libkolab/lib/kolab_dav_client.php b/plugins/libkolab/lib/kolab_dav_client.php index bf8dc7ac..79c23be8 100644 --- a/plugins/libkolab/lib/kolab_dav_client.php +++ b/plugins/libkolab/lib/kolab_dav_client.php @@ -227,8 +227,7 @@ class kolab_dav_client $ns .= ' xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:a="http://apple.com/ns/ical/" xmlns:k="Kolab:"'; $props = '' . '' - . '' - . ''; + . ''; } $body = '' @@ -436,7 +435,7 @@ class kolab_dav_client $ns .= ' xmlns:a="http://apple.com/ns/ical/"'; $props .= '' . htmlspecialchars($value, ENT_XML1, 'UTF-8') . ''; } - else if ($name == 'subscribed' || $name == 'alarms') { + else if ($name == 'alarms') { if (!strpos($ns, 'Kolab:')) { $ns .= ' xmlns:k="Kolab:"'; } @@ -677,7 +676,7 @@ class kolab_dav_client 'resource_type' => $types, ]; - foreach (['subscribed', 'alarms'] as $tag) { + foreach (['alarms'] as $tag) { if ($el = $element->getElementsByTagName($tag)->item(0)) { if (strlen($el->nodeValue) > 0) { $result[$tag] = strtolower($el->nodeValue) === 'true'; diff --git a/plugins/libkolab/lib/kolab_storage_dav.php b/plugins/libkolab/lib/kolab_storage_dav.php index ea7e117c..fecff647 100644 --- a/plugins/libkolab/lib/kolab_storage_dav.php +++ b/plugins/libkolab/lib/kolab_storage_dav.php @@ -435,8 +435,7 @@ class kolab_storage_dav */ public function folder_is_active($folder) { - // TODO - return true; + return true; // TODO } /** @@ -448,7 +447,7 @@ class kolab_storage_dav */ public function folder_activate($folder) { - return true; + return true; // TODO } /** @@ -460,7 +459,7 @@ class kolab_storage_dav */ public function folder_deactivate($folder) { - return false; + return false; // TODO } /** diff --git a/plugins/libkolab/lib/kolab_storage_dav_folder.php b/plugins/libkolab/lib/kolab_storage_dav_folder.php index 258b6d6e..a588b95b 100644 --- a/plugins/libkolab/lib/kolab_storage_dav_folder.php +++ b/plugins/libkolab/lib/kolab_storage_dav_folder.php @@ -200,8 +200,7 @@ class kolab_storage_dav_folder extends kolab_storage_folder */ public function is_active() { - // TODO - return true; + return true; // Unused } /** @@ -213,8 +212,7 @@ class kolab_storage_dav_folder extends kolab_storage_folder */ public function activate($active) { - // TODO - return true; + return true; // Unused } /** @@ -224,7 +222,7 @@ class kolab_storage_dav_folder extends kolab_storage_folder */ public function is_subscribed() { - return !isset($this->attributes['subscribed']) || $this->attributes['subscribed']; + return true; // TODO } /** @@ -236,8 +234,7 @@ class kolab_storage_dav_folder extends kolab_storage_folder */ public function subscribe($subscribed) { - // TODO - return true; + return true; // TODO } /**