-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract caldav sharing stuff from publishing stuff #34873
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (c) 2022 Thomas Citharel <nextcloud@tcit.fr> | ||
* | ||
* @author Thomas Citharel <nextcloud@tcit.fr> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
namespace OCA\DAV\CalDAV; | ||
|
||
use OCP\IConfig; | ||
use Sabre\CalDAV\Xml\Property\AllowedSharingModes; | ||
use Sabre\DAV\INode; | ||
use Sabre\DAV\PropFind; | ||
use Sabre\DAV\Server; | ||
use Sabre\DAV\ServerPlugin; | ||
|
||
class SharingPlugin extends ServerPlugin { | ||
public const NS_CALENDARSERVER = 'http://calendarserver.org/ns/'; | ||
|
||
protected Server $server; | ||
Check notice Code scanning / Psalm PropertyNotSetInConstructor
Property OCA\DAV\CalDAV\SharingPlugin::$server is not defined in constructor of OCA\DAV\CalDAV\SharingPlugin or in any methods called in the constructor
|
||
protected IConfig $config; | ||
|
||
public function __construct(IConfig $config) { | ||
$this->config = $config; | ||
} | ||
|
||
/** | ||
* This method should return a list of server-features. | ||
* | ||
* This is for example 'versioning' and is added to the DAV: header | ||
* in an OPTIONS response. | ||
* | ||
* @return string[] | ||
*/ | ||
public function getFeatures(): array { | ||
// May have to be changed to be detected | ||
return ['calendarserver-sharing']; | ||
} | ||
|
||
/** | ||
* Returns a plugin name. | ||
* | ||
* Using this name other plugins will be able to access other plugins | ||
* using Sabre\DAV\Server::getPlugin | ||
* | ||
* @return string | ||
*/ | ||
public function getPluginName(): string { | ||
return 'oc-calendar-sharing'; | ||
} | ||
|
||
/** | ||
* This initializes the plugin. | ||
* | ||
* This function is called by Sabre\DAV\Server, after | ||
* addPlugin is called. | ||
* | ||
* This method should set up the required event subscriptions. | ||
* | ||
* @param Server $server | ||
*/ | ||
public function initialize(Server $server) { | ||
Check notice Code scanning / Psalm MissingReturnType
Method OCA\DAV\CalDAV\SharingPlugin::initialize does not have a return type, expecting void
|
||
$this->server = $server; | ||
|
||
$this->server->on('propFind', [$this, 'propFind']); | ||
} | ||
|
||
public function propFind(PropFind $propFind, INode $node) { | ||
Check notice Code scanning / Psalm MissingReturnType
Method OCA\DAV\CalDAV\SharingPlugin::propFind does not have a return type, expecting void
|
||
if ($node instanceof Calendar) { | ||
$propFind->handle('{'.self::NS_CALENDARSERVER.'}allowed-sharing-modes', function () use ($node) { | ||
$canShare = (!$node->isSubscription() && $node->canWrite()); | ||
$canPublish = (!$node->isSubscription() && $node->canWrite()); | ||
|
||
if ($this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes') { | ||
$canShare = $canShare && ($node->getOwner() === $node->getPrincipalURI()); | ||
$canPublish = $canPublish && ($node->getOwner() === $node->getPrincipalURI()); | ||
} | ||
|
||
if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') { | ||
$canPublish = false; | ||
} | ||
|
||
return new AllowedSharingModes($canShare, $canPublish); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / Psalm
PropertyNotSetInConstructor