@@ -47,9 +47,14 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
4747 /** @var IConfig */
4848 private $ config ;
4949
50- /** @var ProxyMapper */
51- private $ proxyMapper ;
52-
50+ /**
51+ * Calendar constructor.
52+ *
53+ * @param BackendInterface $caldavBackend
54+ * @param $calendarInfo
55+ * @param IL10N $l10n
56+ * @param IConfig $config
57+ */
5358 public function __construct (BackendInterface $ caldavBackend , $ calendarInfo , IL10N $ l10n , IConfig $ config ) {
5459 parent ::__construct ($ caldavBackend , $ calendarInfo );
5560
@@ -62,9 +67,6 @@ public function __construct(BackendInterface $caldavBackend, $calendarInfo, IL10
6267 }
6368
6469 $ this ->config = $ config ;
65-
66- // TODO: proper DI
67- $ this ->proxyMapper = \OC ::$ server ->query (ProxyMapper::class);
6870 }
6971
7072 /**
@@ -126,29 +128,54 @@ public function getPrincipalURI() {
126128 return $ this ->calendarInfo ['principaluri ' ];
127129 }
128130
131+ /**
132+ * @return array
133+ */
129134 public function getACL () {
130135 $ acl = [
131136 [
132137 'privilege ' => '{DAV:}read ' ,
133138 'principal ' => $ this ->getOwner (),
134139 'protected ' => true ,
135- ]];
140+ ],
141+ [
142+ 'privilege ' => '{DAV:}read ' ,
143+ 'principal ' => $ this ->getOwner () . '/calendar-proxy-write ' ,
144+ 'protected ' => true ,
145+ ],
146+ [
147+ 'privilege ' => '{DAV:}read ' ,
148+ 'principal ' => $ this ->getOwner () . '/calendar-proxy-read ' ,
149+ 'protected ' => true ,
150+ ],
151+ ];
152+
136153 if ($ this ->getName () !== BirthdayService::BIRTHDAY_CALENDAR_URI ) {
137154 $ acl [] = [
138155 'privilege ' => '{DAV:}write ' ,
139156 'principal ' => $ this ->getOwner (),
140157 'protected ' => true ,
141158 ];
159+ $ acl [] = [
160+ 'privilege ' => '{DAV:}write ' ,
161+ 'principal ' => $ this ->getOwner () . '/calendar-proxy-write ' ,
162+ 'protected ' => true ,
163+ ];
142164 } else {
143165 $ acl [] = [
144166 'privilege ' => '{DAV:}write-properties ' ,
145167 'principal ' => $ this ->getOwner (),
146168 'protected ' => true ,
147169 ];
170+ $ acl [] = [
171+ 'privilege ' => '{DAV:}write-properties ' ,
172+ 'principal ' => $ this ->getOwner () . '/calendar-proxy-read ' ,
173+ 'protected ' => true ,
174+ ];
148175 }
149176
150177 if (!$ this ->isShared ()) {
151- return $ this -> addProxies ( $ acl) ;
178+ return $ acl ;
152179 }
153180
154181 if ($ this ->getOwner () !== parent ::getOwner ()) {
@@ -181,37 +208,9 @@ public function getACL() {
181208
182209 $ acl = $ this ->caldavBackend ->applyShareAcl ($ this ->getResourceId (), $ acl );
183210 $ allowedPrincipals = [$ this ->getOwner (), parent ::getOwner (), 'principals/system/public ' ];
184- $ acl = array_filter ($ acl , function ($ rule ) use ($ allowedPrincipals ) {
211+ return array_filter ($ acl , function ($ rule ) use ($ allowedPrincipals ) {
185212 return \in_array ($ rule ['principal ' ], $ allowedPrincipals , true );
186213 });
187-
188- $ acl = $ this ->addProxies ($ acl );
189-
190- return $ acl ;
191- }
192-
193- public function addProxies (array $ acl ): array {
194- list ($ prefix , $ name ) = \Sabre \Uri \split ($ this ->getOwner ());
195- $ proxies = $ this ->proxyMapper ->getProxiesOf ($ name );
196-
197- foreach ($ proxies as $ proxy ) {
198- if ($ proxy ->getPermissions () & ProxyMapper::PERMISSION_READ ) {
199- $ acl [] = [
200- 'privilege ' => '{DAV:}read ' ,
201- 'principal ' => 'principals/users/ ' . $ proxy ->getProxyId (),
202- 'protected ' => true ,
203- ];
204- }
205- if ($ proxy ->getPermissions () & ProxyMapper::PERMISSION_WRITE ) {
206- $ acl [] = [
207- 'privilege ' => '{DAV:}write ' ,
208- 'principal ' => 'principals/users/ ' . $ proxy ->getProxyId (),
209- 'protected ' => true ,
210- ];
211- }
212- }
213-
214- return $ acl ;
215214 }
216215
217216 public function getChildACL () {
0 commit comments