aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Cdav.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-03-25 14:00:49 +0100
committerMario <mario@mariovavti.com>2021-03-25 14:00:49 +0100
commitb50f1657c3e5772dd6235ce98c55e71630b0c626 (patch)
treead1d7b2b00d012163de2163f9d5902f21618a2de /Zotlabs/Module/Cdav.php
parentbc1cc65ff20c97db0323d02ab652b239b4c60eb6 (diff)
parent19b96e37fb2a0fe89e2b6ae537781007bb392532 (diff)
downloadvolse-hubzilla-b50f1657c3e5772dd6235ce98c55e71630b0c626.tar.gz
volse-hubzilla-b50f1657c3e5772dd6235ce98c55e71630b0c626.tar.bz2
volse-hubzilla-b50f1657c3e5772dd6235ce98c55e71630b0c626.zip
Merge branch 'air' of https://framagit.org/hubzilla/core into air
Diffstat (limited to 'Zotlabs/Module/Cdav.php')
-rw-r--r--Zotlabs/Module/Cdav.php41
1 files changed, 21 insertions, 20 deletions
diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php
index fe697a526..a7d2b1169 100644
--- a/Zotlabs/Module/Cdav.php
+++ b/Zotlabs/Module/Cdav.php
@@ -135,7 +135,7 @@ class Cdav extends Controller {
$auth = new \Zotlabs\Storage\BasicAuth();
$auth->setRealm(ucfirst(\Zotlabs\Lib\System::get_platform_name()) . 'CalDAV/CardDAV');
- if (local_channel()) {
+ if(local_channel()) {
logger('loggedin');
@@ -153,9 +153,9 @@ class Cdav extends Controller {
$auth->observer = $channel['channel_hash'];
$principalUri = 'principals/' . $channel['channel_address'];
- if(!cdav_principal($principalUri)) {
+ if(! cdav_principal($principalUri)) {
$this->activate($pdo, $channel);
- if(!cdav_principal($principalUri)) {
+ if(! cdav_principal($principalUri)) {
return;
}
}
@@ -168,21 +168,24 @@ class Cdav extends Controller {
if($httpmethod === 'PUT' || $httpmethod === 'DELETE') {
+ $channel = channelx_by_nick(argv(2));
+ $principalUri = 'principals/' . $channel['channel_address'];
$httpuri = $_SERVER['REQUEST_URI'];
logger("debug: method: " . $httpmethod, LOGGER_DEBUG);
logger("debug: uri: " . $httpuri, LOGGER_DEBUG);
- if(strpos($httpuri, 'cdav/addressbooks')) {
+ if(strpos($httpuri, 'cdav/addressbooks') !== false) {
$sync = 'addressbook';
$cdavtable = 'addressbooks';
}
- elseif(strpos($httpuri, 'cdav/calendars')) {
+ elseif(strpos($httpuri, 'cdav/calendars') !== false) {
$sync = 'calendar';
$cdavtable = 'calendarinstances';
}
- else
+ else {
$sync = false;
+ }
if($sync) {
@@ -191,14 +194,13 @@ class Cdav extends Controller {
logger("debug: body: " . $httpbody, LOGGER_DEBUG);
- if($x = get_cdav_id($principalUri, explode("/", $httpuri)[4], $cdavtable)) {
+ if($x = get_cdav_id($principalUri, argv(3), $cdavtable)) {
$cdavdata = $this->get_cdav_data($x['id'], $cdavtable);
-
$etag = (isset($_SERVER['HTTP_IF_MATCH']) ? $_SERVER['HTTP_IF_MATCH'] : false);
// delete
- if($httpmethod === 'DELETE' && $cdavdata['etag'] == $etag)
+ if($httpmethod === 'DELETE' && $cdavdata['etag'] == $etag) {
Libsync::build_sync_packet($channel['channel_id'], [
$sync => [
'action' => 'delete_card',
@@ -206,18 +208,18 @@ class Cdav extends Controller {
'carduri' => $uri
]
]);
+ }
else {
- if($etag) {
+ if($etag && $cdavdata['etag'] !== $etag) {
// update
- if($cdavdata['etag'] !== $etag)
- Libsync::build_sync_packet($channel['channel_id'], [
- $sync => [
- 'action' => 'update_card',
- 'uri' => $cdavdata['uri'],
- 'carduri' => $uri,
- 'card' => $httpbody
- ]
- ]);
+ Libsync::build_sync_packet($channel['channel_id'], [
+ $sync => [
+ 'action' => 'update_card',
+ 'uri' => $cdavdata['uri'],
+ 'carduri' => $uri,
+ 'card' => $httpbody
+ ]
+ ]);
}
else {
// new
@@ -235,7 +237,6 @@ class Cdav extends Controller {
}
}
-
$principalBackend = new \Sabre\DAVACL\PrincipalBackend\PDO($pdo);
$carddavBackend = new \Sabre\CardDAV\Backend\PDO($pdo);
$caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo);