aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/Share
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public/Share')
-rw-r--r--lib/public/Share/Events/BeforeShareCreatedEvent.php49
-rw-r--r--lib/public/Share/Events/BeforeShareDeletedEvent.php33
-rw-r--r--lib/public/Share/Events/ShareAcceptedEvent.php33
-rw-r--r--lib/public/Share/Events/ShareCreatedEvent.php36
-rw-r--r--lib/public/Share/Events/ShareDeletedEvent.php41
-rw-r--r--lib/public/Share/Events/ShareDeletedFromSelfEvent.php33
-rw-r--r--lib/public/Share/Events/VerifyMountPointEvent.php66
-rw-r--r--lib/public/Share/Exceptions/AlreadySharedException.php35
-rw-r--r--lib/public/Share/Exceptions/GenericShareException.php34
-rw-r--r--lib/public/Share/Exceptions/IllegalIDChangeException.php24
-rw-r--r--lib/public/Share/Exceptions/ShareNotFound.php37
-rw-r--r--lib/public/Share/Exceptions/ShareTokenException.php16
-rw-r--r--lib/public/Share/IAttributes.php54
-rw-r--r--lib/public/Share/IManager.php365
-rw-r--r--lib/public/Share/IProviderFactory.php45
-rw-r--r--lib/public/Share/IPublicShareTemplateFactory.php19
-rw-r--r--lib/public/Share/IPublicShareTemplateProvider.php27
-rw-r--r--lib/public/Share/IShare.php389
-rw-r--r--lib/public/Share/IShareHelper.php23
-rw-r--r--lib/public/Share/IShareProvider.php114
-rw-r--r--lib/public/Share/IShareProviderSupportsAccept.php27
-rw-r--r--lib/public/Share/IShareProviderSupportsAllSharesInFolder.php24
-rw-r--r--lib/public/Share/IShareProviderWithNotification.php23
23 files changed, 1373 insertions, 174 deletions
diff --git a/lib/public/Share/Events/BeforeShareCreatedEvent.php b/lib/public/Share/Events/BeforeShareCreatedEvent.php
new file mode 100644
index 00000000000..a2149b53e97
--- /dev/null
+++ b/lib/public/Share/Events/BeforeShareCreatedEvent.php
@@ -0,0 +1,49 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Share\Events;
+
+use OCP\EventDispatcher\Event;
+use OCP\Share\IShare;
+
+/**
+ * @since 28.0.0
+ */
+class BeforeShareCreatedEvent extends Event {
+ private ?string $error = null;
+
+ /**
+ * @since 28.0.0
+ */
+ public function __construct(
+ private IShare $share,
+ ) {
+ parent::__construct();
+ }
+
+ /**
+ * @since 28.0.0
+ */
+ public function getShare(): IShare {
+ return $this->share;
+ }
+
+ /**
+ * @since 28.0.0
+ */
+ public function setError(string $error): void {
+ $this->error = $error;
+ }
+
+ /**
+ * @since 28.0.0
+ */
+ public function getError(): ?string {
+ return $this->error;
+ }
+}
diff --git a/lib/public/Share/Events/BeforeShareDeletedEvent.php b/lib/public/Share/Events/BeforeShareDeletedEvent.php
new file mode 100644
index 00000000000..0af902f7fb7
--- /dev/null
+++ b/lib/public/Share/Events/BeforeShareDeletedEvent.php
@@ -0,0 +1,33 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Share\Events;
+
+use OCP\EventDispatcher\Event;
+use OCP\Share\IShare;
+
+/**
+ * @since 28.0.0
+ */
+class BeforeShareDeletedEvent extends Event {
+ /**
+ * @since 28.0.0
+ */
+ public function __construct(
+ private IShare $share,
+ ) {
+ parent::__construct();
+ }
+
+ /**
+ * @since 28.0.0
+ */
+ public function getShare(): IShare {
+ return $this->share;
+ }
+}
diff --git a/lib/public/Share/Events/ShareAcceptedEvent.php b/lib/public/Share/Events/ShareAcceptedEvent.php
new file mode 100644
index 00000000000..dd9061563cc
--- /dev/null
+++ b/lib/public/Share/Events/ShareAcceptedEvent.php
@@ -0,0 +1,33 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Share\Events;
+
+use OCP\EventDispatcher\Event;
+use OCP\Share\IShare;
+
+/**
+ * @since 28.0.0
+ */
+class ShareAcceptedEvent extends Event {
+ /**
+ * @since 28.0.0
+ */
+ public function __construct(
+ private IShare $share,
+ ) {
+ parent::__construct();
+ }
+
+ /**
+ * @since 28.0.0
+ */
+ public function getShare(): IShare {
+ return $this->share;
+ }
+}
diff --git a/lib/public/Share/Events/ShareCreatedEvent.php b/lib/public/Share/Events/ShareCreatedEvent.php
new file mode 100644
index 00000000000..e733c56bc74
--- /dev/null
+++ b/lib/public/Share/Events/ShareCreatedEvent.php
@@ -0,0 +1,36 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Share\Events;
+
+use OCP\EventDispatcher\Event;
+use OCP\Share\IShare;
+
+/**
+ * @since 18.0.0
+ */
+class ShareCreatedEvent extends Event {
+ /** @var IShare */
+ private $share;
+
+ /**
+ * @since 18.0.0
+ */
+ public function __construct(IShare $share) {
+ parent::__construct();
+
+ $this->share = $share;
+ }
+
+ /**
+ * @since 18.0.0
+ */
+ public function getShare(): IShare {
+ return $this->share;
+ }
+}
diff --git a/lib/public/Share/Events/ShareDeletedEvent.php b/lib/public/Share/Events/ShareDeletedEvent.php
new file mode 100644
index 00000000000..70887a3f80b
--- /dev/null
+++ b/lib/public/Share/Events/ShareDeletedEvent.php
@@ -0,0 +1,41 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Share\Events;
+
+use OCP\EventDispatcher\Event;
+use OCP\Share\IShare;
+
+/**
+ * @since 21.0.0
+ */
+class ShareDeletedEvent extends Event {
+ /** @var IShare */
+ private $share;
+
+ /**
+ *
+ * @param IShare $share
+ * @param IShare[] $children
+ *
+ * @since 21.0.0
+ */
+ public function __construct(IShare $share) {
+ parent::__construct();
+
+ $this->share = $share;
+ }
+
+ /**
+ * @return IShare
+ * @since 21.0.0
+ */
+ public function getShare(): IShare {
+ return $this->share;
+ }
+}
diff --git a/lib/public/Share/Events/ShareDeletedFromSelfEvent.php b/lib/public/Share/Events/ShareDeletedFromSelfEvent.php
new file mode 100644
index 00000000000..1e49975acea
--- /dev/null
+++ b/lib/public/Share/Events/ShareDeletedFromSelfEvent.php
@@ -0,0 +1,33 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Share\Events;
+
+use OCP\EventDispatcher\Event;
+use OCP\Share\IShare;
+
+/**
+ * @since 28.0.0
+ */
+class ShareDeletedFromSelfEvent extends Event {
+ /**
+ * @since 28.0.0
+ */
+ public function __construct(
+ private IShare $share,
+ ) {
+ parent::__construct();
+ }
+
+ /**
+ * @since 28.0.0
+ */
+ public function getShare(): IShare {
+ return $this->share;
+ }
+}
diff --git a/lib/public/Share/Events/VerifyMountPointEvent.php b/lib/public/Share/Events/VerifyMountPointEvent.php
new file mode 100644
index 00000000000..2eb392773e4
--- /dev/null
+++ b/lib/public/Share/Events/VerifyMountPointEvent.php
@@ -0,0 +1,66 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Share\Events;
+
+use OC\Files\View;
+use OCP\EventDispatcher\Event;
+use OCP\Share\IShare;
+
+/**
+ * @since 19.0.0
+ */
+class VerifyMountPointEvent extends Event {
+ /** @var IShare */
+ private $share;
+ /** @var View */
+ private $view;
+ /** @var string */
+ private $parent;
+
+ /**
+ * @since 19.0.0
+ */
+ public function __construct(IShare $share,
+ View $view,
+ string $parent) {
+ parent::__construct();
+
+ $this->share = $share;
+ $this->view = $view;
+ $this->parent = $parent;
+ }
+
+ /**
+ * @since 19.0.0
+ */
+ public function getShare(): IShare {
+ return $this->share;
+ }
+
+ /**
+ * @since 19.0.0
+ */
+ public function getView(): View {
+ return $this->view;
+ }
+
+ /**
+ * @since 19.0.0
+ */
+ public function getParent(): string {
+ return $this->parent;
+ }
+
+ /**
+ * @since 19.0.0
+ */
+ public function setParent(string $parent): void {
+ $this->parent = $parent;
+ }
+}
diff --git a/lib/public/Share/Exceptions/AlreadySharedException.php b/lib/public/Share/Exceptions/AlreadySharedException.php
new file mode 100644
index 00000000000..ce58dd19e2a
--- /dev/null
+++ b/lib/public/Share/Exceptions/AlreadySharedException.php
@@ -0,0 +1,35 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Share\Exceptions;
+
+use OCP\Share\IShare;
+
+/**
+ * @since 22.0.0
+ */
+class AlreadySharedException extends GenericShareException {
+ /** @var IShare */
+ private $existingShare;
+
+ /**
+ * @since 22.0.0
+ */
+ public function __construct(string $message, IShare $existingShare) {
+ parent::__construct($message);
+
+ $this->existingShare = $existingShare;
+ }
+
+ /**
+ * @since 22.0.0
+ */
+ public function getExistingShare(): IShare {
+ return $this->existingShare;
+ }
+}
diff --git a/lib/public/Share/Exceptions/GenericShareException.php b/lib/public/Share/Exceptions/GenericShareException.php
index b32c2f26574..b94d210f970 100644
--- a/lib/public/Share/Exceptions/GenericShareException.php
+++ b/lib/public/Share/Exceptions/GenericShareException.php
@@ -1,47 +1,31 @@
<?php
+
/**
- * @author Lukas Reschke <lukas@owncloud.com>
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCP\Share\Exceptions;
-use OC\HintException;
+
+use OCP\HintException;
/**
* Class GenericEncryptionException
*
- * @package OCP\Share\Exceptions
* @since 9.0.0
*/
class GenericShareException extends HintException {
-
/**
* @param string $message
* @param string $hint
* @param int $code
- * @param \Exception $previous
+ * @param \Exception|null $previous
* @since 9.0.0
*/
- public function __construct($message = '', $hint = '', $code = 0, \Exception $previous = null) {
+ public function __construct($message = '', $hint = '', $code = 0, ?\Exception $previous = null) {
if (empty($message)) {
- $message = 'Unspecified share exception';
+ $message = 'There was an error retrieving the share. Maybe the link is wrong, it was unshared, or it was deleted.';
}
parent::__construct($message, $hint, $code, $previous);
}
-
}
diff --git a/lib/public/Share/Exceptions/IllegalIDChangeException.php b/lib/public/Share/Exceptions/IllegalIDChangeException.php
index 6cd887c386b..e9ff4b66c42 100644
--- a/lib/public/Share/Exceptions/IllegalIDChangeException.php
+++ b/lib/public/Share/Exceptions/IllegalIDChangeException.php
@@ -1,22 +1,9 @@
<?php
+
/**
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCP\Share\Exceptions;
@@ -24,4 +11,5 @@ namespace OCP\Share\Exceptions;
* Exception for illegal attempts to modify an id of a share
* @since 9.1.0
*/
-class IllegalIDChangeException extends GenericShareException {}
+class IllegalIDChangeException extends GenericShareException {
+}
diff --git a/lib/public/Share/Exceptions/ShareNotFound.php b/lib/public/Share/Exceptions/ShareNotFound.php
index 96e7c096492..0876078424e 100644
--- a/lib/public/Share/Exceptions/ShareNotFound.php
+++ b/lib/public/Share/Exceptions/ShareNotFound.php
@@ -1,32 +1,29 @@
<?php
+
/**
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-
namespace OCP\Share\Exceptions;
/**
* Class ShareNotFound
*
- * @package OCP\Share\Exceptions
* @since 9.0.0
*/
class ShareNotFound extends GenericShareException {
-
+ /**
+ * @param string $message
+ * @param string $hint
+ * @param int $code
+ * @param \Exception|null $previous
+ * @since 9.0.0
+ */
+ public function __construct($message = '', ...$arguments) {
+ if (empty($message)) {
+ $message = 'Share not found';
+ }
+ parent::__construct($message, ...$arguments);
+ }
}
diff --git a/lib/public/Share/Exceptions/ShareTokenException.php b/lib/public/Share/Exceptions/ShareTokenException.php
new file mode 100644
index 00000000000..027d00640e9
--- /dev/null
+++ b/lib/public/Share/Exceptions/ShareTokenException.php
@@ -0,0 +1,16 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Share\Exceptions;
+
+use Exception;
+
+/**
+ * @since 31.0.0
+ */
+class ShareTokenException extends Exception {
+}
diff --git a/lib/public/Share/IAttributes.php b/lib/public/Share/IAttributes.php
new file mode 100644
index 00000000000..9ddd8275dd6
--- /dev/null
+++ b/lib/public/Share/IAttributes.php
@@ -0,0 +1,54 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2019 ownCloud GmbH
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+namespace OCP\Share;
+
+/**
+ * Interface IAttributes
+ *
+ * @package OCP\Share
+ * @since 25.0.0
+ */
+interface IAttributes {
+ /**
+ * Sets an attribute. If the key did not exist before it will be created.
+ *
+ * @param string $scope scope
+ * @param string $key key
+ * @param bool|string|array|null $value value
+ * @return IAttributes The modified object
+ * @since 25.0.0
+ */
+ public function setAttribute(string $scope, string $key, mixed $value): IAttributes;
+
+ /**
+ * Returns the attribute for given scope id and key.
+ * If attribute does not exist, returns null
+ *
+ * @param string $scope scope
+ * @param string $key key
+ * @return bool|string|array|null
+ * @since 25.0.0
+ */
+ public function getAttribute(string $scope, string $key): mixed;
+
+ /**
+ * Formats the IAttributes object to array with the following format:
+ * [
+ * 0 => [
+ * "scope" => <string>,
+ * "key" => <string>,
+ * "value" => <bool|string|array|null>,
+ * ],
+ * ...
+ * ]
+ *
+ * @return array formatted IAttributes
+ * @since 25.0.0
+ * @since 30.0.0, `enabled` was renamed to `value`
+ */
+ public function toArray(): array;
+}
diff --git a/lib/public/Share/IManager.php b/lib/public/Share/IManager.php
index 64e5b554de9..35915ad9d90 100644
--- a/lib/public/Share/IManager.php
+++ b/lib/public/Share/IManager.php
@@ -1,44 +1,36 @@
<?php
+
/**
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-
namespace OCP\Share;
+use OCP\Files\Folder;
use OCP\Files\Node;
-use OCP\IUser;
+use OCP\IUser;
+use OCP\Share\Exceptions\GenericShareException;
use OCP\Share\Exceptions\ShareNotFound;
+use OCP\Share\Exceptions\ShareTokenException;
/**
- * Interface IManager
+ * This interface allows to manage sharing files between users and groups.
+ *
+ * This interface must not be implemented in your application but
+ * instead should be used as a service and injected in your code with
+ * dependency injection.
*
- * @package OCP\Share
* @since 9.0.0
*/
interface IManager {
-
/**
* Create a Share
*
* @param IShare $share
* @return IShare The share object
+ * @throws \Exception
* @since 9.0.0
*/
public function createShare(IShare $share);
@@ -47,18 +39,33 @@ interface IManager {
* Update a share.
* The target of the share can't be changed this way: use moveShare
* The share can't be removed this way (permission 0): use deleteShare
+ * The state can't be changed this way: use acceptShare
*
* @param IShare $share
+ * @param bool $onlyValid Only updates valid shares, invalid shares will be deleted automatically and are not updated
* @return IShare The share object
+ * @throws \InvalidArgumentException
* @since 9.0.0
*/
- public function updateShare(IShare $share);
+ public function updateShare(IShare $share, bool $onlyValid = true);
+
+ /**
+ * Accept a share.
+ *
+ * @param IShare $share
+ * @param string $recipientId
+ * @return IShare The share object
+ * @throws \InvalidArgumentException
+ * @since 18.0.0
+ */
+ public function acceptShare(IShare $share, string $recipientId): IShare;
/**
* Delete a share
*
* @param IShare $share
* @throws ShareNotFound
+ * @throws \InvalidArgumentException
* @since 9.0.0
*/
public function deleteShare(IShare $share);
@@ -76,6 +83,20 @@ interface IManager {
public function deleteFromSelf(IShare $share, $recipientId);
/**
+ * Restore the share when it has been deleted
+ * Certain share types can be restored when they have been deleted
+ * but the provider should properly handle this\
+ *
+ * @param IShare $share The share to restore
+ * @param string $recipientId The user to restore the share for
+ * @return IShare The restored share object
+ * @throws GenericShareException In case restoring the share failed
+ *
+ * @since 14.0.0
+ */
+ public function restoreShare(IShare $share, string $recipientId): IShare;
+
+ /**
* Move the share as a recipient of the share.
* This is updating the share target. So where the recipient has the share mounted.
*
@@ -88,6 +109,18 @@ interface IManager {
public function moveShare(IShare $share, $recipientId);
/**
+ * Get all shares shared by (initiated) by the provided user in a folder.
+ *
+ * @param string $userId
+ * @param Folder $node
+ * @param bool $reshares
+ * @param bool $shallow Whether the method should stop at the first level, or look into sub-folders.
+ * @return IShare[][] [$fileId => IShare[], ...]
+ * @since 11.0.0
+ */
+ public function getSharesInFolder($userId, Folder $node, $reshares = false, $shallow = true);
+
+ /**
* Get shares shared by (initiated) by the provided user.
*
* @param string $userId
@@ -96,10 +129,11 @@ interface IManager {
* @param bool $reshares
* @param int $limit The maximum number of returned results, -1 for all results
* @param int $offset
+ * @param bool $onlyValid Only returns valid shares, invalid shares will be deleted automatically and are not returned
* @return IShare[]
* @since 9.0.0
*/
- public function getSharesBy($userId, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0);
+ public function getSharesBy($userId, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0, bool $onlyValid = true);
/**
* Get shares shared with $user.
@@ -116,18 +150,33 @@ interface IManager {
public function getSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0);
/**
+ * Get deleted shares shared with $user.
+ * Filter by $node if provided
+ *
+ * @param string $userId
+ * @param int $shareType
+ * @param Node|null $node
+ * @param int $limit The maximum number of shares returned, -1 for all
+ * @param int $offset
+ * @return IShare[]
+ * @since 14.0.0
+ */
+ public function getDeletedSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0);
+
+ /**
* Retrieve a share by the share id.
* If the recipient is set make sure to retrieve the file for that user.
* This makes sure that if a user has moved/deleted a group share this
* is reflected.
*
* @param string $id
- * @param IUser|null $recipient
+ * @param string|null $recipient userID of the recipient
+ * @param bool $onlyValid Only returns valid shares, invalid shares will be deleted automatically and are not returned
* @return IShare
* @throws ShareNotFound
* @since 9.0.0
*/
- public function getShareById($id, $recipient = null);
+ public function getShareById($id, $recipient = null, bool $onlyValid = true);
/**
* Get the share by token possible with password
@@ -143,13 +192,93 @@ interface IManager {
* Verify the password of a public share
*
* @param IShare $share
- * @param string $password
+ * @param ?string $password
* @return bool
* @since 9.0.0
*/
public function checkPassword(IShare $share, $password);
/**
+ * The user with UID is deleted.
+ * All share providers have to cleanup the shares with this user as well
+ * as shares owned by this user.
+ * Shares only initiated by this user are fine.
+ *
+ * @param string $uid
+ * @since 9.1.0
+ */
+ public function userDeleted($uid);
+
+ /**
+ * The group with $gid is deleted
+ * We need to clear up all shares to this group
+ *
+ * @param string $gid
+ * @since 9.1.0
+ */
+ public function groupDeleted($gid);
+
+ /**
+ * The user $uid is deleted from the group $gid
+ * All user specific group shares have to be removed
+ *
+ * @param string $uid
+ * @param string $gid
+ * @since 9.1.0
+ */
+ public function userDeletedFromGroup($uid, $gid);
+
+ /**
+ * Get access list to a path. This means
+ * all the users that can access a given path.
+ *
+ * Consider:
+ * -root
+ * |-folder1 (23)
+ * |-folder2 (32)
+ * |-fileA (42)
+ *
+ * fileA is shared with user1 and user1@server1 and email1@maildomain1
+ * folder2 is shared with group2 (user4 is a member of group2)
+ * folder1 is shared with user2 (renamed to "folder (1)") and user2@server2
+ * and email2@maildomain2
+ *
+ * Then the access list to '/folder1/folder2/fileA' with $currentAccess is:
+ * [
+ * users => [
+ * 'user1' => ['node_id' => 42, 'node_path' => '/fileA'],
+ * 'user4' => ['node_id' => 32, 'node_path' => '/folder2'],
+ * 'user2' => ['node_id' => 23, 'node_path' => '/folder (1)'],
+ * ],
+ * remote => [
+ * 'user1@server1' => ['node_id' => 42, 'token' => 'SeCr3t'],
+ * 'user2@server2' => ['node_id' => 23, 'token' => 'FooBaR'],
+ * ],
+ * public => bool
+ * mail => [
+ * 'email1@maildomain1' => ['node_id' => 42, 'token' => 'aBcDeFg'],
+ * 'email2@maildomain2' => ['node_id' => 23, 'token' => 'hIjKlMn'],
+ * ]
+ *
+ * The access list to '/folder1/folder2/fileA' **without** $currentAccess is:
+ * [
+ * users => ['user1', 'user2', 'user4'],
+ * remote => bool,
+ * public => bool
+ * mail => ['email1@maildomain1', 'email2@maildomain2']
+ * ]
+ *
+ * This is required for encryption/activity
+ *
+ * @param \OCP\Files\Node $path
+ * @param bool $recursive Should we check all parent folders as well
+ * @param bool $currentAccess Should the user have currently access to the file
+ * @return array
+ * @since 12
+ */
+ public function getAccessList(\OCP\Files\Node $path, $recursive = true, $currentAccess = false);
+
+ /**
* Instantiates a new share object. This is to be passed to
* createShare.
*
@@ -175,12 +304,14 @@ interface IManager {
public function shareApiAllowLinks();
/**
- * Is password on public link requires
+ * Is password on public link required
*
+ * @param bool $checkGroupMembership Check group membership exclusion
* @return bool
* @since 9.0.0
+ * @since 24.0.0 Added optional $checkGroupMembership parameter
*/
- public function shareApiLinkEnforcePassword();
+ public function shareApiLinkEnforcePassword(bool $checkGroupMembership = true);
/**
* Is default expire date enabled
@@ -207,6 +338,54 @@ interface IManager {
public function shareApiLinkDefaultExpireDays();
/**
+ * Is default internal expire date enabled
+ *
+ * @return bool
+ * @since 22.0.0
+ */
+ public function shareApiInternalDefaultExpireDate(): bool;
+
+ /**
+ * Is default remote expire date enabled
+ *
+ * @return bool
+ * @since 22.0.0
+ */
+ public function shareApiRemoteDefaultExpireDate(): bool;
+
+ /**
+ * Is default expire date enforced
+ *
+ * @return bool
+ * @since 22.0.0
+ */
+ public function shareApiInternalDefaultExpireDateEnforced(): bool;
+
+ /**
+ * Is default expire date enforced for remote shares
+ *
+ * @return bool
+ * @since 22.0.0
+ */
+ public function shareApiRemoteDefaultExpireDateEnforced(): bool;
+
+ /**
+ * Number of default expire days
+ *
+ * @return int
+ * @since 22.0.0
+ */
+ public function shareApiInternalDefaultExpireDays(): int;
+
+ /**
+ * Number of default expire days for remote shares
+ *
+ * @return int
+ * @since 22.0.0
+ */
+ public function shareApiRemoteDefaultExpireDays(): int;
+
+ /**
* Allow public upload on link shares
*
* @return bool
@@ -222,6 +401,15 @@ interface IManager {
public function shareWithGroupMembersOnly();
/**
+ * If shareWithGroupMembersOnly is enabled, return an optional
+ * list of groups that must be excluded from the principle of
+ * belonging to the same group.
+ * @return array
+ * @since 27.0.0
+ */
+ public function shareWithGroupMembersOnlyExcludeGroupsList();
+
+ /**
* Check if users can share with groups
* @return bool
* @since 9.0.1
@@ -229,13 +417,85 @@ interface IManager {
public function allowGroupSharing();
/**
- * Check if sharing is disabled for the given user
+ * Check if user enumeration is allowed
+ *
+ * @return bool
+ * @since 19.0.0
+ */
+ public function allowEnumeration(): bool;
+
+ /**
+ * Check if user enumeration is limited to the users groups
+ *
+ * @return bool
+ * @since 19.0.0
+ */
+ public function limitEnumerationToGroups(): bool;
+
+ /**
+ * Check if user enumeration is limited to the phonebook matches
+ *
+ * @return bool
+ * @since 21.0.1
+ */
+ public function limitEnumerationToPhone(): bool;
+
+ /**
+ * Check if user enumeration is allowed to return on full match
+ *
+ * @return bool
+ * @since 21.0.1
+ */
+ public function allowEnumerationFullMatch(): bool;
+
+ /**
+ * Check if the search should match the email
+ *
+ * @return bool
+ * @since 25.0.0
+ */
+ public function matchEmail(): bool;
+
+ /**
+ * Check if the search should ignore the second in parentheses display name if there is any
*
- * @param string $userId
* @return bool
+ * @since 25.0.0
+ */
+ public function ignoreSecondDisplayName(): bool;
+
+
+ /**
+ * Check if custom tokens are allowed
+ *
+ * @since 31.0.0
+ */
+ public function allowCustomTokens(): bool;
+
+ /**
+ * Check if the current user can view the share
+ * even if the download is disabled.
+ *
+ * @since 32.0.0
+ */
+ public function allowViewWithoutDownload(): bool;
+
+ /**
+ * Check if the current user can enumerate the target user
+ *
+ * @param IUser|null $currentUser
+ * @param IUser $targetUser
+ * @return bool
+ * @since 23.0.0
+ */
+ public function currentUserCanEnumerateTargetUser(?IUser $currentUser, IUser $targetUser): bool;
+
+ /**
+ * Check if sharing is disabled for the given user
+ *
* @since 9.0.0
*/
- public function sharingDisabledForUser($userId);
+ public function sharingDisabledForUser(?string $userId): bool;
/**
* Check if outgoing server2server shares are allowed
@@ -244,4 +504,45 @@ interface IManager {
*/
public function outgoingServer2ServerSharesAllowed();
+ /**
+ * Check if outgoing server2server shares are allowed
+ * @return bool
+ * @since 14.0.0
+ */
+ public function outgoingServer2ServerGroupSharesAllowed();
+
+
+ /**
+ * Check if a given share provider exists
+ * @param int $shareType
+ * @return bool
+ * @since 11.0.0
+ */
+ public function shareProviderExists($shareType);
+
+ /**
+ * @param string $shareProviderClass
+ * @since 21.0.0
+ */
+ public function registerShareProvider(string $shareProviderClass): void;
+
+ /**
+ * @Internal
+ *
+ * Get all the shares as iterable to reduce memory overhead
+ * Note, since this opens up database cursors the iterable should
+ * be fully itterated.
+ *
+ * @return iterable
+ * @since 18.0.0
+ */
+ public function getAllShares(): iterable;
+
+ /**
+ * Generate a unique share token
+ *
+ * @throws ShareTokenException Failed to generate a unique token
+ * @since 31.0.0
+ */
+ public function generateToken(): string;
}
diff --git a/lib/public/Share/IProviderFactory.php b/lib/public/Share/IProviderFactory.php
index 3a8baccf33b..9107274c8c1 100644
--- a/lib/public/Share/IProviderFactory.php
+++ b/lib/public/Share/IProviderFactory.php
@@ -1,44 +1,20 @@
<?php
+
/**
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-
namespace OCP\Share;
use OC\Share20\Exception\ProviderException;
-use OCP\IServerContainer;
/**
* Interface IProviderFactory
*
- * @package OC\Share20
* @since 9.0.0
*/
interface IProviderFactory {
-
- /**
- * IProviderFactory constructor.
- * @param IServerContainer $serverContainer
- * @since 9.0.0
- */
- public function __construct(IServerContainer $serverContainer);
-
/**
* @param string $id
* @return IShareProvider
@@ -54,4 +30,17 @@ interface IProviderFactory {
* @since 9.0.0
*/
public function getProviderForType($shareType);
+
+ /**
+ * @return IShareProvider[]
+ * @since 11.0.0
+ */
+ public function getAllProviders();
+
+ /**
+ * @since 21.0.0
+ * @since 32.0.0 Fix typo in parameter name
+ * @param string $shareProviderClass
+ */
+ public function registerProvider(string $shareProviderClass): void;
}
diff --git a/lib/public/Share/IPublicShareTemplateFactory.php b/lib/public/Share/IPublicShareTemplateFactory.php
new file mode 100644
index 00000000000..1825c0c7dc6
--- /dev/null
+++ b/lib/public/Share/IPublicShareTemplateFactory.php
@@ -0,0 +1,19 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Share;
+
+/**
+ * @since 26.0.0
+ */
+interface IPublicShareTemplateFactory {
+ /**
+ * Returns a provider that is willing to respond for given share.
+ * @since 26.0.0
+ */
+ public function getProvider(IShare $share): IPublicShareTemplateProvider;
+}
diff --git a/lib/public/Share/IPublicShareTemplateProvider.php b/lib/public/Share/IPublicShareTemplateProvider.php
new file mode 100644
index 00000000000..46812a65814
--- /dev/null
+++ b/lib/public/Share/IPublicShareTemplateProvider.php
@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Share;
+
+use OCP\AppFramework\Http\TemplateResponse;
+
+/**
+ * @since 26.0.0
+ */
+interface IPublicShareTemplateProvider {
+ /**
+ * Returns whether the provider can respond for the given share.
+ * @since 26.0.0
+ */
+ public function shouldRespond(IShare $share): bool;
+ /**
+ * Returns the a template for a given share.
+ * @since 26.0.0
+ */
+ public function renderPage(IShare $share, string $token, string $path): TemplateResponse;
+}
diff --git a/lib/public/Share/IShare.php b/lib/public/Share/IShare.php
index ee71715f436..a1bdb01fcd2 100644
--- a/lib/public/Share/IShare.php
+++ b/lib/public/Share/IShare.php
@@ -1,26 +1,13 @@
<?php
+
/**
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-
namespace OCP\Share;
+use OCP\Files\Cache\ICacheEntry;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\Node;
@@ -28,12 +15,106 @@ use OCP\Files\NotFoundException;
use OCP\Share\Exceptions\IllegalIDChangeException;
/**
- * Interface IShare
+ * This interface allows to represent a share object.
+ *
+ * This interface must not be implemented in your application.
*
- * @package OCP\Share
* @since 9.0.0
*/
interface IShare {
+ /**
+ * @since 17.0.0
+ */
+ public const TYPE_USER = 0;
+
+ /**
+ * @since 17.0.0
+ */
+ public const TYPE_GROUP = 1;
+
+ /**
+ * @internal
+ * @since 18.0.0
+ */
+ public const TYPE_USERGROUP = 2;
+
+ /**
+ * @since 17.0.0
+ */
+ public const TYPE_LINK = 3;
+
+ /**
+ * @since 17.0.0
+ */
+ public const TYPE_EMAIL = 4;
+
+ /**
+ * ToDo Check if it is still in use otherwise remove it
+ * @since 17.0.0
+ */
+ // public const TYPE_CONTACT = 5;
+
+ /**
+ * @since 17.0.0
+ */
+ public const TYPE_REMOTE = 6;
+
+ /**
+ * @since 17.0.0
+ */
+ public const TYPE_CIRCLE = 7;
+
+ /**
+ * @since 17.0.0
+ */
+ public const TYPE_GUEST = 8;
+
+ /**
+ * @since 17.0.0
+ */
+ public const TYPE_REMOTE_GROUP = 9;
+
+ /**
+ * @since 17.0.0
+ */
+ public const TYPE_ROOM = 10;
+
+ /**
+ * Internal type used by RoomShareProvider
+ * @since 17.0.0
+ */
+ // const TYPE_USERROOM = 11;
+
+ /**
+ * @since 21.0.0
+ */
+ public const TYPE_DECK = 12;
+
+ /**
+ * @internal
+ * @since 21.0.0
+ */
+ public const TYPE_DECK_USER = 13;
+
+ /**
+ * @since 26.0.0
+ */
+ public const TYPE_SCIENCEMESH = 15;
+
+ /**
+ * @since 18.0.0
+ */
+ public const STATUS_PENDING = 0;
+
+ /**
+ * @since 18.0.0
+ */
+ public const STATUS_ACCEPTED = 1;
+
+ /**
+ * @since 18.0.0
+ */
+ public const STATUS_REJECTED = 2;
/**
* Set the internal id of the share
@@ -111,7 +192,7 @@ interface IShare {
* @since 9.0.0
* @throws NotFoundException
*/
- public function getNodeId();
+ public function getNodeId(): int;
/**
* Set the type of node (file/folder)
@@ -166,11 +247,45 @@ interface IShare {
public function getSharedWith();
/**
+ * Set the display name of the receiver of this share.
+ *
+ * @param string $displayName
+ * @return \OCP\Share\IShare The modified object
+ * @since 14.0.0
+ */
+ public function setSharedWithDisplayName($displayName);
+
+ /**
+ * Get the display name of the receiver of this share.
+ *
+ * @return string
+ * @since 14.0.0
+ */
+ public function getSharedWithDisplayName();
+
+ /**
+ * Set the avatar of the receiver of this share.
+ *
+ * @param string $src
+ * @return \OCP\Share\IShare The modified object
+ * @since 14.0.0
+ */
+ public function setSharedWithAvatar($src);
+
+ /**
+ * Get the avatar of the receiver of this share.
+ *
+ * @return string
+ * @since 14.0.0
+ */
+ public function getSharedWithAvatar();
+
+ /**
* Set the permissions.
* See \OCP\Constants::PERMISSION_*
*
* @param int $permissions
- * @return \OCP\Share\IShare The modified object
+ * @return IShare The modified object
* @since 9.0.0
*/
public function setPermissions($permissions);
@@ -185,23 +300,128 @@ interface IShare {
public function getPermissions();
/**
+ * Create share attributes object
+ *
+ * @since 25.0.0
+ * @return IAttributes
+ */
+ public function newAttributes(): IAttributes;
+
+ /**
+ * Set share attributes
+ *
+ * @param ?IAttributes $attributes
+ * @since 25.0.0
+ * @return IShare The modified object
+ */
+ public function setAttributes(?IAttributes $attributes);
+
+ /**
+ * Get share attributes
+ *
+ * @since 25.0.0
+ * @return ?IAttributes
+ */
+ public function getAttributes(): ?IAttributes;
+
+ /**
+ * Set the accepted status
+ * See self::STATUS_*
+ *
+ * @param int $status
+ * @return IShare The modified object
+ * @since 18.0.0
+ */
+ public function setStatus(int $status): IShare;
+
+ /**
+ * Get the accepted status
+ * See self::STATUS_*
+ *
+ * @return int
+ * @since 18.0.0
+ */
+ public function getStatus(): int;
+
+ /**
+ * Attach a note to a share
+ *
+ * @param string $note
+ * @return \OCP\Share\IShare The modified object
+ * @since 14.0.0
+ */
+ public function setNote($note);
+
+ /**
+ * Get note attached to a share
+ *
+ * @return string
+ * @since 14.0.0
+ */
+ public function getNote();
+
+
+ /**
* Set the expiration date
*
- * @param \DateTime $expireDate
+ * @param \DateTime|null $expireDate
* @return \OCP\Share\IShare The modified object
* @since 9.0.0
*/
- public function setExpirationDate($expireDate);
+ public function setExpirationDate(?\DateTime $expireDate);
/**
* Get the expiration date
*
- * @return \DateTime
+ * @return \DateTime|null
* @since 9.0.0
*/
public function getExpirationDate();
/**
+ * Set overwrite flag for falsy expiry date values
+ *
+ * @param bool $noExpirationDate
+ * @return \OCP\Share\IShare The modified object
+ * @since 30.0.0
+ */
+ public function setNoExpirationDate(bool $noExpirationDate);
+
+
+ /**
+ * Get value of overwrite falsy expiry date flag
+ *
+ * @return bool
+ * @since 30.0.0
+ */
+ public function getNoExpirationDate();
+
+ /**
+ * Is the share expired ?
+ *
+ * @return boolean
+ * @since 18.0.0
+ */
+ public function isExpired();
+
+ /**
+ * set a label for a share, some shares, e.g. public links can have a label
+ *
+ * @param string $label
+ * @return \OCP\Share\IShare The modified object
+ * @since 15.0.0
+ */
+ public function setLabel($label);
+
+ /**
+ * get label for the share, some shares, e.g. public links can have a label
+ *
+ * @return string
+ * @since 15.0.0
+ */
+ public function getLabel();
+
+ /**
* Set the sharer of the path.
*
* @param string $sharedBy
@@ -240,7 +460,7 @@ interface IShare {
* When the share is passed to the share manager to be created
* or updated the password will be hashed.
*
- * @param string $password
+ * @param string|null $password
* @return \OCP\Share\IShare The modified object
* @since 9.0.0
*/
@@ -251,12 +471,48 @@ interface IShare {
* If this share is obtained via a shareprovider the password is
* hashed.
*
- * @return string
+ * @return string|null
* @since 9.0.0
*/
public function getPassword();
/**
+ * Set the password's expiration time of this share.
+ *
+ * @return self The modified object
+ * @since 24.0.0
+ */
+ public function setPasswordExpirationTime(?\DateTimeInterface $passwordExpirationTime = null): IShare;
+
+ /**
+ * Get the password's expiration time of this share.
+ * @since 24.0.0
+ */
+ public function getPasswordExpirationTime(): ?\DateTimeInterface;
+
+ /**
+ * Set if the recipient can start a conversation with the owner to get the
+ * password using Nextcloud Talk.
+ *
+ * @param bool $sendPasswordByTalk
+ * @return \OCP\Share\IShare The modified object
+ * @since 14.0.0
+ */
+ public function setSendPasswordByTalk(bool $sendPasswordByTalk);
+
+ /**
+ * Get if the recipient can start a conversation with the owner to get the
+ * password using Nextcloud Talk.
+ * The returned value does not take into account other factors, like Talk
+ * being enabled for the owner of the share or not; it just cover whether
+ * the option is enabled for the share itself or not.
+ *
+ * @return bool
+ * @since 14.0.0
+ */
+ public function getSendPasswordByTalk(): bool;
+
+ /**
* Set the public link token.
*
* @param string $token
@@ -274,6 +530,20 @@ interface IShare {
public function getToken();
/**
+ * Set the parent of this share
+ *
+ * @since 9.0.0
+ */
+ public function setParent(int $parent): self;
+
+ /**
+ * Get the parent of this share.
+ *
+ * @since 9.0.0
+ */
+ public function getParent(): ?int;
+
+ /**
* Set the target path of this share relative to the recipients user folder.
*
* @param string $target
@@ -308,7 +578,7 @@ interface IShare {
public function getShareTime();
/**
- * Set if the recipient is informed by mail about the share.
+ * Set if the recipient should be informed by mail about the share.
*
* @param bool $mailSend
* @return \OCP\Share\IShare The modified object
@@ -317,10 +587,71 @@ interface IShare {
public function setMailSend($mailSend);
/**
- * Get if the recipient informed by mail about the share.
+ * Get if the recipient should be informed by mail about the share.
*
* @return bool
* @since 9.0.0
*/
public function getMailSend();
+
+ /**
+ * Set the cache entry for the shared node
+ *
+ * @param ICacheEntry $entry
+ * @return void
+ * @since 11.0.0
+ */
+ public function setNodeCacheEntry(ICacheEntry $entry);
+
+ /**
+ * Get the cache entry for the shared node
+ *
+ * @return null|ICacheEntry
+ * @since 11.0.0
+ */
+ public function getNodeCacheEntry();
+
+ /**
+ * Sets a shares hide download state
+ * This is mainly for public shares. It will signal that the share page should
+ * hide download buttons etc.
+ *
+ * @param bool $hide
+ * @return IShare
+ * @since 15.0.0
+ */
+ public function setHideDownload(bool $hide): IShare;
+
+ /**
+ * Gets a shares hide download state
+ * This is mainly for public shares. It will signal that the share page should
+ * hide download buttons etc.
+ *
+ * @return bool
+ * @since 15.0.0
+ */
+ public function getHideDownload(): bool;
+
+ /**
+ * Sets a flag that stores whether a reminder via email has been sent
+ *
+ * @return self The modified object
+ * @since 31.0.0
+ */
+ public function setReminderSent(bool $reminderSent): IShare;
+
+ /**
+ * Gets a flag that stores whether a reminder via email has been sent
+ *
+ * @return bool
+ * @since 31.0.0
+ */
+ public function getReminderSent(): bool;
+
+ /**
+ * Check if the current user can see this share files contents.
+ * This will check the download permissions as well as the global
+ * admin setting to allow viewing files without downloading.
+ */
+ public function canSeeContent(): bool;
}
diff --git a/lib/public/Share/IShareHelper.php b/lib/public/Share/IShareHelper.php
new file mode 100644
index 00000000000..152fc99a446
--- /dev/null
+++ b/lib/public/Share/IShareHelper.php
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Share;
+
+use OCP\Files\Node;
+
+/**
+ * Interface IShareHelper
+ *
+ * @since 12
+ */
+interface IShareHelper {
+ /**
+ * @param Node $node
+ * @return array [ users => [Mapping $uid => $pathForUser], remotes => [Mapping $cloudId => $pathToMountRoot]]
+ * @since 12
+ */
+ public function getPathsForAccessList(Node $node);
+}
diff --git a/lib/public/Share/IShareProvider.php b/lib/public/Share/IShareProvider.php
index d00b9da7b59..23187ca833e 100644
--- a/lib/public/Share/IShareProvider.php
+++ b/lib/public/Share/IShareProvider.php
@@ -1,37 +1,23 @@
<?php
+
/**
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-
namespace OCP\Share;
-use OCP\Share\Exceptions\ShareNotFound;
+use OCP\Files\Folder;
use OCP\Files\Node;
+use OCP\Share\Exceptions\GenericShareException;
+use OCP\Share\Exceptions\ShareNotFound;
/**
* Interface IShareProvider
*
- * @package OCP\Share
* @since 9.0.0
*/
interface IShareProvider {
-
/**
* Return the identifier of this provider.
*
@@ -42,7 +28,7 @@ interface IShareProvider {
/**
* Create a share
- *
+ *
* @param \OCP\Share\IShare $share
* @return \OCP\Share\IShare The share object
* @since 9.0.0
@@ -78,6 +64,18 @@ interface IShareProvider {
public function deleteFromSelf(\OCP\Share\IShare $share, $recipient);
/**
+ * Restore a share for a given recipient. The implementation could be provider independant.
+ *
+ * @param IShare $share
+ * @param string $recipient
+ * @return IShare The restored share object
+ *
+ * @since 14.0.0
+ * @throws GenericShareException In case the share could not be restored
+ */
+ public function restore(IShare $share, string $recipient): IShare;
+
+ /**
* Move a share as a recipient.
* This is updating the share target. Thus the mount point of the recipient.
* This may require special handling. If a user moves a group share
@@ -91,6 +89,18 @@ interface IShareProvider {
public function move(\OCP\Share\IShare $share, $recipient);
/**
+ * Get all shares by the given user in a folder
+ *
+ * @param string $userId
+ * @param Folder $node
+ * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator
+ * @param bool $shallow Whether the method should stop at the first level, or look into sub-folders.
+ * @return \OCP\Share\IShare[][]
+ * @since 11.0.0
+ */
+ public function getSharesInFolder($userId, Folder $node, $reshares, $shallow = true);
+
+ /**
* Get all shares by the given user
*
* @param string $userId
@@ -146,4 +156,64 @@ interface IShareProvider {
* @since 9.0.0
*/
public function getShareByToken($token);
+
+ /**
+ * A user is deleted from the system
+ * So clean up the relevant shares.
+ *
+ * @param string $uid
+ * @param int $shareType
+ * @since 9.1.0
+ */
+ public function userDeleted($uid, $shareType);
+
+ /**
+ * A group is deleted from the system.
+ * We have to clean up all shares to this group.
+ * Providers not handling group shares should just return
+ *
+ * @param string $gid
+ * @since 9.1.0
+ */
+ public function groupDeleted($gid);
+
+ /**
+ * A user is deleted from a group
+ * We have to clean up all the related user specific group shares
+ * Providers not handling group shares should just return
+ *
+ * @param string $uid
+ * @param string $gid
+ * @since 9.1.0
+ */
+ public function userDeletedFromGroup($uid, $gid);
+
+ /**
+ * Get the access list to the array of provided nodes.
+ *
+ * @see IManager::getAccessList() for sample docs
+ *
+ * @param Node[] $nodes The list of nodes to get access for
+ * @param bool $currentAccess If current access is required (like for removed shares that might get revived later)
+ * @return array
+ * @since 12
+ */
+ public function getAccessList($nodes, $currentAccess);
+
+ /**
+ * Get all the shares in this provider returned as iterable to reduce memory
+ * overhead
+ *
+ * @return iterable
+ * @since 18.0.0
+ */
+ public function getAllShares(): iterable;
+
+ /**
+ * Get all children of this share
+ *
+ * @return IShare[]
+ * @since 9.0.0
+ */
+ public function getChildren(IShare $parent);
}
diff --git a/lib/public/Share/IShareProviderSupportsAccept.php b/lib/public/Share/IShareProviderSupportsAccept.php
new file mode 100644
index 00000000000..c3a0c2d0218
--- /dev/null
+++ b/lib/public/Share/IShareProviderSupportsAccept.php
@@ -0,0 +1,27 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Share;
+
+/**
+ * Interface IShareProviderSupportsAccept
+ *
+ * This interface allows to define IShareProvider that can handle the `acceptShare` method,
+ * which is available since Nextcloud 17.
+ *
+ * @since 30.0.0
+ */
+interface IShareProviderSupportsAccept extends IShareProvider {
+ /**
+ * Accept a share.
+ *
+ * @param IShare $share
+ * @param string $recipient
+ * @return IShare The share object
+ * @since 30.0.0
+ */
+ public function acceptShare(IShare $share, string $recipient): IShare;
+}
diff --git a/lib/public/Share/IShareProviderSupportsAllSharesInFolder.php b/lib/public/Share/IShareProviderSupportsAllSharesInFolder.php
new file mode 100644
index 00000000000..e27da7682ce
--- /dev/null
+++ b/lib/public/Share/IShareProviderSupportsAllSharesInFolder.php
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Share;
+
+use OCP\Files\Folder;
+
+/**
+ * Allows defining a IShareProvider with support for the getAllSharesInFolder method.
+ *
+ * @since 32.0.0
+ */
+interface IShareProviderSupportsAllSharesInFolder extends IShareProvider {
+ /**
+ * Get all shares in a folder.
+ *
+ * @return array<int, list<IShare>>
+ * @since 32.0.0
+ */
+ public function getAllSharesInFolder(Folder $node): array;
+}
diff --git a/lib/public/Share/IShareProviderWithNotification.php b/lib/public/Share/IShareProviderWithNotification.php
new file mode 100644
index 00000000000..c2ba8118175
--- /dev/null
+++ b/lib/public/Share/IShareProviderWithNotification.php
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Share;
+
+/**
+ * Interface IShareProvider
+ *
+ * @since 30.0.0
+ */
+interface IShareProviderWithNotification extends IShareProvider {
+ /**
+ * Send a mail notification to the recipient of a share
+ * @param IShare $share
+ * @return bool True if the mail was sent successfully
+ * @throws \Exception If the mail could not be sent
+ * @since 30.0.0
+ */
+ public function sendMailNotification(IShare $share): bool;
+}