-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Add Unified Sharing #62241
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
base: master
Are you sure you want to change the base?
Add Unified Sharing #62241
Changes from all commits
ea255f7
c4cc7da
8089353
10a6b57
5b3870e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. declare should be before licenses to match other files style. |
||
|
|
||
| namespace OCA\Files\Sharing\Permission; | ||
|
|
||
| use OCA\Files\AppInfo\Application; | ||
| use OCP\Constants; | ||
| use OCP\IAppConfig; | ||
| use OCP\L10N\IFactory; | ||
| use OCP\Server; | ||
| use OCP\Sharing\Permission\ISharePermissionType; | ||
|
|
||
| final class NodeCreateSharePermissionType implements ISharePermissionType { | ||
| private ?IAppConfig $appConfig = null; | ||
|
|
||
| private function getAppConfig(): IAppConfig { | ||
| return $this->appConfig ??= Server::get(IAppConfig::class); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getDisplayName(IFactory $l10nFactory): string { | ||
| return $l10nFactory->get(Application::APP_ID)->t('Create files'); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getHint(IFactory $l10nFactory): ?string { | ||
| return null; | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getPriority(): int { | ||
| return 60; | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function isEnabledByDefault(): bool { | ||
| return ($this->getAppConfig()->getValueInt(\OC\Core\AppInfo\Application::APP_ID, 'shareapi_default_permissions') & Constants::PERMISSION_CREATE) === Constants::PERMISSION_CREATE; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace OCA\Files\Sharing\Permission; | ||
|
|
||
| use OCA\Files\AppInfo\Application; | ||
| use OCP\Constants; | ||
| use OCP\IAppConfig; | ||
| use OCP\L10N\IFactory; | ||
| use OCP\Server; | ||
| use OCP\Sharing\Permission\ISharePermissionType; | ||
|
|
||
| final class NodeDeleteSharePermissionType implements ISharePermissionType { | ||
| private ?IAppConfig $appConfig = null; | ||
|
|
||
| private function getAppConfig(): IAppConfig { | ||
| return $this->appConfig ??= Server::get(IAppConfig::class); | ||
| } | ||
|
Comment on lines
+20
to
+24
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How come this is needed and proper DI cannot be used? |
||
|
|
||
| #[\Override] | ||
| public function getDisplayName(IFactory $l10nFactory): string { | ||
| return $l10nFactory->get(Application::APP_ID)->t('Delete files'); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getHint(IFactory $l10nFactory): ?string { | ||
| return null; | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getPriority(): int { | ||
| return 50; | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function isEnabledByDefault(): bool { | ||
| return ($this->getAppConfig()->getValueInt(\OC\Core\AppInfo\Application::APP_ID, 'shareapi_default_permissions') & Constants::PERMISSION_DELETE) === Constants::PERMISSION_DELETE; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace OCA\Files\Sharing\Permission; | ||
|
|
||
| use OCA\Files\AppInfo\Application; | ||
| use OCP\L10N\IFactory; | ||
| use OCP\Server; | ||
| use OCP\Share\IManager; | ||
| use OCP\Sharing\Permission\ISharePermissionType; | ||
|
|
||
| final class NodeDownloadSharePermissionType implements ISharePermissionType { | ||
| private ?IManager $legacyManager = null; | ||
|
|
||
| private function getLegacyManager(): IManager { | ||
| return $this->legacyManager ??= Server::get(IManager::class); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getDisplayName(IFactory $l10nFactory): string { | ||
| return $l10nFactory->get(Application::APP_ID)->t('Download files'); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getHint(IFactory $l10nFactory): ?string { | ||
| // If previews are still allowed, the download option is only hidden, because on a technical level it is still possible to download. | ||
| if ($this->getLegacyManager()->allowViewWithoutDownload()) { | ||
| return $l10nFactory->get(Application::APP_ID)->t('When disabled, the option to download will be hidden'); | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getPriority(): int { | ||
| return 40; | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function isEnabledByDefault(): bool { | ||
| return false; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace OCA\Files\Sharing\Permission; | ||
|
|
||
| use OCA\Files\AppInfo\Application; | ||
| use OCP\L10N\IFactory; | ||
| use OCP\Sharing\Permission\ISharePermissionType; | ||
|
|
||
| final class NodeReadSharePermissionType implements ISharePermissionType { | ||
| #[\Override] | ||
| public function getDisplayName(IFactory $l10nFactory): string { | ||
| return $l10nFactory->get(Application::APP_ID)->t('View files'); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getHint(IFactory $l10nFactory): ?string { | ||
| return null; | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getPriority(): int { | ||
| return 80; | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function isEnabledByDefault(): bool { | ||
| return true; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace OCA\Files\Sharing\Permission; | ||
|
|
||
| use OCA\Files\AppInfo\Application; | ||
| use OCP\Constants; | ||
| use OCP\IAppConfig; | ||
| use OCP\L10N\IFactory; | ||
| use OCP\Server; | ||
| use OCP\Sharing\Permission\ISharePermissionType; | ||
|
|
||
| final class NodeUpdateSharePermissionType implements ISharePermissionType { | ||
| private ?IAppConfig $appConfig = null; | ||
|
|
||
| private function getAppConfig(): IAppConfig { | ||
| return $this->appConfig ??= Server::get(IAppConfig::class); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getDisplayName(IFactory $l10nFactory): string { | ||
| return $l10nFactory->get(Application::APP_ID)->t('Edit files'); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getHint(IFactory $l10nFactory): ?string { | ||
| return null; | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getPriority(): int { | ||
| return 70; | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function isEnabledByDefault(): bool { | ||
| return ($this->getAppConfig()->getValueInt(\OC\Core\AppInfo\Application::APP_ID, 'shareapi_default_permissions') & Constants::PERMISSION_UPDATE) === Constants::PERMISSION_UPDATE; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace OCA\Files\Sharing\Property; | ||
|
|
||
| use OCA\Files\AppInfo\Application; | ||
| use OCP\L10N\IFactory; | ||
| use OCP\Sharing\Property\ABooleanSharePropertyType; | ||
|
|
||
| final class NodeGridViewSharePropertyType extends ABooleanSharePropertyType { | ||
| #[\Override] | ||
| public function getDisplayName(IFactory $l10nFactory): string { | ||
| return $l10nFactory->get(Application::APP_ID)->t('Show files in grid view'); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getHint(IFactory $l10nFactory): ?string { | ||
| return null; | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getPriority(): int { | ||
| return 30; | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function isAdvanced(): bool { | ||
| return true; | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function isRequired(): bool { | ||
| return false; | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getDefaultValue(): string { | ||
| return 'false'; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks weird to me that
registeris pulling instances from Server::get.It’s usually registering classnames in the context that later gets vivified if needed.
Or you can use
injectFninbootand you get proper DI.(I do not have context for this, feel free to ignore if not relevant)