@@ -58,132 +58,132 @@ |
||
58 | 58 | use OCP\Util; |
59 | 59 | |
60 | 60 | class Application extends App implements IBootstrap { |
61 | - public const APP_ID = 'files'; |
|
62 | - |
|
63 | - public function __construct(array $urlParams=[]) { |
|
64 | - parent::__construct(self::APP_ID, $urlParams); |
|
65 | - } |
|
66 | - |
|
67 | - public function register(IRegistrationContext $context): void { |
|
68 | - /** |
|
69 | - * Controllers |
|
70 | - */ |
|
71 | - $context->registerService('APIController', function (IContainer $c) { |
|
72 | - /** @var IServerContainer $server */ |
|
73 | - $server = $c->query(IServerContainer::class); |
|
74 | - |
|
75 | - return new ApiController( |
|
76 | - $c->query('AppName'), |
|
77 | - $c->query('Request'), |
|
78 | - $server->getUserSession(), |
|
79 | - $c->query('TagService'), |
|
80 | - $server->getPreviewManager(), |
|
81 | - $server->getShareManager(), |
|
82 | - $server->getConfig(), |
|
83 | - $server->getUserFolder() |
|
84 | - ); |
|
85 | - }); |
|
86 | - |
|
87 | - /** |
|
88 | - * Services |
|
89 | - */ |
|
90 | - $context->registerService('TagService', function (IContainer $c) { |
|
91 | - /** @var IServerContainer $server */ |
|
92 | - $server = $c->query(IServerContainer::class); |
|
93 | - |
|
94 | - return new TagService( |
|
95 | - $server->getUserSession(), |
|
96 | - $server->getActivityManager(), |
|
97 | - $server->getTagManager()->load(self::APP_ID), |
|
98 | - $server->getUserFolder(), |
|
99 | - $server->getEventDispatcher() |
|
100 | - ); |
|
101 | - }); |
|
102 | - |
|
103 | - /* |
|
61 | + public const APP_ID = 'files'; |
|
62 | + |
|
63 | + public function __construct(array $urlParams=[]) { |
|
64 | + parent::__construct(self::APP_ID, $urlParams); |
|
65 | + } |
|
66 | + |
|
67 | + public function register(IRegistrationContext $context): void { |
|
68 | + /** |
|
69 | + * Controllers |
|
70 | + */ |
|
71 | + $context->registerService('APIController', function (IContainer $c) { |
|
72 | + /** @var IServerContainer $server */ |
|
73 | + $server = $c->query(IServerContainer::class); |
|
74 | + |
|
75 | + return new ApiController( |
|
76 | + $c->query('AppName'), |
|
77 | + $c->query('Request'), |
|
78 | + $server->getUserSession(), |
|
79 | + $c->query('TagService'), |
|
80 | + $server->getPreviewManager(), |
|
81 | + $server->getShareManager(), |
|
82 | + $server->getConfig(), |
|
83 | + $server->getUserFolder() |
|
84 | + ); |
|
85 | + }); |
|
86 | + |
|
87 | + /** |
|
88 | + * Services |
|
89 | + */ |
|
90 | + $context->registerService('TagService', function (IContainer $c) { |
|
91 | + /** @var IServerContainer $server */ |
|
92 | + $server = $c->query(IServerContainer::class); |
|
93 | + |
|
94 | + return new TagService( |
|
95 | + $server->getUserSession(), |
|
96 | + $server->getActivityManager(), |
|
97 | + $server->getTagManager()->load(self::APP_ID), |
|
98 | + $server->getUserFolder(), |
|
99 | + $server->getEventDispatcher() |
|
100 | + ); |
|
101 | + }); |
|
102 | + |
|
103 | + /* |
|
104 | 104 | * Register capabilities |
105 | 105 | */ |
106 | - $context->registerCapability(Capabilities::class); |
|
107 | - |
|
108 | - $context->registerEventListener(LoadAdditionalScriptsEvent::class, LegacyLoadAdditionalScriptsAdapter::class); |
|
109 | - $context->registerEventListener(LoadSidebar::class, LoadSidebarListener::class); |
|
110 | - |
|
111 | - $context->registerSearchProvider(FilesSearchProvider::class); |
|
112 | - } |
|
113 | - |
|
114 | - public function boot(IBootContext $context): void { |
|
115 | - $this->registerCollaboration($context); |
|
116 | - Listener::register($context->getServerContainer()->getEventDispatcher()); |
|
117 | - $this->registerNotification($context); |
|
118 | - $this->registerSearchProvider($context); |
|
119 | - $this->registerTemplates(); |
|
120 | - $this->registerNavigation($context); |
|
121 | - $this->registerHooks(); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * Register Collaboration ResourceProvider |
|
126 | - */ |
|
127 | - private function registerCollaboration(IBootContext $context): void { |
|
128 | - /** @var IProviderManager $providerManager */ |
|
129 | - $providerManager = $context->getAppContainer()->query(IProviderManager::class); |
|
130 | - $providerManager->registerResourceProvider(ResourceProvider::class); |
|
131 | - } |
|
132 | - |
|
133 | - private function registerNotification(IBootContext $context): void { |
|
134 | - /** @var IManager $notifications */ |
|
135 | - $notifications = $context->getAppContainer()->query(IManager::class); |
|
136 | - $notifications->registerNotifierService(Notifier::class); |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * @param IBootContext $context |
|
141 | - */ |
|
142 | - private function registerSearchProvider(IBootContext $context): void { |
|
143 | - $context->getServerContainer()->getSearch()->registerProvider(File::class, ['apps' => ['files']]); |
|
144 | - } |
|
145 | - |
|
146 | - private function registerTemplates(): void { |
|
147 | - $templateManager = \OC_Helper::getFileTemplateManager(); |
|
148 | - $templateManager->registerTemplate('application/vnd.oasis.opendocument.presentation', 'core/templates/filetemplates/template.odp'); |
|
149 | - $templateManager->registerTemplate('application/vnd.oasis.opendocument.text', 'core/templates/filetemplates/template.odt'); |
|
150 | - $templateManager->registerTemplate('application/vnd.oasis.opendocument.spreadsheet', 'core/templates/filetemplates/template.ods'); |
|
151 | - } |
|
152 | - |
|
153 | - private function registerNavigation(IBootContext $context): void { |
|
154 | - /** @var IL10N $l10n */ |
|
155 | - $l10n = $context->getAppContainer()->query(IL10N::class); |
|
156 | - \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) { |
|
157 | - return [ |
|
158 | - 'id' => 'files', |
|
159 | - 'appname' => 'files', |
|
160 | - 'script' => 'list.php', |
|
161 | - 'order' => 0, |
|
162 | - 'name' => $l10n->t('All files') |
|
163 | - ]; |
|
164 | - }); |
|
165 | - \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) { |
|
166 | - return [ |
|
167 | - 'id' => 'recent', |
|
168 | - 'appname' => 'files', |
|
169 | - 'script' => 'recentlist.php', |
|
170 | - 'order' => 2, |
|
171 | - 'name' => $l10n->t('Recent') |
|
172 | - ]; |
|
173 | - }); |
|
174 | - \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) { |
|
175 | - return [ |
|
176 | - 'id' => 'favorites', |
|
177 | - 'appname' => 'files', |
|
178 | - 'script' => 'simplelist.php', |
|
179 | - 'order' => 5, |
|
180 | - 'name' => $l10n->t('Favorites'), |
|
181 | - 'expandedState' => 'show_Quick_Access' |
|
182 | - ]; |
|
183 | - }); |
|
184 | - } |
|
185 | - |
|
186 | - private function registerHooks(): void { |
|
187 | - Util::connectHook('\OCP\Config', 'js', '\OCA\Files\App', 'extendJsConfig'); |
|
188 | - } |
|
106 | + $context->registerCapability(Capabilities::class); |
|
107 | + |
|
108 | + $context->registerEventListener(LoadAdditionalScriptsEvent::class, LegacyLoadAdditionalScriptsAdapter::class); |
|
109 | + $context->registerEventListener(LoadSidebar::class, LoadSidebarListener::class); |
|
110 | + |
|
111 | + $context->registerSearchProvider(FilesSearchProvider::class); |
|
112 | + } |
|
113 | + |
|
114 | + public function boot(IBootContext $context): void { |
|
115 | + $this->registerCollaboration($context); |
|
116 | + Listener::register($context->getServerContainer()->getEventDispatcher()); |
|
117 | + $this->registerNotification($context); |
|
118 | + $this->registerSearchProvider($context); |
|
119 | + $this->registerTemplates(); |
|
120 | + $this->registerNavigation($context); |
|
121 | + $this->registerHooks(); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * Register Collaboration ResourceProvider |
|
126 | + */ |
|
127 | + private function registerCollaboration(IBootContext $context): void { |
|
128 | + /** @var IProviderManager $providerManager */ |
|
129 | + $providerManager = $context->getAppContainer()->query(IProviderManager::class); |
|
130 | + $providerManager->registerResourceProvider(ResourceProvider::class); |
|
131 | + } |
|
132 | + |
|
133 | + private function registerNotification(IBootContext $context): void { |
|
134 | + /** @var IManager $notifications */ |
|
135 | + $notifications = $context->getAppContainer()->query(IManager::class); |
|
136 | + $notifications->registerNotifierService(Notifier::class); |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * @param IBootContext $context |
|
141 | + */ |
|
142 | + private function registerSearchProvider(IBootContext $context): void { |
|
143 | + $context->getServerContainer()->getSearch()->registerProvider(File::class, ['apps' => ['files']]); |
|
144 | + } |
|
145 | + |
|
146 | + private function registerTemplates(): void { |
|
147 | + $templateManager = \OC_Helper::getFileTemplateManager(); |
|
148 | + $templateManager->registerTemplate('application/vnd.oasis.opendocument.presentation', 'core/templates/filetemplates/template.odp'); |
|
149 | + $templateManager->registerTemplate('application/vnd.oasis.opendocument.text', 'core/templates/filetemplates/template.odt'); |
|
150 | + $templateManager->registerTemplate('application/vnd.oasis.opendocument.spreadsheet', 'core/templates/filetemplates/template.ods'); |
|
151 | + } |
|
152 | + |
|
153 | + private function registerNavigation(IBootContext $context): void { |
|
154 | + /** @var IL10N $l10n */ |
|
155 | + $l10n = $context->getAppContainer()->query(IL10N::class); |
|
156 | + \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) { |
|
157 | + return [ |
|
158 | + 'id' => 'files', |
|
159 | + 'appname' => 'files', |
|
160 | + 'script' => 'list.php', |
|
161 | + 'order' => 0, |
|
162 | + 'name' => $l10n->t('All files') |
|
163 | + ]; |
|
164 | + }); |
|
165 | + \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) { |
|
166 | + return [ |
|
167 | + 'id' => 'recent', |
|
168 | + 'appname' => 'files', |
|
169 | + 'script' => 'recentlist.php', |
|
170 | + 'order' => 2, |
|
171 | + 'name' => $l10n->t('Recent') |
|
172 | + ]; |
|
173 | + }); |
|
174 | + \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) { |
|
175 | + return [ |
|
176 | + 'id' => 'favorites', |
|
177 | + 'appname' => 'files', |
|
178 | + 'script' => 'simplelist.php', |
|
179 | + 'order' => 5, |
|
180 | + 'name' => $l10n->t('Favorites'), |
|
181 | + 'expandedState' => 'show_Quick_Access' |
|
182 | + ]; |
|
183 | + }); |
|
184 | + } |
|
185 | + |
|
186 | + private function registerHooks(): void { |
|
187 | + Util::connectHook('\OCP\Config', 'js', '\OCA\Files\App', 'extendJsConfig'); |
|
188 | + } |
|
189 | 189 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | class Application extends App implements IBootstrap { |
61 | 61 | public const APP_ID = 'files'; |
62 | 62 | |
63 | - public function __construct(array $urlParams=[]) { |
|
63 | + public function __construct(array $urlParams = []) { |
|
64 | 64 | parent::__construct(self::APP_ID, $urlParams); |
65 | 65 | } |
66 | 66 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | /** |
69 | 69 | * Controllers |
70 | 70 | */ |
71 | - $context->registerService('APIController', function (IContainer $c) { |
|
71 | + $context->registerService('APIController', function(IContainer $c) { |
|
72 | 72 | /** @var IServerContainer $server */ |
73 | 73 | $server = $c->query(IServerContainer::class); |
74 | 74 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | /** |
88 | 88 | * Services |
89 | 89 | */ |
90 | - $context->registerService('TagService', function (IContainer $c) { |
|
90 | + $context->registerService('TagService', function(IContainer $c) { |
|
91 | 91 | /** @var IServerContainer $server */ |
92 | 92 | $server = $c->query(IServerContainer::class); |
93 | 93 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | private function registerNavigation(IBootContext $context): void { |
154 | 154 | /** @var IL10N $l10n */ |
155 | 155 | $l10n = $context->getAppContainer()->query(IL10N::class); |
156 | - \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) { |
|
156 | + \OCA\Files\App::getNavigationManager()->add(function() use ($l10n) { |
|
157 | 157 | return [ |
158 | 158 | 'id' => 'files', |
159 | 159 | 'appname' => 'files', |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | 'name' => $l10n->t('All files') |
163 | 163 | ]; |
164 | 164 | }); |
165 | - \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) { |
|
165 | + \OCA\Files\App::getNavigationManager()->add(function() use ($l10n) { |
|
166 | 166 | return [ |
167 | 167 | 'id' => 'recent', |
168 | 168 | 'appname' => 'files', |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | 'name' => $l10n->t('Recent') |
172 | 172 | ]; |
173 | 173 | }); |
174 | - \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) { |
|
174 | + \OCA\Files\App::getNavigationManager()->add(function() use ($l10n) { |
|
175 | 175 | return [ |
176 | 176 | 'id' => 'favorites', |
177 | 177 | 'appname' => 'files', |
@@ -58,178 +58,178 @@ |
||
58 | 58 | use Symfony\Component\EventDispatcher\GenericEvent; |
59 | 59 | |
60 | 60 | class Application extends App { |
61 | - public const APP_ID = 'files_sharing'; |
|
62 | - |
|
63 | - public function __construct(array $urlParams = []) { |
|
64 | - parent::__construct(self::APP_ID, $urlParams); |
|
65 | - |
|
66 | - $container = $this->getContainer(); |
|
67 | - |
|
68 | - /** @var IServerContainer $server */ |
|
69 | - $server = $container->getServer(); |
|
70 | - |
|
71 | - /** @var IEventDispatcher $dispatcher */ |
|
72 | - $dispatcher = $container->query(IEventDispatcher::class); |
|
73 | - $mountProviderCollection = $server->getMountProviderCollection(); |
|
74 | - $notifications = $server->getNotificationManager(); |
|
75 | - |
|
76 | - /** |
|
77 | - * Core class wrappers |
|
78 | - */ |
|
79 | - $container->registerService(Manager::class, function (SimpleContainer $c) use ($server) { |
|
80 | - $user = $server->getUserSession()->getUser(); |
|
81 | - $uid = $user ? $user->getUID() : null; |
|
82 | - return new \OCA\Files_Sharing\External\Manager( |
|
83 | - $server->getDatabaseConnection(), |
|
84 | - \OC\Files\Filesystem::getMountManager(), |
|
85 | - \OC\Files\Filesystem::getLoader(), |
|
86 | - $server->getHTTPClientService(), |
|
87 | - $server->getNotificationManager(), |
|
88 | - $server->query(\OCP\OCS\IDiscoveryService::class), |
|
89 | - $server->getCloudFederationProviderManager(), |
|
90 | - $server->getCloudFederationFactory(), |
|
91 | - $server->getGroupManager(), |
|
92 | - $server->getUserManager(), |
|
93 | - $uid |
|
94 | - ); |
|
95 | - }); |
|
96 | - |
|
97 | - /** |
|
98 | - * Middleware |
|
99 | - */ |
|
100 | - $container->registerMiddleWare(SharingCheckMiddleware::class); |
|
101 | - $container->registerMiddleWare(OCSShareAPIMiddleware::class); |
|
102 | - $container->registerMiddleWare(ShareInfoMiddleware::class); |
|
103 | - |
|
104 | - $container->registerService('ExternalMountProvider', function (IContainer $c) { |
|
105 | - /** @var \OCP\IServerContainer $server */ |
|
106 | - $server = $c->query('ServerContainer'); |
|
107 | - return new \OCA\Files_Sharing\External\MountProvider( |
|
108 | - $server->getDatabaseConnection(), |
|
109 | - function () use ($c) { |
|
110 | - return $c->query(Manager::class); |
|
111 | - }, |
|
112 | - $server->getCloudIdManager() |
|
113 | - ); |
|
114 | - }); |
|
115 | - |
|
116 | - /** |
|
117 | - * Register capabilities |
|
118 | - */ |
|
119 | - $container->registerCapability(Capabilities::class); |
|
120 | - |
|
121 | - $notifications->registerNotifierService(Notifier::class); |
|
122 | - |
|
123 | - $this->registerMountProviders($mountProviderCollection); |
|
124 | - $this->registerEventsScripts($dispatcher); |
|
125 | - $this->setupSharingMenus(); |
|
126 | - |
|
127 | - /** |
|
128 | - * Always add main sharing script |
|
129 | - */ |
|
130 | - Util::addScript(self::APP_ID, 'dist/main'); |
|
131 | - } |
|
132 | - |
|
133 | - protected function registerMountProviders(IMountProviderCollection $mountProviderCollection) { |
|
134 | - $mountProviderCollection->registerProvider($this->getContainer()->query(MountProvider::class)); |
|
135 | - $mountProviderCollection->registerProvider($this->getContainer()->query('ExternalMountProvider')); |
|
136 | - } |
|
137 | - |
|
138 | - protected function registerEventsScripts(IEventDispatcher $dispatcher) { |
|
139 | - // sidebar and files scripts |
|
140 | - $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); |
|
141 | - $dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class); |
|
142 | - $dispatcher->addServiceListener(ShareCreatedEvent::class, ShareInteractionListener::class); |
|
143 | - $dispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function () { |
|
144 | - \OCP\Util::addScript('files_sharing', 'dist/collaboration'); |
|
145 | - }); |
|
146 | - $dispatcher->addServiceListener(ShareCreatedEvent::class, UserShareAcceptanceListener::class); |
|
147 | - $dispatcher->addServiceListener(UserAddedEvent::class, UserAddedToGroupListener::class); |
|
148 | - |
|
149 | - // notifications api to accept incoming user shares |
|
150 | - $dispatcher->addListener('OCP\Share::postShare', function (GenericEvent $event) { |
|
151 | - /** @var Listener $listener */ |
|
152 | - $listener = $this->getContainer()->query(Listener::class); |
|
153 | - $listener->shareNotification($event); |
|
154 | - }); |
|
155 | - $dispatcher->addListener(IGroup::class . '::postAddUser', function (GenericEvent $event) { |
|
156 | - /** @var Listener $listener */ |
|
157 | - $listener = $this->getContainer()->query(Listener::class); |
|
158 | - $listener->userAddedToGroup($event); |
|
159 | - }); |
|
160 | - } |
|
161 | - |
|
162 | - protected function setupSharingMenus() { |
|
163 | - $config = \OC::$server->getConfig(); |
|
164 | - |
|
165 | - if ($config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') { |
|
166 | - return; |
|
167 | - } |
|
168 | - |
|
169 | - // show_Quick_Access stored as string |
|
170 | - \OCA\Files\App::getNavigationManager()->add(function () { |
|
171 | - $config = \OC::$server->getConfig(); |
|
172 | - $l = \OC::$server->getL10N('files_sharing'); |
|
173 | - |
|
174 | - $sharingSublistArray = []; |
|
175 | - |
|
176 | - if (\OCP\Util::isSharingDisabledForUser() === false) { |
|
177 | - $sharingSublistArray[] = [ |
|
178 | - 'id' => 'sharingout', |
|
179 | - 'appname' => 'files_sharing', |
|
180 | - 'script' => 'list.php', |
|
181 | - 'order' => 16, |
|
182 | - 'name' => $l->t('Shared with others'), |
|
183 | - ]; |
|
184 | - } |
|
185 | - |
|
186 | - $sharingSublistArray[] = [ |
|
187 | - 'id' => 'sharingin', |
|
188 | - 'appname' => 'files_sharing', |
|
189 | - 'script' => 'list.php', |
|
190 | - 'order' => 15, |
|
191 | - 'name' => $l->t('Shared with you'), |
|
192 | - ]; |
|
193 | - |
|
194 | - if (\OCP\Util::isSharingDisabledForUser() === false) { |
|
195 | - // Check if sharing by link is enabled |
|
196 | - if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') { |
|
197 | - $sharingSublistArray[] = [ |
|
198 | - 'id' => 'sharinglinks', |
|
199 | - 'appname' => 'files_sharing', |
|
200 | - 'script' => 'list.php', |
|
201 | - 'order' => 17, |
|
202 | - 'name' => $l->t('Shared by link'), |
|
203 | - ]; |
|
204 | - } |
|
205 | - } |
|
206 | - |
|
207 | - $sharingSublistArray[] = [ |
|
208 | - 'id' => 'deletedshares', |
|
209 | - 'appname' => 'files_sharing', |
|
210 | - 'script' => 'list.php', |
|
211 | - 'order' => 19, |
|
212 | - 'name' => $l->t('Deleted shares'), |
|
213 | - ]; |
|
214 | - |
|
215 | - $sharingSublistArray[] = [ |
|
216 | - 'id' => 'pendingshares', |
|
217 | - 'appname' => 'files_sharing', |
|
218 | - 'script' => 'list.php', |
|
219 | - 'order' => 19, |
|
220 | - 'name' => $l->t('Pending shares'), |
|
221 | - ]; |
|
222 | - |
|
223 | - return [ |
|
224 | - 'id' => 'shareoverview', |
|
225 | - 'appname' => 'files_sharing', |
|
226 | - 'script' => 'list.php', |
|
227 | - 'order' => 18, |
|
228 | - 'name' => $l->t('Shares'), |
|
229 | - 'classes' => 'collapsible', |
|
230 | - 'sublist' => $sharingSublistArray, |
|
231 | - 'expandedState' => 'show_sharing_menu' |
|
232 | - ]; |
|
233 | - }); |
|
234 | - } |
|
61 | + public const APP_ID = 'files_sharing'; |
|
62 | + |
|
63 | + public function __construct(array $urlParams = []) { |
|
64 | + parent::__construct(self::APP_ID, $urlParams); |
|
65 | + |
|
66 | + $container = $this->getContainer(); |
|
67 | + |
|
68 | + /** @var IServerContainer $server */ |
|
69 | + $server = $container->getServer(); |
|
70 | + |
|
71 | + /** @var IEventDispatcher $dispatcher */ |
|
72 | + $dispatcher = $container->query(IEventDispatcher::class); |
|
73 | + $mountProviderCollection = $server->getMountProviderCollection(); |
|
74 | + $notifications = $server->getNotificationManager(); |
|
75 | + |
|
76 | + /** |
|
77 | + * Core class wrappers |
|
78 | + */ |
|
79 | + $container->registerService(Manager::class, function (SimpleContainer $c) use ($server) { |
|
80 | + $user = $server->getUserSession()->getUser(); |
|
81 | + $uid = $user ? $user->getUID() : null; |
|
82 | + return new \OCA\Files_Sharing\External\Manager( |
|
83 | + $server->getDatabaseConnection(), |
|
84 | + \OC\Files\Filesystem::getMountManager(), |
|
85 | + \OC\Files\Filesystem::getLoader(), |
|
86 | + $server->getHTTPClientService(), |
|
87 | + $server->getNotificationManager(), |
|
88 | + $server->query(\OCP\OCS\IDiscoveryService::class), |
|
89 | + $server->getCloudFederationProviderManager(), |
|
90 | + $server->getCloudFederationFactory(), |
|
91 | + $server->getGroupManager(), |
|
92 | + $server->getUserManager(), |
|
93 | + $uid |
|
94 | + ); |
|
95 | + }); |
|
96 | + |
|
97 | + /** |
|
98 | + * Middleware |
|
99 | + */ |
|
100 | + $container->registerMiddleWare(SharingCheckMiddleware::class); |
|
101 | + $container->registerMiddleWare(OCSShareAPIMiddleware::class); |
|
102 | + $container->registerMiddleWare(ShareInfoMiddleware::class); |
|
103 | + |
|
104 | + $container->registerService('ExternalMountProvider', function (IContainer $c) { |
|
105 | + /** @var \OCP\IServerContainer $server */ |
|
106 | + $server = $c->query('ServerContainer'); |
|
107 | + return new \OCA\Files_Sharing\External\MountProvider( |
|
108 | + $server->getDatabaseConnection(), |
|
109 | + function () use ($c) { |
|
110 | + return $c->query(Manager::class); |
|
111 | + }, |
|
112 | + $server->getCloudIdManager() |
|
113 | + ); |
|
114 | + }); |
|
115 | + |
|
116 | + /** |
|
117 | + * Register capabilities |
|
118 | + */ |
|
119 | + $container->registerCapability(Capabilities::class); |
|
120 | + |
|
121 | + $notifications->registerNotifierService(Notifier::class); |
|
122 | + |
|
123 | + $this->registerMountProviders($mountProviderCollection); |
|
124 | + $this->registerEventsScripts($dispatcher); |
|
125 | + $this->setupSharingMenus(); |
|
126 | + |
|
127 | + /** |
|
128 | + * Always add main sharing script |
|
129 | + */ |
|
130 | + Util::addScript(self::APP_ID, 'dist/main'); |
|
131 | + } |
|
132 | + |
|
133 | + protected function registerMountProviders(IMountProviderCollection $mountProviderCollection) { |
|
134 | + $mountProviderCollection->registerProvider($this->getContainer()->query(MountProvider::class)); |
|
135 | + $mountProviderCollection->registerProvider($this->getContainer()->query('ExternalMountProvider')); |
|
136 | + } |
|
137 | + |
|
138 | + protected function registerEventsScripts(IEventDispatcher $dispatcher) { |
|
139 | + // sidebar and files scripts |
|
140 | + $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); |
|
141 | + $dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class); |
|
142 | + $dispatcher->addServiceListener(ShareCreatedEvent::class, ShareInteractionListener::class); |
|
143 | + $dispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function () { |
|
144 | + \OCP\Util::addScript('files_sharing', 'dist/collaboration'); |
|
145 | + }); |
|
146 | + $dispatcher->addServiceListener(ShareCreatedEvent::class, UserShareAcceptanceListener::class); |
|
147 | + $dispatcher->addServiceListener(UserAddedEvent::class, UserAddedToGroupListener::class); |
|
148 | + |
|
149 | + // notifications api to accept incoming user shares |
|
150 | + $dispatcher->addListener('OCP\Share::postShare', function (GenericEvent $event) { |
|
151 | + /** @var Listener $listener */ |
|
152 | + $listener = $this->getContainer()->query(Listener::class); |
|
153 | + $listener->shareNotification($event); |
|
154 | + }); |
|
155 | + $dispatcher->addListener(IGroup::class . '::postAddUser', function (GenericEvent $event) { |
|
156 | + /** @var Listener $listener */ |
|
157 | + $listener = $this->getContainer()->query(Listener::class); |
|
158 | + $listener->userAddedToGroup($event); |
|
159 | + }); |
|
160 | + } |
|
161 | + |
|
162 | + protected function setupSharingMenus() { |
|
163 | + $config = \OC::$server->getConfig(); |
|
164 | + |
|
165 | + if ($config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') { |
|
166 | + return; |
|
167 | + } |
|
168 | + |
|
169 | + // show_Quick_Access stored as string |
|
170 | + \OCA\Files\App::getNavigationManager()->add(function () { |
|
171 | + $config = \OC::$server->getConfig(); |
|
172 | + $l = \OC::$server->getL10N('files_sharing'); |
|
173 | + |
|
174 | + $sharingSublistArray = []; |
|
175 | + |
|
176 | + if (\OCP\Util::isSharingDisabledForUser() === false) { |
|
177 | + $sharingSublistArray[] = [ |
|
178 | + 'id' => 'sharingout', |
|
179 | + 'appname' => 'files_sharing', |
|
180 | + 'script' => 'list.php', |
|
181 | + 'order' => 16, |
|
182 | + 'name' => $l->t('Shared with others'), |
|
183 | + ]; |
|
184 | + } |
|
185 | + |
|
186 | + $sharingSublistArray[] = [ |
|
187 | + 'id' => 'sharingin', |
|
188 | + 'appname' => 'files_sharing', |
|
189 | + 'script' => 'list.php', |
|
190 | + 'order' => 15, |
|
191 | + 'name' => $l->t('Shared with you'), |
|
192 | + ]; |
|
193 | + |
|
194 | + if (\OCP\Util::isSharingDisabledForUser() === false) { |
|
195 | + // Check if sharing by link is enabled |
|
196 | + if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') { |
|
197 | + $sharingSublistArray[] = [ |
|
198 | + 'id' => 'sharinglinks', |
|
199 | + 'appname' => 'files_sharing', |
|
200 | + 'script' => 'list.php', |
|
201 | + 'order' => 17, |
|
202 | + 'name' => $l->t('Shared by link'), |
|
203 | + ]; |
|
204 | + } |
|
205 | + } |
|
206 | + |
|
207 | + $sharingSublistArray[] = [ |
|
208 | + 'id' => 'deletedshares', |
|
209 | + 'appname' => 'files_sharing', |
|
210 | + 'script' => 'list.php', |
|
211 | + 'order' => 19, |
|
212 | + 'name' => $l->t('Deleted shares'), |
|
213 | + ]; |
|
214 | + |
|
215 | + $sharingSublistArray[] = [ |
|
216 | + 'id' => 'pendingshares', |
|
217 | + 'appname' => 'files_sharing', |
|
218 | + 'script' => 'list.php', |
|
219 | + 'order' => 19, |
|
220 | + 'name' => $l->t('Pending shares'), |
|
221 | + ]; |
|
222 | + |
|
223 | + return [ |
|
224 | + 'id' => 'shareoverview', |
|
225 | + 'appname' => 'files_sharing', |
|
226 | + 'script' => 'list.php', |
|
227 | + 'order' => 18, |
|
228 | + 'name' => $l->t('Shares'), |
|
229 | + 'classes' => 'collapsible', |
|
230 | + 'sublist' => $sharingSublistArray, |
|
231 | + 'expandedState' => 'show_sharing_menu' |
|
232 | + ]; |
|
233 | + }); |
|
234 | + } |
|
235 | 235 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | /** |
77 | 77 | * Core class wrappers |
78 | 78 | */ |
79 | - $container->registerService(Manager::class, function (SimpleContainer $c) use ($server) { |
|
79 | + $container->registerService(Manager::class, function(SimpleContainer $c) use ($server) { |
|
80 | 80 | $user = $server->getUserSession()->getUser(); |
81 | 81 | $uid = $user ? $user->getUID() : null; |
82 | 82 | return new \OCA\Files_Sharing\External\Manager( |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | $container->registerMiddleWare(OCSShareAPIMiddleware::class); |
102 | 102 | $container->registerMiddleWare(ShareInfoMiddleware::class); |
103 | 103 | |
104 | - $container->registerService('ExternalMountProvider', function (IContainer $c) { |
|
104 | + $container->registerService('ExternalMountProvider', function(IContainer $c) { |
|
105 | 105 | /** @var \OCP\IServerContainer $server */ |
106 | 106 | $server = $c->query('ServerContainer'); |
107 | 107 | return new \OCA\Files_Sharing\External\MountProvider( |
108 | 108 | $server->getDatabaseConnection(), |
109 | - function () use ($c) { |
|
109 | + function() use ($c) { |
|
110 | 110 | return $c->query(Manager::class); |
111 | 111 | }, |
112 | 112 | $server->getCloudIdManager() |
@@ -140,19 +140,19 @@ discard block |
||
140 | 140 | $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); |
141 | 141 | $dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class); |
142 | 142 | $dispatcher->addServiceListener(ShareCreatedEvent::class, ShareInteractionListener::class); |
143 | - $dispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function () { |
|
143 | + $dispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function() { |
|
144 | 144 | \OCP\Util::addScript('files_sharing', 'dist/collaboration'); |
145 | 145 | }); |
146 | 146 | $dispatcher->addServiceListener(ShareCreatedEvent::class, UserShareAcceptanceListener::class); |
147 | 147 | $dispatcher->addServiceListener(UserAddedEvent::class, UserAddedToGroupListener::class); |
148 | 148 | |
149 | 149 | // notifications api to accept incoming user shares |
150 | - $dispatcher->addListener('OCP\Share::postShare', function (GenericEvent $event) { |
|
150 | + $dispatcher->addListener('OCP\Share::postShare', function(GenericEvent $event) { |
|
151 | 151 | /** @var Listener $listener */ |
152 | 152 | $listener = $this->getContainer()->query(Listener::class); |
153 | 153 | $listener->shareNotification($event); |
154 | 154 | }); |
155 | - $dispatcher->addListener(IGroup::class . '::postAddUser', function (GenericEvent $event) { |
|
155 | + $dispatcher->addListener(IGroup::class.'::postAddUser', function(GenericEvent $event) { |
|
156 | 156 | /** @var Listener $listener */ |
157 | 157 | $listener = $this->getContainer()->query(Listener::class); |
158 | 158 | $listener->userAddedToGroup($event); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | } |
168 | 168 | |
169 | 169 | // show_Quick_Access stored as string |
170 | - \OCA\Files\App::getNavigationManager()->add(function () { |
|
170 | + \OCA\Files\App::getNavigationManager()->add(function() { |
|
171 | 171 | $config = \OC::$server->getConfig(); |
172 | 172 | $l = \OC::$server->getL10N('files_sharing'); |
173 | 173 |