@@ -18,56 +18,56 @@ |
||
| 18 | 18 | use OCP\Settings\ISettings; |
| 19 | 19 | |
| 20 | 20 | class Personal implements ISettings { |
| 21 | - public function __construct( |
|
| 22 | - private FederatedShareProvider $federatedShareProvider, |
|
| 23 | - private IUserSession $userSession, |
|
| 24 | - private Defaults $defaults, |
|
| 25 | - private IInitialState $initialState, |
|
| 26 | - private IURLGenerator $urlGenerator, |
|
| 27 | - ) { |
|
| 28 | - } |
|
| 21 | + public function __construct( |
|
| 22 | + private FederatedShareProvider $federatedShareProvider, |
|
| 23 | + private IUserSession $userSession, |
|
| 24 | + private Defaults $defaults, |
|
| 25 | + private IInitialState $initialState, |
|
| 26 | + private IURLGenerator $urlGenerator, |
|
| 27 | + ) { |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
| 32 | - * @since 9.1 |
|
| 33 | - */ |
|
| 34 | - public function getForm(): TemplateResponse { |
|
| 35 | - $cloudID = $this->userSession->getUser()->getCloudId(); |
|
| 36 | - $url = 'https://nextcloud.com/sharing#' . $cloudID; |
|
| 30 | + /** |
|
| 31 | + * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
| 32 | + * @since 9.1 |
|
| 33 | + */ |
|
| 34 | + public function getForm(): TemplateResponse { |
|
| 35 | + $cloudID = $this->userSession->getUser()->getCloudId(); |
|
| 36 | + $url = 'https://nextcloud.com/sharing#' . $cloudID; |
|
| 37 | 37 | |
| 38 | - $this->initialState->provideInitialState('color', $this->defaults->getDefaultColorPrimary()); |
|
| 39 | - $this->initialState->provideInitialState('textColor', $this->defaults->getDefaultTextColorPrimary()); |
|
| 40 | - $this->initialState->provideInitialState('logoPath', $this->defaults->getLogo()); |
|
| 41 | - $this->initialState->provideInitialState('reference', $url); |
|
| 42 | - $this->initialState->provideInitialState('cloudId', $cloudID); |
|
| 43 | - $this->initialState->provideInitialState('docUrlFederated', $this->urlGenerator->linkToDocs('user-sharing-federated')); |
|
| 38 | + $this->initialState->provideInitialState('color', $this->defaults->getDefaultColorPrimary()); |
|
| 39 | + $this->initialState->provideInitialState('textColor', $this->defaults->getDefaultTextColorPrimary()); |
|
| 40 | + $this->initialState->provideInitialState('logoPath', $this->defaults->getLogo()); |
|
| 41 | + $this->initialState->provideInitialState('reference', $url); |
|
| 42 | + $this->initialState->provideInitialState('cloudId', $cloudID); |
|
| 43 | + $this->initialState->provideInitialState('docUrlFederated', $this->urlGenerator->linkToDocs('user-sharing-federated')); |
|
| 44 | 44 | |
| 45 | - \OCP\Util::addStyle(Application::APP_ID, 'settings-personal'); |
|
| 46 | - \OCP\Util::addScript(Application::APP_ID, 'settings-personal'); |
|
| 47 | - return new TemplateResponse(Application::APP_ID, 'settings-personal', renderAs: TemplateResponse::RENDER_AS_BLANK); |
|
| 48 | - } |
|
| 45 | + \OCP\Util::addStyle(Application::APP_ID, 'settings-personal'); |
|
| 46 | + \OCP\Util::addScript(Application::APP_ID, 'settings-personal'); |
|
| 47 | + return new TemplateResponse(Application::APP_ID, 'settings-personal', renderAs: TemplateResponse::RENDER_AS_BLANK); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @return string the section ID, e.g. 'sharing' |
|
| 52 | - * @since 9.1 |
|
| 53 | - */ |
|
| 54 | - public function getSection(): ?string { |
|
| 55 | - if ($this->federatedShareProvider->isIncomingServer2serverShareEnabled() |
|
| 56 | - || $this->federatedShareProvider->isIncomingServer2serverGroupShareEnabled()) { |
|
| 57 | - return 'sharing'; |
|
| 58 | - } |
|
| 59 | - return null; |
|
| 60 | - } |
|
| 50 | + /** |
|
| 51 | + * @return string the section ID, e.g. 'sharing' |
|
| 52 | + * @since 9.1 |
|
| 53 | + */ |
|
| 54 | + public function getSection(): ?string { |
|
| 55 | + if ($this->federatedShareProvider->isIncomingServer2serverShareEnabled() |
|
| 56 | + || $this->federatedShareProvider->isIncomingServer2serverGroupShareEnabled()) { |
|
| 57 | + return 'sharing'; |
|
| 58 | + } |
|
| 59 | + return null; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @return int whether the form should be rather on the top or bottom of |
|
| 64 | - * the admin section. The forms are arranged in ascending order of the |
|
| 65 | - * priority values. It is required to return a value between 0 and 100. |
|
| 66 | - * |
|
| 67 | - * E.g.: 70 |
|
| 68 | - * @since 9.1 |
|
| 69 | - */ |
|
| 70 | - public function getPriority(): int { |
|
| 71 | - return 40; |
|
| 72 | - } |
|
| 62 | + /** |
|
| 63 | + * @return int whether the form should be rather on the top or bottom of |
|
| 64 | + * the admin section. The forms are arranged in ascending order of the |
|
| 65 | + * priority values. It is required to return a value between 0 and 100. |
|
| 66 | + * |
|
| 67 | + * E.g.: 70 |
|
| 68 | + * @since 9.1 |
|
| 69 | + */ |
|
| 70 | + public function getPriority(): int { |
|
| 71 | + return 40; |
|
| 72 | + } |
|
| 73 | 73 | } |
@@ -16,73 +16,73 @@ |
||
| 16 | 16 | use OCP\Settings\IDelegatedSettings; |
| 17 | 17 | |
| 18 | 18 | class Admin implements IDelegatedSettings { |
| 19 | - /** |
|
| 20 | - * Admin constructor. |
|
| 21 | - */ |
|
| 22 | - public function __construct( |
|
| 23 | - private FederatedShareProvider $fedShareProvider, |
|
| 24 | - private IConfig $gsConfig, |
|
| 25 | - private IL10N $l, |
|
| 26 | - private IURLGenerator $urlGenerator, |
|
| 27 | - private IInitialState $initialState, |
|
| 28 | - ) { |
|
| 29 | - } |
|
| 19 | + /** |
|
| 20 | + * Admin constructor. |
|
| 21 | + */ |
|
| 22 | + public function __construct( |
|
| 23 | + private FederatedShareProvider $fedShareProvider, |
|
| 24 | + private IConfig $gsConfig, |
|
| 25 | + private IL10N $l, |
|
| 26 | + private IURLGenerator $urlGenerator, |
|
| 27 | + private IInitialState $initialState, |
|
| 28 | + ) { |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @return TemplateResponse |
|
| 33 | - */ |
|
| 34 | - public function getForm() { |
|
| 31 | + /** |
|
| 32 | + * @return TemplateResponse |
|
| 33 | + */ |
|
| 34 | + public function getForm() { |
|
| 35 | 35 | |
| 36 | - $this->initialState->provideInitialState('internalOnly', $this->gsConfig->onlyInternalFederation()); |
|
| 37 | - $this->initialState->provideInitialState('sharingFederatedDocUrl', $this->urlGenerator->linkToDocs('admin-sharing-federated')); |
|
| 38 | - $this->initialState->provideInitialState('outgoingServer2serverShareEnabled', $this->fedShareProvider->isOutgoingServer2serverShareEnabled()); |
|
| 39 | - $this->initialState->provideInitialState('incomingServer2serverShareEnabled', $this->fedShareProvider->isIncomingServer2serverShareEnabled()); |
|
| 40 | - $this->initialState->provideInitialState('federatedGroupSharingSupported', $this->fedShareProvider->isFederatedGroupSharingSupported()); |
|
| 41 | - $this->initialState->provideInitialState('outgoingServer2serverGroupShareEnabled', $this->fedShareProvider->isOutgoingServer2serverGroupShareEnabled()); |
|
| 42 | - $this->initialState->provideInitialState('incomingServer2serverGroupShareEnabled', $this->fedShareProvider->isIncomingServer2serverGroupShareEnabled()); |
|
| 43 | - $this->initialState->provideInitialState('lookupServerEnabled', $this->fedShareProvider->isLookupServerQueriesEnabled()); |
|
| 44 | - $this->initialState->provideInitialState('lookupServerUploadEnabled', $this->fedShareProvider->isLookupServerUploadEnabled()); |
|
| 45 | - $this->initialState->provideInitialState('federatedTrustedShareAutoAccept', $this->fedShareProvider->isFederatedTrustedShareAutoAccept()); |
|
| 36 | + $this->initialState->provideInitialState('internalOnly', $this->gsConfig->onlyInternalFederation()); |
|
| 37 | + $this->initialState->provideInitialState('sharingFederatedDocUrl', $this->urlGenerator->linkToDocs('admin-sharing-federated')); |
|
| 38 | + $this->initialState->provideInitialState('outgoingServer2serverShareEnabled', $this->fedShareProvider->isOutgoingServer2serverShareEnabled()); |
|
| 39 | + $this->initialState->provideInitialState('incomingServer2serverShareEnabled', $this->fedShareProvider->isIncomingServer2serverShareEnabled()); |
|
| 40 | + $this->initialState->provideInitialState('federatedGroupSharingSupported', $this->fedShareProvider->isFederatedGroupSharingSupported()); |
|
| 41 | + $this->initialState->provideInitialState('outgoingServer2serverGroupShareEnabled', $this->fedShareProvider->isOutgoingServer2serverGroupShareEnabled()); |
|
| 42 | + $this->initialState->provideInitialState('incomingServer2serverGroupShareEnabled', $this->fedShareProvider->isIncomingServer2serverGroupShareEnabled()); |
|
| 43 | + $this->initialState->provideInitialState('lookupServerEnabled', $this->fedShareProvider->isLookupServerQueriesEnabled()); |
|
| 44 | + $this->initialState->provideInitialState('lookupServerUploadEnabled', $this->fedShareProvider->isLookupServerUploadEnabled()); |
|
| 45 | + $this->initialState->provideInitialState('federatedTrustedShareAutoAccept', $this->fedShareProvider->isFederatedTrustedShareAutoAccept()); |
|
| 46 | 46 | |
| 47 | - \OCP\Util::addStyle(Application::APP_ID, 'settings-admin'); |
|
| 48 | - \OCP\Util::addScript(Application::APP_ID, 'settings-admin'); |
|
| 49 | - return new TemplateResponse(Application::APP_ID, 'settings-admin', renderAs: ''); |
|
| 50 | - } |
|
| 47 | + \OCP\Util::addStyle(Application::APP_ID, 'settings-admin'); |
|
| 48 | + \OCP\Util::addScript(Application::APP_ID, 'settings-admin'); |
|
| 49 | + return new TemplateResponse(Application::APP_ID, 'settings-admin', renderAs: ''); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @return string the section ID, e.g. 'sharing' |
|
| 54 | - */ |
|
| 55 | - public function getSection() { |
|
| 56 | - return 'sharing'; |
|
| 57 | - } |
|
| 52 | + /** |
|
| 53 | + * @return string the section ID, e.g. 'sharing' |
|
| 54 | + */ |
|
| 55 | + public function getSection() { |
|
| 56 | + return 'sharing'; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * @return int whether the form should be rather on the top or bottom of |
|
| 61 | - * the admin section. The forms are arranged in ascending order of the |
|
| 62 | - * priority values. It is required to return a value between 0 and 100. |
|
| 63 | - * |
|
| 64 | - * E.g.: 70 |
|
| 65 | - */ |
|
| 66 | - public function getPriority() { |
|
| 67 | - return 20; |
|
| 68 | - } |
|
| 59 | + /** |
|
| 60 | + * @return int whether the form should be rather on the top or bottom of |
|
| 61 | + * the admin section. The forms are arranged in ascending order of the |
|
| 62 | + * priority values. It is required to return a value between 0 and 100. |
|
| 63 | + * |
|
| 64 | + * E.g.: 70 |
|
| 65 | + */ |
|
| 66 | + public function getPriority() { |
|
| 67 | + return 20; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - public function getName(): ?string { |
|
| 71 | - return $this->l->t('Federated Cloud Sharing'); |
|
| 72 | - } |
|
| 70 | + public function getName(): ?string { |
|
| 71 | + return $this->l->t('Federated Cloud Sharing'); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - public function getAuthorizedAppConfig(): array { |
|
| 75 | - return [ |
|
| 76 | - 'files_sharing' => [ |
|
| 77 | - 'outgoing_server2server_share_enabled', |
|
| 78 | - 'incoming_server2server_share_enabled', |
|
| 79 | - 'federatedGroupSharingSupported', |
|
| 80 | - 'outgoingServer2serverGroupShareEnabled', |
|
| 81 | - 'incomingServer2serverGroupShareEnabled', |
|
| 82 | - 'lookupServerEnabled', |
|
| 83 | - 'lookupServerUploadEnabled', |
|
| 84 | - 'federatedTrustedShareAutoAccept', |
|
| 85 | - ], |
|
| 86 | - ]; |
|
| 87 | - } |
|
| 74 | + public function getAuthorizedAppConfig(): array { |
|
| 75 | + return [ |
|
| 76 | + 'files_sharing' => [ |
|
| 77 | + 'outgoing_server2server_share_enabled', |
|
| 78 | + 'incoming_server2server_share_enabled', |
|
| 79 | + 'federatedGroupSharingSupported', |
|
| 80 | + 'outgoingServer2serverGroupShareEnabled', |
|
| 81 | + 'incomingServer2serverGroupShareEnabled', |
|
| 82 | + 'lookupServerEnabled', |
|
| 83 | + 'lookupServerUploadEnabled', |
|
| 84 | + 'federatedTrustedShareAutoAccept', |
|
| 85 | + ], |
|
| 86 | + ]; |
|
| 87 | + } |
|
| 88 | 88 | } |
@@ -20,29 +20,29 @@ |
||
| 20 | 20 | |
| 21 | 21 | class Application extends App implements IBootstrap { |
| 22 | 22 | |
| 23 | - public const APP_ID = 'federatedfilesharing'; |
|
| 24 | - |
|
| 25 | - public function __construct() { |
|
| 26 | - parent::__construct(self::APP_ID); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - public function register(IRegistrationContext $context): void { |
|
| 30 | - $context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScriptsListener::class); |
|
| 31 | - $context->registerNotifierService(Notifier::class); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - public function boot(IBootContext $context): void { |
|
| 35 | - $context->injectFn(Closure::fromCallable([$this, 'registerCloudFederationProvider'])); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - private function registerCloudFederationProvider(ICloudFederationProviderManager $manager): void { |
|
| 39 | - $fileResourceTypes = ['file', 'folder']; |
|
| 40 | - foreach ($fileResourceTypes as $type) { |
|
| 41 | - $manager->addCloudFederationProvider($type, |
|
| 42 | - 'Federated Files Sharing', |
|
| 43 | - function (): CloudFederationProviderFiles { |
|
| 44 | - return \OCP\Server::get(CloudFederationProviderFiles::class); |
|
| 45 | - }); |
|
| 46 | - } |
|
| 47 | - } |
|
| 23 | + public const APP_ID = 'federatedfilesharing'; |
|
| 24 | + |
|
| 25 | + public function __construct() { |
|
| 26 | + parent::__construct(self::APP_ID); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + public function register(IRegistrationContext $context): void { |
|
| 30 | + $context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScriptsListener::class); |
|
| 31 | + $context->registerNotifierService(Notifier::class); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + public function boot(IBootContext $context): void { |
|
| 35 | + $context->injectFn(Closure::fromCallable([$this, 'registerCloudFederationProvider'])); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + private function registerCloudFederationProvider(ICloudFederationProviderManager $manager): void { |
|
| 39 | + $fileResourceTypes = ['file', 'folder']; |
|
| 40 | + foreach ($fileResourceTypes as $type) { |
|
| 41 | + $manager->addCloudFederationProvider($type, |
|
| 42 | + 'Federated Files Sharing', |
|
| 43 | + function (): CloudFederationProviderFiles { |
|
| 44 | + return \OCP\Server::get(CloudFederationProviderFiles::class); |
|
| 45 | + }); |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | 48 | } |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | foreach ($fileResourceTypes as $type) { |
| 41 | 41 | $manager->addCloudFederationProvider($type, |
| 42 | 42 | 'Federated Files Sharing', |
| 43 | - function (): CloudFederationProviderFiles { |
|
| 43 | + function(): CloudFederationProviderFiles { |
|
| 44 | 44 | return \OCP\Server::get(CloudFederationProviderFiles::class); |
| 45 | 45 | }); |
| 46 | 46 | } |
@@ -19,25 +19,25 @@ |
||
| 19 | 19 | |
| 20 | 20 | /** @template-implements IEventListener<LoadAdditionalScriptsEvent> */ |
| 21 | 21 | class LoadAdditionalScriptsListener implements IEventListener { |
| 22 | - public function __construct( |
|
| 23 | - private FederatedShareProvider $federatedShareProvider, |
|
| 24 | - private IInitialState $initialState, |
|
| 25 | - private IAppManager $appManager, |
|
| 26 | - ) { |
|
| 27 | - $this->federatedShareProvider = $federatedShareProvider; |
|
| 28 | - $this->initialState = $initialState; |
|
| 29 | - $this->appManager = $appManager; |
|
| 30 | - } |
|
| 22 | + public function __construct( |
|
| 23 | + private FederatedShareProvider $federatedShareProvider, |
|
| 24 | + private IInitialState $initialState, |
|
| 25 | + private IAppManager $appManager, |
|
| 26 | + ) { |
|
| 27 | + $this->federatedShareProvider = $federatedShareProvider; |
|
| 28 | + $this->initialState = $initialState; |
|
| 29 | + $this->appManager = $appManager; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - public function handle(Event $event): void { |
|
| 33 | - if (!$event instanceof LoadAdditionalScriptsEvent) { |
|
| 34 | - return; |
|
| 35 | - } |
|
| 32 | + public function handle(Event $event): void { |
|
| 33 | + if (!$event instanceof LoadAdditionalScriptsEvent) { |
|
| 34 | + return; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - if ($this->federatedShareProvider->isIncomingServer2serverShareEnabled()) { |
|
| 38 | - $this->initialState->provideInitialState('notificationsEnabled', $this->appManager->isEnabledForUser('notifications')); |
|
| 39 | - Util::addStyle(Application::APP_ID, 'init-files'); |
|
| 40 | - Util::addInitScript(Application::APP_ID, 'init-files'); |
|
| 41 | - } |
|
| 42 | - } |
|
| 37 | + if ($this->federatedShareProvider->isIncomingServer2serverShareEnabled()) { |
|
| 38 | + $this->initialState->provideInitialState('notificationsEnabled', $this->appManager->isEnabledForUser('notifications')); |
|
| 39 | + Util::addStyle(Application::APP_ID, 'init-files'); |
|
| 40 | + Util::addInitScript(Application::APP_ID, 'init-files'); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | 43 | } |