fix setting InfoLog primary link

This commit is contained in:
ralf 2024-02-06 21:23:59 +02:00
parent ebac17aa4e
commit 180139af85
3 changed files with 22 additions and 5 deletions

View File

@ -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

View File

@ -80,7 +80,7 @@ Location: https://example.org/egroupware/groupdav.php/<username>/<app>/<id>/link
```
curl -i 'https://example.org/egroupware/groupdav.php/<username>/<app>/<id>/links/' -H "Content-Type: application/json" --data-binary @- --user <username> <<<EOF
{"application":"<2nd-app>","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/<username>/<app>/<id>/link
```
curl -i 'https://example.org/egroupware/groupdav.php/<username>/infolog/<id>/links/' -H "Content-Type: application/json" --data-binary @- --user <username> <<<EOF
{"application":"<2nd-app>","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/<username>/infolog/<id>/li
```
</details>
> `<id>` is the numerical ID of the entry of application `<app>`, 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
<details>

View File

@ -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");
}