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