Fix error when creating a DAV contacts folder

This commit is contained in:
Aleksander Machniak 2022-11-30 13:29:22 +01:00
parent 1b33810f71
commit 52caa307fd
2 changed files with 19 additions and 2 deletions

View file

@ -168,6 +168,23 @@ class kolab_storage_dav
return kolab_storage::get_freebusy_url($email, $start, $end);
}
/**
* Creates folder ID from a DAV folder location and server URI.
*
* @param string $uri DAV server location
* @param string $href Folder location
*
* @return string Folder ID string
*/
public static function folder_id($uri, $href)
{
if (($rootPath = parse_url($uri, PHP_URL_PATH)) && strpos($href, $rootPath) === 0) {
$href = substr($href, strlen($rootPath));
}
return md5(rtrim($uri, '/') . '/' . trim($href, '/'));
}
/**
* Deletes a folder
*
@ -264,7 +281,7 @@ class kolab_storage_dav
$result = $this->dav->folderCreate($location, $type, $prop);
if ($result !== false) {
$result = md5($this->dav->url . '/' . $location);
$result = self::folder_id($this->dav->url, $location);
}
}

View file

@ -34,7 +34,7 @@ class kolab_storage_dav_folder extends kolab_storage_folder
$this->attributes = $attributes;
$this->href = $this->attributes['href'];
$this->id = md5($dav->url . '/' . $this->href);
$this->id = kolab_storage_dav::folder_id($dav->url, $this->href);
$this->dav = $dav;
$this->valid = true;