@@ -133,7 +133,12 @@ public function propFind(PropFind $propFind, INode $node) {
133133 $ canShare = (!$ node ->isSubscription () && $ node ->canWrite ());
134134 $ canPublish = (!$ node ->isSubscription () && $ node ->canWrite ());
135135
136- return new AllowedSharingModes ($ canShare , $ canPublish );
136+ if ($ this ->config ->getAppValue ('dav ' , 'limitAddressBookAndCalendarSharingToOwner ' , 'no ' ) === 'yes ' ) {
137+ $ canShare &= ($ node ->getOwner () === $ node ->getPrincipalURI ());
138+ $ canPublish &= ($ node ->getOwner () === $ node ->getPrincipalURI ());
139+ }
140+
141+ return new AllowedSharingModes ((bool )$ canShare , (bool )$ canPublish );
137142 });
138143 }
139144 }
@@ -190,7 +195,14 @@ public function httpPost(RequestInterface $request, ResponseInterface $response)
190195
191196 // If there's no ACL support, we allow everything
192197 if ($ acl ) {
198+ /** @var \Sabre\DAVACL\Plugin $acl */
193199 $ acl ->checkPrivileges ($ path , '{DAV:}write ' );
200+
201+ $ limitSharingToOwner = $ this ->config ->getAppValue ('dav ' , 'limitAddressBookAndCalendarSharingToOwner ' , 'no ' ) === 'yes ' ;
202+ $ isOwner = $ acl ->getCurrentUserPrincipal () === $ node ->getOwner ();
203+ if ($ limitSharingToOwner && !$ isOwner ) {
204+ return ;
205+ }
194206 }
195207
196208 $ node ->setPublishStatus (true );
@@ -218,7 +230,14 @@ public function httpPost(RequestInterface $request, ResponseInterface $response)
218230
219231 // If there's no ACL support, we allow everything
220232 if ($ acl ) {
233+ /** @var \Sabre\DAVACL\Plugin $acl */
221234 $ acl ->checkPrivileges ($ path , '{DAV:}write ' );
235+
236+ $ limitSharingToOwner = $ this ->config ->getAppValue ('dav ' , 'limitAddressBookAndCalendarSharingToOwner ' , 'no ' ) === 'yes ' ;
237+ $ isOwner = $ acl ->getCurrentUserPrincipal () === $ node ->getOwner ();
238+ if ($ limitSharingToOwner && !$ isOwner ) {
239+ return ;
240+ }
222241 }
223242
224243 $ node ->setPublishStatus (false );
0 commit comments