Skip to content

Commit d0547b3

Browse files
committed
fix: add ACLs for calender delegation
Signed-off-by: Hamza <hamzamahjoubi221@gmail.com>
1 parent 05ecc84 commit d0547b3

5 files changed

Lines changed: 90 additions & 0 deletions

File tree

apps/dav/composer/composer/autoload_classmap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
'OCA\\DAV\\CalDAV\\Outbox' => $baseDir . '/../lib/CalDAV/Outbox.php',
7777
'OCA\\DAV\\CalDAV\\Plugin' => $baseDir . '/../lib/CalDAV/Plugin.php',
7878
'OCA\\DAV\\CalDAV\\Principal\\Collection' => $baseDir . '/../lib/CalDAV/Principal/Collection.php',
79+
'OCA\\DAV\\CalDAV\\Principal\\ProxyRead' => $baseDir . '/../lib/CalDAV/Principal/ProxyRead.php',
80+
'OCA\\DAV\\CalDAV\\Principal\\ProxyWrite' => $baseDir . '/../lib/CalDAV/Principal/ProxyWrite.php',
7981
'OCA\\DAV\\CalDAV\\Principal\\User' => $baseDir . '/../lib/CalDAV/Principal/User.php',
8082
'OCA\\DAV\\CalDAV\\Proxy\\Proxy' => $baseDir . '/../lib/CalDAV/Proxy/Proxy.php',
8183
'OCA\\DAV\\CalDAV\\Proxy\\ProxyMapper' => $baseDir . '/../lib/CalDAV/Proxy/ProxyMapper.php',

apps/dav/composer/composer/autoload_static.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ class ComposerStaticInitDAV
9191
'OCA\\DAV\\CalDAV\\Outbox' => __DIR__ . '/..' . '/../lib/CalDAV/Outbox.php',
9292
'OCA\\DAV\\CalDAV\\Plugin' => __DIR__ . '/..' . '/../lib/CalDAV/Plugin.php',
9393
'OCA\\DAV\\CalDAV\\Principal\\Collection' => __DIR__ . '/..' . '/../lib/CalDAV/Principal/Collection.php',
94+
'OCA\\DAV\\CalDAV\\Principal\\ProxyRead' => __DIR__ . '/..' . '/../lib/CalDAV/Principal/ProxyRead.php',
95+
'OCA\\DAV\\CalDAV\\Principal\\ProxyWrite' => __DIR__ . '/..' . '/../lib/CalDAV/Principal/ProxyWrite.php',
9496
'OCA\\DAV\\CalDAV\\Principal\\User' => __DIR__ . '/..' . '/../lib/CalDAV/Principal/User.php',
9597
'OCA\\DAV\\CalDAV\\Proxy\\Proxy' => __DIR__ . '/..' . '/../lib/CalDAV/Proxy/Proxy.php',
9698
'OCA\\DAV\\CalDAV\\Proxy\\ProxyMapper' => __DIR__ . '/..' . '/../lib/CalDAV/Proxy/ProxyMapper.php',
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OCA\DAV\CalDAV\Principal;
11+
12+
use Sabre\DAVACL;
13+
14+
class ProxyRead extends \Sabre\CalDAV\Principal\ProxyRead implements DAVACL\IACL {
15+
use DAVACL\ACLTrait;
16+
17+
/**
18+
* @inheritDoc
19+
*/
20+
public function getOwner() {
21+
return $this->principalInfo['uri'];
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OCA\DAV\CalDAV\Principal;
11+
12+
use Sabre\DAVACL;
13+
14+
class ProxyWrite extends \Sabre\CalDAV\Principal\ProxyWrite implements DAVACL\IACL {
15+
use DAVACL\ACLTrait;
16+
17+
/**
18+
* @inheritDoc
19+
*/
20+
public function getOwner() {
21+
return $this->principalInfo['uri'];
22+
}
23+
}

apps/dav/lib/CalDAV/Principal/User.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,44 @@ public function getACL() {
3333
];
3434
return $acl;
3535
}
36+
37+
/**
38+
* Returns a specific child node, referenced by its name.
39+
*
40+
* @param string $name
41+
*
42+
* @return \Sabre\DAV\INode
43+
*/
44+
public function getChild($name) {
45+
$principal = $this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/' . $name);
46+
if (!$principal) {
47+
throw new \Sabre\DAV\Exception\NotFound("Node with name $name was not found");
48+
}
49+
if ($name === 'calendar-proxy-read') {
50+
return new ProxyRead($this->principalBackend, $this->principalProperties);
51+
}
52+
53+
if ($name === 'calendar-proxy-write') {
54+
return new ProxyWrite($this->principalBackend, $this->principalProperties);
55+
}
56+
57+
throw new \Sabre\DAV\Exception\NotFound("Node with name $name was not found");
58+
}
59+
60+
/**
61+
* Returns an array with all the child nodes.
62+
*
63+
* @return \Sabre\DAV\INode[]
64+
*/
65+
public function getChildren() {
66+
$r = [];
67+
if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/calendar-proxy-read')) {
68+
$r[] = new ProxyRead($this->principalBackend, $this->principalProperties);
69+
}
70+
if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/calendar-proxy-write')) {
71+
$r[] = new ProxyWrite($this->principalBackend, $this->principalProperties);
72+
}
73+
74+
return $r;
75+
}
3676
}

0 commit comments

Comments
 (0)