Skip to content
Snippets Groups Projects
Unverified Commit c4121a9c authored by Vincent Brillault's avatar Vincent Brillault
Browse files

Caldav: auto-detect calendar type based on supported-calendar-component-set

parent 7368219a
No related branches found
No related tags found
1 merge request!3Caldav: auto-detect calendar type based on supported-calendar-component-set
......@@ -131,14 +131,28 @@ class BackendCalDAV extends BackendDiff {
$folders = array();
$calendars = $this->_caldav->FindCalendars();
foreach ($calendars as $val) {
$folder = array();
$fpath = explode("/", $val->url, -1);
if (is_array($fpath)) {
$folderid = array_pop($fpath);
if ($val->supported_comp == null) {
$id = "C" . $folderid;
$folders[] = $this->StatFolder($id);
$id = "T" . $folderid;
$folders[] = $this->StatFolder($id);
} else {
foreach ($val->supported_comp as $comp) {
switch($comp) {
case 'VEVENT':
$id = "C" . $folderid;
$folders[] = $this->StatFolder($id);
break;
case 'VTODO':
$id = "T" . $folderid;
$folders[] = $this->StatFolder($id);
break;
}
}
}
}
}
return $folders;
......
......@@ -22,12 +22,14 @@ class CalendarInfo {
public $displayname;
public $getctag;
public $id;
public $supported_comp;
function __construct( $url, $displayname = null, $getctag = null, $id = null ) {
function __construct( $url, $displayname = null, $getctag = null, $id = null, $supported_comp = null ) {
$this->url = $url;
$this->displayname = $displayname;
$this->getctag = $getctag;
$this->id = $id;
$this->supported_comp = $supported_comp;
}
function __toString() {
......@@ -616,7 +618,7 @@ class CalDAVClient {
if ( !isset($this->calendar_home_set[0]) ) {
$this->FindCalendarHome();
}
$this->DoPROPFINDRequest( $this->calendar_home_set[0], array('resourcetype','displayname','http://calendarserver.org/ns/:getctag'), 1);
$this->DoPROPFINDRequest( $this->calendar_home_set[0], array('resourcetype','displayname','http://calendarserver.org/ns/:getctag','urn:ietf:params:xml:ns:caldav:supported-calendar-component-set'), 1);
$calendars = array();
if ( isset($this->xmltags['urn:ietf:params:xml:ns:caldav:calendar']) ) {
......@@ -636,6 +638,7 @@ class CalDAVClient {
$calendar = new CalendarInfo($href);
$ok_props = $this->GetOKProps($hnode);
$supported_depth = -1;
foreach( $ok_props AS $v ) {
// printf("Looking at: %s[%s]\n", $href, $v['tag'] );
switch( $v['tag'] ) {
......@@ -645,6 +648,22 @@ class CalDAVClient {
case 'DAV::displayname':
$calendar->displayname = $v['value'];
break;
case 'urn:ietf:params:xml:ns:caldav:supported-calendar-component-set':
if ($v['type'] == 'open') {
$supported_depth = $v['level'] + 1;
}
elseif ($v['type'] == 'close') {
$supported_depth = -1;
}
break;
case 'urn:ietf:params:xml:ns:caldav:comp':
if ($v['level'] == $supported_depth ) {
if ($calendar->supported_comp == null )
$calendar->supported_comp = array();
if ( isset($v['attributes']) && isset($v['attributes']['name']) )
$calendar->supported_comp[] = $v['attributes']['name'];
}
break;
}
}
$calendar->id = rtrim(str_replace($this->calendar_home_set[0], "", $calendar->url), "/");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment