From d472c267b2efe1a9ab2405f06ec379c2eb4145e7 Mon Sep 17 00:00:00 2001 From: ralf Date: Tue, 6 Feb 2024 21:23:59 +0200 Subject: [PATCH] fix setting InfoLog primary link --- api/src/CalDAV.php | 6 ++++++ doc/REST-CalDAV-CardDAV/Links-and-attachments.md | 7 +++++-- infolog/inc/class.infolog_groupdav.inc.php | 14 +++++++++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/api/src/CalDAV.php b/api/src/CalDAV.php index 92443aa02e..ea89b2a1ea 100644 --- a/api/src/CalDAV.php +++ b/api/src/CalDAV.php @@ -2055,6 +2055,12 @@ class CalDAV extends HTTP_WebDAV_Server } if (($handler = $this->app_handler($app))) { + // handle links for all apps supporting links + if ($method === 'POST' && preg_match('#/'.$app.'/'.$id.'/links/#', $options['path'])) + { + return $handler->createLink($options, $id); + } + $status = $handler->put($options, $id, $user, $prefix, $method, $_SERVER['HTTP_CONTENT_TYPE']); // set default stati: true --> 204 No Content, false --> should be already handled diff --git a/doc/REST-CalDAV-CardDAV/Links-and-attachments.md b/doc/REST-CalDAV-CardDAV/Links-and-attachments.md index 17fb3fd2f3..a7ba5bef81 100644 --- a/doc/REST-CalDAV-CardDAV/Links-and-attachments.md +++ b/doc/REST-CalDAV-CardDAV/Links-and-attachments.md @@ -80,7 +80,7 @@ Location: https://example.org/egroupware/groupdav.php////link ``` curl -i 'https://example.org/egroupware/groupdav.php////links/' -H "Content-Type: application/json" --data-binary @- --user <<","id":<2nd-app-id>,"remark":"This is a test ;)"} +{"app":"<2nd-app>","id":<2nd-app-id>,"remark":"This is a test ;)"} EOF HTTP/1.1 204 Created @@ -93,7 +93,7 @@ Location: https://example.org/egroupware/groupdav.php////link ``` curl -i 'https://example.org/egroupware/groupdav.php//infolog//links/' -H "Content-Type: application/json" --data-binary @- --user <<","id":<2nd-app-id>,"rel":"egroupware.org-primary"} +{"app":"<2nd-app>","id":<2nd-app-id>,"rel":"egroupware.org-primary"} EOF HTTP/1.1 204 Created @@ -101,6 +101,9 @@ Location: https://example.org/egroupware/groupdav.php//infolog//li ``` +> `` is the numerical ID of the entry of application ``, NOT the UUID some applications have! +> `<2nd-app-id>` is also the numerical ID of `<2nd-app>`, not the UUID + * **DELETE** request to remove a link or attachment
diff --git a/infolog/inc/class.infolog_groupdav.inc.php b/infolog/inc/class.infolog_groupdav.inc.php index 4d848a4ca8..5cb1161db6 100644 --- a/infolog/inc/class.infolog_groupdav.inc.php +++ b/infolog/inc/class.infolog_groupdav.inc.php @@ -76,8 +76,13 @@ class infolog_groupdav extends Api\CalDAV\Handler $this->bo = new infolog_bo(); $this->vCalendar = new Horde_Icalendar; + if (Api\CalDAV::isJSON()) + { + self::$path_attr = 'info_id'; + self::$path_extension = ''; + } // since 1.9.002 we allow clients to specify the URL when creating a new event, as specified by CalDAV - if (version_compare($GLOBALS['egw_info']['apps']['calendar']['version'], '1.9.002', '>=')) + elseif (version_compare($GLOBALS['egw_info']['apps']['calendar']['version'], '1.9.002', '>=')) { self::$path_attr = 'caldav_name'; self::$path_extension = ''; @@ -951,10 +956,13 @@ class infolog_groupdav extends Api\CalDAV\Handler throw new Api\Exception\NotFound(); } $info['info_link_id'] = $link_id; - $info['info_from'] = Link::titel($data['app'], $data['id']); + $info['info_from'] = Api\Link::title($data['app'], $data['id']); $info['info_custom_from'] = false; - if (!$this->bo->write($info)) + // this is somehow required to update info_link_id, otherwise info_link_id get reset again to old value + $info['info_contact'] = array_intersect_key($data, array_flip(['app', 'id'])); + + if (!$this->bo->write($info, false, true, false)) { throw new Api\Exception("Error storing InfoLog"); }