Disable sharing calendars via link when sharik via link is disabled

This mod disallows sharing calendars via link when `shareapi_allow_links`
is disabled.

Related: https://github.com/nextcloud/calendar/issues/525
Related: https://github.com/nextcloud/calendar/issues/4399
Author-Change-Id: IB#1126264
Signed-off-by: Pawel Boguslawski <pawel.boguslawski@ib.pl>
This commit is contained in:
Pawel Boguslawski 2022-10-01 23:43:43 +02:00
parent 2600a00c00
commit 45eefc221d
2 changed files with 15 additions and 0 deletions

View file

@ -3,6 +3,7 @@
* @copyright Copyright (c) 2016, ownCloud, Inc.
* @copyright Copyright (c) 2018 Georg Ehrke
* @copyright Copyright (c) 2020, leith abdulla (<online-nextcloud@eleith.com>)
* @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
*
* @author Chih-Hsuan Yen <yan12125@gmail.com>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
@ -512,6 +513,10 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
* @return array
*/
public function getPublicCalendars() {
// Sharing via link must be enabled.
if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'no' ) {
return array_values([]);
}
$fields = array_column($this->propertyMap, 0);
$fields[] = 'a.id';
$fields[] = 'a.uri';
@ -570,6 +575,10 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
* @throws NotFound
*/
public function getPublicCalendar($uri) {
// Sharing via link must be enabled.
if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'no' ) {
throw new NotFound('Node with name \'' . $uri . '\' could not be found');
}
$fields = array_column($this->propertyMap, 0);
$fields[] = 'a.id';
$fields[] = 'a.uri';

View file

@ -1,6 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2016 Thomas Citharel <tcit@tcit.fr>
* @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Georg Ehrke <oc.list@georgehrke.com>
@ -205,6 +206,11 @@ class PublishPlugin extends ServerPlugin {
}
}
// Sharing via link must be enabled.
if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'no') {
return;
}
$node->setPublishStatus(true);
// iCloud sends back the 202, so we will too.