Small improvements in DAV handler

This commit is contained in:
Aleksander Machniak 2024-01-04 09:47:07 +01:00
parent 980c5733dd
commit 737f4c119e
3 changed files with 14 additions and 4 deletions

View file

@ -541,7 +541,7 @@ class kolab_storage_cache
* *
* @param string $uid Object UID * @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) public function get_by_uid($uid)
{ {

View file

@ -204,8 +204,7 @@ class kolab_storage_dav_folder extends kolab_storage_folder
*/ */
public function get_uid() public function get_uid()
{ {
// TODO ??? return $this->id;
return '';
} }
/** /**
@ -380,6 +379,17 @@ class kolab_storage_dav_folder extends kolab_storage_folder
$object['changed'] = new DateTime('now'); $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 // generate and save object message
if ($content = $this->to_dav($object)) { if ($content = $this->to_dav($object)) {
$method = $uid ? 'update' : 'create'; $method = $uid ? 'update' : 'create';

View file

@ -270,7 +270,7 @@ class kolab_storage_folder extends kolab_storage_folder_api
* *
* @param string $uid Object UID * @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) public function get_object($uid)
{ {