Passed
Push — master ( 346770...2398d1 )
by Roeland
10:40 queued 35s
created
apps/files_sharing/appinfo/app.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
 
41 41
 $eventDispatcher = \OC::$server->getEventDispatcher();
42 42
 $eventDispatcher->addListener(
43
-	'OCA\Files::loadAdditionalScripts',
44
-	function() {
45
-		\OCP\Util::addScript('files_sharing', 'dist/additionalScripts');
46
-	}
43
+    'OCA\Files::loadAdditionalScripts',
44
+    function() {
45
+        \OCP\Util::addScript('files_sharing', 'dist/additionalScripts');
46
+    }
47 47
 );
48 48
 
49 49
 $config = \OC::$server->getConfig();
@@ -53,62 +53,62 @@  discard block
 block discarded – undo
53 53
 
54 54
 if ($config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes') {
55 55
 
56
-	$sharingSublistArray = [];
56
+    $sharingSublistArray = [];
57 57
 
58
-	if (\OCP\Util::isSharingDisabledForUser() === false) {
59
-		array_push($sharingSublistArray, [
60
-			'id' => 'sharingout',
61
-			'appname' => 'files_sharing',
62
-			'script' => 'list.php',
63
-			'order' => 16,
64
-			'name' => $l->t('Shared with others'),
65
-		]);
66
-	}
58
+    if (\OCP\Util::isSharingDisabledForUser() === false) {
59
+        array_push($sharingSublistArray, [
60
+            'id' => 'sharingout',
61
+            'appname' => 'files_sharing',
62
+            'script' => 'list.php',
63
+            'order' => 16,
64
+            'name' => $l->t('Shared with others'),
65
+        ]);
66
+    }
67 67
 
68
-	array_push($sharingSublistArray, [
69
-		'id' => 'sharingin',
70
-		'appname' => 'files_sharing',
71
-		'script' => 'list.php',
72
-		'order' => 15,
73
-		'name' => $l->t('Shared with you'),
74
-	]);
68
+    array_push($sharingSublistArray, [
69
+        'id' => 'sharingin',
70
+        'appname' => 'files_sharing',
71
+        'script' => 'list.php',
72
+        'order' => 15,
73
+        'name' => $l->t('Shared with you'),
74
+    ]);
75 75
 
76
-	if (\OCP\Util::isSharingDisabledForUser() === false) {
77
-		// Check if sharing by link is enabled
78
-		if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
79
-			array_push($sharingSublistArray, [
80
-				'id' => 'sharinglinks',
81
-				'appname' => 'files_sharing',
82
-				'script' => 'list.php',
83
-				'order' => 17,
84
-				'name' => $l->t('Shared by link'),
85
-			]);
86
-		}
87
-	}
76
+    if (\OCP\Util::isSharingDisabledForUser() === false) {
77
+        // Check if sharing by link is enabled
78
+        if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
79
+            array_push($sharingSublistArray, [
80
+                'id' => 'sharinglinks',
81
+                'appname' => 'files_sharing',
82
+                'script' => 'list.php',
83
+                'order' => 17,
84
+                'name' => $l->t('Shared by link'),
85
+            ]);
86
+        }
87
+    }
88 88
 
89
-	array_push($sharingSublistArray, [
90
-		'id' => 'deletedshares',
91
-		'appname' => 'files_sharing',
92
-		'script' => 'list.php',
93
-		'order' => 19,
94
-		'name' => $l->t('Deleted shares'),
95
-	]);
89
+    array_push($sharingSublistArray, [
90
+        'id' => 'deletedshares',
91
+        'appname' => 'files_sharing',
92
+        'script' => 'list.php',
93
+        'order' => 19,
94
+        'name' => $l->t('Deleted shares'),
95
+    ]);
96 96
 
97
-	// show_Quick_Access stored as string
98
-	$user = $userSession->getUser();
99
-	$defaultExpandedState = true;
100
-	if ($user instanceof \OCP\IUser) {
101
-		$defaultExpandedState = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_sharing_menu', '0') === '1';
102
-	}
97
+    // show_Quick_Access stored as string
98
+    $user = $userSession->getUser();
99
+    $defaultExpandedState = true;
100
+    if ($user instanceof \OCP\IUser) {
101
+        $defaultExpandedState = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_sharing_menu', '0') === '1';
102
+    }
103 103
 
104
-	\OCA\Files\App::getNavigationManager()->add([
105
-		'id' => 'shareoverview',
106
-		'appname' => 'files_sharing',
107
-		'script' => 'list.php',
108
-		'order' => 18,
109
-		'name' => $l->t('Shares'),
110
-		'classes' => 'collapsible',
111
-		'sublist' => $sharingSublistArray,
112
-		'expandedState' => 'show_sharing_menu'
113
-	]);
104
+    \OCA\Files\App::getNavigationManager()->add([
105
+        'id' => 'shareoverview',
106
+        'appname' => 'files_sharing',
107
+        'script' => 'list.php',
108
+        'order' => 18,
109
+        'name' => $l->t('Shares'),
110
+        'classes' => 'collapsible',
111
+        'sublist' => $sharingSublistArray,
112
+        'expandedState' => 'show_sharing_menu'
113
+    ]);
114 114
 }
Please login to merge, or discard this patch.
apps/files/composer/composer/autoload_static.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -6,56 +6,56 @@
 block discarded – undo
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
-        'OCA\\Files\\Activity\\FavoriteProvider' => __DIR__ . '/..' . '/../lib/Activity/FavoriteProvider.php',
25
-        'OCA\\Files\\Activity\\Filter\\Favorites' => __DIR__ . '/..' . '/../lib/Activity/Filter/Favorites.php',
26
-        'OCA\\Files\\Activity\\Filter\\FileChanges' => __DIR__ . '/..' . '/../lib/Activity/Filter/FileChanges.php',
27
-        'OCA\\Files\\Activity\\Helper' => __DIR__ . '/..' . '/../lib/Activity/Helper.php',
28
-        'OCA\\Files\\Activity\\Provider' => __DIR__ . '/..' . '/../lib/Activity/Provider.php',
29
-        'OCA\\Files\\Activity\\Settings\\FavoriteAction' => __DIR__ . '/..' . '/../lib/Activity/Settings/FavoriteAction.php',
30
-        'OCA\\Files\\Activity\\Settings\\FileChanged' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileChanged.php',
31
-        'OCA\\Files\\Activity\\Settings\\FileCreated' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileCreated.php',
32
-        'OCA\\Files\\Activity\\Settings\\FileDeleted' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileDeleted.php',
33
-        'OCA\\Files\\Activity\\Settings\\FileFavorite' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileFavorite.php',
34
-        'OCA\\Files\\Activity\\Settings\\FileRestored' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileRestored.php',
35
-        'OCA\\Files\\App' => __DIR__ . '/..' . '/../lib/App.php',
36
-        'OCA\\Files\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
37
-        'OCA\\Files\\BackgroundJob\\CleanupFileLocks' => __DIR__ . '/..' . '/../lib/BackgroundJob/CleanupFileLocks.php',
38
-        'OCA\\Files\\BackgroundJob\\DeleteOrphanedItems' => __DIR__ . '/..' . '/../lib/BackgroundJob/DeleteOrphanedItems.php',
39
-        'OCA\\Files\\BackgroundJob\\ScanFiles' => __DIR__ . '/..' . '/../lib/BackgroundJob/ScanFiles.php',
40
-        'OCA\\Files\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php',
41
-        'OCA\\Files\\Collaboration\\Resources\\Listener' => __DIR__ . '/..' . '/../lib/Collaboration/Resources/Listener.php',
42
-        'OCA\\Files\\Collaboration\\Resources\\ResourceProvider' => __DIR__ . '/..' . '/../lib/Collaboration/Resources/ResourceProvider.php',
43
-        'OCA\\Files\\Command\\DeleteOrphanedFiles' => __DIR__ . '/..' . '/../lib/Command/DeleteOrphanedFiles.php',
44
-        'OCA\\Files\\Command\\Scan' => __DIR__ . '/..' . '/../lib/Command/Scan.php',
45
-        'OCA\\Files\\Command\\ScanAppData' => __DIR__ . '/..' . '/../lib/Command/ScanAppData.php',
46
-        'OCA\\Files\\Command\\TransferOwnership' => __DIR__ . '/..' . '/../lib/Command/TransferOwnership.php',
47
-        'OCA\\Files\\Controller\\AjaxController' => __DIR__ . '/..' . '/../lib/Controller/AjaxController.php',
48
-        'OCA\\Files\\Controller\\ApiController' => __DIR__ . '/..' . '/../lib/Controller/ApiController.php',
49
-        'OCA\\Files\\Controller\\SettingsController' => __DIR__ . '/..' . '/../lib/Controller/SettingsController.php',
50
-        'OCA\\Files\\Controller\\ViewController' => __DIR__ . '/..' . '/../lib/Controller/ViewController.php',
51
-        'OCA\\Files\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php',
52
-        'OCA\\Files\\Service\\TagService' => __DIR__ . '/..' . '/../lib/Service/TagService.php',
53
-        'OCA\\Files\\Settings\\Admin' => __DIR__ . '/..' . '/../lib/Settings/Admin.php',
23
+    public static $classMap = array(
24
+        'OCA\\Files\\Activity\\FavoriteProvider' => __DIR__.'/..'.'/../lib/Activity/FavoriteProvider.php',
25
+        'OCA\\Files\\Activity\\Filter\\Favorites' => __DIR__.'/..'.'/../lib/Activity/Filter/Favorites.php',
26
+        'OCA\\Files\\Activity\\Filter\\FileChanges' => __DIR__.'/..'.'/../lib/Activity/Filter/FileChanges.php',
27
+        'OCA\\Files\\Activity\\Helper' => __DIR__.'/..'.'/../lib/Activity/Helper.php',
28
+        'OCA\\Files\\Activity\\Provider' => __DIR__.'/..'.'/../lib/Activity/Provider.php',
29
+        'OCA\\Files\\Activity\\Settings\\FavoriteAction' => __DIR__.'/..'.'/../lib/Activity/Settings/FavoriteAction.php',
30
+        'OCA\\Files\\Activity\\Settings\\FileChanged' => __DIR__.'/..'.'/../lib/Activity/Settings/FileChanged.php',
31
+        'OCA\\Files\\Activity\\Settings\\FileCreated' => __DIR__.'/..'.'/../lib/Activity/Settings/FileCreated.php',
32
+        'OCA\\Files\\Activity\\Settings\\FileDeleted' => __DIR__.'/..'.'/../lib/Activity/Settings/FileDeleted.php',
33
+        'OCA\\Files\\Activity\\Settings\\FileFavorite' => __DIR__.'/..'.'/../lib/Activity/Settings/FileFavorite.php',
34
+        'OCA\\Files\\Activity\\Settings\\FileRestored' => __DIR__.'/..'.'/../lib/Activity/Settings/FileRestored.php',
35
+        'OCA\\Files\\App' => __DIR__.'/..'.'/../lib/App.php',
36
+        'OCA\\Files\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php',
37
+        'OCA\\Files\\BackgroundJob\\CleanupFileLocks' => __DIR__.'/..'.'/../lib/BackgroundJob/CleanupFileLocks.php',
38
+        'OCA\\Files\\BackgroundJob\\DeleteOrphanedItems' => __DIR__.'/..'.'/../lib/BackgroundJob/DeleteOrphanedItems.php',
39
+        'OCA\\Files\\BackgroundJob\\ScanFiles' => __DIR__.'/..'.'/../lib/BackgroundJob/ScanFiles.php',
40
+        'OCA\\Files\\Capabilities' => __DIR__.'/..'.'/../lib/Capabilities.php',
41
+        'OCA\\Files\\Collaboration\\Resources\\Listener' => __DIR__.'/..'.'/../lib/Collaboration/Resources/Listener.php',
42
+        'OCA\\Files\\Collaboration\\Resources\\ResourceProvider' => __DIR__.'/..'.'/../lib/Collaboration/Resources/ResourceProvider.php',
43
+        'OCA\\Files\\Command\\DeleteOrphanedFiles' => __DIR__.'/..'.'/../lib/Command/DeleteOrphanedFiles.php',
44
+        'OCA\\Files\\Command\\Scan' => __DIR__.'/..'.'/../lib/Command/Scan.php',
45
+        'OCA\\Files\\Command\\ScanAppData' => __DIR__.'/..'.'/../lib/Command/ScanAppData.php',
46
+        'OCA\\Files\\Command\\TransferOwnership' => __DIR__.'/..'.'/../lib/Command/TransferOwnership.php',
47
+        'OCA\\Files\\Controller\\AjaxController' => __DIR__.'/..'.'/../lib/Controller/AjaxController.php',
48
+        'OCA\\Files\\Controller\\ApiController' => __DIR__.'/..'.'/../lib/Controller/ApiController.php',
49
+        'OCA\\Files\\Controller\\SettingsController' => __DIR__.'/..'.'/../lib/Controller/SettingsController.php',
50
+        'OCA\\Files\\Controller\\ViewController' => __DIR__.'/..'.'/../lib/Controller/ViewController.php',
51
+        'OCA\\Files\\Helper' => __DIR__.'/..'.'/../lib/Helper.php',
52
+        'OCA\\Files\\Service\\TagService' => __DIR__.'/..'.'/../lib/Service/TagService.php',
53
+        'OCA\\Files\\Settings\\Admin' => __DIR__.'/..'.'/../lib/Settings/Admin.php',
54 54
     );
55 55
 
56 56
     public static function getInitializer(ClassLoader $loader)
57 57
     {
58
-        return \Closure::bind(function () use ($loader) {
58
+        return \Closure::bind(function() use ($loader) {
59 59
             $loader->prefixLengthsPsr4 = ComposerStaticInitFiles::$prefixLengthsPsr4;
60 60
             $loader->prefixDirsPsr4 = ComposerStaticInitFiles::$prefixDirsPsr4;
61 61
             $loader->classMap = ComposerStaticInitFiles::$classMap;
Please login to merge, or discard this patch.
apps/files/composer/composer/autoload_classmap.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -6,34 +6,34 @@
 block discarded – undo
6 6
 $baseDir = $vendorDir;
7 7
 
8 8
 return array(
9
-    'OCA\\Files\\Activity\\FavoriteProvider' => $baseDir . '/../lib/Activity/FavoriteProvider.php',
10
-    'OCA\\Files\\Activity\\Filter\\Favorites' => $baseDir . '/../lib/Activity/Filter/Favorites.php',
11
-    'OCA\\Files\\Activity\\Filter\\FileChanges' => $baseDir . '/../lib/Activity/Filter/FileChanges.php',
12
-    'OCA\\Files\\Activity\\Helper' => $baseDir . '/../lib/Activity/Helper.php',
13
-    'OCA\\Files\\Activity\\Provider' => $baseDir . '/../lib/Activity/Provider.php',
14
-    'OCA\\Files\\Activity\\Settings\\FavoriteAction' => $baseDir . '/../lib/Activity/Settings/FavoriteAction.php',
15
-    'OCA\\Files\\Activity\\Settings\\FileChanged' => $baseDir . '/../lib/Activity/Settings/FileChanged.php',
16
-    'OCA\\Files\\Activity\\Settings\\FileCreated' => $baseDir . '/../lib/Activity/Settings/FileCreated.php',
17
-    'OCA\\Files\\Activity\\Settings\\FileDeleted' => $baseDir . '/../lib/Activity/Settings/FileDeleted.php',
18
-    'OCA\\Files\\Activity\\Settings\\FileFavorite' => $baseDir . '/../lib/Activity/Settings/FileFavorite.php',
19
-    'OCA\\Files\\Activity\\Settings\\FileRestored' => $baseDir . '/../lib/Activity/Settings/FileRestored.php',
20
-    'OCA\\Files\\App' => $baseDir . '/../lib/App.php',
21
-    'OCA\\Files\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
22
-    'OCA\\Files\\BackgroundJob\\CleanupFileLocks' => $baseDir . '/../lib/BackgroundJob/CleanupFileLocks.php',
23
-    'OCA\\Files\\BackgroundJob\\DeleteOrphanedItems' => $baseDir . '/../lib/BackgroundJob/DeleteOrphanedItems.php',
24
-    'OCA\\Files\\BackgroundJob\\ScanFiles' => $baseDir . '/../lib/BackgroundJob/ScanFiles.php',
25
-    'OCA\\Files\\Capabilities' => $baseDir . '/../lib/Capabilities.php',
26
-    'OCA\\Files\\Collaboration\\Resources\\Listener' => $baseDir . '/../lib/Collaboration/Resources/Listener.php',
27
-    'OCA\\Files\\Collaboration\\Resources\\ResourceProvider' => $baseDir . '/../lib/Collaboration/Resources/ResourceProvider.php',
28
-    'OCA\\Files\\Command\\DeleteOrphanedFiles' => $baseDir . '/../lib/Command/DeleteOrphanedFiles.php',
29
-    'OCA\\Files\\Command\\Scan' => $baseDir . '/../lib/Command/Scan.php',
30
-    'OCA\\Files\\Command\\ScanAppData' => $baseDir . '/../lib/Command/ScanAppData.php',
31
-    'OCA\\Files\\Command\\TransferOwnership' => $baseDir . '/../lib/Command/TransferOwnership.php',
32
-    'OCA\\Files\\Controller\\AjaxController' => $baseDir . '/../lib/Controller/AjaxController.php',
33
-    'OCA\\Files\\Controller\\ApiController' => $baseDir . '/../lib/Controller/ApiController.php',
34
-    'OCA\\Files\\Controller\\SettingsController' => $baseDir . '/../lib/Controller/SettingsController.php',
35
-    'OCA\\Files\\Controller\\ViewController' => $baseDir . '/../lib/Controller/ViewController.php',
36
-    'OCA\\Files\\Helper' => $baseDir . '/../lib/Helper.php',
37
-    'OCA\\Files\\Service\\TagService' => $baseDir . '/../lib/Service/TagService.php',
38
-    'OCA\\Files\\Settings\\Admin' => $baseDir . '/../lib/Settings/Admin.php',
9
+    'OCA\\Files\\Activity\\FavoriteProvider' => $baseDir.'/../lib/Activity/FavoriteProvider.php',
10
+    'OCA\\Files\\Activity\\Filter\\Favorites' => $baseDir.'/../lib/Activity/Filter/Favorites.php',
11
+    'OCA\\Files\\Activity\\Filter\\FileChanges' => $baseDir.'/../lib/Activity/Filter/FileChanges.php',
12
+    'OCA\\Files\\Activity\\Helper' => $baseDir.'/../lib/Activity/Helper.php',
13
+    'OCA\\Files\\Activity\\Provider' => $baseDir.'/../lib/Activity/Provider.php',
14
+    'OCA\\Files\\Activity\\Settings\\FavoriteAction' => $baseDir.'/../lib/Activity/Settings/FavoriteAction.php',
15
+    'OCA\\Files\\Activity\\Settings\\FileChanged' => $baseDir.'/../lib/Activity/Settings/FileChanged.php',
16
+    'OCA\\Files\\Activity\\Settings\\FileCreated' => $baseDir.'/../lib/Activity/Settings/FileCreated.php',
17
+    'OCA\\Files\\Activity\\Settings\\FileDeleted' => $baseDir.'/../lib/Activity/Settings/FileDeleted.php',
18
+    'OCA\\Files\\Activity\\Settings\\FileFavorite' => $baseDir.'/../lib/Activity/Settings/FileFavorite.php',
19
+    'OCA\\Files\\Activity\\Settings\\FileRestored' => $baseDir.'/../lib/Activity/Settings/FileRestored.php',
20
+    'OCA\\Files\\App' => $baseDir.'/../lib/App.php',
21
+    'OCA\\Files\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php',
22
+    'OCA\\Files\\BackgroundJob\\CleanupFileLocks' => $baseDir.'/../lib/BackgroundJob/CleanupFileLocks.php',
23
+    'OCA\\Files\\BackgroundJob\\DeleteOrphanedItems' => $baseDir.'/../lib/BackgroundJob/DeleteOrphanedItems.php',
24
+    'OCA\\Files\\BackgroundJob\\ScanFiles' => $baseDir.'/../lib/BackgroundJob/ScanFiles.php',
25
+    'OCA\\Files\\Capabilities' => $baseDir.'/../lib/Capabilities.php',
26
+    'OCA\\Files\\Collaboration\\Resources\\Listener' => $baseDir.'/../lib/Collaboration/Resources/Listener.php',
27
+    'OCA\\Files\\Collaboration\\Resources\\ResourceProvider' => $baseDir.'/../lib/Collaboration/Resources/ResourceProvider.php',
28
+    'OCA\\Files\\Command\\DeleteOrphanedFiles' => $baseDir.'/../lib/Command/DeleteOrphanedFiles.php',
29
+    'OCA\\Files\\Command\\Scan' => $baseDir.'/../lib/Command/Scan.php',
30
+    'OCA\\Files\\Command\\ScanAppData' => $baseDir.'/../lib/Command/ScanAppData.php',
31
+    'OCA\\Files\\Command\\TransferOwnership' => $baseDir.'/../lib/Command/TransferOwnership.php',
32
+    'OCA\\Files\\Controller\\AjaxController' => $baseDir.'/../lib/Controller/AjaxController.php',
33
+    'OCA\\Files\\Controller\\ApiController' => $baseDir.'/../lib/Controller/ApiController.php',
34
+    'OCA\\Files\\Controller\\SettingsController' => $baseDir.'/../lib/Controller/SettingsController.php',
35
+    'OCA\\Files\\Controller\\ViewController' => $baseDir.'/../lib/Controller/ViewController.php',
36
+    'OCA\\Files\\Helper' => $baseDir.'/../lib/Helper.php',
37
+    'OCA\\Files\\Service\\TagService' => $baseDir.'/../lib/Service/TagService.php',
38
+    'OCA\\Files\\Settings\\Admin' => $baseDir.'/../lib/Settings/Admin.php',
39 39
 );
Please login to merge, or discard this patch.
apps/files/lib/Collaboration/Resources/ResourceProvider.php 1 patch
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -32,109 +32,109 @@
 block discarded – undo
32 32
 
33 33
 class ResourceProvider implements IProvider {
34 34
 
35
-	const RESOURCE_TYPE = 'files';
36
-
37
-	/** @var IRootFolder */
38
-	protected $rootFolder;
39
-
40
-	/** @var IURLGenerator */
41
-	private $urlGenerator;
42
-
43
-	/** @var array */
44
-	protected $nodes = [];
45
-
46
-	public function __construct(IRootFolder $rootFolder, IURLGenerator $urlGenerator) {
47
-		$this->rootFolder = $rootFolder;
48
-		$this->urlGenerator = $urlGenerator;
49
-	}
50
-
51
-	private function getNode(IResource $resource): ?Node {
52
-		if (isset($this->nodes[(int) $resource->getId()])) {
53
-			return $this->nodes[(int) $resource->getId()];
54
-		}
55
-		$nodes = $this->rootFolder->getById((int) $resource->getId());
56
-		if (!empty($nodes)) {
57
-			$this->nodes[(int) $resource->getId()] = array_shift($nodes);
58
-			return $this->nodes[(int) $resource->getId()];
59
-		}
60
-		return null;
61
-	}
62
-
63
-	/**
64
-	 * Get the display name of a resource
65
-	 *
66
-	 * @param IResource $resource
67
-	 * @return string
68
-	 * @since 15.0.0
69
-	 */
70
-	public function getName(IResource $resource): string {
71
-		if (isset($this->nodes[(int) $resource->getId()])) {
72
-			return $this->nodes[(int) $resource->getId()]->getPath();
73
-		}
74
-		$node = $this->getNode($resource);
75
-		if ($node) {
76
-			return $node->getName();
77
-		}
78
-		return '';
79
-	}
80
-
81
-	/**
82
-	 * Can a user/guest access the collection
83
-	 *
84
-	 * @param IResource $resource
85
-	 * @param IUser $user
86
-	 * @return bool
87
-	 * @since 15.0.0
88
-	 */
89
-	public function canAccessResource(IResource $resource, IUser $user = null): bool {
90
-		if (!$user instanceof IUser) {
91
-			return false;
92
-		}
93
-
94
-		$userFolder = $this->rootFolder->getUserFolder($user->getUID());
95
-		$nodes = $userFolder->getById((int) $resource->getId());
96
-
97
-		if (!empty($nodes)) {
98
-			$this->nodes[(int) $resource->getId()] = array_shift($nodes);
99
-			return true;
100
-		}
101
-
102
-		return false;
103
-	}
104
-
105
-	/**
106
-	 * Get the icon class of a resource
107
-	 *
108
-	 * @param IResource $resource
109
-	 * @return string
110
-	 * @since 15.0.0
111
-	 */
112
-	public function getIconClass(IResource $resource): string {
113
-		$node = $this->getNode($resource);
114
-		if ($node && $node->getMimetype() === 'httpd/unix-directory') {
115
-			return 'icon-files-dark';
116
-		}
117
-		return 'icon-filetype-file';
118
-	}
119
-
120
-	/**
121
-	 * Get the resource type of the provider
122
-	 *
123
-	 * @return string
124
-	 * @since 15.0.0
125
-	 */
126
-	public function getType(): string {
127
-		return self::RESOURCE_TYPE;
128
-	}
129
-
130
-	/**
131
-	 * Get the link to a resource
132
-	 *
133
-	 * @param IResource $resource
134
-	 * @return string
135
-	 * @since 15.0.0
136
-	 */
137
-	public function getLink(IResource $resource): string {
138
-		return $this->urlGenerator->linkToRoute('files.viewcontroller.showFile', ['fileid' => $resource->getId()]);
139
-	}
35
+    const RESOURCE_TYPE = 'files';
36
+
37
+    /** @var IRootFolder */
38
+    protected $rootFolder;
39
+
40
+    /** @var IURLGenerator */
41
+    private $urlGenerator;
42
+
43
+    /** @var array */
44
+    protected $nodes = [];
45
+
46
+    public function __construct(IRootFolder $rootFolder, IURLGenerator $urlGenerator) {
47
+        $this->rootFolder = $rootFolder;
48
+        $this->urlGenerator = $urlGenerator;
49
+    }
50
+
51
+    private function getNode(IResource $resource): ?Node {
52
+        if (isset($this->nodes[(int) $resource->getId()])) {
53
+            return $this->nodes[(int) $resource->getId()];
54
+        }
55
+        $nodes = $this->rootFolder->getById((int) $resource->getId());
56
+        if (!empty($nodes)) {
57
+            $this->nodes[(int) $resource->getId()] = array_shift($nodes);
58
+            return $this->nodes[(int) $resource->getId()];
59
+        }
60
+        return null;
61
+    }
62
+
63
+    /**
64
+     * Get the display name of a resource
65
+     *
66
+     * @param IResource $resource
67
+     * @return string
68
+     * @since 15.0.0
69
+     */
70
+    public function getName(IResource $resource): string {
71
+        if (isset($this->nodes[(int) $resource->getId()])) {
72
+            return $this->nodes[(int) $resource->getId()]->getPath();
73
+        }
74
+        $node = $this->getNode($resource);
75
+        if ($node) {
76
+            return $node->getName();
77
+        }
78
+        return '';
79
+    }
80
+
81
+    /**
82
+     * Can a user/guest access the collection
83
+     *
84
+     * @param IResource $resource
85
+     * @param IUser $user
86
+     * @return bool
87
+     * @since 15.0.0
88
+     */
89
+    public function canAccessResource(IResource $resource, IUser $user = null): bool {
90
+        if (!$user instanceof IUser) {
91
+            return false;
92
+        }
93
+
94
+        $userFolder = $this->rootFolder->getUserFolder($user->getUID());
95
+        $nodes = $userFolder->getById((int) $resource->getId());
96
+
97
+        if (!empty($nodes)) {
98
+            $this->nodes[(int) $resource->getId()] = array_shift($nodes);
99
+            return true;
100
+        }
101
+
102
+        return false;
103
+    }
104
+
105
+    /**
106
+     * Get the icon class of a resource
107
+     *
108
+     * @param IResource $resource
109
+     * @return string
110
+     * @since 15.0.0
111
+     */
112
+    public function getIconClass(IResource $resource): string {
113
+        $node = $this->getNode($resource);
114
+        if ($node && $node->getMimetype() === 'httpd/unix-directory') {
115
+            return 'icon-files-dark';
116
+        }
117
+        return 'icon-filetype-file';
118
+    }
119
+
120
+    /**
121
+     * Get the resource type of the provider
122
+     *
123
+     * @return string
124
+     * @since 15.0.0
125
+     */
126
+    public function getType(): string {
127
+        return self::RESOURCE_TYPE;
128
+    }
129
+
130
+    /**
131
+     * Get the link to a resource
132
+     *
133
+     * @param IResource $resource
134
+     * @return string
135
+     * @since 15.0.0
136
+     */
137
+    public function getLink(IResource $resource): string {
138
+        return $this->urlGenerator->linkToRoute('files.viewcontroller.showFile', ['fileid' => $resource->getId()]);
139
+    }
140 140
 }
Please login to merge, or discard this patch.
apps/files/lib/Collaboration/Resources/Listener.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -27,18 +27,18 @@
 block discarded – undo
27 27
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
28 28
 
29 29
 class Listener {
30
-	public static function register(EventDispatcherInterface $dispatcher): void {
31
-		$dispatcher->addListener('OCP\Share::postShare', [self::class, 'shareModification']);
32
-		$dispatcher->addListener('OCP\Share::postUnshare', [self::class, 'shareModification']);
33
-		$dispatcher->addListener('OCP\Share::postUnshareFromSelf', [self::class, 'shareModification']);
34
-	}
30
+    public static function register(EventDispatcherInterface $dispatcher): void {
31
+        $dispatcher->addListener('OCP\Share::postShare', [self::class, 'shareModification']);
32
+        $dispatcher->addListener('OCP\Share::postUnshare', [self::class, 'shareModification']);
33
+        $dispatcher->addListener('OCP\Share::postUnshareFromSelf', [self::class, 'shareModification']);
34
+    }
35 35
 
36
-	public static function shareModification(): void {
37
-		/** @var IManager $resourceManager */
38
-		$resourceManager = \OC::$server->query(IManager::class);
39
-		/** @var ResourceProvider $resourceProvider */
40
-		$resourceProvider = \OC::$server->query(ResourceProvider::class);
36
+    public static function shareModification(): void {
37
+        /** @var IManager $resourceManager */
38
+        $resourceManager = \OC::$server->query(IManager::class);
39
+        /** @var ResourceProvider $resourceProvider */
40
+        $resourceProvider = \OC::$server->query(ResourceProvider::class);
41 41
 
42
-		$resourceManager->invalidateAccessCacheForProvider($resourceProvider);
43
-	}
42
+        $resourceManager->invalidateAccessCacheForProvider($resourceProvider);
43
+    }
44 44
 }
Please login to merge, or discard this patch.
apps/files/lib/AppInfo/Application.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -38,77 +38,77 @@
 block discarded – undo
38 38
 use OCA\Files\Capabilities;
39 39
 
40 40
 class Application extends App {
41
-	public function __construct(array $urlParams=array()) {
42
-		parent::__construct('files', $urlParams);
43
-		$container = $this->getContainer();
44
-		$server = $container->getServer();
41
+    public function __construct(array $urlParams=array()) {
42
+        parent::__construct('files', $urlParams);
43
+        $container = $this->getContainer();
44
+        $server = $container->getServer();
45 45
 
46
-		/**
47
-		 * Controllers
48
-		 */
49
-		$container->registerService('APIController', function (IContainer $c) use ($server) {
50
-			return new ApiController(
51
-				$c->query('AppName'),
52
-				$c->query('Request'),
53
-				$server->getUserSession(),
54
-				$c->query('TagService'),
55
-				$server->getPreviewManager(),
56
-				$server->getShareManager(),
57
-				$server->getConfig(),
58
-				$server->getUserFolder()
59
-			);
60
-		});
46
+        /**
47
+         * Controllers
48
+         */
49
+        $container->registerService('APIController', function (IContainer $c) use ($server) {
50
+            return new ApiController(
51
+                $c->query('AppName'),
52
+                $c->query('Request'),
53
+                $server->getUserSession(),
54
+                $c->query('TagService'),
55
+                $server->getPreviewManager(),
56
+                $server->getShareManager(),
57
+                $server->getConfig(),
58
+                $server->getUserFolder()
59
+            );
60
+        });
61 61
 
62
-		$container->registerService('ViewController', function (IContainer $c) use ($server) {
63
-			return new ViewController(
64
-				$c->query('AppName'),
65
-				$c->query('Request'),
66
-				$server->getURLGenerator(),
67
-				$c->query('L10N'),
68
-				$server->getConfig(),
69
-				$server->getEventDispatcher(),
70
-				$server->getUserSession(),
71
-				$server->getAppManager(),
72
-				$server->getRootFolder(),
73
-				$c->query(Helper::class)
74
-			);
75
-		});
62
+        $container->registerService('ViewController', function (IContainer $c) use ($server) {
63
+            return new ViewController(
64
+                $c->query('AppName'),
65
+                $c->query('Request'),
66
+                $server->getURLGenerator(),
67
+                $c->query('L10N'),
68
+                $server->getConfig(),
69
+                $server->getEventDispatcher(),
70
+                $server->getUserSession(),
71
+                $server->getAppManager(),
72
+                $server->getRootFolder(),
73
+                $c->query(Helper::class)
74
+            );
75
+        });
76 76
 
77
-		/**
78
-		 * Core
79
-		 */
80
-		$container->registerService('L10N', function(IContainer $c) {
81
-			return $c->query('ServerContainer')->getL10N($c->query('AppName'));
82
-		});
77
+        /**
78
+         * Core
79
+         */
80
+        $container->registerService('L10N', function(IContainer $c) {
81
+            return $c->query('ServerContainer')->getL10N($c->query('AppName'));
82
+        });
83 83
 
84
-		/**
85
-		 * Services
86
-		 */
87
-		$container->registerService('Tagger', function(IContainer $c)  {
88
-			return $c->query('ServerContainer')->getTagManager()->load('files');
89
-		});
90
-		$container->registerService('TagService', function(IContainer $c) use ($server) {
91
-			$homeFolder = $c->query('ServerContainer')->getUserFolder();
92
-			return new TagService(
93
-				$c->query('ServerContainer')->getUserSession(),
94
-				$c->query('ServerContainer')->getActivityManager(),
95
-				$c->query('Tagger'),
96
-				$homeFolder,
97
-				$server->getEventDispatcher()
98
-			);
99
-		});
84
+        /**
85
+         * Services
86
+         */
87
+        $container->registerService('Tagger', function(IContainer $c)  {
88
+            return $c->query('ServerContainer')->getTagManager()->load('files');
89
+        });
90
+        $container->registerService('TagService', function(IContainer $c) use ($server) {
91
+            $homeFolder = $c->query('ServerContainer')->getUserFolder();
92
+            return new TagService(
93
+                $c->query('ServerContainer')->getUserSession(),
94
+                $c->query('ServerContainer')->getActivityManager(),
95
+                $c->query('Tagger'),
96
+                $homeFolder,
97
+                $server->getEventDispatcher()
98
+            );
99
+        });
100 100
 
101
-		/*
101
+        /*
102 102
 		 * Register capabilities
103 103
 		 */
104
-		$container->registerCapability(Capabilities::class);
104
+        $container->registerCapability(Capabilities::class);
105 105
 
106
-		/**
107
-		 * Register Collaboration ResourceProvider
108
-		 */
109
-		/** @var IManager $resourceManager */
110
-		$resourceManager = $container->query(IManager::class);
111
-		$resourceManager->registerResourceProvider(ResourceProvider::class);
112
-		Listener::register($server->getEventDispatcher());
113
-	}
106
+        /**
107
+         * Register Collaboration ResourceProvider
108
+         */
109
+        /** @var IManager $resourceManager */
110
+        $resourceManager = $container->query(IManager::class);
111
+        $resourceManager->registerResourceProvider(ResourceProvider::class);
112
+        Listener::register($server->getEventDispatcher());
113
+    }
114 114
 }
Please login to merge, or discard this patch.
core/routes.php 1 patch
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -36,70 +36,70 @@  discard block
 block discarded – undo
36 36
 
37 37
 $application = new Application();
38 38
 $application->registerRoutes($this, [
39
-	'routes' => [
40
-		['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'],
41
-		['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'],
42
-		['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'],
43
-		['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'],
44
-		['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'],
45
-		['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'],
46
-		['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'],
47
-		['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'],
48
-		['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'],
49
-		['name' => 'GuestAvatar#getAvatar', 'url' => '/avatar/guest/{guestName}/{size}', 'verb' => 'GET'],
50
-		['name' => 'CSRFToken#index', 'url' => '/csrftoken', 'verb' => 'GET'],
51
-		['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'],
52
-		['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'],
53
-		['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'],
54
-		['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'],
55
-		// Original login flow used by all clients
56
-		['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'],
57
-		['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'],
58
-		['name' => 'ClientFlowLogin#grantPage', 'url' => '/login/flow/grant', 'verb' => 'GET'],
59
-		['name' => 'ClientFlowLogin#apptokenRedirect', 'url' => '/login/flow/apptoken', 'verb' => 'POST'],
60
-		// NG login flow used by desktop client in case of Kerberos/fancy 2fa (smart cards for example)
61
-		['name' => 'ClientFlowLoginV2#poll', 'url' => '/login/v2/poll', 'verb' => 'POST'],
62
-		['name' => 'ClientFlowLoginV2#showAuthPickerPage', 'url' => '/login/v2/flow', 'verb' => 'GET'],
63
-		['name' => 'ClientFlowLoginV2#landing', 'url' => '/login/v2/flow/{token}', 'verb' => 'GET'],
64
-		['name' => 'ClientFlowLoginV2#grantPage', 'url' => '/login/v2/grant', 'verb' => 'GET'],
65
-		['name' => 'ClientFlowLoginV2#generateAppPassword', 'url' => '/login/v2/grant', 'verb' => 'POST'],
66
-		['name' => 'ClientFlowLoginV2#init', 'url' => '/login/v2', 'verb' => 'POST'],
67
-		['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'],
68
-		['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'],
69
-		['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'],
70
-		['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'],
71
-		['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'],
72
-		['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'],
73
-		['name' => 'Svg#getSvgFromCore', 'url' => '/svg/core/{folder}/{fileName}', 'verb' => 'GET'],
74
-		['name' => 'Svg#getSvgFromApp', 'url' => '/svg/{app}/{fileName}', 'verb' => 'GET'],
75
-		['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'],
76
-		['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'],
77
-		['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'],
78
-		['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'],
79
-		['name' => 'WalledGarden#get', 'url' => '/204', 'verb' => 'GET'],
80
-		['name' => 'Search#search', 'url' => '/core/search', 'verb' => 'GET'],
81
-	],
82
-	'ocs' => [
83
-		['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'],
84
-		['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'],
85
-		['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'],
86
-		['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'],
87
-		['root' => '/core', 'name' => 'Navigation#getAppsNavigation', 'url' => '/navigation/apps', 'verb' => 'GET'],
88
-		['root' => '/core', 'name' => 'Navigation#getSettingsNavigation', 'url' => '/navigation/settings', 'verb' => 'GET'],
89
-		['root' => '/core', 'name' => 'AutoComplete#get', 'url' => '/autocomplete/get', 'verb' => 'GET'],
90
-		['root' => '/core', 'name' => 'WhatsNew#get', 'url' => '/whatsnew', 'verb' => 'GET'],
91
-		['root' => '/core', 'name' => 'WhatsNew#dismiss', 'url' => '/whatsnew', 'verb' => 'POST'],
92
-		['root' => '/core', 'name' => 'AppPassword#getAppPassword', 'url' => '/getapppassword', 'verb' => 'GET'],
39
+    'routes' => [
40
+        ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'],
41
+        ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'],
42
+        ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'],
43
+        ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'],
44
+        ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'],
45
+        ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'],
46
+        ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'],
47
+        ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'],
48
+        ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'],
49
+        ['name' => 'GuestAvatar#getAvatar', 'url' => '/avatar/guest/{guestName}/{size}', 'verb' => 'GET'],
50
+        ['name' => 'CSRFToken#index', 'url' => '/csrftoken', 'verb' => 'GET'],
51
+        ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'],
52
+        ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'],
53
+        ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'],
54
+        ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'],
55
+        // Original login flow used by all clients
56
+        ['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'],
57
+        ['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'],
58
+        ['name' => 'ClientFlowLogin#grantPage', 'url' => '/login/flow/grant', 'verb' => 'GET'],
59
+        ['name' => 'ClientFlowLogin#apptokenRedirect', 'url' => '/login/flow/apptoken', 'verb' => 'POST'],
60
+        // NG login flow used by desktop client in case of Kerberos/fancy 2fa (smart cards for example)
61
+        ['name' => 'ClientFlowLoginV2#poll', 'url' => '/login/v2/poll', 'verb' => 'POST'],
62
+        ['name' => 'ClientFlowLoginV2#showAuthPickerPage', 'url' => '/login/v2/flow', 'verb' => 'GET'],
63
+        ['name' => 'ClientFlowLoginV2#landing', 'url' => '/login/v2/flow/{token}', 'verb' => 'GET'],
64
+        ['name' => 'ClientFlowLoginV2#grantPage', 'url' => '/login/v2/grant', 'verb' => 'GET'],
65
+        ['name' => 'ClientFlowLoginV2#generateAppPassword', 'url' => '/login/v2/grant', 'verb' => 'POST'],
66
+        ['name' => 'ClientFlowLoginV2#init', 'url' => '/login/v2', 'verb' => 'POST'],
67
+        ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'],
68
+        ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'],
69
+        ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'],
70
+        ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'],
71
+        ['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'],
72
+        ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'],
73
+        ['name' => 'Svg#getSvgFromCore', 'url' => '/svg/core/{folder}/{fileName}', 'verb' => 'GET'],
74
+        ['name' => 'Svg#getSvgFromApp', 'url' => '/svg/{app}/{fileName}', 'verb' => 'GET'],
75
+        ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'],
76
+        ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'],
77
+        ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'],
78
+        ['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'],
79
+        ['name' => 'WalledGarden#get', 'url' => '/204', 'verb' => 'GET'],
80
+        ['name' => 'Search#search', 'url' => '/core/search', 'verb' => 'GET'],
81
+    ],
82
+    'ocs' => [
83
+        ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'],
84
+        ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'],
85
+        ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'],
86
+        ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'],
87
+        ['root' => '/core', 'name' => 'Navigation#getAppsNavigation', 'url' => '/navigation/apps', 'verb' => 'GET'],
88
+        ['root' => '/core', 'name' => 'Navigation#getSettingsNavigation', 'url' => '/navigation/settings', 'verb' => 'GET'],
89
+        ['root' => '/core', 'name' => 'AutoComplete#get', 'url' => '/autocomplete/get', 'verb' => 'GET'],
90
+        ['root' => '/core', 'name' => 'WhatsNew#get', 'url' => '/whatsnew', 'verb' => 'GET'],
91
+        ['root' => '/core', 'name' => 'WhatsNew#dismiss', 'url' => '/whatsnew', 'verb' => 'POST'],
92
+        ['root' => '/core', 'name' => 'AppPassword#getAppPassword', 'url' => '/getapppassword', 'verb' => 'GET'],
93 93
 
94
-		['root' => '/collaboration', 'name' => 'CollaborationResources#searchCollections', 'url' => '/resources/collections/search/{filter}', 'verb' => 'GET'],
95
-		['root' => '/collaboration', 'name' => 'CollaborationResources#listCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'GET'],
96
-		['root' => '/collaboration', 'name' => 'CollaborationResources#renameCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'PUT'],
97
-		['root' => '/collaboration', 'name' => 'CollaborationResources#addResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'POST'],
94
+        ['root' => '/collaboration', 'name' => 'CollaborationResources#searchCollections', 'url' => '/resources/collections/search/{filter}', 'verb' => 'GET'],
95
+        ['root' => '/collaboration', 'name' => 'CollaborationResources#listCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'GET'],
96
+        ['root' => '/collaboration', 'name' => 'CollaborationResources#renameCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'PUT'],
97
+        ['root' => '/collaboration', 'name' => 'CollaborationResources#addResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'POST'],
98 98
 
99
-		['root' => '/collaboration', 'name' => 'CollaborationResources#removeResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'DELETE'],
100
-		['root' => '/collaboration', 'name' => 'CollaborationResources#getCollectionsByResource', 'url' => '/resources/{resourceType}/{resourceId}', 'verb' => 'GET'],
101
-		['root' => '/collaboration', 'name' => 'CollaborationResources#createCollectionOnResource', 'url' => '/resources/{baseResourceType}/{baseResourceId}', 'verb' => 'POST'],
102
-	],
99
+        ['root' => '/collaboration', 'name' => 'CollaborationResources#removeResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'DELETE'],
100
+        ['root' => '/collaboration', 'name' => 'CollaborationResources#getCollectionsByResource', 'url' => '/resources/{resourceType}/{resourceId}', 'verb' => 'GET'],
101
+        ['root' => '/collaboration', 'name' => 'CollaborationResources#createCollectionOnResource', 'url' => '/resources/{baseResourceType}/{baseResourceId}', 'verb' => 'POST'],
102
+    ],
103 103
 ]);
104 104
 
105 105
 // Post installation check
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
 // Core ajax actions
109 109
 // Routing
110 110
 $this->create('core_ajax_update', '/core/ajax/update.php')
111
-	->actionInclude('core/ajax/update.php');
111
+    ->actionInclude('core/ajax/update.php');
112 112
 
113 113
 // File routes
114 114
 $this->create('files.viewcontroller.showFile', '/f/{fileid}')->action(function($urlParams) {
115
-	$app = new \OCA\Files\AppInfo\Application($urlParams);
116
-	$app->dispatch('ViewController', 'index');
115
+    $app = new \OCA\Files\AppInfo\Application($urlParams);
116
+    $app->dispatch('ViewController', 'index');
117 117
 });
118 118
 
119 119
 // Call routes
@@ -122,12 +122,12 @@  discard block
 block discarded – undo
122 122
  * @suppress PhanUndeclaredClassMethod
123 123
  */
124 124
 $this->create('spreed.pagecontroller.showCall', '/call/{token}')->action(function($urlParams) {
125
-	if (class_exists(\OCA\Spreed\AppInfo\Application::class, false)) {
126
-		$app = new \OCA\Spreed\AppInfo\Application($urlParams);
127
-		$app->dispatch('PageController', 'index');
128
-	} else {
129
-		throw new \OC\HintException('App spreed is not enabled');
130
-	}
125
+    if (class_exists(\OCA\Spreed\AppInfo\Application::class, false)) {
126
+        $app = new \OCA\Spreed\AppInfo\Application($urlParams);
127
+        $app->dispatch('PageController', 'index');
128
+    } else {
129
+        throw new \OC\HintException('App spreed is not enabled');
130
+    }
131 131
 });
132 132
 
133 133
 // OCM routes
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
  * @suppress PhanUndeclaredClassMethod
137 137
  */
138 138
 $this->create('cloud_federation_api.requesthandlercontroller.addShare', '/ocm/shares')->post()->action(function($urlParams) {
139
-	if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) {
140
-		$app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams);
141
-		$app->dispatch('RequestHandlerController', 'addShare');
142
-	} else {
143
-		throw new \OC\HintException('Cloud Federation API not enabled');
144
-	}
139
+    if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) {
140
+        $app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams);
141
+        $app->dispatch('RequestHandlerController', 'addShare');
142
+    } else {
143
+        throw new \OC\HintException('Cloud Federation API not enabled');
144
+    }
145 145
 });
146 146
 
147 147
 /**
@@ -149,53 +149,53 @@  discard block
 block discarded – undo
149 149
  * @suppress PhanUndeclaredClassMethod
150 150
  */
151 151
 $this->create('cloud_federation_api.requesthandlercontroller.receiveNotification', '/ocm/notifications')->post()->action(function($urlParams) {
152
-	if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) {
153
-		$app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams);
154
-		$app->dispatch('RequestHandlerController', 'receiveNotification');
155
-	} else {
156
-		throw new \OC\HintException('Cloud Federation API not enabled');
157
-	}
152
+    if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) {
153
+        $app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams);
154
+        $app->dispatch('RequestHandlerController', 'receiveNotification');
155
+    } else {
156
+        throw new \OC\HintException('Cloud Federation API not enabled');
157
+    }
158 158
 });
159 159
 
160 160
 
161 161
 // Sharing routes
162 162
 $this->create('files_sharing.sharecontroller.showShare', '/s/{token}')->action(function($urlParams) {
163
-	if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
164
-		$app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
165
-		$app->dispatch('ShareController', 'showShare');
166
-	} else {
167
-		throw new \OC\HintException('App file sharing is not enabled');
168
-	}
163
+    if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
164
+        $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
165
+        $app->dispatch('ShareController', 'showShare');
166
+    } else {
167
+        throw new \OC\HintException('App file sharing is not enabled');
168
+    }
169 169
 });
170 170
 $this->create('files_sharing.sharecontroller.authenticate', '/s/{token}/authenticate/{redirect}')->post()->action(function($urlParams) {
171
-	if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
172
-		$app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
173
-		$app->dispatch('ShareController', 'authenticate');
174
-	} else {
175
-		throw new \OC\HintException('App file sharing is not enabled');
176
-	}
171
+    if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
172
+        $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
173
+        $app->dispatch('ShareController', 'authenticate');
174
+    } else {
175
+        throw new \OC\HintException('App file sharing is not enabled');
176
+    }
177 177
 });
178 178
 $this->create('files_sharing.sharecontroller.showAuthenticate', '/s/{token}/authenticate/{redirect}')->get()->action(function($urlParams) {
179
-	if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
180
-		$app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
181
-		$app->dispatch('ShareController', 'showAuthenticate');
182
-	} else {
183
-		throw new \OC\HintException('App file sharing is not enabled');
184
-	}
179
+    if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
180
+        $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
181
+        $app->dispatch('ShareController', 'showAuthenticate');
182
+    } else {
183
+        throw new \OC\HintException('App file sharing is not enabled');
184
+    }
185 185
 });
186 186
 $this->create('files_sharing.sharecontroller.downloadShare', '/s/{token}/download')->get()->action(function($urlParams) {
187
-	if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
188
-		$app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
189
-		$app->dispatch('ShareController', 'downloadShare');
190
-	} else {
191
-		throw new \OC\HintException('App file sharing is not enabled');
192
-	}
187
+    if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
188
+        $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
189
+        $app->dispatch('ShareController', 'downloadShare');
190
+    } else {
191
+        throw new \OC\HintException('App file sharing is not enabled');
192
+    }
193 193
 });
194 194
 $this->create('files_sharing.publicpreview.directLink', '/s/{token}/preview')->get()->action(function($urlParams) {
195
-	if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
196
-		$app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
197
-		$app->dispatch('PublicPreviewController', 'directLink');
198
-	} else {
199
-		throw new \OC\HintException('App file sharing is not enabled');
200
-	}
195
+    if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
196
+        $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
197
+        $app->dispatch('PublicPreviewController', 'directLink');
198
+    } else {
199
+        throw new \OC\HintException('App file sharing is not enabled');
200
+    }
201 201
 });
Please login to merge, or discard this patch.
core/Migrations/Version16000Date20190207141427.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -31,81 +31,81 @@
 block discarded – undo
31 31
 class Version16000Date20190207141427 extends SimpleMigrationStep {
32 32
 
33 33
 
34
-	/**
35
-	 * @param IOutput $output
36
-	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
37
-	 * @param array $options
38
-	 * @return null|ISchemaWrapper
39
-	 */
40
-	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
41
-		/** @var ISchemaWrapper $schema */
42
-		$schema = $schemaClosure();
43
-
44
-		if (!$schema->hasTable('collres_collections')) {
45
-			$table = $schema->createTable('collres_collections');
46
-
47
-			$table->addColumn('id', Type::BIGINT, [
48
-				'autoincrement' => true,
49
-				'notnull' => true,
50
-			]);
51
-			$table->addColumn('name', Type::STRING, [
52
-				'notnull' => true,
53
-				'length' => 64,
54
-			]);
55
-
56
-			$table->setPrimaryKey(['id']);
57
-		}
58
-
59
-		if (!$schema->hasTable('collres_resources')) {
60
-			$table = $schema->createTable('collres_resources');
61
-
62
-			$table->addColumn('collection_id', Type::BIGINT, [
63
-				'notnull' => true,
64
-			]);
65
-			$table->addColumn('resource_type', Type::STRING, [
66
-				'notnull' => true,
67
-				'length' => 64,
68
-			]);
69
-			$table->addColumn('resource_id', Type::STRING, [
70
-				'notnull' => true,
71
-				'length' => 64,
72
-			]);
73
-
74
-			$table->addUniqueIndex(['collection_id', 'resource_type', 'resource_id'], 'collres_unique_res');
75
-		}
76
-
77
-		if (!$schema->hasTable('collres_accesscache')) {
78
-			$table = $schema->createTable('collres_accesscache');
79
-
80
-			$table->addColumn('user_id', Type::STRING, [
81
-				'notnull' => true,
82
-				'length' => 64,
83
-			]);
84
-			$table->addColumn('collection_id', Type::BIGINT, [
85
-				'notnull' => false,
86
-				'default' => 0,
87
-			]);
88
-			$table->addColumn('resource_type', Type::STRING, [
89
-				'notnull' => false,
90
-				'length' => 64,
91
-				'default' => '',
92
-			]);
93
-			$table->addColumn('resource_id', Type::STRING, [
94
-				'notnull' => false,
95
-				'length' => 64,
96
-				'default' => '',
97
-			]);
98
-			$table->addColumn('access', Type::SMALLINT, [
99
-				'notnull' => true,
100
-				'default' => 0,
101
-			]);
102
-
103
-			$table->addUniqueIndex(['user_id', 'collection_id', 'resource_type', 'resource_id'], 'collres_unique_user');
104
-			$table->addIndex(['user_id', 'resource_type', 'resource_id'], 'collres_user_res');
105
-			$table->addIndex(['user_id', 'collection_id'], 'collres_user_coll');
106
-		}
107
-
108
-		return $schema;
109
-	}
34
+    /**
35
+     * @param IOutput $output
36
+     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
37
+     * @param array $options
38
+     * @return null|ISchemaWrapper
39
+     */
40
+    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
41
+        /** @var ISchemaWrapper $schema */
42
+        $schema = $schemaClosure();
43
+
44
+        if (!$schema->hasTable('collres_collections')) {
45
+            $table = $schema->createTable('collres_collections');
46
+
47
+            $table->addColumn('id', Type::BIGINT, [
48
+                'autoincrement' => true,
49
+                'notnull' => true,
50
+            ]);
51
+            $table->addColumn('name', Type::STRING, [
52
+                'notnull' => true,
53
+                'length' => 64,
54
+            ]);
55
+
56
+            $table->setPrimaryKey(['id']);
57
+        }
58
+
59
+        if (!$schema->hasTable('collres_resources')) {
60
+            $table = $schema->createTable('collres_resources');
61
+
62
+            $table->addColumn('collection_id', Type::BIGINT, [
63
+                'notnull' => true,
64
+            ]);
65
+            $table->addColumn('resource_type', Type::STRING, [
66
+                'notnull' => true,
67
+                'length' => 64,
68
+            ]);
69
+            $table->addColumn('resource_id', Type::STRING, [
70
+                'notnull' => true,
71
+                'length' => 64,
72
+            ]);
73
+
74
+            $table->addUniqueIndex(['collection_id', 'resource_type', 'resource_id'], 'collres_unique_res');
75
+        }
76
+
77
+        if (!$schema->hasTable('collres_accesscache')) {
78
+            $table = $schema->createTable('collres_accesscache');
79
+
80
+            $table->addColumn('user_id', Type::STRING, [
81
+                'notnull' => true,
82
+                'length' => 64,
83
+            ]);
84
+            $table->addColumn('collection_id', Type::BIGINT, [
85
+                'notnull' => false,
86
+                'default' => 0,
87
+            ]);
88
+            $table->addColumn('resource_type', Type::STRING, [
89
+                'notnull' => false,
90
+                'length' => 64,
91
+                'default' => '',
92
+            ]);
93
+            $table->addColumn('resource_id', Type::STRING, [
94
+                'notnull' => false,
95
+                'length' => 64,
96
+                'default' => '',
97
+            ]);
98
+            $table->addColumn('access', Type::SMALLINT, [
99
+                'notnull' => true,
100
+                'default' => 0,
101
+            ]);
102
+
103
+            $table->addUniqueIndex(['user_id', 'collection_id', 'resource_type', 'resource_id'], 'collres_unique_user');
104
+            $table->addIndex(['user_id', 'resource_type', 'resource_id'], 'collres_user_res');
105
+            $table->addIndex(['user_id', 'collection_id'], 'collres_user_coll');
106
+        }
107
+
108
+        return $schema;
109
+    }
110 110
 
111 111
 }
Please login to merge, or discard this patch.
core/Controller/CollaborationResourcesController.php 1 patch
Indentation   +214 added lines, -214 removed lines patch added patch discarded remove patch
@@ -35,218 +35,218 @@
 block discarded – undo
35 35
 
36 36
 class CollaborationResourcesController extends OCSController {
37 37
 
38
-	/** @var IManager */
39
-	private $manager;
40
-
41
-	/** @var IUserSession */
42
-	private $userSession;
43
-
44
-	public function __construct(
45
-		string $appName,
46
-		IRequest $request,
47
-		IManager $manager,
48
-		IUserSession $userSession
49
-	) {
50
-		parent::__construct($appName, $request);
51
-
52
-		$this->manager = $manager;
53
-		$this->userSession = $userSession;
54
-	}
55
-
56
-	/**
57
-	 * @param int $collectionId
58
-	 * @return ICollection
59
-	 * @throws CollectionException when the collection was not found for the user
60
-	 */
61
-	protected function getCollection(int $collectionId): ICollection {
62
-		$collection = $this->manager->getCollectionForUser($collectionId, $this->userSession->getUser());
63
-
64
-		if (!$collection->canAccess($this->userSession->getUser())) {
65
-			throw new CollectionException('Not found');
66
-		}
67
-
68
-		return $collection;
69
-	}
70
-
71
-	/**
72
-	 * @NoAdminRequired
73
-	 *
74
-	 * @param int $collectionId
75
-	 * @return DataResponse
76
-	 */
77
-	public function listCollection(int $collectionId): DataResponse {
78
-		try {
79
-			$collection = $this->getCollection($collectionId);
80
-		} catch (CollectionException $e) {
81
-			return new DataResponse([], Http::STATUS_NOT_FOUND);
82
-		}
83
-
84
-		return new DataResponse($this->prepareCollection($collection));
85
-	}
86
-
87
-	/**
88
-	 * @NoAdminRequired
89
-	 *
90
-	 * @param string $filter
91
-	 * @return DataResponse
92
-	 */
93
-	public function searchCollections(string $filter): DataResponse {
94
-		try {
95
-			$collections = $this->manager->searchCollections($this->userSession->getUser(), $filter);
96
-		} catch (CollectionException $e) {
97
-			return new DataResponse([], Http::STATUS_NOT_FOUND);
98
-		}
99
-
100
-		return new DataResponse(array_map([$this, 'prepareCollection'], $collections));
101
-	}
102
-
103
-	/**
104
-	 * @NoAdminRequired
105
-	 *
106
-	 * @param int $collectionId
107
-	 * @param string $resourceType
108
-	 * @param string $resourceId
109
-	 * @return DataResponse
110
-	 */
111
-	public function addResource(int $collectionId, string $resourceType, string $resourceId): DataResponse {
112
-		try {
113
-			$collection = $this->getCollection($collectionId);
114
-		} catch (CollectionException $e) {
115
-			return new DataResponse([], Http::STATUS_NOT_FOUND);
116
-		}
117
-
118
-		$resource = $this->manager->createResource($resourceType, $resourceId);
119
-
120
-		if (!$resource->canAccess($this->userSession->getUser())) {
121
-			return new DataResponse([], Http::STATUS_NOT_FOUND);
122
-		}
123
-
124
-		try {
125
-			$collection->addResource($resource);
126
-		} catch (ResourceException $e) {
127
-		}
128
-
129
-		return new DataResponse($this->prepareCollection($collection));
130
-	}
131
-
132
-	/**
133
-	 * @NoAdminRequired
134
-	 *
135
-	 * @param int $collectionId
136
-	 * @param string $resourceType
137
-	 * @param string $resourceId
138
-	 * @return DataResponse
139
-	 */
140
-	public function removeResource(int $collectionId, string $resourceType, string $resourceId): DataResponse {
141
-		try {
142
-			$collection = $this->getCollection($collectionId);
143
-		} catch (CollectionException $e) {
144
-			return new DataResponse([], Http::STATUS_NOT_FOUND);
145
-		}
146
-
147
-		try {
148
-			$resource = $this->manager->getResourceForUser($resourceType, $resourceId, $this->userSession->getUser());
149
-		} catch (CollectionException $e) {
150
-			return new DataResponse([], Http::STATUS_NOT_FOUND);
151
-		}
152
-
153
-		$collection->removeResource($resource);
154
-
155
-		return new DataResponse($this->prepareCollection($collection));
156
-	}
157
-
158
-	/**
159
-	 * @NoAdminRequired
160
-	 *
161
-	 * @param string $resourceType
162
-	 * @param string $resourceId
163
-	 * @return DataResponse
164
-	 */
165
-	public function getCollectionsByResource(string $resourceType, string $resourceId): DataResponse {
166
-		try {
167
-			$resource = $this->manager->getResourceForUser($resourceType, $resourceId, $this->userSession->getUser());
168
-		} catch (ResourceException $e) {
169
-			return new DataResponse([], Http::STATUS_NOT_FOUND);
170
-		}
171
-
172
-		if (!$resource->canAccess($this->userSession->getUser())) {
173
-			return new DataResponse([], Http::STATUS_NOT_FOUND);
174
-		}
175
-
176
-		return new DataResponse(array_map([$this, 'prepareCollection'], $resource->getCollections()));
177
-	}
178
-
179
-	/**
180
-	 * @NoAdminRequired
181
-	 *
182
-	 * @param string $baseResourceType
183
-	 * @param string $baseResourceId
184
-	 * @param string $name
185
-	 * @return DataResponse
186
-	 */
187
-	public function createCollectionOnResource(string $baseResourceType, string $baseResourceId, string $name): DataResponse {
188
-		if (!isset($name[0]) || isset($name[64])) {
189
-			return new DataResponse([], Http::STATUS_BAD_REQUEST);
190
-		}
191
-
192
-		try {
193
-			$resource = $this->manager->createResource($baseResourceType, $baseResourceId);
194
-		} catch (CollectionException $e) {
195
-			return new DataResponse([], Http::STATUS_NOT_FOUND);
196
-		}
197
-
198
-		if (!$resource->canAccess($this->userSession->getUser())) {
199
-			return new DataResponse([], Http::STATUS_NOT_FOUND);
200
-		}
201
-
202
-		$collection = $this->manager->newCollection($name);
203
-		$collection->addResource($resource);
204
-
205
-		return new DataResponse($this->prepareCollection($collection));
206
-	}
207
-
208
-	/**
209
-	 * @NoAdminRequired
210
-	 *
211
-	 * @param int $collectionId
212
-	 * @param string $collectionName
213
-	 * @return DataResponse
214
-	 */
215
-	public function renameCollection(int $collectionId, string $collectionName): DataResponse {
216
-		try {
217
-			$collection = $this->getCollection($collectionId);
218
-		} catch (CollectionException $exception) {
219
-			return new DataResponse([], Http::STATUS_NOT_FOUND);
220
-		}
221
-
222
-		$collection->setName($collectionName);
223
-
224
-		return new DataResponse($this->prepareCollection($collection));
225
-	}
226
-
227
-	protected function prepareCollection(ICollection $collection): array {
228
-		if (!$collection->canAccess($this->userSession->getUser())) {
229
-			return null;
230
-		}
231
-
232
-		return [
233
-			'id' => $collection->getId(),
234
-			'name' => $collection->getName(),
235
-			'resources' => array_values(array_filter(array_map([$this, 'prepareResources'], $collection->getResources()))),
236
-		];
237
-	}
238
-
239
-	protected function prepareResources(IResource $resource): ?array {
240
-		if (!$resource->canAccess($this->userSession->getUser())) {
241
-			return null;
242
-		}
243
-
244
-		return [
245
-			'type' => $resource->getType(),
246
-			'id' => $resource->getId(),
247
-			'name' => $resource->getName(),
248
-			'iconClass' => $resource->getIconClass(),
249
-			'link' => $resource->getLink(),
250
-		];
251
-	}
38
+    /** @var IManager */
39
+    private $manager;
40
+
41
+    /** @var IUserSession */
42
+    private $userSession;
43
+
44
+    public function __construct(
45
+        string $appName,
46
+        IRequest $request,
47
+        IManager $manager,
48
+        IUserSession $userSession
49
+    ) {
50
+        parent::__construct($appName, $request);
51
+
52
+        $this->manager = $manager;
53
+        $this->userSession = $userSession;
54
+    }
55
+
56
+    /**
57
+     * @param int $collectionId
58
+     * @return ICollection
59
+     * @throws CollectionException when the collection was not found for the user
60
+     */
61
+    protected function getCollection(int $collectionId): ICollection {
62
+        $collection = $this->manager->getCollectionForUser($collectionId, $this->userSession->getUser());
63
+
64
+        if (!$collection->canAccess($this->userSession->getUser())) {
65
+            throw new CollectionException('Not found');
66
+        }
67
+
68
+        return $collection;
69
+    }
70
+
71
+    /**
72
+     * @NoAdminRequired
73
+     *
74
+     * @param int $collectionId
75
+     * @return DataResponse
76
+     */
77
+    public function listCollection(int $collectionId): DataResponse {
78
+        try {
79
+            $collection = $this->getCollection($collectionId);
80
+        } catch (CollectionException $e) {
81
+            return new DataResponse([], Http::STATUS_NOT_FOUND);
82
+        }
83
+
84
+        return new DataResponse($this->prepareCollection($collection));
85
+    }
86
+
87
+    /**
88
+     * @NoAdminRequired
89
+     *
90
+     * @param string $filter
91
+     * @return DataResponse
92
+     */
93
+    public function searchCollections(string $filter): DataResponse {
94
+        try {
95
+            $collections = $this->manager->searchCollections($this->userSession->getUser(), $filter);
96
+        } catch (CollectionException $e) {
97
+            return new DataResponse([], Http::STATUS_NOT_FOUND);
98
+        }
99
+
100
+        return new DataResponse(array_map([$this, 'prepareCollection'], $collections));
101
+    }
102
+
103
+    /**
104
+     * @NoAdminRequired
105
+     *
106
+     * @param int $collectionId
107
+     * @param string $resourceType
108
+     * @param string $resourceId
109
+     * @return DataResponse
110
+     */
111
+    public function addResource(int $collectionId, string $resourceType, string $resourceId): DataResponse {
112
+        try {
113
+            $collection = $this->getCollection($collectionId);
114
+        } catch (CollectionException $e) {
115
+            return new DataResponse([], Http::STATUS_NOT_FOUND);
116
+        }
117
+
118
+        $resource = $this->manager->createResource($resourceType, $resourceId);
119
+
120
+        if (!$resource->canAccess($this->userSession->getUser())) {
121
+            return new DataResponse([], Http::STATUS_NOT_FOUND);
122
+        }
123
+
124
+        try {
125
+            $collection->addResource($resource);
126
+        } catch (ResourceException $e) {
127
+        }
128
+
129
+        return new DataResponse($this->prepareCollection($collection));
130
+    }
131
+
132
+    /**
133
+     * @NoAdminRequired
134
+     *
135
+     * @param int $collectionId
136
+     * @param string $resourceType
137
+     * @param string $resourceId
138
+     * @return DataResponse
139
+     */
140
+    public function removeResource(int $collectionId, string $resourceType, string $resourceId): DataResponse {
141
+        try {
142
+            $collection = $this->getCollection($collectionId);
143
+        } catch (CollectionException $e) {
144
+            return new DataResponse([], Http::STATUS_NOT_FOUND);
145
+        }
146
+
147
+        try {
148
+            $resource = $this->manager->getResourceForUser($resourceType, $resourceId, $this->userSession->getUser());
149
+        } catch (CollectionException $e) {
150
+            return new DataResponse([], Http::STATUS_NOT_FOUND);
151
+        }
152
+
153
+        $collection->removeResource($resource);
154
+
155
+        return new DataResponse($this->prepareCollection($collection));
156
+    }
157
+
158
+    /**
159
+     * @NoAdminRequired
160
+     *
161
+     * @param string $resourceType
162
+     * @param string $resourceId
163
+     * @return DataResponse
164
+     */
165
+    public function getCollectionsByResource(string $resourceType, string $resourceId): DataResponse {
166
+        try {
167
+            $resource = $this->manager->getResourceForUser($resourceType, $resourceId, $this->userSession->getUser());
168
+        } catch (ResourceException $e) {
169
+            return new DataResponse([], Http::STATUS_NOT_FOUND);
170
+        }
171
+
172
+        if (!$resource->canAccess($this->userSession->getUser())) {
173
+            return new DataResponse([], Http::STATUS_NOT_FOUND);
174
+        }
175
+
176
+        return new DataResponse(array_map([$this, 'prepareCollection'], $resource->getCollections()));
177
+    }
178
+
179
+    /**
180
+     * @NoAdminRequired
181
+     *
182
+     * @param string $baseResourceType
183
+     * @param string $baseResourceId
184
+     * @param string $name
185
+     * @return DataResponse
186
+     */
187
+    public function createCollectionOnResource(string $baseResourceType, string $baseResourceId, string $name): DataResponse {
188
+        if (!isset($name[0]) || isset($name[64])) {
189
+            return new DataResponse([], Http::STATUS_BAD_REQUEST);
190
+        }
191
+
192
+        try {
193
+            $resource = $this->manager->createResource($baseResourceType, $baseResourceId);
194
+        } catch (CollectionException $e) {
195
+            return new DataResponse([], Http::STATUS_NOT_FOUND);
196
+        }
197
+
198
+        if (!$resource->canAccess($this->userSession->getUser())) {
199
+            return new DataResponse([], Http::STATUS_NOT_FOUND);
200
+        }
201
+
202
+        $collection = $this->manager->newCollection($name);
203
+        $collection->addResource($resource);
204
+
205
+        return new DataResponse($this->prepareCollection($collection));
206
+    }
207
+
208
+    /**
209
+     * @NoAdminRequired
210
+     *
211
+     * @param int $collectionId
212
+     * @param string $collectionName
213
+     * @return DataResponse
214
+     */
215
+    public function renameCollection(int $collectionId, string $collectionName): DataResponse {
216
+        try {
217
+            $collection = $this->getCollection($collectionId);
218
+        } catch (CollectionException $exception) {
219
+            return new DataResponse([], Http::STATUS_NOT_FOUND);
220
+        }
221
+
222
+        $collection->setName($collectionName);
223
+
224
+        return new DataResponse($this->prepareCollection($collection));
225
+    }
226
+
227
+    protected function prepareCollection(ICollection $collection): array {
228
+        if (!$collection->canAccess($this->userSession->getUser())) {
229
+            return null;
230
+        }
231
+
232
+        return [
233
+            'id' => $collection->getId(),
234
+            'name' => $collection->getName(),
235
+            'resources' => array_values(array_filter(array_map([$this, 'prepareResources'], $collection->getResources()))),
236
+        ];
237
+    }
238
+
239
+    protected function prepareResources(IResource $resource): ?array {
240
+        if (!$resource->canAccess($this->userSession->getUser())) {
241
+            return null;
242
+        }
243
+
244
+        return [
245
+            'type' => $resource->getType(),
246
+            'id' => $resource->getId(),
247
+            'name' => $resource->getName(),
248
+            'iconClass' => $resource->getIconClass(),
249
+            'link' => $resource->getLink(),
250
+        ];
251
+    }
252 252
 }
Please login to merge, or discard this patch.