@@ -6,58 +6,58 @@ |
||
6 | 6 | $baseDir = $vendorDir; |
7 | 7 | |
8 | 8 | return array( |
9 | - 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', |
|
10 | - 'OCA\\Files\\Activity\\FavoriteProvider' => $baseDir . '/../lib/Activity/FavoriteProvider.php', |
|
11 | - 'OCA\\Files\\Activity\\Filter\\Favorites' => $baseDir . '/../lib/Activity/Filter/Favorites.php', |
|
12 | - 'OCA\\Files\\Activity\\Filter\\FileChanges' => $baseDir . '/../lib/Activity/Filter/FileChanges.php', |
|
13 | - 'OCA\\Files\\Activity\\Helper' => $baseDir . '/../lib/Activity/Helper.php', |
|
14 | - 'OCA\\Files\\Activity\\Provider' => $baseDir . '/../lib/Activity/Provider.php', |
|
15 | - 'OCA\\Files\\Activity\\Settings\\FavoriteAction' => $baseDir . '/../lib/Activity/Settings/FavoriteAction.php', |
|
16 | - 'OCA\\Files\\Activity\\Settings\\FileActivitySettings' => $baseDir . '/../lib/Activity/Settings/FileActivitySettings.php', |
|
17 | - 'OCA\\Files\\Activity\\Settings\\FileChanged' => $baseDir . '/../lib/Activity/Settings/FileChanged.php', |
|
18 | - 'OCA\\Files\\Activity\\Settings\\FileFavoriteChanged' => $baseDir . '/../lib/Activity/Settings/FileFavoriteChanged.php', |
|
19 | - 'OCA\\Files\\App' => $baseDir . '/../lib/App.php', |
|
20 | - 'OCA\\Files\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', |
|
21 | - 'OCA\\Files\\BackgroundJob\\CleanupDirectEditingTokens' => $baseDir . '/../lib/BackgroundJob/CleanupDirectEditingTokens.php', |
|
22 | - 'OCA\\Files\\BackgroundJob\\CleanupFileLocks' => $baseDir . '/../lib/BackgroundJob/CleanupFileLocks.php', |
|
23 | - 'OCA\\Files\\BackgroundJob\\DeleteExpiredOpenLocalEditor' => $baseDir . '/../lib/BackgroundJob/DeleteExpiredOpenLocalEditor.php', |
|
24 | - 'OCA\\Files\\BackgroundJob\\DeleteOrphanedItems' => $baseDir . '/../lib/BackgroundJob/DeleteOrphanedItems.php', |
|
25 | - 'OCA\\Files\\BackgroundJob\\ScanFiles' => $baseDir . '/../lib/BackgroundJob/ScanFiles.php', |
|
26 | - 'OCA\\Files\\BackgroundJob\\TransferOwnership' => $baseDir . '/../lib/BackgroundJob/TransferOwnership.php', |
|
27 | - 'OCA\\Files\\Capabilities' => $baseDir . '/../lib/Capabilities.php', |
|
28 | - 'OCA\\Files\\Collaboration\\Resources\\Listener' => $baseDir . '/../lib/Collaboration/Resources/Listener.php', |
|
29 | - 'OCA\\Files\\Collaboration\\Resources\\ResourceProvider' => $baseDir . '/../lib/Collaboration/Resources/ResourceProvider.php', |
|
30 | - 'OCA\\Files\\Command\\DeleteOrphanedFiles' => $baseDir . '/../lib/Command/DeleteOrphanedFiles.php', |
|
31 | - 'OCA\\Files\\Command\\RepairTree' => $baseDir . '/../lib/Command/RepairTree.php', |
|
32 | - 'OCA\\Files\\Command\\Scan' => $baseDir . '/../lib/Command/Scan.php', |
|
33 | - 'OCA\\Files\\Command\\ScanAppData' => $baseDir . '/../lib/Command/ScanAppData.php', |
|
34 | - 'OCA\\Files\\Command\\TransferOwnership' => $baseDir . '/../lib/Command/TransferOwnership.php', |
|
35 | - 'OCA\\Files\\Controller\\AjaxController' => $baseDir . '/../lib/Controller/AjaxController.php', |
|
36 | - 'OCA\\Files\\Controller\\ApiController' => $baseDir . '/../lib/Controller/ApiController.php', |
|
37 | - 'OCA\\Files\\Controller\\DirectEditingController' => $baseDir . '/../lib/Controller/DirectEditingController.php', |
|
38 | - 'OCA\\Files\\Controller\\DirectEditingViewController' => $baseDir . '/../lib/Controller/DirectEditingViewController.php', |
|
39 | - 'OCA\\Files\\Controller\\OpenLocalEditorController' => $baseDir . '/../lib/Controller/OpenLocalEditorController.php', |
|
40 | - 'OCA\\Files\\Controller\\TemplateController' => $baseDir . '/../lib/Controller/TemplateController.php', |
|
41 | - 'OCA\\Files\\Controller\\TransferOwnershipController' => $baseDir . '/../lib/Controller/TransferOwnershipController.php', |
|
42 | - 'OCA\\Files\\Controller\\ViewController' => $baseDir . '/../lib/Controller/ViewController.php', |
|
43 | - 'OCA\\Files\\Db\\OpenLocalEditor' => $baseDir . '/../lib/Db/OpenLocalEditor.php', |
|
44 | - 'OCA\\Files\\Db\\OpenLocalEditorMapper' => $baseDir . '/../lib/Db/OpenLocalEditorMapper.php', |
|
45 | - 'OCA\\Files\\Db\\TransferOwnership' => $baseDir . '/../lib/Db/TransferOwnership.php', |
|
46 | - 'OCA\\Files\\Db\\TransferOwnershipMapper' => $baseDir . '/../lib/Db/TransferOwnershipMapper.php', |
|
47 | - 'OCA\\Files\\DirectEditingCapabilities' => $baseDir . '/../lib/DirectEditingCapabilities.php', |
|
48 | - 'OCA\\Files\\Event\\LoadAdditionalScriptsEvent' => $baseDir . '/../lib/Event/LoadAdditionalScriptsEvent.php', |
|
49 | - 'OCA\\Files\\Event\\LoadSidebar' => $baseDir . '/../lib/Event/LoadSidebar.php', |
|
50 | - 'OCA\\Files\\Exception\\TransferOwnershipException' => $baseDir . '/../lib/Exception/TransferOwnershipException.php', |
|
51 | - 'OCA\\Files\\Helper' => $baseDir . '/../lib/Helper.php', |
|
52 | - 'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => $baseDir . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php', |
|
53 | - 'OCA\\Files\\Listener\\LoadSidebarListener' => $baseDir . '/../lib/Listener/LoadSidebarListener.php', |
|
54 | - 'OCA\\Files\\Migration\\Version11301Date20191205150729' => $baseDir . '/../lib/Migration/Version11301Date20191205150729.php', |
|
55 | - 'OCA\\Files\\Migration\\Version12101Date20221011153334' => $baseDir . '/../lib/Migration/Version12101Date20221011153334.php', |
|
56 | - 'OCA\\Files\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php', |
|
57 | - 'OCA\\Files\\Search\\FilesSearchProvider' => $baseDir . '/../lib/Search/FilesSearchProvider.php', |
|
58 | - 'OCA\\Files\\Service\\DirectEditingService' => $baseDir . '/../lib/Service/DirectEditingService.php', |
|
59 | - 'OCA\\Files\\Service\\OwnershipTransferService' => $baseDir . '/../lib/Service/OwnershipTransferService.php', |
|
60 | - 'OCA\\Files\\Service\\TagService' => $baseDir . '/../lib/Service/TagService.php', |
|
61 | - 'OCA\\Files\\Service\\UserConfig' => $baseDir . '/../lib/Service/UserConfig.php', |
|
62 | - 'OCA\\Files\\Settings\\PersonalSettings' => $baseDir . '/../lib/Settings/PersonalSettings.php', |
|
9 | + 'Composer\\InstalledVersions' => $vendorDir.'/composer/InstalledVersions.php', |
|
10 | + 'OCA\\Files\\Activity\\FavoriteProvider' => $baseDir.'/../lib/Activity/FavoriteProvider.php', |
|
11 | + 'OCA\\Files\\Activity\\Filter\\Favorites' => $baseDir.'/../lib/Activity/Filter/Favorites.php', |
|
12 | + 'OCA\\Files\\Activity\\Filter\\FileChanges' => $baseDir.'/../lib/Activity/Filter/FileChanges.php', |
|
13 | + 'OCA\\Files\\Activity\\Helper' => $baseDir.'/../lib/Activity/Helper.php', |
|
14 | + 'OCA\\Files\\Activity\\Provider' => $baseDir.'/../lib/Activity/Provider.php', |
|
15 | + 'OCA\\Files\\Activity\\Settings\\FavoriteAction' => $baseDir.'/../lib/Activity/Settings/FavoriteAction.php', |
|
16 | + 'OCA\\Files\\Activity\\Settings\\FileActivitySettings' => $baseDir.'/../lib/Activity/Settings/FileActivitySettings.php', |
|
17 | + 'OCA\\Files\\Activity\\Settings\\FileChanged' => $baseDir.'/../lib/Activity/Settings/FileChanged.php', |
|
18 | + 'OCA\\Files\\Activity\\Settings\\FileFavoriteChanged' => $baseDir.'/../lib/Activity/Settings/FileFavoriteChanged.php', |
|
19 | + 'OCA\\Files\\App' => $baseDir.'/../lib/App.php', |
|
20 | + 'OCA\\Files\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php', |
|
21 | + 'OCA\\Files\\BackgroundJob\\CleanupDirectEditingTokens' => $baseDir.'/../lib/BackgroundJob/CleanupDirectEditingTokens.php', |
|
22 | + 'OCA\\Files\\BackgroundJob\\CleanupFileLocks' => $baseDir.'/../lib/BackgroundJob/CleanupFileLocks.php', |
|
23 | + 'OCA\\Files\\BackgroundJob\\DeleteExpiredOpenLocalEditor' => $baseDir.'/../lib/BackgroundJob/DeleteExpiredOpenLocalEditor.php', |
|
24 | + 'OCA\\Files\\BackgroundJob\\DeleteOrphanedItems' => $baseDir.'/../lib/BackgroundJob/DeleteOrphanedItems.php', |
|
25 | + 'OCA\\Files\\BackgroundJob\\ScanFiles' => $baseDir.'/../lib/BackgroundJob/ScanFiles.php', |
|
26 | + 'OCA\\Files\\BackgroundJob\\TransferOwnership' => $baseDir.'/../lib/BackgroundJob/TransferOwnership.php', |
|
27 | + 'OCA\\Files\\Capabilities' => $baseDir.'/../lib/Capabilities.php', |
|
28 | + 'OCA\\Files\\Collaboration\\Resources\\Listener' => $baseDir.'/../lib/Collaboration/Resources/Listener.php', |
|
29 | + 'OCA\\Files\\Collaboration\\Resources\\ResourceProvider' => $baseDir.'/../lib/Collaboration/Resources/ResourceProvider.php', |
|
30 | + 'OCA\\Files\\Command\\DeleteOrphanedFiles' => $baseDir.'/../lib/Command/DeleteOrphanedFiles.php', |
|
31 | + 'OCA\\Files\\Command\\RepairTree' => $baseDir.'/../lib/Command/RepairTree.php', |
|
32 | + 'OCA\\Files\\Command\\Scan' => $baseDir.'/../lib/Command/Scan.php', |
|
33 | + 'OCA\\Files\\Command\\ScanAppData' => $baseDir.'/../lib/Command/ScanAppData.php', |
|
34 | + 'OCA\\Files\\Command\\TransferOwnership' => $baseDir.'/../lib/Command/TransferOwnership.php', |
|
35 | + 'OCA\\Files\\Controller\\AjaxController' => $baseDir.'/../lib/Controller/AjaxController.php', |
|
36 | + 'OCA\\Files\\Controller\\ApiController' => $baseDir.'/../lib/Controller/ApiController.php', |
|
37 | + 'OCA\\Files\\Controller\\DirectEditingController' => $baseDir.'/../lib/Controller/DirectEditingController.php', |
|
38 | + 'OCA\\Files\\Controller\\DirectEditingViewController' => $baseDir.'/../lib/Controller/DirectEditingViewController.php', |
|
39 | + 'OCA\\Files\\Controller\\OpenLocalEditorController' => $baseDir.'/../lib/Controller/OpenLocalEditorController.php', |
|
40 | + 'OCA\\Files\\Controller\\TemplateController' => $baseDir.'/../lib/Controller/TemplateController.php', |
|
41 | + 'OCA\\Files\\Controller\\TransferOwnershipController' => $baseDir.'/../lib/Controller/TransferOwnershipController.php', |
|
42 | + 'OCA\\Files\\Controller\\ViewController' => $baseDir.'/../lib/Controller/ViewController.php', |
|
43 | + 'OCA\\Files\\Db\\OpenLocalEditor' => $baseDir.'/../lib/Db/OpenLocalEditor.php', |
|
44 | + 'OCA\\Files\\Db\\OpenLocalEditorMapper' => $baseDir.'/../lib/Db/OpenLocalEditorMapper.php', |
|
45 | + 'OCA\\Files\\Db\\TransferOwnership' => $baseDir.'/../lib/Db/TransferOwnership.php', |
|
46 | + 'OCA\\Files\\Db\\TransferOwnershipMapper' => $baseDir.'/../lib/Db/TransferOwnershipMapper.php', |
|
47 | + 'OCA\\Files\\DirectEditingCapabilities' => $baseDir.'/../lib/DirectEditingCapabilities.php', |
|
48 | + 'OCA\\Files\\Event\\LoadAdditionalScriptsEvent' => $baseDir.'/../lib/Event/LoadAdditionalScriptsEvent.php', |
|
49 | + 'OCA\\Files\\Event\\LoadSidebar' => $baseDir.'/../lib/Event/LoadSidebar.php', |
|
50 | + 'OCA\\Files\\Exception\\TransferOwnershipException' => $baseDir.'/../lib/Exception/TransferOwnershipException.php', |
|
51 | + 'OCA\\Files\\Helper' => $baseDir.'/../lib/Helper.php', |
|
52 | + 'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => $baseDir.'/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php', |
|
53 | + 'OCA\\Files\\Listener\\LoadSidebarListener' => $baseDir.'/../lib/Listener/LoadSidebarListener.php', |
|
54 | + 'OCA\\Files\\Migration\\Version11301Date20191205150729' => $baseDir.'/../lib/Migration/Version11301Date20191205150729.php', |
|
55 | + 'OCA\\Files\\Migration\\Version12101Date20221011153334' => $baseDir.'/../lib/Migration/Version12101Date20221011153334.php', |
|
56 | + 'OCA\\Files\\Notification\\Notifier' => $baseDir.'/../lib/Notification/Notifier.php', |
|
57 | + 'OCA\\Files\\Search\\FilesSearchProvider' => $baseDir.'/../lib/Search/FilesSearchProvider.php', |
|
58 | + 'OCA\\Files\\Service\\DirectEditingService' => $baseDir.'/../lib/Service/DirectEditingService.php', |
|
59 | + 'OCA\\Files\\Service\\OwnershipTransferService' => $baseDir.'/../lib/Service/OwnershipTransferService.php', |
|
60 | + 'OCA\\Files\\Service\\TagService' => $baseDir.'/../lib/Service/TagService.php', |
|
61 | + 'OCA\\Files\\Service\\UserConfig' => $baseDir.'/../lib/Service/UserConfig.php', |
|
62 | + 'OCA\\Files\\Settings\\PersonalSettings' => $baseDir.'/../lib/Settings/PersonalSettings.php', |
|
63 | 63 | ); |
@@ -6,80 +6,80 @@ |
||
6 | 6 | |
7 | 7 | class ComposerStaticInitFiles |
8 | 8 | { |
9 | - public static $prefixLengthsPsr4 = array ( |
|
9 | + public static $prefixLengthsPsr4 = array( |
|
10 | 10 | 'O' => |
11 | - array ( |
|
11 | + array( |
|
12 | 12 | 'OCA\\Files\\' => 10, |
13 | 13 | ), |
14 | 14 | ); |
15 | 15 | |
16 | - public static $prefixDirsPsr4 = array ( |
|
16 | + public static $prefixDirsPsr4 = array( |
|
17 | 17 | 'OCA\\Files\\' => |
18 | - array ( |
|
19 | - 0 => __DIR__ . '/..' . '/../lib', |
|
18 | + array( |
|
19 | + 0 => __DIR__.'/..'.'/../lib', |
|
20 | 20 | ), |
21 | 21 | ); |
22 | 22 | |
23 | - public static $classMap = array ( |
|
24 | - 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
|
25 | - 'OCA\\Files\\Activity\\FavoriteProvider' => __DIR__ . '/..' . '/../lib/Activity/FavoriteProvider.php', |
|
26 | - 'OCA\\Files\\Activity\\Filter\\Favorites' => __DIR__ . '/..' . '/../lib/Activity/Filter/Favorites.php', |
|
27 | - 'OCA\\Files\\Activity\\Filter\\FileChanges' => __DIR__ . '/..' . '/../lib/Activity/Filter/FileChanges.php', |
|
28 | - 'OCA\\Files\\Activity\\Helper' => __DIR__ . '/..' . '/../lib/Activity/Helper.php', |
|
29 | - 'OCA\\Files\\Activity\\Provider' => __DIR__ . '/..' . '/../lib/Activity/Provider.php', |
|
30 | - 'OCA\\Files\\Activity\\Settings\\FavoriteAction' => __DIR__ . '/..' . '/../lib/Activity/Settings/FavoriteAction.php', |
|
31 | - 'OCA\\Files\\Activity\\Settings\\FileActivitySettings' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileActivitySettings.php', |
|
32 | - 'OCA\\Files\\Activity\\Settings\\FileChanged' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileChanged.php', |
|
33 | - 'OCA\\Files\\Activity\\Settings\\FileFavoriteChanged' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileFavoriteChanged.php', |
|
34 | - 'OCA\\Files\\App' => __DIR__ . '/..' . '/../lib/App.php', |
|
35 | - 'OCA\\Files\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', |
|
36 | - 'OCA\\Files\\BackgroundJob\\CleanupDirectEditingTokens' => __DIR__ . '/..' . '/../lib/BackgroundJob/CleanupDirectEditingTokens.php', |
|
37 | - 'OCA\\Files\\BackgroundJob\\CleanupFileLocks' => __DIR__ . '/..' . '/../lib/BackgroundJob/CleanupFileLocks.php', |
|
38 | - 'OCA\\Files\\BackgroundJob\\DeleteExpiredOpenLocalEditor' => __DIR__ . '/..' . '/../lib/BackgroundJob/DeleteExpiredOpenLocalEditor.php', |
|
39 | - 'OCA\\Files\\BackgroundJob\\DeleteOrphanedItems' => __DIR__ . '/..' . '/../lib/BackgroundJob/DeleteOrphanedItems.php', |
|
40 | - 'OCA\\Files\\BackgroundJob\\ScanFiles' => __DIR__ . '/..' . '/../lib/BackgroundJob/ScanFiles.php', |
|
41 | - 'OCA\\Files\\BackgroundJob\\TransferOwnership' => __DIR__ . '/..' . '/../lib/BackgroundJob/TransferOwnership.php', |
|
42 | - 'OCA\\Files\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php', |
|
43 | - 'OCA\\Files\\Collaboration\\Resources\\Listener' => __DIR__ . '/..' . '/../lib/Collaboration/Resources/Listener.php', |
|
44 | - 'OCA\\Files\\Collaboration\\Resources\\ResourceProvider' => __DIR__ . '/..' . '/../lib/Collaboration/Resources/ResourceProvider.php', |
|
45 | - 'OCA\\Files\\Command\\DeleteOrphanedFiles' => __DIR__ . '/..' . '/../lib/Command/DeleteOrphanedFiles.php', |
|
46 | - 'OCA\\Files\\Command\\RepairTree' => __DIR__ . '/..' . '/../lib/Command/RepairTree.php', |
|
47 | - 'OCA\\Files\\Command\\Scan' => __DIR__ . '/..' . '/../lib/Command/Scan.php', |
|
48 | - 'OCA\\Files\\Command\\ScanAppData' => __DIR__ . '/..' . '/../lib/Command/ScanAppData.php', |
|
49 | - 'OCA\\Files\\Command\\TransferOwnership' => __DIR__ . '/..' . '/../lib/Command/TransferOwnership.php', |
|
50 | - 'OCA\\Files\\Controller\\AjaxController' => __DIR__ . '/..' . '/../lib/Controller/AjaxController.php', |
|
51 | - 'OCA\\Files\\Controller\\ApiController' => __DIR__ . '/..' . '/../lib/Controller/ApiController.php', |
|
52 | - 'OCA\\Files\\Controller\\DirectEditingController' => __DIR__ . '/..' . '/../lib/Controller/DirectEditingController.php', |
|
53 | - 'OCA\\Files\\Controller\\DirectEditingViewController' => __DIR__ . '/..' . '/../lib/Controller/DirectEditingViewController.php', |
|
54 | - 'OCA\\Files\\Controller\\OpenLocalEditorController' => __DIR__ . '/..' . '/../lib/Controller/OpenLocalEditorController.php', |
|
55 | - 'OCA\\Files\\Controller\\TemplateController' => __DIR__ . '/..' . '/../lib/Controller/TemplateController.php', |
|
56 | - 'OCA\\Files\\Controller\\TransferOwnershipController' => __DIR__ . '/..' . '/../lib/Controller/TransferOwnershipController.php', |
|
57 | - 'OCA\\Files\\Controller\\ViewController' => __DIR__ . '/..' . '/../lib/Controller/ViewController.php', |
|
58 | - 'OCA\\Files\\Db\\OpenLocalEditor' => __DIR__ . '/..' . '/../lib/Db/OpenLocalEditor.php', |
|
59 | - 'OCA\\Files\\Db\\OpenLocalEditorMapper' => __DIR__ . '/..' . '/../lib/Db/OpenLocalEditorMapper.php', |
|
60 | - 'OCA\\Files\\Db\\TransferOwnership' => __DIR__ . '/..' . '/../lib/Db/TransferOwnership.php', |
|
61 | - 'OCA\\Files\\Db\\TransferOwnershipMapper' => __DIR__ . '/..' . '/../lib/Db/TransferOwnershipMapper.php', |
|
62 | - 'OCA\\Files\\DirectEditingCapabilities' => __DIR__ . '/..' . '/../lib/DirectEditingCapabilities.php', |
|
63 | - 'OCA\\Files\\Event\\LoadAdditionalScriptsEvent' => __DIR__ . '/..' . '/../lib/Event/LoadAdditionalScriptsEvent.php', |
|
64 | - 'OCA\\Files\\Event\\LoadSidebar' => __DIR__ . '/..' . '/../lib/Event/LoadSidebar.php', |
|
65 | - 'OCA\\Files\\Exception\\TransferOwnershipException' => __DIR__ . '/..' . '/../lib/Exception/TransferOwnershipException.php', |
|
66 | - 'OCA\\Files\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php', |
|
67 | - 'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => __DIR__ . '/..' . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php', |
|
68 | - 'OCA\\Files\\Listener\\LoadSidebarListener' => __DIR__ . '/..' . '/../lib/Listener/LoadSidebarListener.php', |
|
69 | - 'OCA\\Files\\Migration\\Version11301Date20191205150729' => __DIR__ . '/..' . '/../lib/Migration/Version11301Date20191205150729.php', |
|
70 | - 'OCA\\Files\\Migration\\Version12101Date20221011153334' => __DIR__ . '/..' . '/../lib/Migration/Version12101Date20221011153334.php', |
|
71 | - 'OCA\\Files\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php', |
|
72 | - 'OCA\\Files\\Search\\FilesSearchProvider' => __DIR__ . '/..' . '/../lib/Search/FilesSearchProvider.php', |
|
73 | - 'OCA\\Files\\Service\\DirectEditingService' => __DIR__ . '/..' . '/../lib/Service/DirectEditingService.php', |
|
74 | - 'OCA\\Files\\Service\\OwnershipTransferService' => __DIR__ . '/..' . '/../lib/Service/OwnershipTransferService.php', |
|
75 | - 'OCA\\Files\\Service\\TagService' => __DIR__ . '/..' . '/../lib/Service/TagService.php', |
|
76 | - 'OCA\\Files\\Service\\UserConfig' => __DIR__ . '/..' . '/../lib/Service/UserConfig.php', |
|
77 | - 'OCA\\Files\\Settings\\PersonalSettings' => __DIR__ . '/..' . '/../lib/Settings/PersonalSettings.php', |
|
23 | + public static $classMap = array( |
|
24 | + 'Composer\\InstalledVersions' => __DIR__.'/..'.'/composer/InstalledVersions.php', |
|
25 | + 'OCA\\Files\\Activity\\FavoriteProvider' => __DIR__.'/..'.'/../lib/Activity/FavoriteProvider.php', |
|
26 | + 'OCA\\Files\\Activity\\Filter\\Favorites' => __DIR__.'/..'.'/../lib/Activity/Filter/Favorites.php', |
|
27 | + 'OCA\\Files\\Activity\\Filter\\FileChanges' => __DIR__.'/..'.'/../lib/Activity/Filter/FileChanges.php', |
|
28 | + 'OCA\\Files\\Activity\\Helper' => __DIR__.'/..'.'/../lib/Activity/Helper.php', |
|
29 | + 'OCA\\Files\\Activity\\Provider' => __DIR__.'/..'.'/../lib/Activity/Provider.php', |
|
30 | + 'OCA\\Files\\Activity\\Settings\\FavoriteAction' => __DIR__.'/..'.'/../lib/Activity/Settings/FavoriteAction.php', |
|
31 | + 'OCA\\Files\\Activity\\Settings\\FileActivitySettings' => __DIR__.'/..'.'/../lib/Activity/Settings/FileActivitySettings.php', |
|
32 | + 'OCA\\Files\\Activity\\Settings\\FileChanged' => __DIR__.'/..'.'/../lib/Activity/Settings/FileChanged.php', |
|
33 | + 'OCA\\Files\\Activity\\Settings\\FileFavoriteChanged' => __DIR__.'/..'.'/../lib/Activity/Settings/FileFavoriteChanged.php', |
|
34 | + 'OCA\\Files\\App' => __DIR__.'/..'.'/../lib/App.php', |
|
35 | + 'OCA\\Files\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php', |
|
36 | + 'OCA\\Files\\BackgroundJob\\CleanupDirectEditingTokens' => __DIR__.'/..'.'/../lib/BackgroundJob/CleanupDirectEditingTokens.php', |
|
37 | + 'OCA\\Files\\BackgroundJob\\CleanupFileLocks' => __DIR__.'/..'.'/../lib/BackgroundJob/CleanupFileLocks.php', |
|
38 | + 'OCA\\Files\\BackgroundJob\\DeleteExpiredOpenLocalEditor' => __DIR__.'/..'.'/../lib/BackgroundJob/DeleteExpiredOpenLocalEditor.php', |
|
39 | + 'OCA\\Files\\BackgroundJob\\DeleteOrphanedItems' => __DIR__.'/..'.'/../lib/BackgroundJob/DeleteOrphanedItems.php', |
|
40 | + 'OCA\\Files\\BackgroundJob\\ScanFiles' => __DIR__.'/..'.'/../lib/BackgroundJob/ScanFiles.php', |
|
41 | + 'OCA\\Files\\BackgroundJob\\TransferOwnership' => __DIR__.'/..'.'/../lib/BackgroundJob/TransferOwnership.php', |
|
42 | + 'OCA\\Files\\Capabilities' => __DIR__.'/..'.'/../lib/Capabilities.php', |
|
43 | + 'OCA\\Files\\Collaboration\\Resources\\Listener' => __DIR__.'/..'.'/../lib/Collaboration/Resources/Listener.php', |
|
44 | + 'OCA\\Files\\Collaboration\\Resources\\ResourceProvider' => __DIR__.'/..'.'/../lib/Collaboration/Resources/ResourceProvider.php', |
|
45 | + 'OCA\\Files\\Command\\DeleteOrphanedFiles' => __DIR__.'/..'.'/../lib/Command/DeleteOrphanedFiles.php', |
|
46 | + 'OCA\\Files\\Command\\RepairTree' => __DIR__.'/..'.'/../lib/Command/RepairTree.php', |
|
47 | + 'OCA\\Files\\Command\\Scan' => __DIR__.'/..'.'/../lib/Command/Scan.php', |
|
48 | + 'OCA\\Files\\Command\\ScanAppData' => __DIR__.'/..'.'/../lib/Command/ScanAppData.php', |
|
49 | + 'OCA\\Files\\Command\\TransferOwnership' => __DIR__.'/..'.'/../lib/Command/TransferOwnership.php', |
|
50 | + 'OCA\\Files\\Controller\\AjaxController' => __DIR__.'/..'.'/../lib/Controller/AjaxController.php', |
|
51 | + 'OCA\\Files\\Controller\\ApiController' => __DIR__.'/..'.'/../lib/Controller/ApiController.php', |
|
52 | + 'OCA\\Files\\Controller\\DirectEditingController' => __DIR__.'/..'.'/../lib/Controller/DirectEditingController.php', |
|
53 | + 'OCA\\Files\\Controller\\DirectEditingViewController' => __DIR__.'/..'.'/../lib/Controller/DirectEditingViewController.php', |
|
54 | + 'OCA\\Files\\Controller\\OpenLocalEditorController' => __DIR__.'/..'.'/../lib/Controller/OpenLocalEditorController.php', |
|
55 | + 'OCA\\Files\\Controller\\TemplateController' => __DIR__.'/..'.'/../lib/Controller/TemplateController.php', |
|
56 | + 'OCA\\Files\\Controller\\TransferOwnershipController' => __DIR__.'/..'.'/../lib/Controller/TransferOwnershipController.php', |
|
57 | + 'OCA\\Files\\Controller\\ViewController' => __DIR__.'/..'.'/../lib/Controller/ViewController.php', |
|
58 | + 'OCA\\Files\\Db\\OpenLocalEditor' => __DIR__.'/..'.'/../lib/Db/OpenLocalEditor.php', |
|
59 | + 'OCA\\Files\\Db\\OpenLocalEditorMapper' => __DIR__.'/..'.'/../lib/Db/OpenLocalEditorMapper.php', |
|
60 | + 'OCA\\Files\\Db\\TransferOwnership' => __DIR__.'/..'.'/../lib/Db/TransferOwnership.php', |
|
61 | + 'OCA\\Files\\Db\\TransferOwnershipMapper' => __DIR__.'/..'.'/../lib/Db/TransferOwnershipMapper.php', |
|
62 | + 'OCA\\Files\\DirectEditingCapabilities' => __DIR__.'/..'.'/../lib/DirectEditingCapabilities.php', |
|
63 | + 'OCA\\Files\\Event\\LoadAdditionalScriptsEvent' => __DIR__.'/..'.'/../lib/Event/LoadAdditionalScriptsEvent.php', |
|
64 | + 'OCA\\Files\\Event\\LoadSidebar' => __DIR__.'/..'.'/../lib/Event/LoadSidebar.php', |
|
65 | + 'OCA\\Files\\Exception\\TransferOwnershipException' => __DIR__.'/..'.'/../lib/Exception/TransferOwnershipException.php', |
|
66 | + 'OCA\\Files\\Helper' => __DIR__.'/..'.'/../lib/Helper.php', |
|
67 | + 'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => __DIR__.'/..'.'/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php', |
|
68 | + 'OCA\\Files\\Listener\\LoadSidebarListener' => __DIR__.'/..'.'/../lib/Listener/LoadSidebarListener.php', |
|
69 | + 'OCA\\Files\\Migration\\Version11301Date20191205150729' => __DIR__.'/..'.'/../lib/Migration/Version11301Date20191205150729.php', |
|
70 | + 'OCA\\Files\\Migration\\Version12101Date20221011153334' => __DIR__.'/..'.'/../lib/Migration/Version12101Date20221011153334.php', |
|
71 | + 'OCA\\Files\\Notification\\Notifier' => __DIR__.'/..'.'/../lib/Notification/Notifier.php', |
|
72 | + 'OCA\\Files\\Search\\FilesSearchProvider' => __DIR__.'/..'.'/../lib/Search/FilesSearchProvider.php', |
|
73 | + 'OCA\\Files\\Service\\DirectEditingService' => __DIR__.'/..'.'/../lib/Service/DirectEditingService.php', |
|
74 | + 'OCA\\Files\\Service\\OwnershipTransferService' => __DIR__.'/..'.'/../lib/Service/OwnershipTransferService.php', |
|
75 | + 'OCA\\Files\\Service\\TagService' => __DIR__.'/..'.'/../lib/Service/TagService.php', |
|
76 | + 'OCA\\Files\\Service\\UserConfig' => __DIR__.'/..'.'/../lib/Service/UserConfig.php', |
|
77 | + 'OCA\\Files\\Settings\\PersonalSettings' => __DIR__.'/..'.'/../lib/Settings/PersonalSettings.php', |
|
78 | 78 | ); |
79 | 79 | |
80 | 80 | public static function getInitializer(ClassLoader $loader) |
81 | 81 | { |
82 | - return \Closure::bind(function () use ($loader) { |
|
82 | + return \Closure::bind(function() use ($loader) { |
|
83 | 83 | $loader->prefixLengthsPsr4 = ComposerStaticInitFiles::$prefixLengthsPsr4; |
84 | 84 | $loader->prefixDirsPsr4 = ComposerStaticInitFiles::$prefixDirsPsr4; |
85 | 85 | $loader->classMap = ComposerStaticInitFiles::$classMap; |
@@ -28,117 +28,117 @@ |
||
28 | 28 | use OCP\IUserSession; |
29 | 29 | |
30 | 30 | class UserConfig { |
31 | - const ALLOWED_CONFIGS = [ |
|
32 | - [ |
|
33 | - // Whether to crop the files previews or not in the files list |
|
34 | - 'key' => 'crop_image_previews', |
|
35 | - 'default' => true, |
|
36 | - 'allowed' => [true, false], |
|
37 | - ], |
|
38 | - [ |
|
39 | - // Whether to show the hidden files or not in the files list |
|
40 | - 'key' => 'show_hidden', |
|
41 | - 'default' => false, |
|
42 | - 'allowed' => [true, false], |
|
43 | - ], |
|
44 | - ]; |
|
31 | + const ALLOWED_CONFIGS = [ |
|
32 | + [ |
|
33 | + // Whether to crop the files previews or not in the files list |
|
34 | + 'key' => 'crop_image_previews', |
|
35 | + 'default' => true, |
|
36 | + 'allowed' => [true, false], |
|
37 | + ], |
|
38 | + [ |
|
39 | + // Whether to show the hidden files or not in the files list |
|
40 | + 'key' => 'show_hidden', |
|
41 | + 'default' => false, |
|
42 | + 'allowed' => [true, false], |
|
43 | + ], |
|
44 | + ]; |
|
45 | 45 | |
46 | - protected IConfig $config; |
|
47 | - protected ?IUser $user = null; |
|
46 | + protected IConfig $config; |
|
47 | + protected ?IUser $user = null; |
|
48 | 48 | |
49 | - public function __construct(IConfig $config, IUserSession $userSession) { |
|
50 | - $this->config = $config; |
|
51 | - $this->user = $userSession->getUser(); |
|
52 | - } |
|
49 | + public function __construct(IConfig $config, IUserSession $userSession) { |
|
50 | + $this->config = $config; |
|
51 | + $this->user = $userSession->getUser(); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Get the list of all allowed user config keys |
|
56 | - * @return string[] |
|
57 | - */ |
|
58 | - public function getAllowedConfigKeys(): array { |
|
59 | - return array_map(function($config) { |
|
60 | - return $config['key']; |
|
61 | - }, self::ALLOWED_CONFIGS); |
|
62 | - } |
|
54 | + /** |
|
55 | + * Get the list of all allowed user config keys |
|
56 | + * @return string[] |
|
57 | + */ |
|
58 | + public function getAllowedConfigKeys(): array { |
|
59 | + return array_map(function($config) { |
|
60 | + return $config['key']; |
|
61 | + }, self::ALLOWED_CONFIGS); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Get the list of allowed config values for a given key |
|
66 | - * |
|
67 | - * @param string $key a valid config key |
|
68 | - * @return array |
|
69 | - */ |
|
70 | - private function getAllowedConfigValues(string $key): array { |
|
71 | - foreach (self::ALLOWED_CONFIGS as $config) { |
|
72 | - if ($config['key'] === $key) { |
|
73 | - return $config['allowed']; |
|
74 | - } |
|
75 | - } |
|
76 | - return []; |
|
77 | - } |
|
64 | + /** |
|
65 | + * Get the list of allowed config values for a given key |
|
66 | + * |
|
67 | + * @param string $key a valid config key |
|
68 | + * @return array |
|
69 | + */ |
|
70 | + private function getAllowedConfigValues(string $key): array { |
|
71 | + foreach (self::ALLOWED_CONFIGS as $config) { |
|
72 | + if ($config['key'] === $key) { |
|
73 | + return $config['allowed']; |
|
74 | + } |
|
75 | + } |
|
76 | + return []; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Get the default config value for a given key |
|
81 | - * |
|
82 | - * @param string $key a valid config key |
|
83 | - * @return string|bool |
|
84 | - */ |
|
85 | - private function getDefaultConfigValue(string $key) { |
|
86 | - foreach (self::ALLOWED_CONFIGS as $config) { |
|
87 | - if ($config['key'] === $key) { |
|
88 | - return $config['default']; |
|
89 | - } |
|
90 | - } |
|
91 | - return ''; |
|
92 | - } |
|
79 | + /** |
|
80 | + * Get the default config value for a given key |
|
81 | + * |
|
82 | + * @param string $key a valid config key |
|
83 | + * @return string|bool |
|
84 | + */ |
|
85 | + private function getDefaultConfigValue(string $key) { |
|
86 | + foreach (self::ALLOWED_CONFIGS as $config) { |
|
87 | + if ($config['key'] === $key) { |
|
88 | + return $config['default']; |
|
89 | + } |
|
90 | + } |
|
91 | + return ''; |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * Set a user config |
|
96 | - * |
|
97 | - * @param string $key |
|
98 | - * @param string|bool $value |
|
99 | - * @throws \Exception |
|
100 | - * @throws \InvalidArgumentException |
|
101 | - */ |
|
102 | - public function setConfig(string $key, $value): void { |
|
103 | - if ($this->user === null) { |
|
104 | - throw new \Exception('No user logged in'); |
|
105 | - } |
|
94 | + /** |
|
95 | + * Set a user config |
|
96 | + * |
|
97 | + * @param string $key |
|
98 | + * @param string|bool $value |
|
99 | + * @throws \Exception |
|
100 | + * @throws \InvalidArgumentException |
|
101 | + */ |
|
102 | + public function setConfig(string $key, $value): void { |
|
103 | + if ($this->user === null) { |
|
104 | + throw new \Exception('No user logged in'); |
|
105 | + } |
|
106 | 106 | |
107 | - if (!in_array($key, $this->getAllowedConfigKeys())) { |
|
108 | - throw new \InvalidArgumentException('Unknown config key'); |
|
109 | - } |
|
107 | + if (!in_array($key, $this->getAllowedConfigKeys())) { |
|
108 | + throw new \InvalidArgumentException('Unknown config key'); |
|
109 | + } |
|
110 | 110 | |
111 | - if (!in_array($value, $this->getAllowedConfigValues($key))) { |
|
112 | - throw new \InvalidArgumentException('Invalid config value'); |
|
113 | - } |
|
111 | + if (!in_array($value, $this->getAllowedConfigValues($key))) { |
|
112 | + throw new \InvalidArgumentException('Invalid config value'); |
|
113 | + } |
|
114 | 114 | |
115 | - if (is_bool($value)) { |
|
116 | - $value = $value ? '1' : '0'; |
|
117 | - } |
|
115 | + if (is_bool($value)) { |
|
116 | + $value = $value ? '1' : '0'; |
|
117 | + } |
|
118 | 118 | |
119 | - $this->config->setUserValue($this->user->getUID(), Application::APP_ID, $key, $value); |
|
120 | - } |
|
119 | + $this->config->setUserValue($this->user->getUID(), Application::APP_ID, $key, $value); |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Get the current user configs array |
|
124 | - * |
|
125 | - * @return array |
|
126 | - */ |
|
127 | - public function getConfigs(): array { |
|
128 | - if ($this->user === null) { |
|
129 | - throw new \Exception('No user logged in'); |
|
130 | - } |
|
122 | + /** |
|
123 | + * Get the current user configs array |
|
124 | + * |
|
125 | + * @return array |
|
126 | + */ |
|
127 | + public function getConfigs(): array { |
|
128 | + if ($this->user === null) { |
|
129 | + throw new \Exception('No user logged in'); |
|
130 | + } |
|
131 | 131 | |
132 | - $userId = $this->user->getUID(); |
|
133 | - $userConfigs = array_map(function(string $key) use ($userId) { |
|
134 | - $value = $this->config->getUserValue($userId, Application::APP_ID, $key, $this->getDefaultConfigValue($key)); |
|
135 | - // If the default is expected to be a boolean, we need to cast the value |
|
136 | - if (is_bool($this->getDefaultConfigValue($key))) { |
|
137 | - return $value === '1'; |
|
138 | - } |
|
139 | - return $value; |
|
140 | - }, $this->getAllowedConfigKeys()); |
|
132 | + $userId = $this->user->getUID(); |
|
133 | + $userConfigs = array_map(function(string $key) use ($userId) { |
|
134 | + $value = $this->config->getUserValue($userId, Application::APP_ID, $key, $this->getDefaultConfigValue($key)); |
|
135 | + // If the default is expected to be a boolean, we need to cast the value |
|
136 | + if (is_bool($this->getDefaultConfigValue($key))) { |
|
137 | + return $value === '1'; |
|
138 | + } |
|
139 | + return $value; |
|
140 | + }, $this->getAllowedConfigKeys()); |
|
141 | 141 | |
142 | - return array_combine($this->getAllowedConfigKeys(), $userConfigs); |
|
143 | - } |
|
142 | + return array_combine($this->getAllowedConfigKeys(), $userConfigs); |
|
143 | + } |
|
144 | 144 | } |
@@ -67,118 +67,118 @@ |
||
67 | 67 | use Psr\Container\ContainerInterface; |
68 | 68 | |
69 | 69 | class Application extends App implements IBootstrap { |
70 | - public const APP_ID = 'files'; |
|
71 | - |
|
72 | - public function __construct(array $urlParams = []) { |
|
73 | - parent::__construct(self::APP_ID, $urlParams); |
|
74 | - } |
|
75 | - |
|
76 | - public function register(IRegistrationContext $context): void { |
|
77 | - /** |
|
78 | - * Controllers |
|
79 | - */ |
|
80 | - $context->registerService('APIController', function (ContainerInterface $c) { |
|
81 | - /** @var IServerContainer $server */ |
|
82 | - $server = $c->get(IServerContainer::class); |
|
83 | - |
|
84 | - return new ApiController( |
|
85 | - $c->get('AppName'), |
|
86 | - $c->get(IRequest::class), |
|
87 | - $c->get(IUserSession::class), |
|
88 | - $c->get(TagService::class), |
|
89 | - $c->get(IPreview::class), |
|
90 | - $c->get(IShareManager::class), |
|
91 | - $c->get(IConfig::class), |
|
92 | - $server->getUserFolder(), |
|
93 | - $c->get(UserConfig::class), |
|
94 | - ); |
|
95 | - }); |
|
96 | - |
|
97 | - /** |
|
98 | - * Services |
|
99 | - */ |
|
100 | - $context->registerService(TagService::class, function (ContainerInterface $c) { |
|
101 | - /** @var IServerContainer $server */ |
|
102 | - $server = $c->get(IServerContainer::class); |
|
103 | - |
|
104 | - return new TagService( |
|
105 | - $c->get(IUserSession::class), |
|
106 | - $c->get(IActivityManager::class), |
|
107 | - $c->get(ITagManager::class)->load(self::APP_ID), |
|
108 | - $server->getUserFolder(), |
|
109 | - $server->getEventDispatcher() |
|
110 | - ); |
|
111 | - }); |
|
112 | - |
|
113 | - /* |
|
70 | + public const APP_ID = 'files'; |
|
71 | + |
|
72 | + public function __construct(array $urlParams = []) { |
|
73 | + parent::__construct(self::APP_ID, $urlParams); |
|
74 | + } |
|
75 | + |
|
76 | + public function register(IRegistrationContext $context): void { |
|
77 | + /** |
|
78 | + * Controllers |
|
79 | + */ |
|
80 | + $context->registerService('APIController', function (ContainerInterface $c) { |
|
81 | + /** @var IServerContainer $server */ |
|
82 | + $server = $c->get(IServerContainer::class); |
|
83 | + |
|
84 | + return new ApiController( |
|
85 | + $c->get('AppName'), |
|
86 | + $c->get(IRequest::class), |
|
87 | + $c->get(IUserSession::class), |
|
88 | + $c->get(TagService::class), |
|
89 | + $c->get(IPreview::class), |
|
90 | + $c->get(IShareManager::class), |
|
91 | + $c->get(IConfig::class), |
|
92 | + $server->getUserFolder(), |
|
93 | + $c->get(UserConfig::class), |
|
94 | + ); |
|
95 | + }); |
|
96 | + |
|
97 | + /** |
|
98 | + * Services |
|
99 | + */ |
|
100 | + $context->registerService(TagService::class, function (ContainerInterface $c) { |
|
101 | + /** @var IServerContainer $server */ |
|
102 | + $server = $c->get(IServerContainer::class); |
|
103 | + |
|
104 | + return new TagService( |
|
105 | + $c->get(IUserSession::class), |
|
106 | + $c->get(IActivityManager::class), |
|
107 | + $c->get(ITagManager::class)->load(self::APP_ID), |
|
108 | + $server->getUserFolder(), |
|
109 | + $server->getEventDispatcher() |
|
110 | + ); |
|
111 | + }); |
|
112 | + |
|
113 | + /* |
|
114 | 114 | * Register capabilities |
115 | 115 | */ |
116 | - $context->registerCapability(Capabilities::class); |
|
117 | - $context->registerCapability(DirectEditingCapabilities::class); |
|
118 | - |
|
119 | - $context->registerEventListener(LoadAdditionalScriptsEvent::class, LegacyLoadAdditionalScriptsAdapter::class); |
|
120 | - $context->registerEventListener(LoadSidebar::class, LoadSidebarListener::class); |
|
121 | - |
|
122 | - $context->registerSearchProvider(FilesSearchProvider::class); |
|
123 | - |
|
124 | - $context->registerNotifierService(Notifier::class); |
|
125 | - } |
|
126 | - |
|
127 | - public function boot(IBootContext $context): void { |
|
128 | - $context->injectFn(Closure::fromCallable([$this, 'registerCollaboration'])); |
|
129 | - $context->injectFn([Listener::class, 'register']); |
|
130 | - $context->injectFn(Closure::fromCallable([$this, 'registerSearchProvider'])); |
|
131 | - $this->registerTemplates(); |
|
132 | - $context->injectFn(Closure::fromCallable([$this, 'registerNavigation'])); |
|
133 | - $this->registerHooks(); |
|
134 | - } |
|
135 | - |
|
136 | - private function registerCollaboration(IProviderManager $providerManager): void { |
|
137 | - $providerManager->registerResourceProvider(ResourceProvider::class); |
|
138 | - } |
|
139 | - |
|
140 | - private function registerSearchProvider(ISearch $search): void { |
|
141 | - $search->registerProvider(File::class, ['apps' => ['files']]); |
|
142 | - } |
|
143 | - |
|
144 | - private function registerTemplates(): void { |
|
145 | - $templateManager = \OC_Helper::getFileTemplateManager(); |
|
146 | - $templateManager->registerTemplate('application/vnd.oasis.opendocument.presentation', 'core/templates/filetemplates/template.odp'); |
|
147 | - $templateManager->registerTemplate('application/vnd.oasis.opendocument.text', 'core/templates/filetemplates/template.odt'); |
|
148 | - $templateManager->registerTemplate('application/vnd.oasis.opendocument.spreadsheet', 'core/templates/filetemplates/template.ods'); |
|
149 | - } |
|
150 | - |
|
151 | - private function registerNavigation(IL10N $l10n): void { |
|
152 | - \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) { |
|
153 | - return [ |
|
154 | - 'id' => 'files', |
|
155 | - 'appname' => 'files', |
|
156 | - 'script' => 'list.php', |
|
157 | - 'order' => 0, |
|
158 | - 'name' => $l10n->t('All files') |
|
159 | - ]; |
|
160 | - }); |
|
161 | - \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) { |
|
162 | - return [ |
|
163 | - 'id' => 'recent', |
|
164 | - 'appname' => 'files', |
|
165 | - 'script' => 'recentlist.php', |
|
166 | - 'order' => 2, |
|
167 | - 'name' => $l10n->t('Recent') |
|
168 | - ]; |
|
169 | - }); |
|
170 | - \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) { |
|
171 | - return [ |
|
172 | - 'id' => 'favorites', |
|
173 | - 'appname' => 'files', |
|
174 | - 'script' => 'simplelist.php', |
|
175 | - 'order' => 5, |
|
176 | - 'name' => $l10n->t('Favorites'), |
|
177 | - ]; |
|
178 | - }); |
|
179 | - } |
|
180 | - |
|
181 | - private function registerHooks(): void { |
|
182 | - Util::connectHook('\OCP\Config', 'js', '\OCA\Files\App', 'extendJsConfig'); |
|
183 | - } |
|
116 | + $context->registerCapability(Capabilities::class); |
|
117 | + $context->registerCapability(DirectEditingCapabilities::class); |
|
118 | + |
|
119 | + $context->registerEventListener(LoadAdditionalScriptsEvent::class, LegacyLoadAdditionalScriptsAdapter::class); |
|
120 | + $context->registerEventListener(LoadSidebar::class, LoadSidebarListener::class); |
|
121 | + |
|
122 | + $context->registerSearchProvider(FilesSearchProvider::class); |
|
123 | + |
|
124 | + $context->registerNotifierService(Notifier::class); |
|
125 | + } |
|
126 | + |
|
127 | + public function boot(IBootContext $context): void { |
|
128 | + $context->injectFn(Closure::fromCallable([$this, 'registerCollaboration'])); |
|
129 | + $context->injectFn([Listener::class, 'register']); |
|
130 | + $context->injectFn(Closure::fromCallable([$this, 'registerSearchProvider'])); |
|
131 | + $this->registerTemplates(); |
|
132 | + $context->injectFn(Closure::fromCallable([$this, 'registerNavigation'])); |
|
133 | + $this->registerHooks(); |
|
134 | + } |
|
135 | + |
|
136 | + private function registerCollaboration(IProviderManager $providerManager): void { |
|
137 | + $providerManager->registerResourceProvider(ResourceProvider::class); |
|
138 | + } |
|
139 | + |
|
140 | + private function registerSearchProvider(ISearch $search): void { |
|
141 | + $search->registerProvider(File::class, ['apps' => ['files']]); |
|
142 | + } |
|
143 | + |
|
144 | + private function registerTemplates(): void { |
|
145 | + $templateManager = \OC_Helper::getFileTemplateManager(); |
|
146 | + $templateManager->registerTemplate('application/vnd.oasis.opendocument.presentation', 'core/templates/filetemplates/template.odp'); |
|
147 | + $templateManager->registerTemplate('application/vnd.oasis.opendocument.text', 'core/templates/filetemplates/template.odt'); |
|
148 | + $templateManager->registerTemplate('application/vnd.oasis.opendocument.spreadsheet', 'core/templates/filetemplates/template.ods'); |
|
149 | + } |
|
150 | + |
|
151 | + private function registerNavigation(IL10N $l10n): void { |
|
152 | + \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) { |
|
153 | + return [ |
|
154 | + 'id' => 'files', |
|
155 | + 'appname' => 'files', |
|
156 | + 'script' => 'list.php', |
|
157 | + 'order' => 0, |
|
158 | + 'name' => $l10n->t('All files') |
|
159 | + ]; |
|
160 | + }); |
|
161 | + \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) { |
|
162 | + return [ |
|
163 | + 'id' => 'recent', |
|
164 | + 'appname' => 'files', |
|
165 | + 'script' => 'recentlist.php', |
|
166 | + 'order' => 2, |
|
167 | + 'name' => $l10n->t('Recent') |
|
168 | + ]; |
|
169 | + }); |
|
170 | + \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) { |
|
171 | + return [ |
|
172 | + 'id' => 'favorites', |
|
173 | + 'appname' => 'files', |
|
174 | + 'script' => 'simplelist.php', |
|
175 | + 'order' => 5, |
|
176 | + 'name' => $l10n->t('Favorites'), |
|
177 | + ]; |
|
178 | + }); |
|
179 | + } |
|
180 | + |
|
181 | + private function registerHooks(): void { |
|
182 | + Util::connectHook('\OCP\Config', 'js', '\OCA\Files\App', 'extendJsConfig'); |
|
183 | + } |
|
184 | 184 | } |
@@ -62,344 +62,344 @@ |
||
62 | 62 | * @package OCA\Files\Controller |
63 | 63 | */ |
64 | 64 | class ApiController extends Controller { |
65 | - private TagService $tagService; |
|
66 | - private IManager $shareManager; |
|
67 | - private IPreview $previewManager; |
|
68 | - private IUserSession $userSession; |
|
69 | - private IConfig $config; |
|
70 | - private Folder $userFolder; |
|
71 | - private UserConfig $userConfig; |
|
65 | + private TagService $tagService; |
|
66 | + private IManager $shareManager; |
|
67 | + private IPreview $previewManager; |
|
68 | + private IUserSession $userSession; |
|
69 | + private IConfig $config; |
|
70 | + private Folder $userFolder; |
|
71 | + private UserConfig $userConfig; |
|
72 | 72 | |
73 | - /** |
|
74 | - * @param string $appName |
|
75 | - * @param IRequest $request |
|
76 | - * @param IUserSession $userSession |
|
77 | - * @param TagService $tagService |
|
78 | - * @param IPreview $previewManager |
|
79 | - * @param IManager $shareManager |
|
80 | - * @param IConfig $config |
|
81 | - * @param Folder $userFolder |
|
82 | - */ |
|
83 | - public function __construct($appName, |
|
84 | - IRequest $request, |
|
85 | - IUserSession $userSession, |
|
86 | - TagService $tagService, |
|
87 | - IPreview $previewManager, |
|
88 | - IManager $shareManager, |
|
89 | - IConfig $config, |
|
90 | - Folder $userFolder, |
|
91 | - UserConfig $userConfig) { |
|
92 | - parent::__construct($appName, $request); |
|
93 | - $this->userSession = $userSession; |
|
94 | - $this->tagService = $tagService; |
|
95 | - $this->previewManager = $previewManager; |
|
96 | - $this->shareManager = $shareManager; |
|
97 | - $this->config = $config; |
|
98 | - $this->userFolder = $userFolder; |
|
99 | - $this->userConfig = $userConfig; |
|
100 | - } |
|
73 | + /** |
|
74 | + * @param string $appName |
|
75 | + * @param IRequest $request |
|
76 | + * @param IUserSession $userSession |
|
77 | + * @param TagService $tagService |
|
78 | + * @param IPreview $previewManager |
|
79 | + * @param IManager $shareManager |
|
80 | + * @param IConfig $config |
|
81 | + * @param Folder $userFolder |
|
82 | + */ |
|
83 | + public function __construct($appName, |
|
84 | + IRequest $request, |
|
85 | + IUserSession $userSession, |
|
86 | + TagService $tagService, |
|
87 | + IPreview $previewManager, |
|
88 | + IManager $shareManager, |
|
89 | + IConfig $config, |
|
90 | + Folder $userFolder, |
|
91 | + UserConfig $userConfig) { |
|
92 | + parent::__construct($appName, $request); |
|
93 | + $this->userSession = $userSession; |
|
94 | + $this->tagService = $tagService; |
|
95 | + $this->previewManager = $previewManager; |
|
96 | + $this->shareManager = $shareManager; |
|
97 | + $this->config = $config; |
|
98 | + $this->userFolder = $userFolder; |
|
99 | + $this->userConfig = $userConfig; |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * Gets a thumbnail of the specified file |
|
104 | - * |
|
105 | - * @since API version 1.0 |
|
106 | - * |
|
107 | - * @NoAdminRequired |
|
108 | - * @NoCSRFRequired |
|
109 | - * @StrictCookieRequired |
|
110 | - * |
|
111 | - * @param int $x |
|
112 | - * @param int $y |
|
113 | - * @param string $file URL-encoded filename |
|
114 | - * @return DataResponse|FileDisplayResponse |
|
115 | - */ |
|
116 | - public function getThumbnail($x, $y, $file) { |
|
117 | - if ($x < 1 || $y < 1) { |
|
118 | - return new DataResponse(['message' => 'Requested size must be numeric and a positive value.'], Http::STATUS_BAD_REQUEST); |
|
119 | - } |
|
102 | + /** |
|
103 | + * Gets a thumbnail of the specified file |
|
104 | + * |
|
105 | + * @since API version 1.0 |
|
106 | + * |
|
107 | + * @NoAdminRequired |
|
108 | + * @NoCSRFRequired |
|
109 | + * @StrictCookieRequired |
|
110 | + * |
|
111 | + * @param int $x |
|
112 | + * @param int $y |
|
113 | + * @param string $file URL-encoded filename |
|
114 | + * @return DataResponse|FileDisplayResponse |
|
115 | + */ |
|
116 | + public function getThumbnail($x, $y, $file) { |
|
117 | + if ($x < 1 || $y < 1) { |
|
118 | + return new DataResponse(['message' => 'Requested size must be numeric and a positive value.'], Http::STATUS_BAD_REQUEST); |
|
119 | + } |
|
120 | 120 | |
121 | - try { |
|
122 | - $file = $this->userFolder->get($file); |
|
123 | - if ($file instanceof Folder) { |
|
124 | - throw new NotFoundException(); |
|
125 | - } |
|
121 | + try { |
|
122 | + $file = $this->userFolder->get($file); |
|
123 | + if ($file instanceof Folder) { |
|
124 | + throw new NotFoundException(); |
|
125 | + } |
|
126 | 126 | |
127 | - /** @var File $file */ |
|
128 | - $preview = $this->previewManager->getPreview($file, $x, $y, true); |
|
127 | + /** @var File $file */ |
|
128 | + $preview = $this->previewManager->getPreview($file, $x, $y, true); |
|
129 | 129 | |
130 | - return new FileDisplayResponse($preview, Http::STATUS_OK, ['Content-Type' => $preview->getMimeType()]); |
|
131 | - } catch (NotFoundException $e) { |
|
132 | - return new DataResponse(['message' => 'File not found.'], Http::STATUS_NOT_FOUND); |
|
133 | - } catch (\Exception $e) { |
|
134 | - return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
135 | - } |
|
136 | - } |
|
130 | + return new FileDisplayResponse($preview, Http::STATUS_OK, ['Content-Type' => $preview->getMimeType()]); |
|
131 | + } catch (NotFoundException $e) { |
|
132 | + return new DataResponse(['message' => 'File not found.'], Http::STATUS_NOT_FOUND); |
|
133 | + } catch (\Exception $e) { |
|
134 | + return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
135 | + } |
|
136 | + } |
|
137 | 137 | |
138 | - /** |
|
139 | - * Updates the info of the specified file path |
|
140 | - * The passed tags are absolute, which means they will |
|
141 | - * replace the actual tag selection. |
|
142 | - * |
|
143 | - * @NoAdminRequired |
|
144 | - * |
|
145 | - * @param string $path path |
|
146 | - * @param array|string $tags array of tags |
|
147 | - * @return DataResponse |
|
148 | - */ |
|
149 | - public function updateFileTags($path, $tags = null) { |
|
150 | - $result = []; |
|
151 | - // if tags specified or empty array, update tags |
|
152 | - if (!is_null($tags)) { |
|
153 | - try { |
|
154 | - $this->tagService->updateFileTags($path, $tags); |
|
155 | - } catch (\OCP\Files\NotFoundException $e) { |
|
156 | - return new DataResponse([ |
|
157 | - 'message' => $e->getMessage() |
|
158 | - ], Http::STATUS_NOT_FOUND); |
|
159 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
160 | - return new DataResponse([ |
|
161 | - 'message' => $e->getMessage() |
|
162 | - ], Http::STATUS_SERVICE_UNAVAILABLE); |
|
163 | - } catch (\Exception $e) { |
|
164 | - return new DataResponse([ |
|
165 | - 'message' => $e->getMessage() |
|
166 | - ], Http::STATUS_NOT_FOUND); |
|
167 | - } |
|
168 | - $result['tags'] = $tags; |
|
169 | - } |
|
170 | - return new DataResponse($result); |
|
171 | - } |
|
138 | + /** |
|
139 | + * Updates the info of the specified file path |
|
140 | + * The passed tags are absolute, which means they will |
|
141 | + * replace the actual tag selection. |
|
142 | + * |
|
143 | + * @NoAdminRequired |
|
144 | + * |
|
145 | + * @param string $path path |
|
146 | + * @param array|string $tags array of tags |
|
147 | + * @return DataResponse |
|
148 | + */ |
|
149 | + public function updateFileTags($path, $tags = null) { |
|
150 | + $result = []; |
|
151 | + // if tags specified or empty array, update tags |
|
152 | + if (!is_null($tags)) { |
|
153 | + try { |
|
154 | + $this->tagService->updateFileTags($path, $tags); |
|
155 | + } catch (\OCP\Files\NotFoundException $e) { |
|
156 | + return new DataResponse([ |
|
157 | + 'message' => $e->getMessage() |
|
158 | + ], Http::STATUS_NOT_FOUND); |
|
159 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
160 | + return new DataResponse([ |
|
161 | + 'message' => $e->getMessage() |
|
162 | + ], Http::STATUS_SERVICE_UNAVAILABLE); |
|
163 | + } catch (\Exception $e) { |
|
164 | + return new DataResponse([ |
|
165 | + 'message' => $e->getMessage() |
|
166 | + ], Http::STATUS_NOT_FOUND); |
|
167 | + } |
|
168 | + $result['tags'] = $tags; |
|
169 | + } |
|
170 | + return new DataResponse($result); |
|
171 | + } |
|
172 | 172 | |
173 | - /** |
|
174 | - * @param \OCP\Files\Node[] $nodes |
|
175 | - * @return array |
|
176 | - */ |
|
177 | - private function formatNodes(array $nodes) { |
|
178 | - $shareTypesForNodes = $this->getShareTypesForNodes($nodes); |
|
179 | - return array_values(array_map(function (Node $node) use ($shareTypesForNodes) { |
|
180 | - $shareTypes = $shareTypesForNodes[$node->getId()] ?? []; |
|
181 | - $file = \OCA\Files\Helper::formatFileInfo($node->getFileInfo()); |
|
182 | - $file['hasPreview'] = $this->previewManager->isAvailable($node); |
|
183 | - $parts = explode('/', dirname($node->getPath()), 4); |
|
184 | - if (isset($parts[3])) { |
|
185 | - $file['path'] = '/' . $parts[3]; |
|
186 | - } else { |
|
187 | - $file['path'] = '/'; |
|
188 | - } |
|
189 | - if (!empty($shareTypes)) { |
|
190 | - $file['shareTypes'] = $shareTypes; |
|
191 | - } |
|
192 | - return $file; |
|
193 | - }, $nodes)); |
|
194 | - } |
|
173 | + /** |
|
174 | + * @param \OCP\Files\Node[] $nodes |
|
175 | + * @return array |
|
176 | + */ |
|
177 | + private function formatNodes(array $nodes) { |
|
178 | + $shareTypesForNodes = $this->getShareTypesForNodes($nodes); |
|
179 | + return array_values(array_map(function (Node $node) use ($shareTypesForNodes) { |
|
180 | + $shareTypes = $shareTypesForNodes[$node->getId()] ?? []; |
|
181 | + $file = \OCA\Files\Helper::formatFileInfo($node->getFileInfo()); |
|
182 | + $file['hasPreview'] = $this->previewManager->isAvailable($node); |
|
183 | + $parts = explode('/', dirname($node->getPath()), 4); |
|
184 | + if (isset($parts[3])) { |
|
185 | + $file['path'] = '/' . $parts[3]; |
|
186 | + } else { |
|
187 | + $file['path'] = '/'; |
|
188 | + } |
|
189 | + if (!empty($shareTypes)) { |
|
190 | + $file['shareTypes'] = $shareTypes; |
|
191 | + } |
|
192 | + return $file; |
|
193 | + }, $nodes)); |
|
194 | + } |
|
195 | 195 | |
196 | - /** |
|
197 | - * Get the share types for each node |
|
198 | - * |
|
199 | - * @param \OCP\Files\Node[] $nodes |
|
200 | - * @return array<int, int[]> list of share types for each fileid |
|
201 | - */ |
|
202 | - private function getShareTypesForNodes(array $nodes): array { |
|
203 | - $userId = $this->userSession->getUser()->getUID(); |
|
204 | - $requestedShareTypes = [ |
|
205 | - IShare::TYPE_USER, |
|
206 | - IShare::TYPE_GROUP, |
|
207 | - IShare::TYPE_LINK, |
|
208 | - IShare::TYPE_REMOTE, |
|
209 | - IShare::TYPE_EMAIL, |
|
210 | - IShare::TYPE_ROOM, |
|
211 | - IShare::TYPE_DECK, |
|
212 | - ]; |
|
213 | - $shareTypes = []; |
|
196 | + /** |
|
197 | + * Get the share types for each node |
|
198 | + * |
|
199 | + * @param \OCP\Files\Node[] $nodes |
|
200 | + * @return array<int, int[]> list of share types for each fileid |
|
201 | + */ |
|
202 | + private function getShareTypesForNodes(array $nodes): array { |
|
203 | + $userId = $this->userSession->getUser()->getUID(); |
|
204 | + $requestedShareTypes = [ |
|
205 | + IShare::TYPE_USER, |
|
206 | + IShare::TYPE_GROUP, |
|
207 | + IShare::TYPE_LINK, |
|
208 | + IShare::TYPE_REMOTE, |
|
209 | + IShare::TYPE_EMAIL, |
|
210 | + IShare::TYPE_ROOM, |
|
211 | + IShare::TYPE_DECK, |
|
212 | + ]; |
|
213 | + $shareTypes = []; |
|
214 | 214 | |
215 | - $nodeIds = array_map(function (Node $node) { |
|
216 | - return $node->getId(); |
|
217 | - }, $nodes); |
|
215 | + $nodeIds = array_map(function (Node $node) { |
|
216 | + return $node->getId(); |
|
217 | + }, $nodes); |
|
218 | 218 | |
219 | - foreach ($requestedShareTypes as $shareType) { |
|
220 | - $nodesLeft = array_combine($nodeIds, array_fill(0, count($nodeIds), true)); |
|
221 | - $offset = 0; |
|
219 | + foreach ($requestedShareTypes as $shareType) { |
|
220 | + $nodesLeft = array_combine($nodeIds, array_fill(0, count($nodeIds), true)); |
|
221 | + $offset = 0; |
|
222 | 222 | |
223 | - // fetch shares until we've either found shares for all nodes or there are no more shares left |
|
224 | - while (count($nodesLeft) > 0) { |
|
225 | - $shares = $this->shareManager->getSharesBy($userId, $shareType, null, false, 100, $offset); |
|
226 | - foreach ($shares as $share) { |
|
227 | - $fileId = $share->getNodeId(); |
|
228 | - if (isset($nodesLeft[$fileId])) { |
|
229 | - if (!isset($shareTypes[$fileId])) { |
|
230 | - $shareTypes[$fileId] = []; |
|
231 | - } |
|
232 | - $shareTypes[$fileId][] = $shareType; |
|
233 | - unset($nodesLeft[$fileId]); |
|
234 | - } |
|
235 | - } |
|
223 | + // fetch shares until we've either found shares for all nodes or there are no more shares left |
|
224 | + while (count($nodesLeft) > 0) { |
|
225 | + $shares = $this->shareManager->getSharesBy($userId, $shareType, null, false, 100, $offset); |
|
226 | + foreach ($shares as $share) { |
|
227 | + $fileId = $share->getNodeId(); |
|
228 | + if (isset($nodesLeft[$fileId])) { |
|
229 | + if (!isset($shareTypes[$fileId])) { |
|
230 | + $shareTypes[$fileId] = []; |
|
231 | + } |
|
232 | + $shareTypes[$fileId][] = $shareType; |
|
233 | + unset($nodesLeft[$fileId]); |
|
234 | + } |
|
235 | + } |
|
236 | 236 | |
237 | - if (count($shares) < 100) { |
|
238 | - break; |
|
239 | - } else { |
|
240 | - $offset += count($shares); |
|
241 | - } |
|
242 | - } |
|
243 | - } |
|
244 | - return $shareTypes; |
|
245 | - } |
|
237 | + if (count($shares) < 100) { |
|
238 | + break; |
|
239 | + } else { |
|
240 | + $offset += count($shares); |
|
241 | + } |
|
242 | + } |
|
243 | + } |
|
244 | + return $shareTypes; |
|
245 | + } |
|
246 | 246 | |
247 | - /** |
|
248 | - * Returns a list of recently modified files. |
|
249 | - * |
|
250 | - * @NoAdminRequired |
|
251 | - * |
|
252 | - * @return DataResponse |
|
253 | - */ |
|
254 | - public function getRecentFiles() { |
|
255 | - $nodes = $this->userFolder->getRecent(100); |
|
256 | - $files = $this->formatNodes($nodes); |
|
257 | - return new DataResponse(['files' => $files]); |
|
258 | - } |
|
247 | + /** |
|
248 | + * Returns a list of recently modified files. |
|
249 | + * |
|
250 | + * @NoAdminRequired |
|
251 | + * |
|
252 | + * @return DataResponse |
|
253 | + */ |
|
254 | + public function getRecentFiles() { |
|
255 | + $nodes = $this->userFolder->getRecent(100); |
|
256 | + $files = $this->formatNodes($nodes); |
|
257 | + return new DataResponse(['files' => $files]); |
|
258 | + } |
|
259 | 259 | |
260 | - /** |
|
261 | - * Change the default sort mode |
|
262 | - * |
|
263 | - * @NoAdminRequired |
|
264 | - * |
|
265 | - * @param string $mode |
|
266 | - * @param string $direction |
|
267 | - * @return Response |
|
268 | - * @throws \OCP\PreConditionNotMetException |
|
269 | - */ |
|
270 | - public function updateFileSorting($mode, $direction) { |
|
271 | - $allowedMode = ['name', 'size', 'mtime']; |
|
272 | - $allowedDirection = ['asc', 'desc']; |
|
273 | - if (!in_array($mode, $allowedMode) || !in_array($direction, $allowedDirection)) { |
|
274 | - $response = new Response(); |
|
275 | - $response->setStatus(Http::STATUS_UNPROCESSABLE_ENTITY); |
|
276 | - return $response; |
|
277 | - } |
|
278 | - $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'file_sorting', $mode); |
|
279 | - $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'file_sorting_direction', $direction); |
|
280 | - return new Response(); |
|
281 | - } |
|
260 | + /** |
|
261 | + * Change the default sort mode |
|
262 | + * |
|
263 | + * @NoAdminRequired |
|
264 | + * |
|
265 | + * @param string $mode |
|
266 | + * @param string $direction |
|
267 | + * @return Response |
|
268 | + * @throws \OCP\PreConditionNotMetException |
|
269 | + */ |
|
270 | + public function updateFileSorting($mode, $direction) { |
|
271 | + $allowedMode = ['name', 'size', 'mtime']; |
|
272 | + $allowedDirection = ['asc', 'desc']; |
|
273 | + if (!in_array($mode, $allowedMode) || !in_array($direction, $allowedDirection)) { |
|
274 | + $response = new Response(); |
|
275 | + $response->setStatus(Http::STATUS_UNPROCESSABLE_ENTITY); |
|
276 | + return $response; |
|
277 | + } |
|
278 | + $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'file_sorting', $mode); |
|
279 | + $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'file_sorting_direction', $direction); |
|
280 | + return new Response(); |
|
281 | + } |
|
282 | 282 | |
283 | - /** |
|
284 | - * Toggle default files user config |
|
285 | - * |
|
286 | - * @NoAdminRequired |
|
287 | - * |
|
288 | - * @param string $key |
|
289 | - * @param string|bool $value |
|
290 | - * @return JSONResponse |
|
291 | - */ |
|
292 | - public function setConfig(string $key, $value): JSONResponse { |
|
293 | - try { |
|
294 | - $this->userConfig->setConfig($key, (string)$value); |
|
295 | - } catch (\InvalidArgumentException $e) { |
|
296 | - return new JSONResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST); |
|
297 | - } |
|
283 | + /** |
|
284 | + * Toggle default files user config |
|
285 | + * |
|
286 | + * @NoAdminRequired |
|
287 | + * |
|
288 | + * @param string $key |
|
289 | + * @param string|bool $value |
|
290 | + * @return JSONResponse |
|
291 | + */ |
|
292 | + public function setConfig(string $key, $value): JSONResponse { |
|
293 | + try { |
|
294 | + $this->userConfig->setConfig($key, (string)$value); |
|
295 | + } catch (\InvalidArgumentException $e) { |
|
296 | + return new JSONResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST); |
|
297 | + } |
|
298 | 298 | |
299 | - return new JSONResponse(['message' => 'ok', 'data' => ['key' => $key, 'value' => $value]]); |
|
300 | - } |
|
299 | + return new JSONResponse(['message' => 'ok', 'data' => ['key' => $key, 'value' => $value]]); |
|
300 | + } |
|
301 | 301 | |
302 | 302 | |
303 | - /** |
|
304 | - * Get the user config |
|
305 | - * |
|
306 | - * @NoAdminRequired |
|
307 | - * |
|
308 | - * @return JSONResponse |
|
309 | - */ |
|
310 | - public function getConfigs(): JSONResponse { |
|
311 | - return new JSONResponse(['message' => 'ok', 'data' => $this->userConfig->getConfigs()]); |
|
312 | - } |
|
303 | + /** |
|
304 | + * Get the user config |
|
305 | + * |
|
306 | + * @NoAdminRequired |
|
307 | + * |
|
308 | + * @return JSONResponse |
|
309 | + */ |
|
310 | + public function getConfigs(): JSONResponse { |
|
311 | + return new JSONResponse(['message' => 'ok', 'data' => $this->userConfig->getConfigs()]); |
|
312 | + } |
|
313 | 313 | |
314 | - /** |
|
315 | - * Toggle default for showing/hiding hidden files |
|
316 | - * |
|
317 | - * @NoAdminRequired |
|
318 | - * |
|
319 | - * @param bool $value |
|
320 | - * @return Response |
|
321 | - * @throws \OCP\PreConditionNotMetException |
|
322 | - */ |
|
323 | - public function showHiddenFiles(bool $value): Response { |
|
324 | - $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', $value ? '1' : '0'); |
|
325 | - return new Response(); |
|
326 | - } |
|
314 | + /** |
|
315 | + * Toggle default for showing/hiding hidden files |
|
316 | + * |
|
317 | + * @NoAdminRequired |
|
318 | + * |
|
319 | + * @param bool $value |
|
320 | + * @return Response |
|
321 | + * @throws \OCP\PreConditionNotMetException |
|
322 | + */ |
|
323 | + public function showHiddenFiles(bool $value): Response { |
|
324 | + $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', $value ? '1' : '0'); |
|
325 | + return new Response(); |
|
326 | + } |
|
327 | 327 | |
328 | - /** |
|
329 | - * Toggle default for cropping preview images |
|
330 | - * |
|
331 | - * @NoAdminRequired |
|
332 | - * |
|
333 | - * @param bool $value |
|
334 | - * @return Response |
|
335 | - * @throws \OCP\PreConditionNotMetException |
|
336 | - */ |
|
337 | - public function cropImagePreviews(bool $value): Response { |
|
338 | - $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'crop_image_previews', $value ? '1' : '0'); |
|
339 | - return new Response(); |
|
340 | - } |
|
328 | + /** |
|
329 | + * Toggle default for cropping preview images |
|
330 | + * |
|
331 | + * @NoAdminRequired |
|
332 | + * |
|
333 | + * @param bool $value |
|
334 | + * @return Response |
|
335 | + * @throws \OCP\PreConditionNotMetException |
|
336 | + */ |
|
337 | + public function cropImagePreviews(bool $value): Response { |
|
338 | + $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'crop_image_previews', $value ? '1' : '0'); |
|
339 | + return new Response(); |
|
340 | + } |
|
341 | 341 | |
342 | - /** |
|
343 | - * Toggle default for files grid view |
|
344 | - * |
|
345 | - * @NoAdminRequired |
|
346 | - * |
|
347 | - * @param bool $show |
|
348 | - * @return Response |
|
349 | - * @throws \OCP\PreConditionNotMetException |
|
350 | - */ |
|
351 | - public function showGridView(bool $show): Response { |
|
352 | - $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_grid', $show ? '1' : '0'); |
|
353 | - return new Response(); |
|
354 | - } |
|
342 | + /** |
|
343 | + * Toggle default for files grid view |
|
344 | + * |
|
345 | + * @NoAdminRequired |
|
346 | + * |
|
347 | + * @param bool $show |
|
348 | + * @return Response |
|
349 | + * @throws \OCP\PreConditionNotMetException |
|
350 | + */ |
|
351 | + public function showGridView(bool $show): Response { |
|
352 | + $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_grid', $show ? '1' : '0'); |
|
353 | + return new Response(); |
|
354 | + } |
|
355 | 355 | |
356 | - /** |
|
357 | - * Get default settings for the grid view |
|
358 | - * |
|
359 | - * @NoAdminRequired |
|
360 | - */ |
|
361 | - public function getGridView() { |
|
362 | - $status = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_grid', '0') === '1'; |
|
363 | - return new JSONResponse(['gridview' => $status]); |
|
364 | - } |
|
356 | + /** |
|
357 | + * Get default settings for the grid view |
|
358 | + * |
|
359 | + * @NoAdminRequired |
|
360 | + */ |
|
361 | + public function getGridView() { |
|
362 | + $status = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_grid', '0') === '1'; |
|
363 | + return new JSONResponse(['gridview' => $status]); |
|
364 | + } |
|
365 | 365 | |
366 | - /** |
|
367 | - * Toggle default for showing/hiding xxx folder |
|
368 | - * |
|
369 | - * @NoAdminRequired |
|
370 | - * |
|
371 | - * @param int $show |
|
372 | - * @param string $key the key of the folder |
|
373 | - * |
|
374 | - * @return Response |
|
375 | - * @throws \OCP\PreConditionNotMetException |
|
376 | - */ |
|
377 | - public function toggleShowFolder(int $show, string $key): Response { |
|
378 | - if ($show !== 0 && $show !== 1) { |
|
379 | - return new DataResponse([ |
|
380 | - 'message' => 'Invalid show value. Only 0 and 1 are allowed.' |
|
381 | - ], Http::STATUS_BAD_REQUEST); |
|
382 | - } |
|
366 | + /** |
|
367 | + * Toggle default for showing/hiding xxx folder |
|
368 | + * |
|
369 | + * @NoAdminRequired |
|
370 | + * |
|
371 | + * @param int $show |
|
372 | + * @param string $key the key of the folder |
|
373 | + * |
|
374 | + * @return Response |
|
375 | + * @throws \OCP\PreConditionNotMetException |
|
376 | + */ |
|
377 | + public function toggleShowFolder(int $show, string $key): Response { |
|
378 | + if ($show !== 0 && $show !== 1) { |
|
379 | + return new DataResponse([ |
|
380 | + 'message' => 'Invalid show value. Only 0 and 1 are allowed.' |
|
381 | + ], Http::STATUS_BAD_REQUEST); |
|
382 | + } |
|
383 | 383 | |
384 | - $userId = $this->userSession->getUser()->getUID(); |
|
384 | + $userId = $this->userSession->getUser()->getUID(); |
|
385 | 385 | |
386 | - // Set the new value and return it |
|
387 | - // Using a prefix prevents the user from setting arbitrary keys |
|
388 | - $this->config->setUserValue($userId, 'files', 'show_' . $key, (string)$show); |
|
389 | - return new JSONResponse([$key => $show]); |
|
390 | - } |
|
386 | + // Set the new value and return it |
|
387 | + // Using a prefix prevents the user from setting arbitrary keys |
|
388 | + $this->config->setUserValue($userId, 'files', 'show_' . $key, (string)$show); |
|
389 | + return new JSONResponse([$key => $show]); |
|
390 | + } |
|
391 | 391 | |
392 | - /** |
|
393 | - * Get sorting-order for custom sorting |
|
394 | - * |
|
395 | - * @NoAdminRequired |
|
396 | - * |
|
397 | - * @param string $folderpath |
|
398 | - * @return string |
|
399 | - * @throws \OCP\Files\NotFoundException |
|
400 | - */ |
|
401 | - public function getNodeType($folderpath) { |
|
402 | - $node = $this->userFolder->get($folderpath); |
|
403 | - return $node->getType(); |
|
404 | - } |
|
392 | + /** |
|
393 | + * Get sorting-order for custom sorting |
|
394 | + * |
|
395 | + * @NoAdminRequired |
|
396 | + * |
|
397 | + * @param string $folderpath |
|
398 | + * @return string |
|
399 | + * @throws \OCP\Files\NotFoundException |
|
400 | + */ |
|
401 | + public function getNodeType($folderpath) { |
|
402 | + $node = $this->userFolder->get($folderpath); |
|
403 | + return $node->getType(); |
|
404 | + } |
|
405 | 405 | } |
@@ -176,13 +176,13 @@ discard block |
||
176 | 176 | */ |
177 | 177 | private function formatNodes(array $nodes) { |
178 | 178 | $shareTypesForNodes = $this->getShareTypesForNodes($nodes); |
179 | - return array_values(array_map(function (Node $node) use ($shareTypesForNodes) { |
|
179 | + return array_values(array_map(function(Node $node) use ($shareTypesForNodes) { |
|
180 | 180 | $shareTypes = $shareTypesForNodes[$node->getId()] ?? []; |
181 | 181 | $file = \OCA\Files\Helper::formatFileInfo($node->getFileInfo()); |
182 | 182 | $file['hasPreview'] = $this->previewManager->isAvailable($node); |
183 | 183 | $parts = explode('/', dirname($node->getPath()), 4); |
184 | 184 | if (isset($parts[3])) { |
185 | - $file['path'] = '/' . $parts[3]; |
|
185 | + $file['path'] = '/'.$parts[3]; |
|
186 | 186 | } else { |
187 | 187 | $file['path'] = '/'; |
188 | 188 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | ]; |
213 | 213 | $shareTypes = []; |
214 | 214 | |
215 | - $nodeIds = array_map(function (Node $node) { |
|
215 | + $nodeIds = array_map(function(Node $node) { |
|
216 | 216 | return $node->getId(); |
217 | 217 | }, $nodes); |
218 | 218 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | */ |
292 | 292 | public function setConfig(string $key, $value): JSONResponse { |
293 | 293 | try { |
294 | - $this->userConfig->setConfig($key, (string)$value); |
|
294 | + $this->userConfig->setConfig($key, (string) $value); |
|
295 | 295 | } catch (\InvalidArgumentException $e) { |
296 | 296 | return new JSONResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST); |
297 | 297 | } |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | |
386 | 386 | // Set the new value and return it |
387 | 387 | // Using a prefix prevents the user from setting arbitrary keys |
388 | - $this->config->setUserValue($userId, 'files', 'show_' . $key, (string)$show); |
|
388 | + $this->config->setUserValue($userId, 'files', 'show_'.$key, (string) $show); |
|
389 | 389 | return new JSONResponse([$key => $show]); |
390 | 390 | } |
391 | 391 |
@@ -67,353 +67,353 @@ |
||
67 | 67 | * @package OCA\Files\Controller |
68 | 68 | */ |
69 | 69 | class ViewController extends Controller { |
70 | - private IURLGenerator $urlGenerator; |
|
71 | - private IL10N $l10n; |
|
72 | - private IConfig $config; |
|
73 | - private IEventDispatcher $eventDispatcher; |
|
74 | - private IUserSession $userSession; |
|
75 | - private IAppManager $appManager; |
|
76 | - private IRootFolder $rootFolder; |
|
77 | - private Helper $activityHelper; |
|
78 | - private IInitialState $initialState; |
|
79 | - private ITemplateManager $templateManager; |
|
80 | - private IManager $shareManager; |
|
81 | - private UserConfig $userConfig; |
|
82 | - |
|
83 | - public function __construct(string $appName, |
|
84 | - IRequest $request, |
|
85 | - IURLGenerator $urlGenerator, |
|
86 | - IL10N $l10n, |
|
87 | - IConfig $config, |
|
88 | - IEventDispatcher $eventDispatcher, |
|
89 | - IUserSession $userSession, |
|
90 | - IAppManager $appManager, |
|
91 | - IRootFolder $rootFolder, |
|
92 | - Helper $activityHelper, |
|
93 | - IInitialState $initialState, |
|
94 | - ITemplateManager $templateManager, |
|
95 | - IManager $shareManager, |
|
96 | - UserConfig $userConfig |
|
97 | - ) { |
|
98 | - parent::__construct($appName, $request); |
|
99 | - $this->urlGenerator = $urlGenerator; |
|
100 | - $this->l10n = $l10n; |
|
101 | - $this->config = $config; |
|
102 | - $this->eventDispatcher = $eventDispatcher; |
|
103 | - $this->userSession = $userSession; |
|
104 | - $this->appManager = $appManager; |
|
105 | - $this->rootFolder = $rootFolder; |
|
106 | - $this->activityHelper = $activityHelper; |
|
107 | - $this->initialState = $initialState; |
|
108 | - $this->templateManager = $templateManager; |
|
109 | - $this->shareManager = $shareManager; |
|
110 | - $this->userConfig = $userConfig; |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * @param string $appName |
|
115 | - * @param string $scriptName |
|
116 | - * @return string |
|
117 | - */ |
|
118 | - protected function renderScript($appName, $scriptName) { |
|
119 | - $content = ''; |
|
120 | - $appPath = \OC_App::getAppPath($appName); |
|
121 | - $scriptPath = $appPath . '/' . $scriptName; |
|
122 | - if (file_exists($scriptPath)) { |
|
123 | - // TODO: sanitize path / script name ? |
|
124 | - ob_start(); |
|
125 | - include $scriptPath; |
|
126 | - $content = ob_get_contents(); |
|
127 | - @ob_end_clean(); |
|
128 | - } |
|
129 | - |
|
130 | - return $content; |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * FIXME: Replace with non static code |
|
135 | - * |
|
136 | - * @return array |
|
137 | - * @throws \OCP\Files\NotFoundException |
|
138 | - */ |
|
139 | - protected function getStorageInfo() { |
|
140 | - \OC_Util::setupFS(); |
|
141 | - $dirInfo = \OC\Files\Filesystem::getFileInfo('/', false); |
|
142 | - |
|
143 | - return \OC_Helper::getStorageInfo('/', $dirInfo); |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * @NoCSRFRequired |
|
148 | - * @NoAdminRequired |
|
149 | - * |
|
150 | - * @param string $fileid |
|
151 | - * @return TemplateResponse|RedirectResponse |
|
152 | - * @throws NotFoundException |
|
153 | - */ |
|
154 | - public function showFile(string $fileid = null, int $openfile = 1): Response { |
|
155 | - // This is the entry point from the `/f/{fileid}` URL which is hardcoded in the server. |
|
156 | - try { |
|
157 | - return $this->redirectToFile($fileid, $openfile !== 0); |
|
158 | - } catch (NotFoundException $e) { |
|
159 | - return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true])); |
|
160 | - } |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * @NoCSRFRequired |
|
165 | - * @NoAdminRequired |
|
166 | - * @UseSession |
|
167 | - * |
|
168 | - * @param string $dir |
|
169 | - * @param string $view |
|
170 | - * @param string $fileid |
|
171 | - * @param bool $fileNotFound |
|
172 | - * @param string $openfile - the openfile URL parameter if it was present in the initial request |
|
173 | - * @return TemplateResponse|RedirectResponse |
|
174 | - * @throws NotFoundException |
|
175 | - */ |
|
176 | - public function index($dir = '', $view = '', $fileid = null, $fileNotFound = false, $openfile = null) { |
|
177 | - |
|
178 | - if ($fileid !== null && $dir === '') { |
|
179 | - try { |
|
180 | - return $this->redirectToFile($fileid); |
|
181 | - } catch (NotFoundException $e) { |
|
182 | - return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true])); |
|
183 | - } |
|
184 | - } |
|
185 | - |
|
186 | - $nav = new \OCP\Template('files', 'appnavigation', ''); |
|
187 | - |
|
188 | - // Load the files we need |
|
189 | - \OCP\Util::addStyle('files', 'merged'); |
|
190 | - \OCP\Util::addScript('files', 'merged-index', 'files'); |
|
191 | - \OCP\Util::addScript('files', 'main'); |
|
192 | - |
|
193 | - // mostly for the home storage's free space |
|
194 | - // FIXME: Make non static |
|
195 | - $storageInfo = $this->getStorageInfo(); |
|
196 | - |
|
197 | - $userId = $this->userSession->getUser()->getUID(); |
|
198 | - |
|
199 | - // Get all the user favorites to create a submenu |
|
200 | - try { |
|
201 | - $favElements = $this->activityHelper->getFavoriteFilePaths($userId); |
|
202 | - } catch (\RuntimeException $e) { |
|
203 | - $favElements['folders'] = []; |
|
204 | - } |
|
205 | - |
|
206 | - $collapseClasses = ''; |
|
207 | - if (count($favElements['folders']) > 0) { |
|
208 | - $collapseClasses = 'collapsible'; |
|
209 | - } |
|
210 | - |
|
211 | - $favoritesSublistArray = []; |
|
212 | - |
|
213 | - $navBarPositionPosition = 6; |
|
214 | - foreach ($favElements['folders'] as $favElement) { |
|
215 | - $element = [ |
|
216 | - 'id' => str_replace('/', '-', $favElement), |
|
217 | - 'dir' => $favElement, |
|
218 | - 'order' => $navBarPositionPosition, |
|
219 | - 'name' => basename($favElement), |
|
220 | - 'icon' => 'folder', |
|
221 | - 'params' => [ |
|
222 | - 'view' => 'files', |
|
223 | - 'dir' => $favElement, |
|
224 | - ], |
|
225 | - ]; |
|
226 | - |
|
227 | - array_push($favoritesSublistArray, $element); |
|
228 | - $navBarPositionPosition++; |
|
229 | - } |
|
230 | - |
|
231 | - $navItems = \OCA\Files\App::getNavigationManager()->getAll(); |
|
232 | - |
|
233 | - // add the favorites entry in menu |
|
234 | - $navItems['favorites']['sublist'] = $favoritesSublistArray; |
|
235 | - $navItems['favorites']['classes'] = $collapseClasses; |
|
236 | - |
|
237 | - // parse every menu and add the expanded user value |
|
238 | - foreach ($navItems as $key => $item) { |
|
239 | - $navItems[$key]['expanded'] = $this->config->getUserValue($userId, 'files', 'show_' . $item['id'], '0') === '1'; |
|
240 | - } |
|
241 | - |
|
242 | - $nav->assign('navigationItems', $navItems); |
|
243 | - |
|
244 | - $nav->assign('usage', \OC_Helper::humanFileSize($storageInfo['used'])); |
|
245 | - if ($storageInfo['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED) { |
|
246 | - $totalSpace = $this->l10n->t('Unlimited'); |
|
247 | - } else { |
|
248 | - $totalSpace = \OC_Helper::humanFileSize($storageInfo['total']); |
|
249 | - } |
|
250 | - $nav->assign('total_space', $totalSpace); |
|
251 | - $nav->assign('quota', $storageInfo['quota']); |
|
252 | - $nav->assign('usage_relative', $storageInfo['relative']); |
|
253 | - |
|
254 | - $contentItems = []; |
|
255 | - |
|
256 | - $this->initialState->provideInitialState('navigation', $navItems); |
|
257 | - $this->initialState->provideInitialState('config', $this->userConfig->getConfigs()); |
|
258 | - |
|
259 | - // render the container content for every navigation item |
|
260 | - foreach ($navItems as $item) { |
|
261 | - $content = ''; |
|
262 | - if (isset($item['script'])) { |
|
263 | - $content = $this->renderScript($item['appname'], $item['script']); |
|
264 | - } |
|
265 | - // parse submenus |
|
266 | - if (isset($item['sublist'])) { |
|
267 | - foreach ($item['sublist'] as $subitem) { |
|
268 | - $subcontent = ''; |
|
269 | - if (isset($subitem['script'])) { |
|
270 | - $subcontent = $this->renderScript($subitem['appname'], $subitem['script']); |
|
271 | - } |
|
272 | - $contentItems[$subitem['id']] = [ |
|
273 | - 'id' => $subitem['id'], |
|
274 | - 'content' => $subcontent |
|
275 | - ]; |
|
276 | - } |
|
277 | - } |
|
278 | - $contentItems[$item['id']] = [ |
|
279 | - 'id' => $item['id'], |
|
280 | - 'content' => $content |
|
281 | - ]; |
|
282 | - } |
|
283 | - |
|
284 | - $this->eventDispatcher->dispatchTyped(new ResourcesLoadAdditionalScriptsEvent()); |
|
285 | - $event = new LoadAdditionalScriptsEvent(); |
|
286 | - $this->eventDispatcher->dispatchTyped($event); |
|
287 | - $this->eventDispatcher->dispatchTyped(new LoadSidebar()); |
|
288 | - // Load Viewer scripts |
|
289 | - if (class_exists(LoadViewer::class)) { |
|
290 | - $this->eventDispatcher->dispatchTyped(new LoadViewer()); |
|
291 | - } |
|
292 | - |
|
293 | - $this->initialState->provideInitialState('templates_path', $this->templateManager->hasTemplateDirectory() ? $this->templateManager->getTemplatePath() : false); |
|
294 | - $this->initialState->provideInitialState('templates', $this->templateManager->listCreators()); |
|
295 | - |
|
296 | - $params = []; |
|
297 | - $params['usedSpacePercent'] = (int) $storageInfo['relative']; |
|
298 | - $params['owner'] = $storageInfo['owner'] ?? ''; |
|
299 | - $params['ownerDisplayName'] = $storageInfo['ownerDisplayName'] ?? ''; |
|
300 | - $params['isPublic'] = false; |
|
301 | - $params['allowShareWithLink'] = $this->shareManager->shareApiAllowLinks() ? 'yes' : 'no'; |
|
302 | - $params['defaultFileSorting'] = $this->config->getUserValue($userId, 'files', 'file_sorting', 'name'); |
|
303 | - $params['defaultFileSortingDirection'] = $this->config->getUserValue($userId, 'files', 'file_sorting_direction', 'asc'); |
|
304 | - $params['showgridview'] = $this->config->getUserValue($userId, 'files', 'show_grid', false); |
|
305 | - $showHidden = (bool) $this->config->getUserValue($userId, 'files', 'show_hidden', false); |
|
306 | - $params['showHiddenFiles'] = $showHidden ? 1 : 0; |
|
307 | - $cropImagePreviews = (bool) $this->config->getUserValue($userId, 'files', 'crop_image_previews', true); |
|
308 | - $params['cropImagePreviews'] = $cropImagePreviews ? 1 : 0; |
|
309 | - $params['fileNotFound'] = $fileNotFound ? 1 : 0; |
|
310 | - $params['appNavigation'] = $nav; |
|
311 | - $params['appContents'] = $contentItems; |
|
312 | - $params['hiddenFields'] = $event->getHiddenFields(); |
|
313 | - |
|
314 | - $response = new TemplateResponse( |
|
315 | - Application::APP_ID, |
|
316 | - 'index', |
|
317 | - $params |
|
318 | - ); |
|
319 | - $policy = new ContentSecurityPolicy(); |
|
320 | - $policy->addAllowedFrameDomain('\'self\''); |
|
321 | - $response->setContentSecurityPolicy($policy); |
|
322 | - |
|
323 | - $this->provideInitialState($dir, $openfile); |
|
324 | - |
|
325 | - return $response; |
|
326 | - } |
|
327 | - |
|
328 | - /** |
|
329 | - * Add openFileInfo in initialState if $openfile is set. |
|
330 | - * @param string $dir - the ?dir= URL param |
|
331 | - * @param string $openfile - the ?openfile= URL param |
|
332 | - * @return void |
|
333 | - */ |
|
334 | - private function provideInitialState(string $dir, ?string $openfile): void { |
|
335 | - if ($openfile === null) { |
|
336 | - return; |
|
337 | - } |
|
338 | - |
|
339 | - $user = $this->userSession->getUser(); |
|
340 | - |
|
341 | - if ($user === null) { |
|
342 | - return; |
|
343 | - } |
|
344 | - |
|
345 | - $uid = $user->getUID(); |
|
346 | - $userFolder = $this->rootFolder->getUserFolder($uid); |
|
347 | - $nodes = $userFolder->getById((int) $openfile); |
|
348 | - $node = array_shift($nodes); |
|
349 | - |
|
350 | - if ($node === null) { |
|
351 | - return; |
|
352 | - } |
|
353 | - |
|
354 | - // properly format full path and make sure |
|
355 | - // we're relative to the user home folder |
|
356 | - $isRoot = $node === $userFolder; |
|
357 | - $path = $userFolder->getRelativePath($node->getPath()); |
|
358 | - $directory = $userFolder->getRelativePath($node->getParent()->getPath()); |
|
359 | - |
|
360 | - // Prevent opening a file from another folder. |
|
361 | - if ($dir !== $directory) { |
|
362 | - return; |
|
363 | - } |
|
364 | - |
|
365 | - $this->initialState->provideInitialState( |
|
366 | - 'openFileInfo', [ |
|
367 | - 'id' => $node->getId(), |
|
368 | - 'name' => $isRoot ? '' : $node->getName(), |
|
369 | - 'path' => $path, |
|
370 | - 'directory' => $directory, |
|
371 | - 'mime' => $node->getMimetype(), |
|
372 | - 'type' => $node->getType(), |
|
373 | - 'permissions' => $node->getPermissions(), |
|
374 | - ] |
|
375 | - ); |
|
376 | - } |
|
377 | - |
|
378 | - /** |
|
379 | - * Redirects to the file list and highlight the given file id |
|
380 | - * |
|
381 | - * @param string $fileId file id to show |
|
382 | - * @param bool $setOpenfile - whether or not to set the openfile URL parameter |
|
383 | - * @return RedirectResponse redirect response or not found response |
|
384 | - * @throws \OCP\Files\NotFoundException |
|
385 | - */ |
|
386 | - private function redirectToFile($fileId, bool $setOpenfile = false) { |
|
387 | - $uid = $this->userSession->getUser()->getUID(); |
|
388 | - $baseFolder = $this->rootFolder->getUserFolder($uid); |
|
389 | - $files = $baseFolder->getById($fileId); |
|
390 | - $params = []; |
|
391 | - |
|
392 | - if (empty($files) && $this->appManager->isEnabledForUser('files_trashbin')) { |
|
393 | - $baseFolder = $this->rootFolder->get($uid . '/files_trashbin/files/'); |
|
394 | - $files = $baseFolder->getById($fileId); |
|
395 | - $params['view'] = 'trashbin'; |
|
396 | - } |
|
397 | - |
|
398 | - if (!empty($files)) { |
|
399 | - $file = current($files); |
|
400 | - if ($file instanceof Folder) { |
|
401 | - // set the full path to enter the folder |
|
402 | - $params['dir'] = $baseFolder->getRelativePath($file->getPath()); |
|
403 | - } else { |
|
404 | - // set parent path as dir |
|
405 | - $params['dir'] = $baseFolder->getRelativePath($file->getParent()->getPath()); |
|
406 | - // and scroll to the entry |
|
407 | - $params['scrollto'] = $file->getName(); |
|
408 | - |
|
409 | - if ($setOpenfile) { |
|
410 | - // forward the openfile URL parameter. |
|
411 | - $params['openfile'] = $fileId; |
|
412 | - } |
|
413 | - } |
|
414 | - |
|
415 | - return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', $params)); |
|
416 | - } |
|
417 | - throw new \OCP\Files\NotFoundException(); |
|
418 | - } |
|
70 | + private IURLGenerator $urlGenerator; |
|
71 | + private IL10N $l10n; |
|
72 | + private IConfig $config; |
|
73 | + private IEventDispatcher $eventDispatcher; |
|
74 | + private IUserSession $userSession; |
|
75 | + private IAppManager $appManager; |
|
76 | + private IRootFolder $rootFolder; |
|
77 | + private Helper $activityHelper; |
|
78 | + private IInitialState $initialState; |
|
79 | + private ITemplateManager $templateManager; |
|
80 | + private IManager $shareManager; |
|
81 | + private UserConfig $userConfig; |
|
82 | + |
|
83 | + public function __construct(string $appName, |
|
84 | + IRequest $request, |
|
85 | + IURLGenerator $urlGenerator, |
|
86 | + IL10N $l10n, |
|
87 | + IConfig $config, |
|
88 | + IEventDispatcher $eventDispatcher, |
|
89 | + IUserSession $userSession, |
|
90 | + IAppManager $appManager, |
|
91 | + IRootFolder $rootFolder, |
|
92 | + Helper $activityHelper, |
|
93 | + IInitialState $initialState, |
|
94 | + ITemplateManager $templateManager, |
|
95 | + IManager $shareManager, |
|
96 | + UserConfig $userConfig |
|
97 | + ) { |
|
98 | + parent::__construct($appName, $request); |
|
99 | + $this->urlGenerator = $urlGenerator; |
|
100 | + $this->l10n = $l10n; |
|
101 | + $this->config = $config; |
|
102 | + $this->eventDispatcher = $eventDispatcher; |
|
103 | + $this->userSession = $userSession; |
|
104 | + $this->appManager = $appManager; |
|
105 | + $this->rootFolder = $rootFolder; |
|
106 | + $this->activityHelper = $activityHelper; |
|
107 | + $this->initialState = $initialState; |
|
108 | + $this->templateManager = $templateManager; |
|
109 | + $this->shareManager = $shareManager; |
|
110 | + $this->userConfig = $userConfig; |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * @param string $appName |
|
115 | + * @param string $scriptName |
|
116 | + * @return string |
|
117 | + */ |
|
118 | + protected function renderScript($appName, $scriptName) { |
|
119 | + $content = ''; |
|
120 | + $appPath = \OC_App::getAppPath($appName); |
|
121 | + $scriptPath = $appPath . '/' . $scriptName; |
|
122 | + if (file_exists($scriptPath)) { |
|
123 | + // TODO: sanitize path / script name ? |
|
124 | + ob_start(); |
|
125 | + include $scriptPath; |
|
126 | + $content = ob_get_contents(); |
|
127 | + @ob_end_clean(); |
|
128 | + } |
|
129 | + |
|
130 | + return $content; |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * FIXME: Replace with non static code |
|
135 | + * |
|
136 | + * @return array |
|
137 | + * @throws \OCP\Files\NotFoundException |
|
138 | + */ |
|
139 | + protected function getStorageInfo() { |
|
140 | + \OC_Util::setupFS(); |
|
141 | + $dirInfo = \OC\Files\Filesystem::getFileInfo('/', false); |
|
142 | + |
|
143 | + return \OC_Helper::getStorageInfo('/', $dirInfo); |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * @NoCSRFRequired |
|
148 | + * @NoAdminRequired |
|
149 | + * |
|
150 | + * @param string $fileid |
|
151 | + * @return TemplateResponse|RedirectResponse |
|
152 | + * @throws NotFoundException |
|
153 | + */ |
|
154 | + public function showFile(string $fileid = null, int $openfile = 1): Response { |
|
155 | + // This is the entry point from the `/f/{fileid}` URL which is hardcoded in the server. |
|
156 | + try { |
|
157 | + return $this->redirectToFile($fileid, $openfile !== 0); |
|
158 | + } catch (NotFoundException $e) { |
|
159 | + return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true])); |
|
160 | + } |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * @NoCSRFRequired |
|
165 | + * @NoAdminRequired |
|
166 | + * @UseSession |
|
167 | + * |
|
168 | + * @param string $dir |
|
169 | + * @param string $view |
|
170 | + * @param string $fileid |
|
171 | + * @param bool $fileNotFound |
|
172 | + * @param string $openfile - the openfile URL parameter if it was present in the initial request |
|
173 | + * @return TemplateResponse|RedirectResponse |
|
174 | + * @throws NotFoundException |
|
175 | + */ |
|
176 | + public function index($dir = '', $view = '', $fileid = null, $fileNotFound = false, $openfile = null) { |
|
177 | + |
|
178 | + if ($fileid !== null && $dir === '') { |
|
179 | + try { |
|
180 | + return $this->redirectToFile($fileid); |
|
181 | + } catch (NotFoundException $e) { |
|
182 | + return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true])); |
|
183 | + } |
|
184 | + } |
|
185 | + |
|
186 | + $nav = new \OCP\Template('files', 'appnavigation', ''); |
|
187 | + |
|
188 | + // Load the files we need |
|
189 | + \OCP\Util::addStyle('files', 'merged'); |
|
190 | + \OCP\Util::addScript('files', 'merged-index', 'files'); |
|
191 | + \OCP\Util::addScript('files', 'main'); |
|
192 | + |
|
193 | + // mostly for the home storage's free space |
|
194 | + // FIXME: Make non static |
|
195 | + $storageInfo = $this->getStorageInfo(); |
|
196 | + |
|
197 | + $userId = $this->userSession->getUser()->getUID(); |
|
198 | + |
|
199 | + // Get all the user favorites to create a submenu |
|
200 | + try { |
|
201 | + $favElements = $this->activityHelper->getFavoriteFilePaths($userId); |
|
202 | + } catch (\RuntimeException $e) { |
|
203 | + $favElements['folders'] = []; |
|
204 | + } |
|
205 | + |
|
206 | + $collapseClasses = ''; |
|
207 | + if (count($favElements['folders']) > 0) { |
|
208 | + $collapseClasses = 'collapsible'; |
|
209 | + } |
|
210 | + |
|
211 | + $favoritesSublistArray = []; |
|
212 | + |
|
213 | + $navBarPositionPosition = 6; |
|
214 | + foreach ($favElements['folders'] as $favElement) { |
|
215 | + $element = [ |
|
216 | + 'id' => str_replace('/', '-', $favElement), |
|
217 | + 'dir' => $favElement, |
|
218 | + 'order' => $navBarPositionPosition, |
|
219 | + 'name' => basename($favElement), |
|
220 | + 'icon' => 'folder', |
|
221 | + 'params' => [ |
|
222 | + 'view' => 'files', |
|
223 | + 'dir' => $favElement, |
|
224 | + ], |
|
225 | + ]; |
|
226 | + |
|
227 | + array_push($favoritesSublistArray, $element); |
|
228 | + $navBarPositionPosition++; |
|
229 | + } |
|
230 | + |
|
231 | + $navItems = \OCA\Files\App::getNavigationManager()->getAll(); |
|
232 | + |
|
233 | + // add the favorites entry in menu |
|
234 | + $navItems['favorites']['sublist'] = $favoritesSublistArray; |
|
235 | + $navItems['favorites']['classes'] = $collapseClasses; |
|
236 | + |
|
237 | + // parse every menu and add the expanded user value |
|
238 | + foreach ($navItems as $key => $item) { |
|
239 | + $navItems[$key]['expanded'] = $this->config->getUserValue($userId, 'files', 'show_' . $item['id'], '0') === '1'; |
|
240 | + } |
|
241 | + |
|
242 | + $nav->assign('navigationItems', $navItems); |
|
243 | + |
|
244 | + $nav->assign('usage', \OC_Helper::humanFileSize($storageInfo['used'])); |
|
245 | + if ($storageInfo['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED) { |
|
246 | + $totalSpace = $this->l10n->t('Unlimited'); |
|
247 | + } else { |
|
248 | + $totalSpace = \OC_Helper::humanFileSize($storageInfo['total']); |
|
249 | + } |
|
250 | + $nav->assign('total_space', $totalSpace); |
|
251 | + $nav->assign('quota', $storageInfo['quota']); |
|
252 | + $nav->assign('usage_relative', $storageInfo['relative']); |
|
253 | + |
|
254 | + $contentItems = []; |
|
255 | + |
|
256 | + $this->initialState->provideInitialState('navigation', $navItems); |
|
257 | + $this->initialState->provideInitialState('config', $this->userConfig->getConfigs()); |
|
258 | + |
|
259 | + // render the container content for every navigation item |
|
260 | + foreach ($navItems as $item) { |
|
261 | + $content = ''; |
|
262 | + if (isset($item['script'])) { |
|
263 | + $content = $this->renderScript($item['appname'], $item['script']); |
|
264 | + } |
|
265 | + // parse submenus |
|
266 | + if (isset($item['sublist'])) { |
|
267 | + foreach ($item['sublist'] as $subitem) { |
|
268 | + $subcontent = ''; |
|
269 | + if (isset($subitem['script'])) { |
|
270 | + $subcontent = $this->renderScript($subitem['appname'], $subitem['script']); |
|
271 | + } |
|
272 | + $contentItems[$subitem['id']] = [ |
|
273 | + 'id' => $subitem['id'], |
|
274 | + 'content' => $subcontent |
|
275 | + ]; |
|
276 | + } |
|
277 | + } |
|
278 | + $contentItems[$item['id']] = [ |
|
279 | + 'id' => $item['id'], |
|
280 | + 'content' => $content |
|
281 | + ]; |
|
282 | + } |
|
283 | + |
|
284 | + $this->eventDispatcher->dispatchTyped(new ResourcesLoadAdditionalScriptsEvent()); |
|
285 | + $event = new LoadAdditionalScriptsEvent(); |
|
286 | + $this->eventDispatcher->dispatchTyped($event); |
|
287 | + $this->eventDispatcher->dispatchTyped(new LoadSidebar()); |
|
288 | + // Load Viewer scripts |
|
289 | + if (class_exists(LoadViewer::class)) { |
|
290 | + $this->eventDispatcher->dispatchTyped(new LoadViewer()); |
|
291 | + } |
|
292 | + |
|
293 | + $this->initialState->provideInitialState('templates_path', $this->templateManager->hasTemplateDirectory() ? $this->templateManager->getTemplatePath() : false); |
|
294 | + $this->initialState->provideInitialState('templates', $this->templateManager->listCreators()); |
|
295 | + |
|
296 | + $params = []; |
|
297 | + $params['usedSpacePercent'] = (int) $storageInfo['relative']; |
|
298 | + $params['owner'] = $storageInfo['owner'] ?? ''; |
|
299 | + $params['ownerDisplayName'] = $storageInfo['ownerDisplayName'] ?? ''; |
|
300 | + $params['isPublic'] = false; |
|
301 | + $params['allowShareWithLink'] = $this->shareManager->shareApiAllowLinks() ? 'yes' : 'no'; |
|
302 | + $params['defaultFileSorting'] = $this->config->getUserValue($userId, 'files', 'file_sorting', 'name'); |
|
303 | + $params['defaultFileSortingDirection'] = $this->config->getUserValue($userId, 'files', 'file_sorting_direction', 'asc'); |
|
304 | + $params['showgridview'] = $this->config->getUserValue($userId, 'files', 'show_grid', false); |
|
305 | + $showHidden = (bool) $this->config->getUserValue($userId, 'files', 'show_hidden', false); |
|
306 | + $params['showHiddenFiles'] = $showHidden ? 1 : 0; |
|
307 | + $cropImagePreviews = (bool) $this->config->getUserValue($userId, 'files', 'crop_image_previews', true); |
|
308 | + $params['cropImagePreviews'] = $cropImagePreviews ? 1 : 0; |
|
309 | + $params['fileNotFound'] = $fileNotFound ? 1 : 0; |
|
310 | + $params['appNavigation'] = $nav; |
|
311 | + $params['appContents'] = $contentItems; |
|
312 | + $params['hiddenFields'] = $event->getHiddenFields(); |
|
313 | + |
|
314 | + $response = new TemplateResponse( |
|
315 | + Application::APP_ID, |
|
316 | + 'index', |
|
317 | + $params |
|
318 | + ); |
|
319 | + $policy = new ContentSecurityPolicy(); |
|
320 | + $policy->addAllowedFrameDomain('\'self\''); |
|
321 | + $response->setContentSecurityPolicy($policy); |
|
322 | + |
|
323 | + $this->provideInitialState($dir, $openfile); |
|
324 | + |
|
325 | + return $response; |
|
326 | + } |
|
327 | + |
|
328 | + /** |
|
329 | + * Add openFileInfo in initialState if $openfile is set. |
|
330 | + * @param string $dir - the ?dir= URL param |
|
331 | + * @param string $openfile - the ?openfile= URL param |
|
332 | + * @return void |
|
333 | + */ |
|
334 | + private function provideInitialState(string $dir, ?string $openfile): void { |
|
335 | + if ($openfile === null) { |
|
336 | + return; |
|
337 | + } |
|
338 | + |
|
339 | + $user = $this->userSession->getUser(); |
|
340 | + |
|
341 | + if ($user === null) { |
|
342 | + return; |
|
343 | + } |
|
344 | + |
|
345 | + $uid = $user->getUID(); |
|
346 | + $userFolder = $this->rootFolder->getUserFolder($uid); |
|
347 | + $nodes = $userFolder->getById((int) $openfile); |
|
348 | + $node = array_shift($nodes); |
|
349 | + |
|
350 | + if ($node === null) { |
|
351 | + return; |
|
352 | + } |
|
353 | + |
|
354 | + // properly format full path and make sure |
|
355 | + // we're relative to the user home folder |
|
356 | + $isRoot = $node === $userFolder; |
|
357 | + $path = $userFolder->getRelativePath($node->getPath()); |
|
358 | + $directory = $userFolder->getRelativePath($node->getParent()->getPath()); |
|
359 | + |
|
360 | + // Prevent opening a file from another folder. |
|
361 | + if ($dir !== $directory) { |
|
362 | + return; |
|
363 | + } |
|
364 | + |
|
365 | + $this->initialState->provideInitialState( |
|
366 | + 'openFileInfo', [ |
|
367 | + 'id' => $node->getId(), |
|
368 | + 'name' => $isRoot ? '' : $node->getName(), |
|
369 | + 'path' => $path, |
|
370 | + 'directory' => $directory, |
|
371 | + 'mime' => $node->getMimetype(), |
|
372 | + 'type' => $node->getType(), |
|
373 | + 'permissions' => $node->getPermissions(), |
|
374 | + ] |
|
375 | + ); |
|
376 | + } |
|
377 | + |
|
378 | + /** |
|
379 | + * Redirects to the file list and highlight the given file id |
|
380 | + * |
|
381 | + * @param string $fileId file id to show |
|
382 | + * @param bool $setOpenfile - whether or not to set the openfile URL parameter |
|
383 | + * @return RedirectResponse redirect response or not found response |
|
384 | + * @throws \OCP\Files\NotFoundException |
|
385 | + */ |
|
386 | + private function redirectToFile($fileId, bool $setOpenfile = false) { |
|
387 | + $uid = $this->userSession->getUser()->getUID(); |
|
388 | + $baseFolder = $this->rootFolder->getUserFolder($uid); |
|
389 | + $files = $baseFolder->getById($fileId); |
|
390 | + $params = []; |
|
391 | + |
|
392 | + if (empty($files) && $this->appManager->isEnabledForUser('files_trashbin')) { |
|
393 | + $baseFolder = $this->rootFolder->get($uid . '/files_trashbin/files/'); |
|
394 | + $files = $baseFolder->getById($fileId); |
|
395 | + $params['view'] = 'trashbin'; |
|
396 | + } |
|
397 | + |
|
398 | + if (!empty($files)) { |
|
399 | + $file = current($files); |
|
400 | + if ($file instanceof Folder) { |
|
401 | + // set the full path to enter the folder |
|
402 | + $params['dir'] = $baseFolder->getRelativePath($file->getPath()); |
|
403 | + } else { |
|
404 | + // set parent path as dir |
|
405 | + $params['dir'] = $baseFolder->getRelativePath($file->getParent()->getPath()); |
|
406 | + // and scroll to the entry |
|
407 | + $params['scrollto'] = $file->getName(); |
|
408 | + |
|
409 | + if ($setOpenfile) { |
|
410 | + // forward the openfile URL parameter. |
|
411 | + $params['openfile'] = $fileId; |
|
412 | + } |
|
413 | + } |
|
414 | + |
|
415 | + return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', $params)); |
|
416 | + } |
|
417 | + throw new \OCP\Files\NotFoundException(); |
|
418 | + } |
|
419 | 419 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | protected function renderScript($appName, $scriptName) { |
119 | 119 | $content = ''; |
120 | 120 | $appPath = \OC_App::getAppPath($appName); |
121 | - $scriptPath = $appPath . '/' . $scriptName; |
|
121 | + $scriptPath = $appPath.'/'.$scriptName; |
|
122 | 122 | if (file_exists($scriptPath)) { |
123 | 123 | // TODO: sanitize path / script name ? |
124 | 124 | ob_start(); |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | // parse every menu and add the expanded user value |
238 | 238 | foreach ($navItems as $key => $item) { |
239 | - $navItems[$key]['expanded'] = $this->config->getUserValue($userId, 'files', 'show_' . $item['id'], '0') === '1'; |
|
239 | + $navItems[$key]['expanded'] = $this->config->getUserValue($userId, 'files', 'show_'.$item['id'], '0') === '1'; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | $nav->assign('navigationItems', $navItems); |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | $params = []; |
391 | 391 | |
392 | 392 | if (empty($files) && $this->appManager->isEnabledForUser('files_trashbin')) { |
393 | - $baseFolder = $this->rootFolder->get($uid . '/files_trashbin/files/'); |
|
393 | + $baseFolder = $this->rootFolder->get($uid.'/files_trashbin/files/'); |
|
394 | 394 | $files = $baseFolder->getById($fileId); |
395 | 395 | $params['view'] = 'trashbin'; |
396 | 396 | } |
@@ -42,175 +42,175 @@ |
||
42 | 42 | // Legacy routes above |
43 | 43 | /** @var $this \OC\Route\Router */ |
44 | 44 | $this->create('files_ajax_download', 'apps/files/ajax/download.php') |
45 | - ->actionInclude('files/ajax/download.php'); |
|
45 | + ->actionInclude('files/ajax/download.php'); |
|
46 | 46 | $this->create('files_ajax_list', 'apps/files/ajax/list.php') |
47 | - ->actionInclude('files/ajax/list.php'); |
|
47 | + ->actionInclude('files/ajax/list.php'); |
|
48 | 48 | |
49 | 49 | /** @var Application $application */ |
50 | 50 | $application = \OC::$server->query(Application::class); |
51 | 51 | $application->registerRoutes( |
52 | - $this, |
|
53 | - [ |
|
54 | - 'routes' => [ |
|
55 | - [ |
|
56 | - 'name' => 'view#index', |
|
57 | - 'url' => '/', |
|
58 | - 'verb' => 'GET', |
|
59 | - ], |
|
60 | - [ |
|
61 | - 'name' => 'view#index', |
|
62 | - 'url' => '/{view}', |
|
63 | - 'verb' => 'GET', |
|
64 | - 'postfix' => 'view', |
|
65 | - ], |
|
66 | - [ |
|
67 | - 'name' => 'view#index', |
|
68 | - 'url' => '/{view}/{fileid}', |
|
69 | - 'verb' => 'GET', |
|
70 | - 'postfix' => 'fileid', |
|
71 | - ], |
|
72 | - [ |
|
73 | - 'name' => 'View#showFile', |
|
74 | - 'url' => '/f/{fileid}', |
|
75 | - 'verb' => 'GET', |
|
76 | - 'root' => '', |
|
77 | - ], |
|
78 | - [ |
|
79 | - 'name' => 'ajax#getStorageStats', |
|
80 | - 'url' => '/ajax/getstoragestats', |
|
81 | - 'verb' => 'GET', |
|
82 | - ], |
|
83 | - [ |
|
84 | - 'name' => 'API#getThumbnail', |
|
85 | - 'url' => '/api/v1/thumbnail/{x}/{y}/{file}', |
|
86 | - 'verb' => 'GET', |
|
87 | - 'requirements' => ['file' => '.+'] |
|
88 | - ], |
|
89 | - [ |
|
90 | - 'name' => 'API#updateFileTags', |
|
91 | - 'url' => '/api/v1/files/{path}', |
|
92 | - 'verb' => 'POST', |
|
93 | - 'requirements' => ['path' => '.+'], |
|
94 | - ], |
|
95 | - [ |
|
96 | - 'name' => 'API#getRecentFiles', |
|
97 | - 'url' => '/api/v1/recent/', |
|
98 | - 'verb' => 'GET' |
|
99 | - ], |
|
100 | - [ |
|
101 | - 'name' => 'API#setConfig', |
|
102 | - 'url' => '/api/v1/config/{key}', |
|
103 | - 'verb' => 'POST' |
|
104 | - ], |
|
105 | - [ |
|
106 | - 'name' => 'API#getConfigs', |
|
107 | - 'url' => '/api/v1/configs', |
|
108 | - 'verb' => 'GET' |
|
109 | - ], |
|
110 | - [ |
|
111 | - 'name' => 'API#updateFileSorting', |
|
112 | - 'url' => '/api/v1/sorting', |
|
113 | - 'verb' => 'POST' |
|
114 | - ], |
|
115 | - [ |
|
116 | - 'name' => 'API#showHiddenFiles', |
|
117 | - 'url' => '/api/v1/showhidden', |
|
118 | - 'verb' => 'POST' |
|
119 | - ], |
|
120 | - [ |
|
121 | - 'name' => 'API#cropImagePreviews', |
|
122 | - 'url' => '/api/v1/cropimagepreviews', |
|
123 | - 'verb' => 'POST' |
|
124 | - ], |
|
125 | - [ |
|
126 | - 'name' => 'API#showGridView', |
|
127 | - 'url' => '/api/v1/showgridview', |
|
128 | - 'verb' => 'POST' |
|
129 | - ], |
|
130 | - [ |
|
131 | - 'name' => 'API#getGridView', |
|
132 | - 'url' => '/api/v1/showgridview', |
|
133 | - 'verb' => 'GET' |
|
134 | - ], |
|
135 | - [ |
|
136 | - 'name' => 'API#toggleShowFolder', |
|
137 | - 'url' => '/api/v1/toggleShowFolder/{key}', |
|
138 | - 'verb' => 'POST' |
|
139 | - ], |
|
140 | - [ |
|
141 | - 'name' => 'API#getNodeType', |
|
142 | - 'url' => '/api/v1/quickaccess/get/NodeType', |
|
143 | - 'verb' => 'GET', |
|
144 | - ], |
|
145 | - [ |
|
146 | - 'name' => 'DirectEditingView#edit', |
|
147 | - 'url' => '/directEditing/{token}', |
|
148 | - 'verb' => 'GET' |
|
149 | - ], |
|
150 | - ], |
|
151 | - 'ocs' => [ |
|
152 | - [ |
|
153 | - 'name' => 'DirectEditing#info', |
|
154 | - 'url' => '/api/v1/directEditing', |
|
155 | - 'verb' => 'GET' |
|
156 | - ], |
|
157 | - [ |
|
158 | - 'name' => 'DirectEditing#templates', |
|
159 | - 'url' => '/api/v1/directEditing/templates/{editorId}/{creatorId}', |
|
160 | - 'verb' => 'GET' |
|
161 | - ], |
|
162 | - [ |
|
163 | - 'name' => 'DirectEditing#open', |
|
164 | - 'url' => '/api/v1/directEditing/open', |
|
165 | - 'verb' => 'POST' |
|
166 | - ], |
|
167 | - [ |
|
168 | - 'name' => 'DirectEditing#create', |
|
169 | - 'url' => '/api/v1/directEditing/create', |
|
170 | - 'verb' => 'POST' |
|
171 | - ], |
|
172 | - [ |
|
173 | - 'name' => 'Template#list', |
|
174 | - 'url' => '/api/v1/templates', |
|
175 | - 'verb' => 'GET' |
|
176 | - ], |
|
177 | - [ |
|
178 | - 'name' => 'Template#create', |
|
179 | - 'url' => '/api/v1/templates/create', |
|
180 | - 'verb' => 'POST' |
|
181 | - ], |
|
182 | - [ |
|
183 | - 'name' => 'Template#path', |
|
184 | - 'url' => '/api/v1/templates/path', |
|
185 | - 'verb' => 'POST' |
|
186 | - ], |
|
187 | - [ |
|
188 | - 'name' => 'TransferOwnership#transfer', |
|
189 | - 'url' => '/api/v1/transferownership', |
|
190 | - 'verb' => 'POST', |
|
191 | - ], |
|
192 | - [ |
|
193 | - 'name' => 'TransferOwnership#accept', |
|
194 | - 'url' => '/api/v1/transferownership/{id}', |
|
195 | - 'verb' => 'POST', |
|
196 | - ], |
|
197 | - [ |
|
198 | - 'name' => 'TransferOwnership#reject', |
|
199 | - 'url' => '/api/v1/transferownership/{id}', |
|
200 | - 'verb' => 'DELETE', |
|
201 | - ], |
|
202 | - [ |
|
203 | - /** @see OpenLocalEditorController::create() */ |
|
204 | - 'name' => 'OpenLocalEditor#create', |
|
205 | - 'url' => '/api/v1/openlocaleditor', |
|
206 | - 'verb' => 'POST', |
|
207 | - ], |
|
208 | - [ |
|
209 | - /** @see OpenLocalEditorController::validate() */ |
|
210 | - 'name' => 'OpenLocalEditor#validate', |
|
211 | - 'url' => '/api/v1/openlocaleditor/{token}', |
|
212 | - 'verb' => 'POST', |
|
213 | - ], |
|
214 | - ], |
|
215 | - ] |
|
52 | + $this, |
|
53 | + [ |
|
54 | + 'routes' => [ |
|
55 | + [ |
|
56 | + 'name' => 'view#index', |
|
57 | + 'url' => '/', |
|
58 | + 'verb' => 'GET', |
|
59 | + ], |
|
60 | + [ |
|
61 | + 'name' => 'view#index', |
|
62 | + 'url' => '/{view}', |
|
63 | + 'verb' => 'GET', |
|
64 | + 'postfix' => 'view', |
|
65 | + ], |
|
66 | + [ |
|
67 | + 'name' => 'view#index', |
|
68 | + 'url' => '/{view}/{fileid}', |
|
69 | + 'verb' => 'GET', |
|
70 | + 'postfix' => 'fileid', |
|
71 | + ], |
|
72 | + [ |
|
73 | + 'name' => 'View#showFile', |
|
74 | + 'url' => '/f/{fileid}', |
|
75 | + 'verb' => 'GET', |
|
76 | + 'root' => '', |
|
77 | + ], |
|
78 | + [ |
|
79 | + 'name' => 'ajax#getStorageStats', |
|
80 | + 'url' => '/ajax/getstoragestats', |
|
81 | + 'verb' => 'GET', |
|
82 | + ], |
|
83 | + [ |
|
84 | + 'name' => 'API#getThumbnail', |
|
85 | + 'url' => '/api/v1/thumbnail/{x}/{y}/{file}', |
|
86 | + 'verb' => 'GET', |
|
87 | + 'requirements' => ['file' => '.+'] |
|
88 | + ], |
|
89 | + [ |
|
90 | + 'name' => 'API#updateFileTags', |
|
91 | + 'url' => '/api/v1/files/{path}', |
|
92 | + 'verb' => 'POST', |
|
93 | + 'requirements' => ['path' => '.+'], |
|
94 | + ], |
|
95 | + [ |
|
96 | + 'name' => 'API#getRecentFiles', |
|
97 | + 'url' => '/api/v1/recent/', |
|
98 | + 'verb' => 'GET' |
|
99 | + ], |
|
100 | + [ |
|
101 | + 'name' => 'API#setConfig', |
|
102 | + 'url' => '/api/v1/config/{key}', |
|
103 | + 'verb' => 'POST' |
|
104 | + ], |
|
105 | + [ |
|
106 | + 'name' => 'API#getConfigs', |
|
107 | + 'url' => '/api/v1/configs', |
|
108 | + 'verb' => 'GET' |
|
109 | + ], |
|
110 | + [ |
|
111 | + 'name' => 'API#updateFileSorting', |
|
112 | + 'url' => '/api/v1/sorting', |
|
113 | + 'verb' => 'POST' |
|
114 | + ], |
|
115 | + [ |
|
116 | + 'name' => 'API#showHiddenFiles', |
|
117 | + 'url' => '/api/v1/showhidden', |
|
118 | + 'verb' => 'POST' |
|
119 | + ], |
|
120 | + [ |
|
121 | + 'name' => 'API#cropImagePreviews', |
|
122 | + 'url' => '/api/v1/cropimagepreviews', |
|
123 | + 'verb' => 'POST' |
|
124 | + ], |
|
125 | + [ |
|
126 | + 'name' => 'API#showGridView', |
|
127 | + 'url' => '/api/v1/showgridview', |
|
128 | + 'verb' => 'POST' |
|
129 | + ], |
|
130 | + [ |
|
131 | + 'name' => 'API#getGridView', |
|
132 | + 'url' => '/api/v1/showgridview', |
|
133 | + 'verb' => 'GET' |
|
134 | + ], |
|
135 | + [ |
|
136 | + 'name' => 'API#toggleShowFolder', |
|
137 | + 'url' => '/api/v1/toggleShowFolder/{key}', |
|
138 | + 'verb' => 'POST' |
|
139 | + ], |
|
140 | + [ |
|
141 | + 'name' => 'API#getNodeType', |
|
142 | + 'url' => '/api/v1/quickaccess/get/NodeType', |
|
143 | + 'verb' => 'GET', |
|
144 | + ], |
|
145 | + [ |
|
146 | + 'name' => 'DirectEditingView#edit', |
|
147 | + 'url' => '/directEditing/{token}', |
|
148 | + 'verb' => 'GET' |
|
149 | + ], |
|
150 | + ], |
|
151 | + 'ocs' => [ |
|
152 | + [ |
|
153 | + 'name' => 'DirectEditing#info', |
|
154 | + 'url' => '/api/v1/directEditing', |
|
155 | + 'verb' => 'GET' |
|
156 | + ], |
|
157 | + [ |
|
158 | + 'name' => 'DirectEditing#templates', |
|
159 | + 'url' => '/api/v1/directEditing/templates/{editorId}/{creatorId}', |
|
160 | + 'verb' => 'GET' |
|
161 | + ], |
|
162 | + [ |
|
163 | + 'name' => 'DirectEditing#open', |
|
164 | + 'url' => '/api/v1/directEditing/open', |
|
165 | + 'verb' => 'POST' |
|
166 | + ], |
|
167 | + [ |
|
168 | + 'name' => 'DirectEditing#create', |
|
169 | + 'url' => '/api/v1/directEditing/create', |
|
170 | + 'verb' => 'POST' |
|
171 | + ], |
|
172 | + [ |
|
173 | + 'name' => 'Template#list', |
|
174 | + 'url' => '/api/v1/templates', |
|
175 | + 'verb' => 'GET' |
|
176 | + ], |
|
177 | + [ |
|
178 | + 'name' => 'Template#create', |
|
179 | + 'url' => '/api/v1/templates/create', |
|
180 | + 'verb' => 'POST' |
|
181 | + ], |
|
182 | + [ |
|
183 | + 'name' => 'Template#path', |
|
184 | + 'url' => '/api/v1/templates/path', |
|
185 | + 'verb' => 'POST' |
|
186 | + ], |
|
187 | + [ |
|
188 | + 'name' => 'TransferOwnership#transfer', |
|
189 | + 'url' => '/api/v1/transferownership', |
|
190 | + 'verb' => 'POST', |
|
191 | + ], |
|
192 | + [ |
|
193 | + 'name' => 'TransferOwnership#accept', |
|
194 | + 'url' => '/api/v1/transferownership/{id}', |
|
195 | + 'verb' => 'POST', |
|
196 | + ], |
|
197 | + [ |
|
198 | + 'name' => 'TransferOwnership#reject', |
|
199 | + 'url' => '/api/v1/transferownership/{id}', |
|
200 | + 'verb' => 'DELETE', |
|
201 | + ], |
|
202 | + [ |
|
203 | + /** @see OpenLocalEditorController::create() */ |
|
204 | + 'name' => 'OpenLocalEditor#create', |
|
205 | + 'url' => '/api/v1/openlocaleditor', |
|
206 | + 'verb' => 'POST', |
|
207 | + ], |
|
208 | + [ |
|
209 | + /** @see OpenLocalEditorController::validate() */ |
|
210 | + 'name' => 'OpenLocalEditor#validate', |
|
211 | + 'url' => '/api/v1/openlocaleditor/{token}', |
|
212 | + 'verb' => 'POST', |
|
213 | + ], |
|
214 | + ], |
|
215 | + ] |
|
216 | 216 | ); |
@@ -82,209 +82,209 @@ |
||
82 | 82 | use Symfony\Component\EventDispatcher\GenericEvent as OldGenericEvent; |
83 | 83 | |
84 | 84 | class Application extends App implements IBootstrap { |
85 | - public const APP_ID = 'files_sharing'; |
|
85 | + public const APP_ID = 'files_sharing'; |
|
86 | 86 | |
87 | - public function __construct(array $urlParams = []) { |
|
88 | - parent::__construct(self::APP_ID, $urlParams); |
|
89 | - } |
|
87 | + public function __construct(array $urlParams = []) { |
|
88 | + parent::__construct(self::APP_ID, $urlParams); |
|
89 | + } |
|
90 | 90 | |
91 | - public function register(IRegistrationContext $context): void { |
|
92 | - $context->registerService(ExternalMountProvider::class, function (ContainerInterface $c) { |
|
93 | - return new ExternalMountProvider( |
|
94 | - $c->get(IDBConnection::class), |
|
95 | - function () use ($c) { |
|
96 | - return $c->get(Manager::class); |
|
97 | - }, |
|
98 | - $c->get(ICloudIdManager::class) |
|
99 | - ); |
|
100 | - }); |
|
91 | + public function register(IRegistrationContext $context): void { |
|
92 | + $context->registerService(ExternalMountProvider::class, function (ContainerInterface $c) { |
|
93 | + return new ExternalMountProvider( |
|
94 | + $c->get(IDBConnection::class), |
|
95 | + function () use ($c) { |
|
96 | + return $c->get(Manager::class); |
|
97 | + }, |
|
98 | + $c->get(ICloudIdManager::class) |
|
99 | + ); |
|
100 | + }); |
|
101 | 101 | |
102 | - /** |
|
103 | - * Middleware |
|
104 | - */ |
|
105 | - $context->registerMiddleWare(SharingCheckMiddleware::class); |
|
106 | - $context->registerMiddleWare(OCSShareAPIMiddleware::class); |
|
107 | - $context->registerMiddleWare(ShareInfoMiddleware::class); |
|
102 | + /** |
|
103 | + * Middleware |
|
104 | + */ |
|
105 | + $context->registerMiddleWare(SharingCheckMiddleware::class); |
|
106 | + $context->registerMiddleWare(OCSShareAPIMiddleware::class); |
|
107 | + $context->registerMiddleWare(ShareInfoMiddleware::class); |
|
108 | 108 | |
109 | - $context->registerCapability(Capabilities::class); |
|
109 | + $context->registerCapability(Capabilities::class); |
|
110 | 110 | |
111 | - $context->registerNotifierService(Notifier::class); |
|
112 | - $context->registerEventListener(UserChangedEvent::class, DisplayNameCache::class); |
|
113 | - $context->registerEventListener(GroupChangedEvent::class, GroupDisplayNameCache::class); |
|
114 | - } |
|
111 | + $context->registerNotifierService(Notifier::class); |
|
112 | + $context->registerEventListener(UserChangedEvent::class, DisplayNameCache::class); |
|
113 | + $context->registerEventListener(GroupChangedEvent::class, GroupDisplayNameCache::class); |
|
114 | + } |
|
115 | 115 | |
116 | - public function boot(IBootContext $context): void { |
|
117 | - $context->injectFn([$this, 'registerMountProviders']); |
|
118 | - $context->injectFn([$this, 'registerEventsScripts']); |
|
119 | - $context->injectFn([$this, 'registerDownloadEvents']); |
|
120 | - $context->injectFn([$this, 'setupSharingMenus']); |
|
116 | + public function boot(IBootContext $context): void { |
|
117 | + $context->injectFn([$this, 'registerMountProviders']); |
|
118 | + $context->injectFn([$this, 'registerEventsScripts']); |
|
119 | + $context->injectFn([$this, 'registerDownloadEvents']); |
|
120 | + $context->injectFn([$this, 'setupSharingMenus']); |
|
121 | 121 | |
122 | - Helper::registerHooks(); |
|
122 | + Helper::registerHooks(); |
|
123 | 123 | |
124 | - Share::registerBackend('file', File::class); |
|
125 | - Share::registerBackend('folder', Folder::class, 'file'); |
|
124 | + Share::registerBackend('file', File::class); |
|
125 | + Share::registerBackend('folder', Folder::class, 'file'); |
|
126 | 126 | |
127 | - /** |
|
128 | - * Always add main sharing script |
|
129 | - */ |
|
130 | - Util::addScript(self::APP_ID, 'main'); |
|
131 | - } |
|
127 | + /** |
|
128 | + * Always add main sharing script |
|
129 | + */ |
|
130 | + Util::addScript(self::APP_ID, 'main'); |
|
131 | + } |
|
132 | 132 | |
133 | 133 | |
134 | - public function registerMountProviders(IMountProviderCollection $mountProviderCollection, MountProvider $mountProvider, ExternalMountProvider $externalMountProvider): void { |
|
135 | - $mountProviderCollection->registerProvider($mountProvider); |
|
136 | - $mountProviderCollection->registerProvider($externalMountProvider); |
|
137 | - } |
|
134 | + public function registerMountProviders(IMountProviderCollection $mountProviderCollection, MountProvider $mountProvider, ExternalMountProvider $externalMountProvider): void { |
|
135 | + $mountProviderCollection->registerProvider($mountProvider); |
|
136 | + $mountProviderCollection->registerProvider($externalMountProvider); |
|
137 | + } |
|
138 | 138 | |
139 | - public function registerEventsScripts(IEventDispatcher $dispatcher, EventDispatcherInterface $oldDispatcher): void { |
|
140 | - // sidebar and files scripts |
|
141 | - $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); |
|
142 | - $dispatcher->addServiceListener(BeforeTemplateRenderedEvent::class, LegacyBeforeTemplateRenderedListener::class); |
|
143 | - $dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class); |
|
144 | - $dispatcher->addServiceListener(ShareCreatedEvent::class, ShareInteractionListener::class); |
|
145 | - $dispatcher->addServiceListener(ShareCreatedEvent::class, UserShareAcceptanceListener::class); |
|
146 | - $dispatcher->addServiceListener(UserAddedEvent::class, UserAddedToGroupListener::class); |
|
147 | - $dispatcher->addListener(ResourcesLoadAdditionalScriptsEvent::class, function () { |
|
148 | - \OCP\Util::addScript('files_sharing', 'collaboration'); |
|
149 | - }); |
|
139 | + public function registerEventsScripts(IEventDispatcher $dispatcher, EventDispatcherInterface $oldDispatcher): void { |
|
140 | + // sidebar and files scripts |
|
141 | + $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); |
|
142 | + $dispatcher->addServiceListener(BeforeTemplateRenderedEvent::class, LegacyBeforeTemplateRenderedListener::class); |
|
143 | + $dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class); |
|
144 | + $dispatcher->addServiceListener(ShareCreatedEvent::class, ShareInteractionListener::class); |
|
145 | + $dispatcher->addServiceListener(ShareCreatedEvent::class, UserShareAcceptanceListener::class); |
|
146 | + $dispatcher->addServiceListener(UserAddedEvent::class, UserAddedToGroupListener::class); |
|
147 | + $dispatcher->addListener(ResourcesLoadAdditionalScriptsEvent::class, function () { |
|
148 | + \OCP\Util::addScript('files_sharing', 'collaboration'); |
|
149 | + }); |
|
150 | 150 | |
151 | - // notifications api to accept incoming user shares |
|
152 | - $oldDispatcher->addListener('OCP\Share::postShare', function (OldGenericEvent $event) { |
|
153 | - /** @var Listener $listener */ |
|
154 | - $listener = $this->getContainer()->query(Listener::class); |
|
155 | - $listener->shareNotification($event); |
|
156 | - }); |
|
157 | - $oldDispatcher->addListener(IGroup::class . '::postAddUser', function (OldGenericEvent $event) { |
|
158 | - /** @var Listener $listener */ |
|
159 | - $listener = $this->getContainer()->query(Listener::class); |
|
160 | - $listener->userAddedToGroup($event); |
|
161 | - }); |
|
162 | - } |
|
151 | + // notifications api to accept incoming user shares |
|
152 | + $oldDispatcher->addListener('OCP\Share::postShare', function (OldGenericEvent $event) { |
|
153 | + /** @var Listener $listener */ |
|
154 | + $listener = $this->getContainer()->query(Listener::class); |
|
155 | + $listener->shareNotification($event); |
|
156 | + }); |
|
157 | + $oldDispatcher->addListener(IGroup::class . '::postAddUser', function (OldGenericEvent $event) { |
|
158 | + /** @var Listener $listener */ |
|
159 | + $listener = $this->getContainer()->query(Listener::class); |
|
160 | + $listener->userAddedToGroup($event); |
|
161 | + }); |
|
162 | + } |
|
163 | 163 | |
164 | - public function registerDownloadEvents( |
|
165 | - IEventDispatcher $dispatcher, |
|
166 | - IUserSession $userSession, |
|
167 | - IRootFolder $rootFolder |
|
168 | - ): void { |
|
164 | + public function registerDownloadEvents( |
|
165 | + IEventDispatcher $dispatcher, |
|
166 | + IUserSession $userSession, |
|
167 | + IRootFolder $rootFolder |
|
168 | + ): void { |
|
169 | 169 | |
170 | - $dispatcher->addListener( |
|
171 | - BeforeDirectFileDownloadEvent::class, |
|
172 | - function (BeforeDirectFileDownloadEvent $event) use ($userSession, $rootFolder): void { |
|
173 | - $pathsToCheck = [$event->getPath()]; |
|
174 | - // Check only for user/group shares. Don't restrict e.g. share links |
|
175 | - $user = $userSession->getUser(); |
|
176 | - if ($user) { |
|
177 | - $viewOnlyHandler = new ViewOnly( |
|
178 | - $rootFolder->getUserFolder($user->getUID()) |
|
179 | - ); |
|
180 | - if (!$viewOnlyHandler->check($pathsToCheck)) { |
|
181 | - $event->setSuccessful(false); |
|
182 | - $event->setErrorMessage('Access to this resource or one of its sub-items has been denied.'); |
|
183 | - } |
|
184 | - } |
|
185 | - } |
|
186 | - ); |
|
170 | + $dispatcher->addListener( |
|
171 | + BeforeDirectFileDownloadEvent::class, |
|
172 | + function (BeforeDirectFileDownloadEvent $event) use ($userSession, $rootFolder): void { |
|
173 | + $pathsToCheck = [$event->getPath()]; |
|
174 | + // Check only for user/group shares. Don't restrict e.g. share links |
|
175 | + $user = $userSession->getUser(); |
|
176 | + if ($user) { |
|
177 | + $viewOnlyHandler = new ViewOnly( |
|
178 | + $rootFolder->getUserFolder($user->getUID()) |
|
179 | + ); |
|
180 | + if (!$viewOnlyHandler->check($pathsToCheck)) { |
|
181 | + $event->setSuccessful(false); |
|
182 | + $event->setErrorMessage('Access to this resource or one of its sub-items has been denied.'); |
|
183 | + } |
|
184 | + } |
|
185 | + } |
|
186 | + ); |
|
187 | 187 | |
188 | - $dispatcher->addListener( |
|
189 | - BeforeZipCreatedEvent::class, |
|
190 | - function (BeforeZipCreatedEvent $event) use ($userSession, $rootFolder): void { |
|
191 | - $dir = $event->getDirectory(); |
|
192 | - $files = $event->getFiles(); |
|
188 | + $dispatcher->addListener( |
|
189 | + BeforeZipCreatedEvent::class, |
|
190 | + function (BeforeZipCreatedEvent $event) use ($userSession, $rootFolder): void { |
|
191 | + $dir = $event->getDirectory(); |
|
192 | + $files = $event->getFiles(); |
|
193 | 193 | |
194 | - $pathsToCheck = []; |
|
195 | - foreach ($files as $file) { |
|
196 | - $pathsToCheck[] = $dir . '/' . $file; |
|
197 | - } |
|
194 | + $pathsToCheck = []; |
|
195 | + foreach ($files as $file) { |
|
196 | + $pathsToCheck[] = $dir . '/' . $file; |
|
197 | + } |
|
198 | 198 | |
199 | - // Check only for user/group shares. Don't restrict e.g. share links |
|
200 | - $user = $userSession->getUser(); |
|
201 | - if ($user) { |
|
202 | - $viewOnlyHandler = new ViewOnly( |
|
203 | - $rootFolder->getUserFolder($user->getUID()) |
|
204 | - ); |
|
205 | - if (!$viewOnlyHandler->check($pathsToCheck)) { |
|
206 | - $event->setErrorMessage('Access to this resource or one of its sub-items has been denied.'); |
|
207 | - $event->setSuccessful(false); |
|
208 | - } else { |
|
209 | - $event->setSuccessful(true); |
|
210 | - } |
|
211 | - } else { |
|
212 | - $event->setSuccessful(true); |
|
213 | - } |
|
214 | - } |
|
215 | - ); |
|
216 | - } |
|
199 | + // Check only for user/group shares. Don't restrict e.g. share links |
|
200 | + $user = $userSession->getUser(); |
|
201 | + if ($user) { |
|
202 | + $viewOnlyHandler = new ViewOnly( |
|
203 | + $rootFolder->getUserFolder($user->getUID()) |
|
204 | + ); |
|
205 | + if (!$viewOnlyHandler->check($pathsToCheck)) { |
|
206 | + $event->setErrorMessage('Access to this resource or one of its sub-items has been denied.'); |
|
207 | + $event->setSuccessful(false); |
|
208 | + } else { |
|
209 | + $event->setSuccessful(true); |
|
210 | + } |
|
211 | + } else { |
|
212 | + $event->setSuccessful(true); |
|
213 | + } |
|
214 | + } |
|
215 | + ); |
|
216 | + } |
|
217 | 217 | |
218 | - public function setupSharingMenus(IManager $shareManager, IFactory $l10nFactory, IUserSession $userSession): void { |
|
219 | - if (!$shareManager->shareApiEnabled() || !class_exists('\OCA\Files\App')) { |
|
220 | - return; |
|
221 | - } |
|
218 | + public function setupSharingMenus(IManager $shareManager, IFactory $l10nFactory, IUserSession $userSession): void { |
|
219 | + if (!$shareManager->shareApiEnabled() || !class_exists('\OCA\Files\App')) { |
|
220 | + return; |
|
221 | + } |
|
222 | 222 | |
223 | - $navigationManager = \OCA\Files\App::getNavigationManager(); |
|
224 | - // show_Quick_Access stored as string |
|
225 | - $navigationManager->add(function () use ($shareManager, $l10nFactory, $userSession) { |
|
226 | - $l = $l10nFactory->get('files_sharing'); |
|
227 | - $user = $userSession->getUser(); |
|
228 | - $userId = $user ? $user->getUID() : null; |
|
223 | + $navigationManager = \OCA\Files\App::getNavigationManager(); |
|
224 | + // show_Quick_Access stored as string |
|
225 | + $navigationManager->add(function () use ($shareManager, $l10nFactory, $userSession) { |
|
226 | + $l = $l10nFactory->get('files_sharing'); |
|
227 | + $user = $userSession->getUser(); |
|
228 | + $userId = $user ? $user->getUID() : null; |
|
229 | 229 | |
230 | - $sharingSublistArray = []; |
|
230 | + $sharingSublistArray = []; |
|
231 | 231 | |
232 | - if ($shareManager->sharingDisabledForUser($userId) === false) { |
|
233 | - $sharingSublistArray[] = [ |
|
234 | - 'id' => 'sharingout', |
|
235 | - 'appname' => 'files_sharing', |
|
236 | - 'script' => 'list.php', |
|
237 | - 'order' => 16, |
|
238 | - 'name' => $l->t('Shared with others'), |
|
239 | - ]; |
|
240 | - } |
|
232 | + if ($shareManager->sharingDisabledForUser($userId) === false) { |
|
233 | + $sharingSublistArray[] = [ |
|
234 | + 'id' => 'sharingout', |
|
235 | + 'appname' => 'files_sharing', |
|
236 | + 'script' => 'list.php', |
|
237 | + 'order' => 16, |
|
238 | + 'name' => $l->t('Shared with others'), |
|
239 | + ]; |
|
240 | + } |
|
241 | 241 | |
242 | - $sharingSublistArray[] = [ |
|
243 | - 'id' => 'sharingin', |
|
244 | - 'appname' => 'files_sharing', |
|
245 | - 'script' => 'list.php', |
|
246 | - 'order' => 15, |
|
247 | - 'name' => $l->t('Shared with you'), |
|
248 | - ]; |
|
242 | + $sharingSublistArray[] = [ |
|
243 | + 'id' => 'sharingin', |
|
244 | + 'appname' => 'files_sharing', |
|
245 | + 'script' => 'list.php', |
|
246 | + 'order' => 15, |
|
247 | + 'name' => $l->t('Shared with you'), |
|
248 | + ]; |
|
249 | 249 | |
250 | - if ($shareManager->sharingDisabledForUser($userId) === false) { |
|
251 | - // Check if sharing by link is enabled |
|
252 | - if ($shareManager->shareApiAllowLinks()) { |
|
253 | - $sharingSublistArray[] = [ |
|
254 | - 'id' => 'sharinglinks', |
|
255 | - 'appname' => 'files_sharing', |
|
256 | - 'script' => 'list.php', |
|
257 | - 'order' => 17, |
|
258 | - 'name' => $l->t('Shared by link'), |
|
259 | - ]; |
|
260 | - } |
|
261 | - } |
|
250 | + if ($shareManager->sharingDisabledForUser($userId) === false) { |
|
251 | + // Check if sharing by link is enabled |
|
252 | + if ($shareManager->shareApiAllowLinks()) { |
|
253 | + $sharingSublistArray[] = [ |
|
254 | + 'id' => 'sharinglinks', |
|
255 | + 'appname' => 'files_sharing', |
|
256 | + 'script' => 'list.php', |
|
257 | + 'order' => 17, |
|
258 | + 'name' => $l->t('Shared by link'), |
|
259 | + ]; |
|
260 | + } |
|
261 | + } |
|
262 | 262 | |
263 | - $sharingSublistArray[] = [ |
|
264 | - 'id' => 'deletedshares', |
|
265 | - 'appname' => 'files_sharing', |
|
266 | - 'script' => 'list.php', |
|
267 | - 'order' => 19, |
|
268 | - 'name' => $l->t('Deleted shares'), |
|
269 | - ]; |
|
263 | + $sharingSublistArray[] = [ |
|
264 | + 'id' => 'deletedshares', |
|
265 | + 'appname' => 'files_sharing', |
|
266 | + 'script' => 'list.php', |
|
267 | + 'order' => 19, |
|
268 | + 'name' => $l->t('Deleted shares'), |
|
269 | + ]; |
|
270 | 270 | |
271 | - $sharingSublistArray[] = [ |
|
272 | - 'id' => 'pendingshares', |
|
273 | - 'appname' => 'files_sharing', |
|
274 | - 'script' => 'list.php', |
|
275 | - 'order' => 19, |
|
276 | - 'name' => $l->t('Pending shares'), |
|
277 | - ]; |
|
271 | + $sharingSublistArray[] = [ |
|
272 | + 'id' => 'pendingshares', |
|
273 | + 'appname' => 'files_sharing', |
|
274 | + 'script' => 'list.php', |
|
275 | + 'order' => 19, |
|
276 | + 'name' => $l->t('Pending shares'), |
|
277 | + ]; |
|
278 | 278 | |
279 | - return [ |
|
280 | - 'id' => 'shareoverview', |
|
281 | - 'appname' => 'files_sharing', |
|
282 | - 'script' => 'list.php', |
|
283 | - 'order' => 18, |
|
284 | - 'name' => $l->t('Shares'), |
|
285 | - 'classes' => 'collapsible', |
|
286 | - 'sublist' => $sharingSublistArray, |
|
287 | - ]; |
|
288 | - }); |
|
289 | - } |
|
279 | + return [ |
|
280 | + 'id' => 'shareoverview', |
|
281 | + 'appname' => 'files_sharing', |
|
282 | + 'script' => 'list.php', |
|
283 | + 'order' => 18, |
|
284 | + 'name' => $l->t('Shares'), |
|
285 | + 'classes' => 'collapsible', |
|
286 | + 'sublist' => $sharingSublistArray, |
|
287 | + ]; |
|
288 | + }); |
|
289 | + } |
|
290 | 290 | } |