From 737f4c119e82c3d3f2d32f1f5bb891a9e06deac6 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 4 Jan 2024 09:47:07 +0100 Subject: [PATCH] Small improvements in DAV handler --- plugins/libkolab/lib/kolab_storage_cache.php | 2 +- plugins/libkolab/lib/kolab_storage_dav_folder.php | 14 ++++++++++++-- plugins/libkolab/lib/kolab_storage_folder.php | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php index 360688b5..dfc1d5b1 100644 --- a/plugins/libkolab/lib/kolab_storage_cache.php +++ b/plugins/libkolab/lib/kolab_storage_cache.php @@ -541,7 +541,7 @@ class kolab_storage_cache * * @param string $uid Object UID * - * @return array The Kolab object represented as hash array + * @return array|null The Kolab object represented as hash array */ public function get_by_uid($uid) { diff --git a/plugins/libkolab/lib/kolab_storage_dav_folder.php b/plugins/libkolab/lib/kolab_storage_dav_folder.php index 02efa686..76ebe32d 100644 --- a/plugins/libkolab/lib/kolab_storage_dav_folder.php +++ b/plugins/libkolab/lib/kolab_storage_dav_folder.php @@ -204,8 +204,7 @@ class kolab_storage_dav_folder extends kolab_storage_folder */ public function get_uid() { - // TODO ??? - return ''; + return $this->id; } /** @@ -380,6 +379,17 @@ class kolab_storage_dav_folder extends kolab_storage_folder $object['changed'] = new DateTime('now'); } + // Make sure UID exists + if (empty($object['uid'])) { + if ($uid) { + $object['uid'] = $uid; + } + else { + $username = rcube::get_instance()->user->get_username(); + $object['uid'] = strtoupper(md5(time() . uniqid(rand())) . '-' . substr(md5($username), 0, 16)); + } + } + // generate and save object message if ($content = $this->to_dav($object)) { $method = $uid ? 'update' : 'create'; diff --git a/plugins/libkolab/lib/kolab_storage_folder.php b/plugins/libkolab/lib/kolab_storage_folder.php index 33bebd74..91f12c38 100644 --- a/plugins/libkolab/lib/kolab_storage_folder.php +++ b/plugins/libkolab/lib/kolab_storage_folder.php @@ -270,7 +270,7 @@ class kolab_storage_folder extends kolab_storage_folder_api * * @param string $uid Object UID * - * @return array The Kolab object represented as hash array + * @return array|false|null The Kolab object represented as hash array, False on error */ public function get_object($uid) {