Skip to content

Commit bbaf2af

Browse files
pboguslawskitcitworld
authored andcommitted
Disable sharing calendars via link adjusted
Fixes: 45eefc2 Related: #34372 Author-Change-Id: IB#1126264 Signed-off-by: Pawel Boguslawski <pawel.boguslawski@ib.pl>
1 parent f931259 commit bbaf2af

4 files changed

Lines changed: 12 additions & 19 deletions

File tree

apps/dav/lib/CalDAV/CalDavBackend.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* @copyright Copyright (c) 2016, ownCloud, Inc.
44
* @copyright Copyright (c) 2018 Georg Ehrke
55
* @copyright Copyright (c) 2020, leith abdulla (<online-nextcloud@eleith.com>)
6-
* @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
76
*
87
* @author Chih-Hsuan Yen <yan12125@gmail.com>
98
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
@@ -498,10 +497,6 @@ public function getUsersOwnCalendars($principalUri) {
498497
* @return array
499498
*/
500499
public function getPublicCalendars() {
501-
// Sharing via link must be enabled.
502-
if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'no' ) {
503-
return array_values([]);
504-
}
505500
$fields = array_column($this->propertyMap, 0);
506501
$fields[] = 'a.id';
507502
$fields[] = 'a.uri';
@@ -560,10 +555,6 @@ public function getPublicCalendars() {
560555
* @throws NotFound
561556
*/
562557
public function getPublicCalendar($uri) {
563-
// Sharing via link must be enabled.
564-
if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'no' ) {
565-
throw new NotFound('Node with name \'' . $uri . '\' could not be found');
566-
}
567558
$fields = array_column($this->propertyMap, 0);
568559
$fields[] = 'a.id';
569560
$fields[] = 'a.uri';

apps/dav/lib/CalDAV/PublicCalendarRoot.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
/**
33
* @copyright Copyright (c) 2016, ownCloud, Inc.
4+
* @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
45
*
56
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
67
* @author Georg Ehrke <oc.list@georgehrke.com>
@@ -29,6 +30,7 @@
2930
use OCP\IL10N;
3031
use Psr\Log\LoggerInterface;
3132
use Sabre\DAV\Collection;
33+
use Sabre\DAV\Exception\Forbidden;
3234

3335
class PublicCalendarRoot extends Collection {
3436

@@ -70,6 +72,10 @@ public function getName() {
7072
* @inheritdoc
7173
*/
7274
public function getChild($name) {
75+
// Sharing via link is allowed by default, but if the option is set it should be checked.
76+
if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'no' ) {
77+
throw new \Sabre\DAV\Exception\Forbidden();
78+
}
7379
$calendar = $this->caldavBackend->getPublicCalendar($name);
7480
return new PublicCalendar($this->caldavBackend, $calendar, $this->l10n, $this->config, $this->logger);
7581
}

apps/dav/lib/CalDAV/Publishing/PublishPlugin.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
/**
33
* @copyright Copyright (c) 2016 Thomas Citharel <tcit@tcit.fr>
4-
* @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
54
*
65
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
76
* @author Georg Ehrke <oc.list@georgehrke.com>
@@ -206,11 +205,6 @@ public function httpPost(RequestInterface $request, ResponseInterface $response)
206205
}
207206
}
208207

209-
// Sharing via link must be enabled.
210-
if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'no') {
211-
return;
212-
}
213-
214208
$node->setPublishStatus(true);
215209

216210
// iCloud sends back the 202, so we will too.

apps/dav/lib/Server.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,12 @@ public function __construct(IRequest $request, string $baseUri) {
184184

185185
$this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
186186
$this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest(), \OC::$server->getConfig()));
187-
$this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
188-
\OC::$server->getConfig(),
189-
\OC::$server->getURLGenerator()
190-
));
187+
if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
188+
$this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
189+
\OC::$server->getConfig(),
190+
\OC::$server->getURLGenerator()
191+
));
192+
}
191193
}
192194

193195
// addressbook plugins

0 commit comments

Comments
 (0)