@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * appending or prepending to the ones previously set for this namespace. |
149 | 149 | * |
150 | 150 | * @param string $prefix The prefix/namespace, with trailing '\\' |
151 | - * @param array|string $paths The PSR-4 base directories |
|
151 | + * @param string $paths The PSR-4 base directories |
|
152 | 152 | * @param bool $prepend Whether to prepend the directories |
153 | 153 | * |
154 | 154 | * @throws \InvalidArgumentException |
@@ -367,6 +367,10 @@ discard block |
||
367 | 367 | return $file; |
368 | 368 | } |
369 | 369 | |
370 | + /** |
|
371 | + * @param string $class |
|
372 | + * @param string $ext |
|
373 | + */ |
|
370 | 374 | private function findFileWithExtension($class, $ext) |
371 | 375 | { |
372 | 376 | // PSR-4 lookup |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | private function findFileWithExtension($class, $ext) |
371 | 371 | { |
372 | 372 | // PSR-4 lookup |
373 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
373 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
374 | 374 | |
375 | 375 | $first = $class[0]; |
376 | 376 | if (isset($this->prefixLengthsPsr4[$first])) { |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | if (isset($this->prefixDirsPsr4[$search])) { |
382 | 382 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
383 | 383 | $length = $this->prefixLengthsPsr4[$first][$search]; |
384 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { |
|
384 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $length))) { |
|
385 | 385 | return $file; |
386 | 386 | } |
387 | 387 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | |
392 | 392 | // PSR-4 fallback dirs |
393 | 393 | foreach ($this->fallbackDirsPsr4 as $dir) { |
394 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
394 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
395 | 395 | return $file; |
396 | 396 | } |
397 | 397 | } |
@@ -403,14 +403,14 @@ discard block |
||
403 | 403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
404 | 404 | } else { |
405 | 405 | // PEAR-like class name |
406 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
406 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | if (isset($this->prefixesPsr0[$first])) { |
410 | 410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
411 | 411 | if (0 === strpos($class, $prefix)) { |
412 | 412 | foreach ($dirs as $dir) { |
413 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
413 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
414 | 414 | return $file; |
415 | 415 | } |
416 | 416 | } |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | |
421 | 421 | // PSR-0 fallback dirs |
422 | 422 | foreach ($this->fallbackDirsPsr0 as $dir) { |
423 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
423 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
424 | 424 | return $file; |
425 | 425 | } |
426 | 426 | } |
@@ -6,51 +6,51 @@ |
||
6 | 6 | $baseDir = $vendorDir; |
7 | 7 | |
8 | 8 | return array( |
9 | - 'OCA\\Files_Sharing\\Activity\\Filter' => $baseDir . '/../lib/Activity/Filter.php', |
|
10 | - 'OCA\\Files_Sharing\\Activity\\Providers\\Base' => $baseDir . '/../lib/Activity/Providers/Base.php', |
|
11 | - 'OCA\\Files_Sharing\\Activity\\Providers\\Downloads' => $baseDir . '/../lib/Activity/Providers/Downloads.php', |
|
12 | - 'OCA\\Files_Sharing\\Activity\\Providers\\Groups' => $baseDir . '/../lib/Activity/Providers/Groups.php', |
|
13 | - 'OCA\\Files_Sharing\\Activity\\Providers\\PublicLinks' => $baseDir . '/../lib/Activity/Providers/PublicLinks.php', |
|
14 | - 'OCA\\Files_Sharing\\Activity\\Providers\\RemoteShares' => $baseDir . '/../lib/Activity/Providers/RemoteShares.php', |
|
15 | - 'OCA\\Files_Sharing\\Activity\\Providers\\Users' => $baseDir . '/../lib/Activity/Providers/Users.php', |
|
16 | - 'OCA\\Files_Sharing\\Activity\\Settings\\PublicLinks' => $baseDir . '/../lib/Activity/Settings/PublicLinks.php', |
|
17 | - 'OCA\\Files_Sharing\\Activity\\Settings\\RemoteShare' => $baseDir . '/../lib/Activity/Settings/RemoteShare.php', |
|
18 | - 'OCA\\Files_Sharing\\Activity\\Settings\\Shared' => $baseDir . '/../lib/Activity/Settings/Shared.php', |
|
19 | - 'OCA\\Files_Sharing\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', |
|
20 | - 'OCA\\Files_Sharing\\Cache' => $baseDir . '/../lib/Cache.php', |
|
21 | - 'OCA\\Files_Sharing\\Capabilities' => $baseDir . '/../lib/Capabilities.php', |
|
22 | - 'OCA\\Files_Sharing\\Command\\CleanupRemoteStorages' => $baseDir . '/../lib/Command/CleanupRemoteStorages.php', |
|
23 | - 'OCA\\Files_Sharing\\Controller\\ExternalSharesController' => $baseDir . '/../lib/Controller/ExternalSharesController.php', |
|
24 | - 'OCA\\Files_Sharing\\Controller\\PublicPreviewController' => $baseDir . '/../lib/Controller/PublicPreviewController.php', |
|
25 | - 'OCA\\Files_Sharing\\Controller\\RemoteController' => $baseDir . '/../lib/Controller/RemoteController.php', |
|
26 | - 'OCA\\Files_Sharing\\Controller\\ShareAPIController' => $baseDir . '/../lib/Controller/ShareAPIController.php', |
|
27 | - 'OCA\\Files_Sharing\\Controller\\ShareController' => $baseDir . '/../lib/Controller/ShareController.php', |
|
28 | - 'OCA\\Files_Sharing\\Controller\\ShareInfoController' => $baseDir . '/../lib/Controller/ShareInfoController.php', |
|
29 | - 'OCA\\Files_Sharing\\Controller\\ShareesAPIController' => $baseDir . '/../lib/Controller/ShareesAPIController.php', |
|
30 | - 'OCA\\Files_Sharing\\DeleteOrphanedSharesJob' => $baseDir . '/../lib/DeleteOrphanedSharesJob.php', |
|
31 | - 'OCA\\Files_Sharing\\Exceptions\\BrokenPath' => $baseDir . '/../lib/Exceptions/BrokenPath.php', |
|
32 | - 'OCA\\Files_Sharing\\Exceptions\\S2SException' => $baseDir . '/../lib/Exceptions/S2SException.php', |
|
33 | - 'OCA\\Files_Sharing\\ExpireSharesJob' => $baseDir . '/../lib/ExpireSharesJob.php', |
|
34 | - 'OCA\\Files_Sharing\\External\\Cache' => $baseDir . '/../lib/External/Cache.php', |
|
35 | - 'OCA\\Files_Sharing\\External\\Manager' => $baseDir . '/../lib/External/Manager.php', |
|
36 | - 'OCA\\Files_Sharing\\External\\Mount' => $baseDir . '/../lib/External/Mount.php', |
|
37 | - 'OCA\\Files_Sharing\\External\\MountProvider' => $baseDir . '/../lib/External/MountProvider.php', |
|
38 | - 'OCA\\Files_Sharing\\External\\Scanner' => $baseDir . '/../lib/External/Scanner.php', |
|
39 | - 'OCA\\Files_Sharing\\External\\Storage' => $baseDir . '/../lib/External/Storage.php', |
|
40 | - 'OCA\\Files_Sharing\\External\\Watcher' => $baseDir . '/../lib/External/Watcher.php', |
|
41 | - 'OCA\\Files_Sharing\\Helper' => $baseDir . '/../lib/Helper.php', |
|
42 | - 'OCA\\Files_Sharing\\Hooks' => $baseDir . '/../lib/Hooks.php', |
|
43 | - 'OCA\\Files_Sharing\\ISharedStorage' => $baseDir . '/../lib/ISharedStorage.php', |
|
44 | - 'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => $baseDir . '/../lib/Middleware/OCSShareAPIMiddleware.php', |
|
45 | - 'OCA\\Files_Sharing\\Middleware\\ShareInfoMiddleware' => $baseDir . '/../lib/Middleware/ShareInfoMiddleware.php', |
|
46 | - 'OCA\\Files_Sharing\\Middleware\\SharingCheckMiddleware' => $baseDir . '/../lib/Middleware/SharingCheckMiddleware.php', |
|
47 | - 'OCA\\Files_Sharing\\Migration\\OwncloudGuestShareType' => $baseDir . '/../lib/Migration/OwncloudGuestShareType.php', |
|
48 | - 'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => $baseDir . '/../lib/Migration/SetPasswordColumn.php', |
|
49 | - 'OCA\\Files_Sharing\\MountProvider' => $baseDir . '/../lib/MountProvider.php', |
|
50 | - 'OCA\\Files_Sharing\\Scanner' => $baseDir . '/../lib/Scanner.php', |
|
51 | - 'OCA\\Files_Sharing\\ShareBackend\\File' => $baseDir . '/../lib/ShareBackend/File.php', |
|
52 | - 'OCA\\Files_Sharing\\ShareBackend\\Folder' => $baseDir . '/../lib/ShareBackend/Folder.php', |
|
53 | - 'OCA\\Files_Sharing\\SharedMount' => $baseDir . '/../lib/SharedMount.php', |
|
54 | - 'OCA\\Files_Sharing\\SharedStorage' => $baseDir . '/../lib/SharedStorage.php', |
|
55 | - 'OCA\\Files_Sharing\\Updater' => $baseDir . '/../lib/Updater.php', |
|
9 | + 'OCA\\Files_Sharing\\Activity\\Filter' => $baseDir.'/../lib/Activity/Filter.php', |
|
10 | + 'OCA\\Files_Sharing\\Activity\\Providers\\Base' => $baseDir.'/../lib/Activity/Providers/Base.php', |
|
11 | + 'OCA\\Files_Sharing\\Activity\\Providers\\Downloads' => $baseDir.'/../lib/Activity/Providers/Downloads.php', |
|
12 | + 'OCA\\Files_Sharing\\Activity\\Providers\\Groups' => $baseDir.'/../lib/Activity/Providers/Groups.php', |
|
13 | + 'OCA\\Files_Sharing\\Activity\\Providers\\PublicLinks' => $baseDir.'/../lib/Activity/Providers/PublicLinks.php', |
|
14 | + 'OCA\\Files_Sharing\\Activity\\Providers\\RemoteShares' => $baseDir.'/../lib/Activity/Providers/RemoteShares.php', |
|
15 | + 'OCA\\Files_Sharing\\Activity\\Providers\\Users' => $baseDir.'/../lib/Activity/Providers/Users.php', |
|
16 | + 'OCA\\Files_Sharing\\Activity\\Settings\\PublicLinks' => $baseDir.'/../lib/Activity/Settings/PublicLinks.php', |
|
17 | + 'OCA\\Files_Sharing\\Activity\\Settings\\RemoteShare' => $baseDir.'/../lib/Activity/Settings/RemoteShare.php', |
|
18 | + 'OCA\\Files_Sharing\\Activity\\Settings\\Shared' => $baseDir.'/../lib/Activity/Settings/Shared.php', |
|
19 | + 'OCA\\Files_Sharing\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php', |
|
20 | + 'OCA\\Files_Sharing\\Cache' => $baseDir.'/../lib/Cache.php', |
|
21 | + 'OCA\\Files_Sharing\\Capabilities' => $baseDir.'/../lib/Capabilities.php', |
|
22 | + 'OCA\\Files_Sharing\\Command\\CleanupRemoteStorages' => $baseDir.'/../lib/Command/CleanupRemoteStorages.php', |
|
23 | + 'OCA\\Files_Sharing\\Controller\\ExternalSharesController' => $baseDir.'/../lib/Controller/ExternalSharesController.php', |
|
24 | + 'OCA\\Files_Sharing\\Controller\\PublicPreviewController' => $baseDir.'/../lib/Controller/PublicPreviewController.php', |
|
25 | + 'OCA\\Files_Sharing\\Controller\\RemoteController' => $baseDir.'/../lib/Controller/RemoteController.php', |
|
26 | + 'OCA\\Files_Sharing\\Controller\\ShareAPIController' => $baseDir.'/../lib/Controller/ShareAPIController.php', |
|
27 | + 'OCA\\Files_Sharing\\Controller\\ShareController' => $baseDir.'/../lib/Controller/ShareController.php', |
|
28 | + 'OCA\\Files_Sharing\\Controller\\ShareInfoController' => $baseDir.'/../lib/Controller/ShareInfoController.php', |
|
29 | + 'OCA\\Files_Sharing\\Controller\\ShareesAPIController' => $baseDir.'/../lib/Controller/ShareesAPIController.php', |
|
30 | + 'OCA\\Files_Sharing\\DeleteOrphanedSharesJob' => $baseDir.'/../lib/DeleteOrphanedSharesJob.php', |
|
31 | + 'OCA\\Files_Sharing\\Exceptions\\BrokenPath' => $baseDir.'/../lib/Exceptions/BrokenPath.php', |
|
32 | + 'OCA\\Files_Sharing\\Exceptions\\S2SException' => $baseDir.'/../lib/Exceptions/S2SException.php', |
|
33 | + 'OCA\\Files_Sharing\\ExpireSharesJob' => $baseDir.'/../lib/ExpireSharesJob.php', |
|
34 | + 'OCA\\Files_Sharing\\External\\Cache' => $baseDir.'/../lib/External/Cache.php', |
|
35 | + 'OCA\\Files_Sharing\\External\\Manager' => $baseDir.'/../lib/External/Manager.php', |
|
36 | + 'OCA\\Files_Sharing\\External\\Mount' => $baseDir.'/../lib/External/Mount.php', |
|
37 | + 'OCA\\Files_Sharing\\External\\MountProvider' => $baseDir.'/../lib/External/MountProvider.php', |
|
38 | + 'OCA\\Files_Sharing\\External\\Scanner' => $baseDir.'/../lib/External/Scanner.php', |
|
39 | + 'OCA\\Files_Sharing\\External\\Storage' => $baseDir.'/../lib/External/Storage.php', |
|
40 | + 'OCA\\Files_Sharing\\External\\Watcher' => $baseDir.'/../lib/External/Watcher.php', |
|
41 | + 'OCA\\Files_Sharing\\Helper' => $baseDir.'/../lib/Helper.php', |
|
42 | + 'OCA\\Files_Sharing\\Hooks' => $baseDir.'/../lib/Hooks.php', |
|
43 | + 'OCA\\Files_Sharing\\ISharedStorage' => $baseDir.'/../lib/ISharedStorage.php', |
|
44 | + 'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => $baseDir.'/../lib/Middleware/OCSShareAPIMiddleware.php', |
|
45 | + 'OCA\\Files_Sharing\\Middleware\\ShareInfoMiddleware' => $baseDir.'/../lib/Middleware/ShareInfoMiddleware.php', |
|
46 | + 'OCA\\Files_Sharing\\Middleware\\SharingCheckMiddleware' => $baseDir.'/../lib/Middleware/SharingCheckMiddleware.php', |
|
47 | + 'OCA\\Files_Sharing\\Migration\\OwncloudGuestShareType' => $baseDir.'/../lib/Migration/OwncloudGuestShareType.php', |
|
48 | + 'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => $baseDir.'/../lib/Migration/SetPasswordColumn.php', |
|
49 | + 'OCA\\Files_Sharing\\MountProvider' => $baseDir.'/../lib/MountProvider.php', |
|
50 | + 'OCA\\Files_Sharing\\Scanner' => $baseDir.'/../lib/Scanner.php', |
|
51 | + 'OCA\\Files_Sharing\\ShareBackend\\File' => $baseDir.'/../lib/ShareBackend/File.php', |
|
52 | + 'OCA\\Files_Sharing\\ShareBackend\\Folder' => $baseDir.'/../lib/ShareBackend/Folder.php', |
|
53 | + 'OCA\\Files_Sharing\\SharedMount' => $baseDir.'/../lib/SharedMount.php', |
|
54 | + 'OCA\\Files_Sharing\\SharedStorage' => $baseDir.'/../lib/SharedStorage.php', |
|
55 | + 'OCA\\Files_Sharing\\Updater' => $baseDir.'/../lib/Updater.php', |
|
56 | 56 | ); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | public static function loadClassLoader($class) |
10 | 10 | { |
11 | 11 | if ('Composer\Autoload\ClassLoader' === $class) { |
12 | - require __DIR__ . '/ClassLoader.php'; |
|
12 | + require __DIR__.'/ClassLoader.php'; |
|
13 | 13 | } |
14 | 14 | } |
15 | 15 | |
@@ -25,21 +25,21 @@ discard block |
||
25 | 25 | |
26 | 26 | $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); |
27 | 27 | if ($useStaticLoader) { |
28 | - require_once __DIR__ . '/autoload_static.php'; |
|
28 | + require_once __DIR__.'/autoload_static.php'; |
|
29 | 29 | |
30 | 30 | call_user_func(\Composer\Autoload\ComposerStaticInitf32f03f7cd82bff20d6a51be16689441::getInitializer($loader)); |
31 | 31 | } else { |
32 | - $map = require __DIR__ . '/autoload_namespaces.php'; |
|
32 | + $map = require __DIR__.'/autoload_namespaces.php'; |
|
33 | 33 | foreach ($map as $namespace => $path) { |
34 | 34 | $loader->set($namespace, $path); |
35 | 35 | } |
36 | 36 | |
37 | - $map = require __DIR__ . '/autoload_psr4.php'; |
|
37 | + $map = require __DIR__.'/autoload_psr4.php'; |
|
38 | 38 | foreach ($map as $namespace => $path) { |
39 | 39 | $loader->setPsr4($namespace, $path); |
40 | 40 | } |
41 | 41 | |
42 | - $classMap = require __DIR__ . '/autoload_classmap.php'; |
|
42 | + $classMap = require __DIR__.'/autoload_classmap.php'; |
|
43 | 43 | if ($classMap) { |
44 | 44 | $loader->addClassMap($classMap); |
45 | 45 | } |
@@ -6,5 +6,5 @@ |
||
6 | 6 | $baseDir = $vendorDir; |
7 | 7 | |
8 | 8 | return array( |
9 | - 'OCA\\Files_Sharing\\' => array($baseDir . '/../lib'), |
|
9 | + 'OCA\\Files_Sharing\\' => array($baseDir.'/../lib'), |
|
10 | 10 | ); |
@@ -6,73 +6,73 @@ |
||
6 | 6 | |
7 | 7 | class ComposerStaticInitf32f03f7cd82bff20d6a51be16689441 |
8 | 8 | { |
9 | - public static $prefixLengthsPsr4 = array ( |
|
9 | + public static $prefixLengthsPsr4 = array( |
|
10 | 10 | 'O' => |
11 | - array ( |
|
11 | + array( |
|
12 | 12 | 'OCA\\Files_Sharing\\' => 18, |
13 | 13 | ), |
14 | 14 | ); |
15 | 15 | |
16 | - public static $prefixDirsPsr4 = array ( |
|
16 | + public static $prefixDirsPsr4 = array( |
|
17 | 17 | 'OCA\\Files_Sharing\\' => |
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_Sharing\\Activity\\Filter' => __DIR__ . '/..' . '/../lib/Activity/Filter.php', |
|
25 | - 'OCA\\Files_Sharing\\Activity\\Providers\\Base' => __DIR__ . '/..' . '/../lib/Activity/Providers/Base.php', |
|
26 | - 'OCA\\Files_Sharing\\Activity\\Providers\\Downloads' => __DIR__ . '/..' . '/../lib/Activity/Providers/Downloads.php', |
|
27 | - 'OCA\\Files_Sharing\\Activity\\Providers\\Groups' => __DIR__ . '/..' . '/../lib/Activity/Providers/Groups.php', |
|
28 | - 'OCA\\Files_Sharing\\Activity\\Providers\\PublicLinks' => __DIR__ . '/..' . '/../lib/Activity/Providers/PublicLinks.php', |
|
29 | - 'OCA\\Files_Sharing\\Activity\\Providers\\RemoteShares' => __DIR__ . '/..' . '/../lib/Activity/Providers/RemoteShares.php', |
|
30 | - 'OCA\\Files_Sharing\\Activity\\Providers\\Users' => __DIR__ . '/..' . '/../lib/Activity/Providers/Users.php', |
|
31 | - 'OCA\\Files_Sharing\\Activity\\Settings\\PublicLinks' => __DIR__ . '/..' . '/../lib/Activity/Settings/PublicLinks.php', |
|
32 | - 'OCA\\Files_Sharing\\Activity\\Settings\\RemoteShare' => __DIR__ . '/..' . '/../lib/Activity/Settings/RemoteShare.php', |
|
33 | - 'OCA\\Files_Sharing\\Activity\\Settings\\Shared' => __DIR__ . '/..' . '/../lib/Activity/Settings/Shared.php', |
|
34 | - 'OCA\\Files_Sharing\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', |
|
35 | - 'OCA\\Files_Sharing\\Cache' => __DIR__ . '/..' . '/../lib/Cache.php', |
|
36 | - 'OCA\\Files_Sharing\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php', |
|
37 | - 'OCA\\Files_Sharing\\Command\\CleanupRemoteStorages' => __DIR__ . '/..' . '/../lib/Command/CleanupRemoteStorages.php', |
|
38 | - 'OCA\\Files_Sharing\\Controller\\ExternalSharesController' => __DIR__ . '/..' . '/../lib/Controller/ExternalSharesController.php', |
|
39 | - 'OCA\\Files_Sharing\\Controller\\PublicPreviewController' => __DIR__ . '/..' . '/../lib/Controller/PublicPreviewController.php', |
|
40 | - 'OCA\\Files_Sharing\\Controller\\RemoteController' => __DIR__ . '/..' . '/../lib/Controller/RemoteController.php', |
|
41 | - 'OCA\\Files_Sharing\\Controller\\ShareAPIController' => __DIR__ . '/..' . '/../lib/Controller/ShareAPIController.php', |
|
42 | - 'OCA\\Files_Sharing\\Controller\\ShareController' => __DIR__ . '/..' . '/../lib/Controller/ShareController.php', |
|
43 | - 'OCA\\Files_Sharing\\Controller\\ShareInfoController' => __DIR__ . '/..' . '/../lib/Controller/ShareInfoController.php', |
|
44 | - 'OCA\\Files_Sharing\\Controller\\ShareesAPIController' => __DIR__ . '/..' . '/../lib/Controller/ShareesAPIController.php', |
|
45 | - 'OCA\\Files_Sharing\\DeleteOrphanedSharesJob' => __DIR__ . '/..' . '/../lib/DeleteOrphanedSharesJob.php', |
|
46 | - 'OCA\\Files_Sharing\\Exceptions\\BrokenPath' => __DIR__ . '/..' . '/../lib/Exceptions/BrokenPath.php', |
|
47 | - 'OCA\\Files_Sharing\\Exceptions\\S2SException' => __DIR__ . '/..' . '/../lib/Exceptions/S2SException.php', |
|
48 | - 'OCA\\Files_Sharing\\ExpireSharesJob' => __DIR__ . '/..' . '/../lib/ExpireSharesJob.php', |
|
49 | - 'OCA\\Files_Sharing\\External\\Cache' => __DIR__ . '/..' . '/../lib/External/Cache.php', |
|
50 | - 'OCA\\Files_Sharing\\External\\Manager' => __DIR__ . '/..' . '/../lib/External/Manager.php', |
|
51 | - 'OCA\\Files_Sharing\\External\\Mount' => __DIR__ . '/..' . '/../lib/External/Mount.php', |
|
52 | - 'OCA\\Files_Sharing\\External\\MountProvider' => __DIR__ . '/..' . '/../lib/External/MountProvider.php', |
|
53 | - 'OCA\\Files_Sharing\\External\\Scanner' => __DIR__ . '/..' . '/../lib/External/Scanner.php', |
|
54 | - 'OCA\\Files_Sharing\\External\\Storage' => __DIR__ . '/..' . '/../lib/External/Storage.php', |
|
55 | - 'OCA\\Files_Sharing\\External\\Watcher' => __DIR__ . '/..' . '/../lib/External/Watcher.php', |
|
56 | - 'OCA\\Files_Sharing\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php', |
|
57 | - 'OCA\\Files_Sharing\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php', |
|
58 | - 'OCA\\Files_Sharing\\ISharedStorage' => __DIR__ . '/..' . '/../lib/ISharedStorage.php', |
|
59 | - 'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/OCSShareAPIMiddleware.php', |
|
60 | - 'OCA\\Files_Sharing\\Middleware\\ShareInfoMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/ShareInfoMiddleware.php', |
|
61 | - 'OCA\\Files_Sharing\\Middleware\\SharingCheckMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/SharingCheckMiddleware.php', |
|
62 | - 'OCA\\Files_Sharing\\Migration\\OwncloudGuestShareType' => __DIR__ . '/..' . '/../lib/Migration/OwncloudGuestShareType.php', |
|
63 | - 'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => __DIR__ . '/..' . '/../lib/Migration/SetPasswordColumn.php', |
|
64 | - 'OCA\\Files_Sharing\\MountProvider' => __DIR__ . '/..' . '/../lib/MountProvider.php', |
|
65 | - 'OCA\\Files_Sharing\\Scanner' => __DIR__ . '/..' . '/../lib/Scanner.php', |
|
66 | - 'OCA\\Files_Sharing\\ShareBackend\\File' => __DIR__ . '/..' . '/../lib/ShareBackend/File.php', |
|
67 | - 'OCA\\Files_Sharing\\ShareBackend\\Folder' => __DIR__ . '/..' . '/../lib/ShareBackend/Folder.php', |
|
68 | - 'OCA\\Files_Sharing\\SharedMount' => __DIR__ . '/..' . '/../lib/SharedMount.php', |
|
69 | - 'OCA\\Files_Sharing\\SharedStorage' => __DIR__ . '/..' . '/../lib/SharedStorage.php', |
|
70 | - 'OCA\\Files_Sharing\\Updater' => __DIR__ . '/..' . '/../lib/Updater.php', |
|
23 | + public static $classMap = array( |
|
24 | + 'OCA\\Files_Sharing\\Activity\\Filter' => __DIR__.'/..'.'/../lib/Activity/Filter.php', |
|
25 | + 'OCA\\Files_Sharing\\Activity\\Providers\\Base' => __DIR__.'/..'.'/../lib/Activity/Providers/Base.php', |
|
26 | + 'OCA\\Files_Sharing\\Activity\\Providers\\Downloads' => __DIR__.'/..'.'/../lib/Activity/Providers/Downloads.php', |
|
27 | + 'OCA\\Files_Sharing\\Activity\\Providers\\Groups' => __DIR__.'/..'.'/../lib/Activity/Providers/Groups.php', |
|
28 | + 'OCA\\Files_Sharing\\Activity\\Providers\\PublicLinks' => __DIR__.'/..'.'/../lib/Activity/Providers/PublicLinks.php', |
|
29 | + 'OCA\\Files_Sharing\\Activity\\Providers\\RemoteShares' => __DIR__.'/..'.'/../lib/Activity/Providers/RemoteShares.php', |
|
30 | + 'OCA\\Files_Sharing\\Activity\\Providers\\Users' => __DIR__.'/..'.'/../lib/Activity/Providers/Users.php', |
|
31 | + 'OCA\\Files_Sharing\\Activity\\Settings\\PublicLinks' => __DIR__.'/..'.'/../lib/Activity/Settings/PublicLinks.php', |
|
32 | + 'OCA\\Files_Sharing\\Activity\\Settings\\RemoteShare' => __DIR__.'/..'.'/../lib/Activity/Settings/RemoteShare.php', |
|
33 | + 'OCA\\Files_Sharing\\Activity\\Settings\\Shared' => __DIR__.'/..'.'/../lib/Activity/Settings/Shared.php', |
|
34 | + 'OCA\\Files_Sharing\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php', |
|
35 | + 'OCA\\Files_Sharing\\Cache' => __DIR__.'/..'.'/../lib/Cache.php', |
|
36 | + 'OCA\\Files_Sharing\\Capabilities' => __DIR__.'/..'.'/../lib/Capabilities.php', |
|
37 | + 'OCA\\Files_Sharing\\Command\\CleanupRemoteStorages' => __DIR__.'/..'.'/../lib/Command/CleanupRemoteStorages.php', |
|
38 | + 'OCA\\Files_Sharing\\Controller\\ExternalSharesController' => __DIR__.'/..'.'/../lib/Controller/ExternalSharesController.php', |
|
39 | + 'OCA\\Files_Sharing\\Controller\\PublicPreviewController' => __DIR__.'/..'.'/../lib/Controller/PublicPreviewController.php', |
|
40 | + 'OCA\\Files_Sharing\\Controller\\RemoteController' => __DIR__.'/..'.'/../lib/Controller/RemoteController.php', |
|
41 | + 'OCA\\Files_Sharing\\Controller\\ShareAPIController' => __DIR__.'/..'.'/../lib/Controller/ShareAPIController.php', |
|
42 | + 'OCA\\Files_Sharing\\Controller\\ShareController' => __DIR__.'/..'.'/../lib/Controller/ShareController.php', |
|
43 | + 'OCA\\Files_Sharing\\Controller\\ShareInfoController' => __DIR__.'/..'.'/../lib/Controller/ShareInfoController.php', |
|
44 | + 'OCA\\Files_Sharing\\Controller\\ShareesAPIController' => __DIR__.'/..'.'/../lib/Controller/ShareesAPIController.php', |
|
45 | + 'OCA\\Files_Sharing\\DeleteOrphanedSharesJob' => __DIR__.'/..'.'/../lib/DeleteOrphanedSharesJob.php', |
|
46 | + 'OCA\\Files_Sharing\\Exceptions\\BrokenPath' => __DIR__.'/..'.'/../lib/Exceptions/BrokenPath.php', |
|
47 | + 'OCA\\Files_Sharing\\Exceptions\\S2SException' => __DIR__.'/..'.'/../lib/Exceptions/S2SException.php', |
|
48 | + 'OCA\\Files_Sharing\\ExpireSharesJob' => __DIR__.'/..'.'/../lib/ExpireSharesJob.php', |
|
49 | + 'OCA\\Files_Sharing\\External\\Cache' => __DIR__.'/..'.'/../lib/External/Cache.php', |
|
50 | + 'OCA\\Files_Sharing\\External\\Manager' => __DIR__.'/..'.'/../lib/External/Manager.php', |
|
51 | + 'OCA\\Files_Sharing\\External\\Mount' => __DIR__.'/..'.'/../lib/External/Mount.php', |
|
52 | + 'OCA\\Files_Sharing\\External\\MountProvider' => __DIR__.'/..'.'/../lib/External/MountProvider.php', |
|
53 | + 'OCA\\Files_Sharing\\External\\Scanner' => __DIR__.'/..'.'/../lib/External/Scanner.php', |
|
54 | + 'OCA\\Files_Sharing\\External\\Storage' => __DIR__.'/..'.'/../lib/External/Storage.php', |
|
55 | + 'OCA\\Files_Sharing\\External\\Watcher' => __DIR__.'/..'.'/../lib/External/Watcher.php', |
|
56 | + 'OCA\\Files_Sharing\\Helper' => __DIR__.'/..'.'/../lib/Helper.php', |
|
57 | + 'OCA\\Files_Sharing\\Hooks' => __DIR__.'/..'.'/../lib/Hooks.php', |
|
58 | + 'OCA\\Files_Sharing\\ISharedStorage' => __DIR__.'/..'.'/../lib/ISharedStorage.php', |
|
59 | + 'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => __DIR__.'/..'.'/../lib/Middleware/OCSShareAPIMiddleware.php', |
|
60 | + 'OCA\\Files_Sharing\\Middleware\\ShareInfoMiddleware' => __DIR__.'/..'.'/../lib/Middleware/ShareInfoMiddleware.php', |
|
61 | + 'OCA\\Files_Sharing\\Middleware\\SharingCheckMiddleware' => __DIR__.'/..'.'/../lib/Middleware/SharingCheckMiddleware.php', |
|
62 | + 'OCA\\Files_Sharing\\Migration\\OwncloudGuestShareType' => __DIR__.'/..'.'/../lib/Migration/OwncloudGuestShareType.php', |
|
63 | + 'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => __DIR__.'/..'.'/../lib/Migration/SetPasswordColumn.php', |
|
64 | + 'OCA\\Files_Sharing\\MountProvider' => __DIR__.'/..'.'/../lib/MountProvider.php', |
|
65 | + 'OCA\\Files_Sharing\\Scanner' => __DIR__.'/..'.'/../lib/Scanner.php', |
|
66 | + 'OCA\\Files_Sharing\\ShareBackend\\File' => __DIR__.'/..'.'/../lib/ShareBackend/File.php', |
|
67 | + 'OCA\\Files_Sharing\\ShareBackend\\Folder' => __DIR__.'/..'.'/../lib/ShareBackend/Folder.php', |
|
68 | + 'OCA\\Files_Sharing\\SharedMount' => __DIR__.'/..'.'/../lib/SharedMount.php', |
|
69 | + 'OCA\\Files_Sharing\\SharedStorage' => __DIR__.'/..'.'/../lib/SharedStorage.php', |
|
70 | + 'OCA\\Files_Sharing\\Updater' => __DIR__.'/..'.'/../lib/Updater.php', |
|
71 | 71 | ); |
72 | 72 | |
73 | 73 | public static function getInitializer(ClassLoader $loader) |
74 | 74 | { |
75 | - return \Closure::bind(function () use ($loader) { |
|
75 | + return \Closure::bind(function() use ($loader) { |
|
76 | 76 | $loader->prefixLengthsPsr4 = ComposerStaticInitf32f03f7cd82bff20d6a51be16689441::$prefixLengthsPsr4; |
77 | 77 | $loader->prefixDirsPsr4 = ComposerStaticInitf32f03f7cd82bff20d6a51be16689441::$prefixDirsPsr4; |
78 | 78 | $loader->classMap = ComposerStaticInitf32f03f7cd82bff20d6a51be16689441::$classMap; |
@@ -2,6 +2,6 @@ |
||
2 | 2 | |
3 | 3 | // autoload.php @generated by Composer |
4 | 4 | |
5 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
5 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
6 | 6 | |
7 | 7 | return ComposerAutoloaderInitf32f03f7cd82bff20d6a51be16689441::getLoader(); |
@@ -61,1208 +61,1208 @@ |
||
61 | 61 | * upgrading and removing apps. |
62 | 62 | */ |
63 | 63 | class OC_App { |
64 | - static private $appVersion = []; |
|
65 | - static private $adminForms = array(); |
|
66 | - static private $personalForms = array(); |
|
67 | - static private $appInfo = array(); |
|
68 | - static private $appTypes = array(); |
|
69 | - static private $loadedApps = array(); |
|
70 | - static private $altLogin = array(); |
|
71 | - static private $alreadyRegistered = []; |
|
72 | - const officialApp = 200; |
|
73 | - |
|
74 | - /** |
|
75 | - * clean the appId |
|
76 | - * |
|
77 | - * @param string|boolean $app AppId that needs to be cleaned |
|
78 | - * @return string |
|
79 | - */ |
|
80 | - public static function cleanAppId($app) { |
|
81 | - return str_replace(array('\0', '/', '\\', '..'), '', $app); |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * Check if an app is loaded |
|
86 | - * |
|
87 | - * @param string $app |
|
88 | - * @return bool |
|
89 | - */ |
|
90 | - public static function isAppLoaded($app) { |
|
91 | - return in_array($app, self::$loadedApps, true); |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * loads all apps |
|
96 | - * |
|
97 | - * @param string[] | string | null $types |
|
98 | - * @return bool |
|
99 | - * |
|
100 | - * This function walks through the ownCloud directory and loads all apps |
|
101 | - * it can find. A directory contains an app if the file /appinfo/info.xml |
|
102 | - * exists. |
|
103 | - * |
|
104 | - * if $types is set, only apps of those types will be loaded |
|
105 | - */ |
|
106 | - public static function loadApps($types = null) { |
|
107 | - if (\OC::$server->getSystemConfig()->getValue('maintenance', false)) { |
|
108 | - return false; |
|
109 | - } |
|
110 | - // Load the enabled apps here |
|
111 | - $apps = self::getEnabledApps(); |
|
112 | - |
|
113 | - // Add each apps' folder as allowed class path |
|
114 | - foreach($apps as $app) { |
|
115 | - $path = self::getAppPath($app); |
|
116 | - if($path !== false) { |
|
117 | - self::registerAutoloading($app, $path); |
|
118 | - } |
|
119 | - } |
|
120 | - |
|
121 | - // prevent app.php from printing output |
|
122 | - ob_start(); |
|
123 | - foreach ($apps as $app) { |
|
124 | - if ((is_null($types) or self::isType($app, $types)) && !in_array($app, self::$loadedApps)) { |
|
125 | - self::loadApp($app); |
|
126 | - } |
|
127 | - } |
|
128 | - ob_end_clean(); |
|
129 | - |
|
130 | - return true; |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * load a single app |
|
135 | - * |
|
136 | - * @param string $app |
|
137 | - */ |
|
138 | - public static function loadApp($app) { |
|
139 | - self::$loadedApps[] = $app; |
|
140 | - $appPath = self::getAppPath($app); |
|
141 | - if($appPath === false) { |
|
142 | - return; |
|
143 | - } |
|
144 | - |
|
145 | - // in case someone calls loadApp() directly |
|
146 | - self::registerAutoloading($app, $appPath); |
|
147 | - |
|
148 | - if (is_file($appPath . '/appinfo/app.php')) { |
|
149 | - \OC::$server->getEventLogger()->start('load_app_' . $app, 'Load app: ' . $app); |
|
150 | - self::requireAppFile($app); |
|
151 | - if (self::isType($app, array('authentication'))) { |
|
152 | - // since authentication apps affect the "is app enabled for group" check, |
|
153 | - // the enabled apps cache needs to be cleared to make sure that the |
|
154 | - // next time getEnableApps() is called it will also include apps that were |
|
155 | - // enabled for groups |
|
156 | - self::$enabledAppsCache = array(); |
|
157 | - } |
|
158 | - \OC::$server->getEventLogger()->end('load_app_' . $app); |
|
159 | - } |
|
160 | - |
|
161 | - $info = self::getAppInfo($app); |
|
162 | - if (!empty($info['activity']['filters'])) { |
|
163 | - foreach ($info['activity']['filters'] as $filter) { |
|
164 | - \OC::$server->getActivityManager()->registerFilter($filter); |
|
165 | - } |
|
166 | - } |
|
167 | - if (!empty($info['activity']['settings'])) { |
|
168 | - foreach ($info['activity']['settings'] as $setting) { |
|
169 | - \OC::$server->getActivityManager()->registerSetting($setting); |
|
170 | - } |
|
171 | - } |
|
172 | - if (!empty($info['activity']['providers'])) { |
|
173 | - foreach ($info['activity']['providers'] as $provider) { |
|
174 | - \OC::$server->getActivityManager()->registerProvider($provider); |
|
175 | - } |
|
176 | - } |
|
177 | - if (!empty($info['collaboration']['plugins'])) { |
|
178 | - // deal with one or many plugin entries |
|
179 | - $plugins = isset($info['collaboration']['plugins']['plugin']['@value']) ? |
|
180 | - [$info['collaboration']['plugins']['plugin']] : $info['collaboration']['plugins']['plugin']; |
|
181 | - foreach ($plugins as $plugin) { |
|
182 | - if($plugin['@attributes']['type'] === 'collaborator-search') { |
|
183 | - $pluginInfo = [ |
|
184 | - 'shareType' => $plugin['@attributes']['share-type'], |
|
185 | - 'class' => $plugin['@value'], |
|
186 | - ]; |
|
187 | - \OC::$server->getCollaboratorSearch()->registerPlugin($pluginInfo); |
|
188 | - } |
|
189 | - } |
|
190 | - } |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * @internal |
|
195 | - * @param string $app |
|
196 | - * @param string $path |
|
197 | - */ |
|
198 | - public static function registerAutoloading($app, $path) { |
|
199 | - $key = $app . '-' . $path; |
|
200 | - if(isset(self::$alreadyRegistered[$key])) { |
|
201 | - return; |
|
202 | - } |
|
203 | - |
|
204 | - self::$alreadyRegistered[$key] = true; |
|
205 | - |
|
206 | - // Register on PSR-4 composer autoloader |
|
207 | - $appNamespace = \OC\AppFramework\App::buildAppNamespace($app); |
|
208 | - \OC::$server->registerNamespace($app, $appNamespace); |
|
209 | - |
|
210 | - if (file_exists($path . '/composer/autoload.php')) { |
|
211 | - require_once $path . '/composer/autoload.php'; |
|
212 | - } else { |
|
213 | - \OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true); |
|
214 | - // Register on legacy autoloader |
|
215 | - \OC::$loader->addValidRoot($path); |
|
216 | - } |
|
217 | - |
|
218 | - // Register Test namespace only when testing |
|
219 | - if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) { |
|
220 | - \OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true); |
|
221 | - } |
|
222 | - } |
|
223 | - |
|
224 | - /** |
|
225 | - * Load app.php from the given app |
|
226 | - * |
|
227 | - * @param string $app app name |
|
228 | - */ |
|
229 | - private static function requireAppFile($app) { |
|
230 | - try { |
|
231 | - // encapsulated here to avoid variable scope conflicts |
|
232 | - require_once $app . '/appinfo/app.php'; |
|
233 | - } catch (Error $ex) { |
|
234 | - \OC::$server->getLogger()->logException($ex); |
|
235 | - $blacklist = \OC::$server->getAppManager()->getAlwaysEnabledApps(); |
|
236 | - if (!in_array($app, $blacklist)) { |
|
237 | - self::disable($app); |
|
238 | - } |
|
239 | - } |
|
240 | - } |
|
241 | - |
|
242 | - /** |
|
243 | - * check if an app is of a specific type |
|
244 | - * |
|
245 | - * @param string $app |
|
246 | - * @param string|array $types |
|
247 | - * @return bool |
|
248 | - */ |
|
249 | - public static function isType($app, $types) { |
|
250 | - if (is_string($types)) { |
|
251 | - $types = array($types); |
|
252 | - } |
|
253 | - $appTypes = self::getAppTypes($app); |
|
254 | - foreach ($types as $type) { |
|
255 | - if (array_search($type, $appTypes) !== false) { |
|
256 | - return true; |
|
257 | - } |
|
258 | - } |
|
259 | - return false; |
|
260 | - } |
|
261 | - |
|
262 | - /** |
|
263 | - * get the types of an app |
|
264 | - * |
|
265 | - * @param string $app |
|
266 | - * @return array |
|
267 | - */ |
|
268 | - private static function getAppTypes($app) { |
|
269 | - //load the cache |
|
270 | - if (count(self::$appTypes) == 0) { |
|
271 | - self::$appTypes = \OC::$server->getAppConfig()->getValues(false, 'types'); |
|
272 | - } |
|
273 | - |
|
274 | - if (isset(self::$appTypes[$app])) { |
|
275 | - return explode(',', self::$appTypes[$app]); |
|
276 | - } else { |
|
277 | - return array(); |
|
278 | - } |
|
279 | - } |
|
280 | - |
|
281 | - /** |
|
282 | - * read app types from info.xml and cache them in the database |
|
283 | - */ |
|
284 | - public static function setAppTypes($app) { |
|
285 | - $appData = self::getAppInfo($app); |
|
286 | - if(!is_array($appData)) { |
|
287 | - return; |
|
288 | - } |
|
289 | - |
|
290 | - if (isset($appData['types'])) { |
|
291 | - $appTypes = implode(',', $appData['types']); |
|
292 | - } else { |
|
293 | - $appTypes = ''; |
|
294 | - $appData['types'] = []; |
|
295 | - } |
|
296 | - |
|
297 | - \OC::$server->getAppConfig()->setValue($app, 'types', $appTypes); |
|
298 | - |
|
299 | - if (\OC::$server->getAppManager()->hasProtectedAppType($appData['types'])) { |
|
300 | - $enabled = \OC::$server->getAppConfig()->getValue($app, 'enabled', 'yes'); |
|
301 | - if ($enabled !== 'yes' && $enabled !== 'no') { |
|
302 | - \OC::$server->getAppConfig()->setValue($app, 'enabled', 'yes'); |
|
303 | - } |
|
304 | - } |
|
305 | - } |
|
306 | - |
|
307 | - /** |
|
308 | - * get all enabled apps |
|
309 | - */ |
|
310 | - protected static $enabledAppsCache = array(); |
|
311 | - |
|
312 | - /** |
|
313 | - * Returns apps enabled for the current user. |
|
314 | - * |
|
315 | - * @param bool $forceRefresh whether to refresh the cache |
|
316 | - * @param bool $all whether to return apps for all users, not only the |
|
317 | - * currently logged in one |
|
318 | - * @return string[] |
|
319 | - */ |
|
320 | - public static function getEnabledApps($forceRefresh = false, $all = false) { |
|
321 | - if (!\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
322 | - return array(); |
|
323 | - } |
|
324 | - // in incognito mode or when logged out, $user will be false, |
|
325 | - // which is also the case during an upgrade |
|
326 | - $appManager = \OC::$server->getAppManager(); |
|
327 | - if ($all) { |
|
328 | - $user = null; |
|
329 | - } else { |
|
330 | - $user = \OC::$server->getUserSession()->getUser(); |
|
331 | - } |
|
332 | - |
|
333 | - if (is_null($user)) { |
|
334 | - $apps = $appManager->getInstalledApps(); |
|
335 | - } else { |
|
336 | - $apps = $appManager->getEnabledAppsForUser($user); |
|
337 | - } |
|
338 | - $apps = array_filter($apps, function ($app) { |
|
339 | - return $app !== 'files';//we add this manually |
|
340 | - }); |
|
341 | - sort($apps); |
|
342 | - array_unshift($apps, 'files'); |
|
343 | - return $apps; |
|
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * checks whether or not an app is enabled |
|
348 | - * |
|
349 | - * @param string $app app |
|
350 | - * @return bool |
|
351 | - * |
|
352 | - * This function checks whether or not an app is enabled. |
|
353 | - */ |
|
354 | - public static function isEnabled($app) { |
|
355 | - return \OC::$server->getAppManager()->isEnabledForUser($app); |
|
356 | - } |
|
357 | - |
|
358 | - /** |
|
359 | - * enables an app |
|
360 | - * |
|
361 | - * @param string $appId |
|
362 | - * @param array $groups (optional) when set, only these groups will have access to the app |
|
363 | - * @throws \Exception |
|
364 | - * @return void |
|
365 | - * |
|
366 | - * This function set an app as enabled in appconfig. |
|
367 | - */ |
|
368 | - public function enable($appId, |
|
369 | - $groups = null) { |
|
370 | - self::$enabledAppsCache = []; // flush |
|
371 | - |
|
372 | - // Check if app is already downloaded |
|
373 | - $installer = new Installer( |
|
374 | - \OC::$server->getAppFetcher(), |
|
375 | - \OC::$server->getHTTPClientService(), |
|
376 | - \OC::$server->getTempManager(), |
|
377 | - \OC::$server->getLogger(), |
|
378 | - \OC::$server->getConfig() |
|
379 | - ); |
|
380 | - $isDownloaded = $installer->isDownloaded($appId); |
|
381 | - |
|
382 | - if(!$isDownloaded) { |
|
383 | - $installer->downloadApp($appId); |
|
384 | - } |
|
385 | - |
|
386 | - $installer->installApp($appId); |
|
387 | - |
|
388 | - $appManager = \OC::$server->getAppManager(); |
|
389 | - if (!is_null($groups)) { |
|
390 | - $groupManager = \OC::$server->getGroupManager(); |
|
391 | - $groupsList = []; |
|
392 | - foreach ($groups as $group) { |
|
393 | - $groupItem = $groupManager->get($group); |
|
394 | - if ($groupItem instanceof \OCP\IGroup) { |
|
395 | - $groupsList[] = $groupManager->get($group); |
|
396 | - } |
|
397 | - } |
|
398 | - $appManager->enableAppForGroups($appId, $groupsList); |
|
399 | - } else { |
|
400 | - $appManager->enableApp($appId); |
|
401 | - } |
|
402 | - } |
|
403 | - |
|
404 | - /** |
|
405 | - * @param string $app |
|
406 | - * @return bool |
|
407 | - */ |
|
408 | - public static function removeApp($app) { |
|
409 | - if (\OC::$server->getAppManager()->isShipped($app)) { |
|
410 | - return false; |
|
411 | - } |
|
412 | - |
|
413 | - $installer = new Installer( |
|
414 | - \OC::$server->getAppFetcher(), |
|
415 | - \OC::$server->getHTTPClientService(), |
|
416 | - \OC::$server->getTempManager(), |
|
417 | - \OC::$server->getLogger(), |
|
418 | - \OC::$server->getConfig() |
|
419 | - ); |
|
420 | - return $installer->removeApp($app); |
|
421 | - } |
|
422 | - |
|
423 | - /** |
|
424 | - * This function set an app as disabled in appconfig. |
|
425 | - * |
|
426 | - * @param string $app app |
|
427 | - * @throws Exception |
|
428 | - */ |
|
429 | - public static function disable($app) { |
|
430 | - // flush |
|
431 | - self::$enabledAppsCache = array(); |
|
432 | - |
|
433 | - // run uninstall steps |
|
434 | - $appData = OC_App::getAppInfo($app); |
|
435 | - if (!is_null($appData)) { |
|
436 | - OC_App::executeRepairSteps($app, $appData['repair-steps']['uninstall']); |
|
437 | - } |
|
438 | - |
|
439 | - // emit disable hook - needed anymore ? |
|
440 | - \OC_Hook::emit('OC_App', 'pre_disable', array('app' => $app)); |
|
441 | - |
|
442 | - // finally disable it |
|
443 | - $appManager = \OC::$server->getAppManager(); |
|
444 | - $appManager->disableApp($app); |
|
445 | - } |
|
446 | - |
|
447 | - // This is private as well. It simply works, so don't ask for more details |
|
448 | - private static function proceedNavigation($list) { |
|
449 | - usort($list, function($a, $b) { |
|
450 | - if (isset($a['order']) && isset($b['order'])) { |
|
451 | - return ($a['order'] < $b['order']) ? -1 : 1; |
|
452 | - } else if (isset($a['order']) || isset($b['order'])) { |
|
453 | - return isset($a['order']) ? -1 : 1; |
|
454 | - } else { |
|
455 | - return ($a['name'] < $b['name']) ? -1 : 1; |
|
456 | - } |
|
457 | - }); |
|
458 | - |
|
459 | - $activeApp = OC::$server->getNavigationManager()->getActiveEntry(); |
|
460 | - foreach ($list as $index => &$navEntry) { |
|
461 | - if ($navEntry['id'] == $activeApp) { |
|
462 | - $navEntry['active'] = true; |
|
463 | - } else { |
|
464 | - $navEntry['active'] = false; |
|
465 | - } |
|
466 | - } |
|
467 | - unset($navEntry); |
|
468 | - |
|
469 | - return $list; |
|
470 | - } |
|
471 | - |
|
472 | - /** |
|
473 | - * Get the path where to install apps |
|
474 | - * |
|
475 | - * @return string|false |
|
476 | - */ |
|
477 | - public static function getInstallPath() { |
|
478 | - if (\OC::$server->getSystemConfig()->getValue('appstoreenabled', true) == false) { |
|
479 | - return false; |
|
480 | - } |
|
481 | - |
|
482 | - foreach (OC::$APPSROOTS as $dir) { |
|
483 | - if (isset($dir['writable']) && $dir['writable'] === true) { |
|
484 | - return $dir['path']; |
|
485 | - } |
|
486 | - } |
|
487 | - |
|
488 | - \OCP\Util::writeLog('core', 'No application directories are marked as writable.', \OCP\Util::ERROR); |
|
489 | - return null; |
|
490 | - } |
|
491 | - |
|
492 | - |
|
493 | - /** |
|
494 | - * search for an app in all app-directories |
|
495 | - * |
|
496 | - * @param string $appId |
|
497 | - * @return false|string |
|
498 | - */ |
|
499 | - public static function findAppInDirectories($appId) { |
|
500 | - $sanitizedAppId = self::cleanAppId($appId); |
|
501 | - if($sanitizedAppId !== $appId) { |
|
502 | - return false; |
|
503 | - } |
|
504 | - static $app_dir = array(); |
|
505 | - |
|
506 | - if (isset($app_dir[$appId])) { |
|
507 | - return $app_dir[$appId]; |
|
508 | - } |
|
509 | - |
|
510 | - $possibleApps = array(); |
|
511 | - foreach (OC::$APPSROOTS as $dir) { |
|
512 | - if (file_exists($dir['path'] . '/' . $appId)) { |
|
513 | - $possibleApps[] = $dir; |
|
514 | - } |
|
515 | - } |
|
516 | - |
|
517 | - if (empty($possibleApps)) { |
|
518 | - return false; |
|
519 | - } elseif (count($possibleApps) === 1) { |
|
520 | - $dir = array_shift($possibleApps); |
|
521 | - $app_dir[$appId] = $dir; |
|
522 | - return $dir; |
|
523 | - } else { |
|
524 | - $versionToLoad = array(); |
|
525 | - foreach ($possibleApps as $possibleApp) { |
|
526 | - $version = self::getAppVersionByPath($possibleApp['path']); |
|
527 | - if (empty($versionToLoad) || version_compare($version, $versionToLoad['version'], '>')) { |
|
528 | - $versionToLoad = array( |
|
529 | - 'dir' => $possibleApp, |
|
530 | - 'version' => $version, |
|
531 | - ); |
|
532 | - } |
|
533 | - } |
|
534 | - $app_dir[$appId] = $versionToLoad['dir']; |
|
535 | - return $versionToLoad['dir']; |
|
536 | - //TODO - write test |
|
537 | - } |
|
538 | - } |
|
539 | - |
|
540 | - /** |
|
541 | - * Get the directory for the given app. |
|
542 | - * If the app is defined in multiple directories, the first one is taken. (false if not found) |
|
543 | - * |
|
544 | - * @param string $appId |
|
545 | - * @return string|false |
|
546 | - */ |
|
547 | - public static function getAppPath($appId) { |
|
548 | - if ($appId === null || trim($appId) === '') { |
|
549 | - return false; |
|
550 | - } |
|
551 | - |
|
552 | - if (($dir = self::findAppInDirectories($appId)) != false) { |
|
553 | - return $dir['path'] . '/' . $appId; |
|
554 | - } |
|
555 | - return false; |
|
556 | - } |
|
557 | - |
|
558 | - /** |
|
559 | - * Get the path for the given app on the access |
|
560 | - * If the app is defined in multiple directories, the first one is taken. (false if not found) |
|
561 | - * |
|
562 | - * @param string $appId |
|
563 | - * @return string|false |
|
564 | - */ |
|
565 | - public static function getAppWebPath($appId) { |
|
566 | - if (($dir = self::findAppInDirectories($appId)) != false) { |
|
567 | - return OC::$WEBROOT . $dir['url'] . '/' . $appId; |
|
568 | - } |
|
569 | - return false; |
|
570 | - } |
|
571 | - |
|
572 | - /** |
|
573 | - * get the last version of the app from appinfo/info.xml |
|
574 | - * |
|
575 | - * @param string $appId |
|
576 | - * @param bool $useCache |
|
577 | - * @return string |
|
578 | - */ |
|
579 | - public static function getAppVersion($appId, $useCache = true) { |
|
580 | - if($useCache && isset(self::$appVersion[$appId])) { |
|
581 | - return self::$appVersion[$appId]; |
|
582 | - } |
|
583 | - |
|
584 | - $file = self::getAppPath($appId); |
|
585 | - self::$appVersion[$appId] = ($file !== false) ? self::getAppVersionByPath($file) : '0'; |
|
586 | - return self::$appVersion[$appId]; |
|
587 | - } |
|
588 | - |
|
589 | - /** |
|
590 | - * get app's version based on it's path |
|
591 | - * |
|
592 | - * @param string $path |
|
593 | - * @return string |
|
594 | - */ |
|
595 | - public static function getAppVersionByPath($path) { |
|
596 | - $infoFile = $path . '/appinfo/info.xml'; |
|
597 | - $appData = self::getAppInfo($infoFile, true); |
|
598 | - return isset($appData['version']) ? $appData['version'] : ''; |
|
599 | - } |
|
600 | - |
|
601 | - |
|
602 | - /** |
|
603 | - * Read all app metadata from the info.xml file |
|
604 | - * |
|
605 | - * @param string $appId id of the app or the path of the info.xml file |
|
606 | - * @param bool $path |
|
607 | - * @param string $lang |
|
608 | - * @return array|null |
|
609 | - * @note all data is read from info.xml, not just pre-defined fields |
|
610 | - */ |
|
611 | - public static function getAppInfo($appId, $path = false, $lang = null) { |
|
612 | - if ($path) { |
|
613 | - $file = $appId; |
|
614 | - } else { |
|
615 | - if ($lang === null && isset(self::$appInfo[$appId])) { |
|
616 | - return self::$appInfo[$appId]; |
|
617 | - } |
|
618 | - $appPath = self::getAppPath($appId); |
|
619 | - if($appPath === false) { |
|
620 | - return null; |
|
621 | - } |
|
622 | - $file = $appPath . '/appinfo/info.xml'; |
|
623 | - } |
|
624 | - |
|
625 | - $parser = new InfoParser(\OC::$server->getMemCacheFactory()->createLocal('core.appinfo')); |
|
626 | - $data = $parser->parse($file); |
|
627 | - |
|
628 | - if (is_array($data)) { |
|
629 | - $data = OC_App::parseAppInfo($data, $lang); |
|
630 | - } |
|
631 | - if(isset($data['ocsid'])) { |
|
632 | - $storedId = \OC::$server->getConfig()->getAppValue($appId, 'ocsid'); |
|
633 | - if($storedId !== '' && $storedId !== $data['ocsid']) { |
|
634 | - $data['ocsid'] = $storedId; |
|
635 | - } |
|
636 | - } |
|
637 | - |
|
638 | - if ($lang === null) { |
|
639 | - self::$appInfo[$appId] = $data; |
|
640 | - } |
|
641 | - |
|
642 | - return $data; |
|
643 | - } |
|
644 | - |
|
645 | - /** |
|
646 | - * Returns the navigation |
|
647 | - * |
|
648 | - * @return array |
|
649 | - * |
|
650 | - * This function returns an array containing all entries added. The |
|
651 | - * entries are sorted by the key 'order' ascending. Additional to the keys |
|
652 | - * given for each app the following keys exist: |
|
653 | - * - active: boolean, signals if the user is on this navigation entry |
|
654 | - */ |
|
655 | - public static function getNavigation() { |
|
656 | - $entries = OC::$server->getNavigationManager()->getAll(); |
|
657 | - return self::proceedNavigation($entries); |
|
658 | - } |
|
659 | - |
|
660 | - /** |
|
661 | - * Returns the Settings Navigation |
|
662 | - * |
|
663 | - * @return string[] |
|
664 | - * |
|
665 | - * This function returns an array containing all settings pages added. The |
|
666 | - * entries are sorted by the key 'order' ascending. |
|
667 | - */ |
|
668 | - public static function getSettingsNavigation() { |
|
669 | - $entries = OC::$server->getNavigationManager()->getAll('settings'); |
|
670 | - return self::proceedNavigation($entries); |
|
671 | - } |
|
672 | - |
|
673 | - /** |
|
674 | - * get the id of loaded app |
|
675 | - * |
|
676 | - * @return string |
|
677 | - */ |
|
678 | - public static function getCurrentApp() { |
|
679 | - $request = \OC::$server->getRequest(); |
|
680 | - $script = substr($request->getScriptName(), strlen(OC::$WEBROOT) + 1); |
|
681 | - $topFolder = substr($script, 0, strpos($script, '/')); |
|
682 | - if (empty($topFolder)) { |
|
683 | - $path_info = $request->getPathInfo(); |
|
684 | - if ($path_info) { |
|
685 | - $topFolder = substr($path_info, 1, strpos($path_info, '/', 1) - 1); |
|
686 | - } |
|
687 | - } |
|
688 | - if ($topFolder == 'apps') { |
|
689 | - $length = strlen($topFolder); |
|
690 | - return substr($script, $length + 1, strpos($script, '/', $length + 1) - $length - 1); |
|
691 | - } else { |
|
692 | - return $topFolder; |
|
693 | - } |
|
694 | - } |
|
695 | - |
|
696 | - /** |
|
697 | - * @param string $type |
|
698 | - * @return array |
|
699 | - */ |
|
700 | - public static function getForms($type) { |
|
701 | - $forms = array(); |
|
702 | - switch ($type) { |
|
703 | - case 'admin': |
|
704 | - $source = self::$adminForms; |
|
705 | - break; |
|
706 | - case 'personal': |
|
707 | - $source = self::$personalForms; |
|
708 | - break; |
|
709 | - default: |
|
710 | - return array(); |
|
711 | - } |
|
712 | - foreach ($source as $form) { |
|
713 | - $forms[] = include $form; |
|
714 | - } |
|
715 | - return $forms; |
|
716 | - } |
|
717 | - |
|
718 | - /** |
|
719 | - * register an admin form to be shown |
|
720 | - * |
|
721 | - * @param string $app |
|
722 | - * @param string $page |
|
723 | - */ |
|
724 | - public static function registerAdmin($app, $page) { |
|
725 | - self::$adminForms[] = $app . '/' . $page . '.php'; |
|
726 | - } |
|
727 | - |
|
728 | - /** |
|
729 | - * register a personal form to be shown |
|
730 | - * @param string $app |
|
731 | - * @param string $page |
|
732 | - */ |
|
733 | - public static function registerPersonal($app, $page) { |
|
734 | - self::$personalForms[] = $app . '/' . $page . '.php'; |
|
735 | - } |
|
736 | - |
|
737 | - /** |
|
738 | - * @param array $entry |
|
739 | - */ |
|
740 | - public static function registerLogIn(array $entry) { |
|
741 | - self::$altLogin[] = $entry; |
|
742 | - } |
|
743 | - |
|
744 | - /** |
|
745 | - * @return array |
|
746 | - */ |
|
747 | - public static function getAlternativeLogIns() { |
|
748 | - return self::$altLogin; |
|
749 | - } |
|
750 | - |
|
751 | - /** |
|
752 | - * get a list of all apps in the apps folder |
|
753 | - * |
|
754 | - * @return array an array of app names (string IDs) |
|
755 | - * @todo: change the name of this method to getInstalledApps, which is more accurate |
|
756 | - */ |
|
757 | - public static function getAllApps() { |
|
758 | - |
|
759 | - $apps = array(); |
|
760 | - |
|
761 | - foreach (OC::$APPSROOTS as $apps_dir) { |
|
762 | - if (!is_readable($apps_dir['path'])) { |
|
763 | - \OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], \OCP\Util::WARN); |
|
764 | - continue; |
|
765 | - } |
|
766 | - $dh = opendir($apps_dir['path']); |
|
767 | - |
|
768 | - if (is_resource($dh)) { |
|
769 | - while (($file = readdir($dh)) !== false) { |
|
770 | - |
|
771 | - if ($file[0] != '.' and is_dir($apps_dir['path'] . '/' . $file) and is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')) { |
|
772 | - |
|
773 | - $apps[] = $file; |
|
774 | - } |
|
775 | - } |
|
776 | - } |
|
777 | - } |
|
778 | - |
|
779 | - $apps = array_unique($apps); |
|
780 | - |
|
781 | - return $apps; |
|
782 | - } |
|
783 | - |
|
784 | - /** |
|
785 | - * List all apps, this is used in apps.php |
|
786 | - * |
|
787 | - * @return array |
|
788 | - */ |
|
789 | - public function listAllApps() { |
|
790 | - $installedApps = OC_App::getAllApps(); |
|
791 | - |
|
792 | - $appManager = \OC::$server->getAppManager(); |
|
793 | - //we don't want to show configuration for these |
|
794 | - $blacklist = $appManager->getAlwaysEnabledApps(); |
|
795 | - $appList = array(); |
|
796 | - $langCode = \OC::$server->getL10N('core')->getLanguageCode(); |
|
797 | - $urlGenerator = \OC::$server->getURLGenerator(); |
|
798 | - |
|
799 | - foreach ($installedApps as $app) { |
|
800 | - if (array_search($app, $blacklist) === false) { |
|
801 | - |
|
802 | - $info = OC_App::getAppInfo($app, false, $langCode); |
|
803 | - if (!is_array($info)) { |
|
804 | - \OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', \OCP\Util::ERROR); |
|
805 | - continue; |
|
806 | - } |
|
807 | - |
|
808 | - if (!isset($info['name'])) { |
|
809 | - \OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', \OCP\Util::ERROR); |
|
810 | - continue; |
|
811 | - } |
|
812 | - |
|
813 | - $enabled = \OC::$server->getAppConfig()->getValue($app, 'enabled', 'no'); |
|
814 | - $info['groups'] = null; |
|
815 | - if ($enabled === 'yes') { |
|
816 | - $active = true; |
|
817 | - } else if ($enabled === 'no') { |
|
818 | - $active = false; |
|
819 | - } else { |
|
820 | - $active = true; |
|
821 | - $info['groups'] = $enabled; |
|
822 | - } |
|
823 | - |
|
824 | - $info['active'] = $active; |
|
825 | - |
|
826 | - if ($appManager->isShipped($app)) { |
|
827 | - $info['internal'] = true; |
|
828 | - $info['level'] = self::officialApp; |
|
829 | - $info['removable'] = false; |
|
830 | - } else { |
|
831 | - $info['internal'] = false; |
|
832 | - $info['removable'] = true; |
|
833 | - } |
|
834 | - |
|
835 | - $appPath = self::getAppPath($app); |
|
836 | - if($appPath !== false) { |
|
837 | - $appIcon = $appPath . '/img/' . $app . '.svg'; |
|
838 | - if (file_exists($appIcon)) { |
|
839 | - $info['preview'] = $urlGenerator->imagePath($app, $app . '.svg'); |
|
840 | - $info['previewAsIcon'] = true; |
|
841 | - } else { |
|
842 | - $appIcon = $appPath . '/img/app.svg'; |
|
843 | - if (file_exists($appIcon)) { |
|
844 | - $info['preview'] = $urlGenerator->imagePath($app, 'app.svg'); |
|
845 | - $info['previewAsIcon'] = true; |
|
846 | - } |
|
847 | - } |
|
848 | - } |
|
849 | - // fix documentation |
|
850 | - if (isset($info['documentation']) && is_array($info['documentation'])) { |
|
851 | - foreach ($info['documentation'] as $key => $url) { |
|
852 | - // If it is not an absolute URL we assume it is a key |
|
853 | - // i.e. admin-ldap will get converted to go.php?to=admin-ldap |
|
854 | - if (stripos($url, 'https://') !== 0 && stripos($url, 'http://') !== 0) { |
|
855 | - $url = $urlGenerator->linkToDocs($url); |
|
856 | - } |
|
857 | - |
|
858 | - $info['documentation'][$key] = $url; |
|
859 | - } |
|
860 | - } |
|
861 | - |
|
862 | - $info['version'] = OC_App::getAppVersion($app); |
|
863 | - $appList[] = $info; |
|
864 | - } |
|
865 | - } |
|
866 | - |
|
867 | - return $appList; |
|
868 | - } |
|
869 | - |
|
870 | - /** |
|
871 | - * Returns the internal app ID or false |
|
872 | - * @param string $ocsID |
|
873 | - * @return string|false |
|
874 | - */ |
|
875 | - public static function getInternalAppIdByOcs($ocsID) { |
|
876 | - if(is_numeric($ocsID)) { |
|
877 | - $idArray = \OC::$server->getAppConfig()->getValues(false, 'ocsid'); |
|
878 | - if(array_search($ocsID, $idArray)) { |
|
879 | - return array_search($ocsID, $idArray); |
|
880 | - } |
|
881 | - } |
|
882 | - return false; |
|
883 | - } |
|
884 | - |
|
885 | - public static function shouldUpgrade($app) { |
|
886 | - $versions = self::getAppVersions(); |
|
887 | - $currentVersion = OC_App::getAppVersion($app); |
|
888 | - if ($currentVersion && isset($versions[$app])) { |
|
889 | - $installedVersion = $versions[$app]; |
|
890 | - if (!version_compare($currentVersion, $installedVersion, '=')) { |
|
891 | - return true; |
|
892 | - } |
|
893 | - } |
|
894 | - return false; |
|
895 | - } |
|
896 | - |
|
897 | - /** |
|
898 | - * Adjust the number of version parts of $version1 to match |
|
899 | - * the number of version parts of $version2. |
|
900 | - * |
|
901 | - * @param string $version1 version to adjust |
|
902 | - * @param string $version2 version to take the number of parts from |
|
903 | - * @return string shortened $version1 |
|
904 | - */ |
|
905 | - private static function adjustVersionParts($version1, $version2) { |
|
906 | - $version1 = explode('.', $version1); |
|
907 | - $version2 = explode('.', $version2); |
|
908 | - // reduce $version1 to match the number of parts in $version2 |
|
909 | - while (count($version1) > count($version2)) { |
|
910 | - array_pop($version1); |
|
911 | - } |
|
912 | - // if $version1 does not have enough parts, add some |
|
913 | - while (count($version1) < count($version2)) { |
|
914 | - $version1[] = '0'; |
|
915 | - } |
|
916 | - return implode('.', $version1); |
|
917 | - } |
|
918 | - |
|
919 | - /** |
|
920 | - * Check whether the current ownCloud version matches the given |
|
921 | - * application's version requirements. |
|
922 | - * |
|
923 | - * The comparison is made based on the number of parts that the |
|
924 | - * app info version has. For example for ownCloud 6.0.3 if the |
|
925 | - * app info version is expecting version 6.0, the comparison is |
|
926 | - * made on the first two parts of the ownCloud version. |
|
927 | - * This means that it's possible to specify "requiremin" => 6 |
|
928 | - * and "requiremax" => 6 and it will still match ownCloud 6.0.3. |
|
929 | - * |
|
930 | - * @param string $ocVersion ownCloud version to check against |
|
931 | - * @param array $appInfo app info (from xml) |
|
932 | - * |
|
933 | - * @return boolean true if compatible, otherwise false |
|
934 | - */ |
|
935 | - public static function isAppCompatible($ocVersion, $appInfo) { |
|
936 | - $requireMin = ''; |
|
937 | - $requireMax = ''; |
|
938 | - if (isset($appInfo['dependencies']['nextcloud']['@attributes']['min-version'])) { |
|
939 | - $requireMin = $appInfo['dependencies']['nextcloud']['@attributes']['min-version']; |
|
940 | - } elseif (isset($appInfo['dependencies']['owncloud']['@attributes']['min-version'])) { |
|
941 | - $requireMin = $appInfo['dependencies']['owncloud']['@attributes']['min-version']; |
|
942 | - } else if (isset($appInfo['requiremin'])) { |
|
943 | - $requireMin = $appInfo['requiremin']; |
|
944 | - } else if (isset($appInfo['require'])) { |
|
945 | - $requireMin = $appInfo['require']; |
|
946 | - } |
|
947 | - |
|
948 | - if (isset($appInfo['dependencies']['nextcloud']['@attributes']['max-version'])) { |
|
949 | - $requireMax = $appInfo['dependencies']['nextcloud']['@attributes']['max-version']; |
|
950 | - } elseif (isset($appInfo['dependencies']['owncloud']['@attributes']['max-version'])) { |
|
951 | - $requireMax = $appInfo['dependencies']['owncloud']['@attributes']['max-version']; |
|
952 | - } else if (isset($appInfo['requiremax'])) { |
|
953 | - $requireMax = $appInfo['requiremax']; |
|
954 | - } |
|
955 | - |
|
956 | - if (is_array($ocVersion)) { |
|
957 | - $ocVersion = implode('.', $ocVersion); |
|
958 | - } |
|
959 | - |
|
960 | - if (!empty($requireMin) |
|
961 | - && version_compare(self::adjustVersionParts($ocVersion, $requireMin), $requireMin, '<') |
|
962 | - ) { |
|
963 | - |
|
964 | - return false; |
|
965 | - } |
|
966 | - |
|
967 | - if (!empty($requireMax) |
|
968 | - && version_compare(self::adjustVersionParts($ocVersion, $requireMax), $requireMax, '>') |
|
969 | - ) { |
|
970 | - return false; |
|
971 | - } |
|
972 | - |
|
973 | - return true; |
|
974 | - } |
|
975 | - |
|
976 | - /** |
|
977 | - * get the installed version of all apps |
|
978 | - */ |
|
979 | - public static function getAppVersions() { |
|
980 | - static $versions; |
|
981 | - |
|
982 | - if(!$versions) { |
|
983 | - $appConfig = \OC::$server->getAppConfig(); |
|
984 | - $versions = $appConfig->getValues(false, 'installed_version'); |
|
985 | - } |
|
986 | - return $versions; |
|
987 | - } |
|
988 | - |
|
989 | - /** |
|
990 | - * @param string $app |
|
991 | - * @param \OCP\IConfig $config |
|
992 | - * @param \OCP\IL10N $l |
|
993 | - * @return bool |
|
994 | - * |
|
995 | - * @throws Exception if app is not compatible with this version of ownCloud |
|
996 | - * @throws Exception if no app-name was specified |
|
997 | - */ |
|
998 | - public function installApp($app, |
|
999 | - \OCP\IConfig $config, |
|
1000 | - \OCP\IL10N $l) { |
|
1001 | - if ($app !== false) { |
|
1002 | - // check if the app is compatible with this version of ownCloud |
|
1003 | - $info = self::getAppInfo($app); |
|
1004 | - if(!is_array($info)) { |
|
1005 | - throw new \Exception( |
|
1006 | - $l->t('App "%s" cannot be installed because appinfo file cannot be read.', |
|
1007 | - [$info['name']] |
|
1008 | - ) |
|
1009 | - ); |
|
1010 | - } |
|
1011 | - |
|
1012 | - $version = \OCP\Util::getVersion(); |
|
1013 | - if (!self::isAppCompatible($version, $info)) { |
|
1014 | - throw new \Exception( |
|
1015 | - $l->t('App "%s" cannot be installed because it is not compatible with this version of the server.', |
|
1016 | - array($info['name']) |
|
1017 | - ) |
|
1018 | - ); |
|
1019 | - } |
|
1020 | - |
|
1021 | - // check for required dependencies |
|
1022 | - self::checkAppDependencies($config, $l, $info); |
|
1023 | - |
|
1024 | - $config->setAppValue($app, 'enabled', 'yes'); |
|
1025 | - if (isset($appData['id'])) { |
|
1026 | - $config->setAppValue($app, 'ocsid', $appData['id']); |
|
1027 | - } |
|
1028 | - |
|
1029 | - if(isset($info['settings']) && is_array($info['settings'])) { |
|
1030 | - $appPath = self::getAppPath($app); |
|
1031 | - self::registerAutoloading($app, $appPath); |
|
1032 | - \OC::$server->getSettingsManager()->setupSettings($info['settings']); |
|
1033 | - } |
|
1034 | - |
|
1035 | - \OC_Hook::emit('OC_App', 'post_enable', array('app' => $app)); |
|
1036 | - } else { |
|
1037 | - if(empty($appName) ) { |
|
1038 | - throw new \Exception($l->t("No app name specified")); |
|
1039 | - } else { |
|
1040 | - throw new \Exception($l->t("App '%s' could not be installed!", $appName)); |
|
1041 | - } |
|
1042 | - } |
|
1043 | - |
|
1044 | - return $app; |
|
1045 | - } |
|
1046 | - |
|
1047 | - /** |
|
1048 | - * update the database for the app and call the update script |
|
1049 | - * |
|
1050 | - * @param string $appId |
|
1051 | - * @return bool |
|
1052 | - */ |
|
1053 | - public static function updateApp($appId) { |
|
1054 | - $appPath = self::getAppPath($appId); |
|
1055 | - if($appPath === false) { |
|
1056 | - return false; |
|
1057 | - } |
|
1058 | - self::registerAutoloading($appId, $appPath); |
|
1059 | - |
|
1060 | - $appData = self::getAppInfo($appId); |
|
1061 | - self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']); |
|
1062 | - |
|
1063 | - if (file_exists($appPath . '/appinfo/database.xml')) { |
|
1064 | - OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml'); |
|
1065 | - } else { |
|
1066 | - $ms = new MigrationService($appId, \OC::$server->getDatabaseConnection()); |
|
1067 | - $ms->migrate(); |
|
1068 | - } |
|
1069 | - |
|
1070 | - self::executeRepairSteps($appId, $appData['repair-steps']['post-migration']); |
|
1071 | - self::setupLiveMigrations($appId, $appData['repair-steps']['live-migration']); |
|
1072 | - unset(self::$appVersion[$appId]); |
|
1073 | - |
|
1074 | - // run upgrade code |
|
1075 | - if (file_exists($appPath . '/appinfo/update.php')) { |
|
1076 | - self::loadApp($appId); |
|
1077 | - include $appPath . '/appinfo/update.php'; |
|
1078 | - } |
|
1079 | - self::setupBackgroundJobs($appData['background-jobs']); |
|
1080 | - if(isset($appData['settings']) && is_array($appData['settings'])) { |
|
1081 | - \OC::$server->getSettingsManager()->setupSettings($appData['settings']); |
|
1082 | - } |
|
1083 | - |
|
1084 | - //set remote/public handlers |
|
1085 | - if (array_key_exists('ocsid', $appData)) { |
|
1086 | - \OC::$server->getConfig()->setAppValue($appId, 'ocsid', $appData['ocsid']); |
|
1087 | - } elseif(\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) { |
|
1088 | - \OC::$server->getConfig()->deleteAppValue($appId, 'ocsid'); |
|
1089 | - } |
|
1090 | - foreach ($appData['remote'] as $name => $path) { |
|
1091 | - \OC::$server->getConfig()->setAppValue('core', 'remote_' . $name, $appId . '/' . $path); |
|
1092 | - } |
|
1093 | - foreach ($appData['public'] as $name => $path) { |
|
1094 | - \OC::$server->getConfig()->setAppValue('core', 'public_' . $name, $appId . '/' . $path); |
|
1095 | - } |
|
1096 | - |
|
1097 | - self::setAppTypes($appId); |
|
1098 | - |
|
1099 | - $version = \OC_App::getAppVersion($appId); |
|
1100 | - \OC::$server->getAppConfig()->setValue($appId, 'installed_version', $version); |
|
1101 | - |
|
1102 | - \OC::$server->getEventDispatcher()->dispatch(ManagerEvent::EVENT_APP_UPDATE, new ManagerEvent( |
|
1103 | - ManagerEvent::EVENT_APP_UPDATE, $appId |
|
1104 | - )); |
|
1105 | - |
|
1106 | - return true; |
|
1107 | - } |
|
1108 | - |
|
1109 | - /** |
|
1110 | - * @param string $appId |
|
1111 | - * @param string[] $steps |
|
1112 | - * @throws \OC\NeedsUpdateException |
|
1113 | - */ |
|
1114 | - public static function executeRepairSteps($appId, array $steps) { |
|
1115 | - if (empty($steps)) { |
|
1116 | - return; |
|
1117 | - } |
|
1118 | - // load the app |
|
1119 | - self::loadApp($appId); |
|
1120 | - |
|
1121 | - $dispatcher = OC::$server->getEventDispatcher(); |
|
1122 | - |
|
1123 | - // load the steps |
|
1124 | - $r = new Repair([], $dispatcher); |
|
1125 | - foreach ($steps as $step) { |
|
1126 | - try { |
|
1127 | - $r->addStep($step); |
|
1128 | - } catch (Exception $ex) { |
|
1129 | - $r->emit('\OC\Repair', 'error', [$ex->getMessage()]); |
|
1130 | - \OC::$server->getLogger()->logException($ex); |
|
1131 | - } |
|
1132 | - } |
|
1133 | - // run the steps |
|
1134 | - $r->run(); |
|
1135 | - } |
|
1136 | - |
|
1137 | - public static function setupBackgroundJobs(array $jobs) { |
|
1138 | - $queue = \OC::$server->getJobList(); |
|
1139 | - foreach ($jobs as $job) { |
|
1140 | - $queue->add($job); |
|
1141 | - } |
|
1142 | - } |
|
1143 | - |
|
1144 | - /** |
|
1145 | - * @param string $appId |
|
1146 | - * @param string[] $steps |
|
1147 | - */ |
|
1148 | - private static function setupLiveMigrations($appId, array $steps) { |
|
1149 | - $queue = \OC::$server->getJobList(); |
|
1150 | - foreach ($steps as $step) { |
|
1151 | - $queue->add('OC\Migration\BackgroundRepair', [ |
|
1152 | - 'app' => $appId, |
|
1153 | - 'step' => $step]); |
|
1154 | - } |
|
1155 | - } |
|
1156 | - |
|
1157 | - /** |
|
1158 | - * @param string $appId |
|
1159 | - * @return \OC\Files\View|false |
|
1160 | - */ |
|
1161 | - public static function getStorage($appId) { |
|
1162 | - if (OC_App::isEnabled($appId)) { //sanity check |
|
1163 | - if (\OC::$server->getUserSession()->isLoggedIn()) { |
|
1164 | - $view = new \OC\Files\View('/' . OC_User::getUser()); |
|
1165 | - if (!$view->file_exists($appId)) { |
|
1166 | - $view->mkdir($appId); |
|
1167 | - } |
|
1168 | - return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId); |
|
1169 | - } else { |
|
1170 | - \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', \OCP\Util::ERROR); |
|
1171 | - return false; |
|
1172 | - } |
|
1173 | - } else { |
|
1174 | - \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', \OCP\Util::ERROR); |
|
1175 | - return false; |
|
1176 | - } |
|
1177 | - } |
|
1178 | - |
|
1179 | - protected static function findBestL10NOption($options, $lang) { |
|
1180 | - $fallback = $similarLangFallback = $englishFallback = false; |
|
1181 | - |
|
1182 | - $lang = strtolower($lang); |
|
1183 | - $similarLang = $lang; |
|
1184 | - if (strpos($similarLang, '_')) { |
|
1185 | - // For "de_DE" we want to find "de" and the other way around |
|
1186 | - $similarLang = substr($lang, 0, strpos($lang, '_')); |
|
1187 | - } |
|
1188 | - |
|
1189 | - foreach ($options as $option) { |
|
1190 | - if (is_array($option)) { |
|
1191 | - if ($fallback === false) { |
|
1192 | - $fallback = $option['@value']; |
|
1193 | - } |
|
1194 | - |
|
1195 | - if (!isset($option['@attributes']['lang'])) { |
|
1196 | - continue; |
|
1197 | - } |
|
1198 | - |
|
1199 | - $attributeLang = strtolower($option['@attributes']['lang']); |
|
1200 | - if ($attributeLang === $lang) { |
|
1201 | - return $option['@value']; |
|
1202 | - } |
|
1203 | - |
|
1204 | - if ($attributeLang === $similarLang) { |
|
1205 | - $similarLangFallback = $option['@value']; |
|
1206 | - } else if (strpos($attributeLang, $similarLang . '_') === 0) { |
|
1207 | - if ($similarLangFallback === false) { |
|
1208 | - $similarLangFallback = $option['@value']; |
|
1209 | - } |
|
1210 | - } |
|
1211 | - } else { |
|
1212 | - $englishFallback = $option; |
|
1213 | - } |
|
1214 | - } |
|
1215 | - |
|
1216 | - if ($similarLangFallback !== false) { |
|
1217 | - return $similarLangFallback; |
|
1218 | - } else if ($englishFallback !== false) { |
|
1219 | - return $englishFallback; |
|
1220 | - } |
|
1221 | - return (string) $fallback; |
|
1222 | - } |
|
1223 | - |
|
1224 | - /** |
|
1225 | - * parses the app data array and enhanced the 'description' value |
|
1226 | - * |
|
1227 | - * @param array $data the app data |
|
1228 | - * @param string $lang |
|
1229 | - * @return array improved app data |
|
1230 | - */ |
|
1231 | - public static function parseAppInfo(array $data, $lang = null) { |
|
1232 | - |
|
1233 | - if ($lang && isset($data['name']) && is_array($data['name'])) { |
|
1234 | - $data['name'] = self::findBestL10NOption($data['name'], $lang); |
|
1235 | - } |
|
1236 | - if ($lang && isset($data['summary']) && is_array($data['summary'])) { |
|
1237 | - $data['summary'] = self::findBestL10NOption($data['summary'], $lang); |
|
1238 | - } |
|
1239 | - if ($lang && isset($data['description']) && is_array($data['description'])) { |
|
1240 | - $data['description'] = trim(self::findBestL10NOption($data['description'], $lang)); |
|
1241 | - } else if (isset($data['description']) && is_string($data['description'])) { |
|
1242 | - $data['description'] = trim($data['description']); |
|
1243 | - } else { |
|
1244 | - $data['description'] = ''; |
|
1245 | - } |
|
1246 | - |
|
1247 | - return $data; |
|
1248 | - } |
|
1249 | - |
|
1250 | - /** |
|
1251 | - * @param \OCP\IConfig $config |
|
1252 | - * @param \OCP\IL10N $l |
|
1253 | - * @param array $info |
|
1254 | - * @throws \Exception |
|
1255 | - */ |
|
1256 | - public static function checkAppDependencies($config, $l, $info) { |
|
1257 | - $dependencyAnalyzer = new DependencyAnalyzer(new Platform($config), $l); |
|
1258 | - $missing = $dependencyAnalyzer->analyze($info); |
|
1259 | - if (!empty($missing)) { |
|
1260 | - $missingMsg = implode(PHP_EOL, $missing); |
|
1261 | - throw new \Exception( |
|
1262 | - $l->t('App "%s" cannot be installed because the following dependencies are not fulfilled: %s', |
|
1263 | - [$info['name'], $missingMsg] |
|
1264 | - ) |
|
1265 | - ); |
|
1266 | - } |
|
1267 | - } |
|
64 | + static private $appVersion = []; |
|
65 | + static private $adminForms = array(); |
|
66 | + static private $personalForms = array(); |
|
67 | + static private $appInfo = array(); |
|
68 | + static private $appTypes = array(); |
|
69 | + static private $loadedApps = array(); |
|
70 | + static private $altLogin = array(); |
|
71 | + static private $alreadyRegistered = []; |
|
72 | + const officialApp = 200; |
|
73 | + |
|
74 | + /** |
|
75 | + * clean the appId |
|
76 | + * |
|
77 | + * @param string|boolean $app AppId that needs to be cleaned |
|
78 | + * @return string |
|
79 | + */ |
|
80 | + public static function cleanAppId($app) { |
|
81 | + return str_replace(array('\0', '/', '\\', '..'), '', $app); |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * Check if an app is loaded |
|
86 | + * |
|
87 | + * @param string $app |
|
88 | + * @return bool |
|
89 | + */ |
|
90 | + public static function isAppLoaded($app) { |
|
91 | + return in_array($app, self::$loadedApps, true); |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * loads all apps |
|
96 | + * |
|
97 | + * @param string[] | string | null $types |
|
98 | + * @return bool |
|
99 | + * |
|
100 | + * This function walks through the ownCloud directory and loads all apps |
|
101 | + * it can find. A directory contains an app if the file /appinfo/info.xml |
|
102 | + * exists. |
|
103 | + * |
|
104 | + * if $types is set, only apps of those types will be loaded |
|
105 | + */ |
|
106 | + public static function loadApps($types = null) { |
|
107 | + if (\OC::$server->getSystemConfig()->getValue('maintenance', false)) { |
|
108 | + return false; |
|
109 | + } |
|
110 | + // Load the enabled apps here |
|
111 | + $apps = self::getEnabledApps(); |
|
112 | + |
|
113 | + // Add each apps' folder as allowed class path |
|
114 | + foreach($apps as $app) { |
|
115 | + $path = self::getAppPath($app); |
|
116 | + if($path !== false) { |
|
117 | + self::registerAutoloading($app, $path); |
|
118 | + } |
|
119 | + } |
|
120 | + |
|
121 | + // prevent app.php from printing output |
|
122 | + ob_start(); |
|
123 | + foreach ($apps as $app) { |
|
124 | + if ((is_null($types) or self::isType($app, $types)) && !in_array($app, self::$loadedApps)) { |
|
125 | + self::loadApp($app); |
|
126 | + } |
|
127 | + } |
|
128 | + ob_end_clean(); |
|
129 | + |
|
130 | + return true; |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * load a single app |
|
135 | + * |
|
136 | + * @param string $app |
|
137 | + */ |
|
138 | + public static function loadApp($app) { |
|
139 | + self::$loadedApps[] = $app; |
|
140 | + $appPath = self::getAppPath($app); |
|
141 | + if($appPath === false) { |
|
142 | + return; |
|
143 | + } |
|
144 | + |
|
145 | + // in case someone calls loadApp() directly |
|
146 | + self::registerAutoloading($app, $appPath); |
|
147 | + |
|
148 | + if (is_file($appPath . '/appinfo/app.php')) { |
|
149 | + \OC::$server->getEventLogger()->start('load_app_' . $app, 'Load app: ' . $app); |
|
150 | + self::requireAppFile($app); |
|
151 | + if (self::isType($app, array('authentication'))) { |
|
152 | + // since authentication apps affect the "is app enabled for group" check, |
|
153 | + // the enabled apps cache needs to be cleared to make sure that the |
|
154 | + // next time getEnableApps() is called it will also include apps that were |
|
155 | + // enabled for groups |
|
156 | + self::$enabledAppsCache = array(); |
|
157 | + } |
|
158 | + \OC::$server->getEventLogger()->end('load_app_' . $app); |
|
159 | + } |
|
160 | + |
|
161 | + $info = self::getAppInfo($app); |
|
162 | + if (!empty($info['activity']['filters'])) { |
|
163 | + foreach ($info['activity']['filters'] as $filter) { |
|
164 | + \OC::$server->getActivityManager()->registerFilter($filter); |
|
165 | + } |
|
166 | + } |
|
167 | + if (!empty($info['activity']['settings'])) { |
|
168 | + foreach ($info['activity']['settings'] as $setting) { |
|
169 | + \OC::$server->getActivityManager()->registerSetting($setting); |
|
170 | + } |
|
171 | + } |
|
172 | + if (!empty($info['activity']['providers'])) { |
|
173 | + foreach ($info['activity']['providers'] as $provider) { |
|
174 | + \OC::$server->getActivityManager()->registerProvider($provider); |
|
175 | + } |
|
176 | + } |
|
177 | + if (!empty($info['collaboration']['plugins'])) { |
|
178 | + // deal with one or many plugin entries |
|
179 | + $plugins = isset($info['collaboration']['plugins']['plugin']['@value']) ? |
|
180 | + [$info['collaboration']['plugins']['plugin']] : $info['collaboration']['plugins']['plugin']; |
|
181 | + foreach ($plugins as $plugin) { |
|
182 | + if($plugin['@attributes']['type'] === 'collaborator-search') { |
|
183 | + $pluginInfo = [ |
|
184 | + 'shareType' => $plugin['@attributes']['share-type'], |
|
185 | + 'class' => $plugin['@value'], |
|
186 | + ]; |
|
187 | + \OC::$server->getCollaboratorSearch()->registerPlugin($pluginInfo); |
|
188 | + } |
|
189 | + } |
|
190 | + } |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | + * @internal |
|
195 | + * @param string $app |
|
196 | + * @param string $path |
|
197 | + */ |
|
198 | + public static function registerAutoloading($app, $path) { |
|
199 | + $key = $app . '-' . $path; |
|
200 | + if(isset(self::$alreadyRegistered[$key])) { |
|
201 | + return; |
|
202 | + } |
|
203 | + |
|
204 | + self::$alreadyRegistered[$key] = true; |
|
205 | + |
|
206 | + // Register on PSR-4 composer autoloader |
|
207 | + $appNamespace = \OC\AppFramework\App::buildAppNamespace($app); |
|
208 | + \OC::$server->registerNamespace($app, $appNamespace); |
|
209 | + |
|
210 | + if (file_exists($path . '/composer/autoload.php')) { |
|
211 | + require_once $path . '/composer/autoload.php'; |
|
212 | + } else { |
|
213 | + \OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true); |
|
214 | + // Register on legacy autoloader |
|
215 | + \OC::$loader->addValidRoot($path); |
|
216 | + } |
|
217 | + |
|
218 | + // Register Test namespace only when testing |
|
219 | + if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) { |
|
220 | + \OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true); |
|
221 | + } |
|
222 | + } |
|
223 | + |
|
224 | + /** |
|
225 | + * Load app.php from the given app |
|
226 | + * |
|
227 | + * @param string $app app name |
|
228 | + */ |
|
229 | + private static function requireAppFile($app) { |
|
230 | + try { |
|
231 | + // encapsulated here to avoid variable scope conflicts |
|
232 | + require_once $app . '/appinfo/app.php'; |
|
233 | + } catch (Error $ex) { |
|
234 | + \OC::$server->getLogger()->logException($ex); |
|
235 | + $blacklist = \OC::$server->getAppManager()->getAlwaysEnabledApps(); |
|
236 | + if (!in_array($app, $blacklist)) { |
|
237 | + self::disable($app); |
|
238 | + } |
|
239 | + } |
|
240 | + } |
|
241 | + |
|
242 | + /** |
|
243 | + * check if an app is of a specific type |
|
244 | + * |
|
245 | + * @param string $app |
|
246 | + * @param string|array $types |
|
247 | + * @return bool |
|
248 | + */ |
|
249 | + public static function isType($app, $types) { |
|
250 | + if (is_string($types)) { |
|
251 | + $types = array($types); |
|
252 | + } |
|
253 | + $appTypes = self::getAppTypes($app); |
|
254 | + foreach ($types as $type) { |
|
255 | + if (array_search($type, $appTypes) !== false) { |
|
256 | + return true; |
|
257 | + } |
|
258 | + } |
|
259 | + return false; |
|
260 | + } |
|
261 | + |
|
262 | + /** |
|
263 | + * get the types of an app |
|
264 | + * |
|
265 | + * @param string $app |
|
266 | + * @return array |
|
267 | + */ |
|
268 | + private static function getAppTypes($app) { |
|
269 | + //load the cache |
|
270 | + if (count(self::$appTypes) == 0) { |
|
271 | + self::$appTypes = \OC::$server->getAppConfig()->getValues(false, 'types'); |
|
272 | + } |
|
273 | + |
|
274 | + if (isset(self::$appTypes[$app])) { |
|
275 | + return explode(',', self::$appTypes[$app]); |
|
276 | + } else { |
|
277 | + return array(); |
|
278 | + } |
|
279 | + } |
|
280 | + |
|
281 | + /** |
|
282 | + * read app types from info.xml and cache them in the database |
|
283 | + */ |
|
284 | + public static function setAppTypes($app) { |
|
285 | + $appData = self::getAppInfo($app); |
|
286 | + if(!is_array($appData)) { |
|
287 | + return; |
|
288 | + } |
|
289 | + |
|
290 | + if (isset($appData['types'])) { |
|
291 | + $appTypes = implode(',', $appData['types']); |
|
292 | + } else { |
|
293 | + $appTypes = ''; |
|
294 | + $appData['types'] = []; |
|
295 | + } |
|
296 | + |
|
297 | + \OC::$server->getAppConfig()->setValue($app, 'types', $appTypes); |
|
298 | + |
|
299 | + if (\OC::$server->getAppManager()->hasProtectedAppType($appData['types'])) { |
|
300 | + $enabled = \OC::$server->getAppConfig()->getValue($app, 'enabled', 'yes'); |
|
301 | + if ($enabled !== 'yes' && $enabled !== 'no') { |
|
302 | + \OC::$server->getAppConfig()->setValue($app, 'enabled', 'yes'); |
|
303 | + } |
|
304 | + } |
|
305 | + } |
|
306 | + |
|
307 | + /** |
|
308 | + * get all enabled apps |
|
309 | + */ |
|
310 | + protected static $enabledAppsCache = array(); |
|
311 | + |
|
312 | + /** |
|
313 | + * Returns apps enabled for the current user. |
|
314 | + * |
|
315 | + * @param bool $forceRefresh whether to refresh the cache |
|
316 | + * @param bool $all whether to return apps for all users, not only the |
|
317 | + * currently logged in one |
|
318 | + * @return string[] |
|
319 | + */ |
|
320 | + public static function getEnabledApps($forceRefresh = false, $all = false) { |
|
321 | + if (!\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
322 | + return array(); |
|
323 | + } |
|
324 | + // in incognito mode or when logged out, $user will be false, |
|
325 | + // which is also the case during an upgrade |
|
326 | + $appManager = \OC::$server->getAppManager(); |
|
327 | + if ($all) { |
|
328 | + $user = null; |
|
329 | + } else { |
|
330 | + $user = \OC::$server->getUserSession()->getUser(); |
|
331 | + } |
|
332 | + |
|
333 | + if (is_null($user)) { |
|
334 | + $apps = $appManager->getInstalledApps(); |
|
335 | + } else { |
|
336 | + $apps = $appManager->getEnabledAppsForUser($user); |
|
337 | + } |
|
338 | + $apps = array_filter($apps, function ($app) { |
|
339 | + return $app !== 'files';//we add this manually |
|
340 | + }); |
|
341 | + sort($apps); |
|
342 | + array_unshift($apps, 'files'); |
|
343 | + return $apps; |
|
344 | + } |
|
345 | + |
|
346 | + /** |
|
347 | + * checks whether or not an app is enabled |
|
348 | + * |
|
349 | + * @param string $app app |
|
350 | + * @return bool |
|
351 | + * |
|
352 | + * This function checks whether or not an app is enabled. |
|
353 | + */ |
|
354 | + public static function isEnabled($app) { |
|
355 | + return \OC::$server->getAppManager()->isEnabledForUser($app); |
|
356 | + } |
|
357 | + |
|
358 | + /** |
|
359 | + * enables an app |
|
360 | + * |
|
361 | + * @param string $appId |
|
362 | + * @param array $groups (optional) when set, only these groups will have access to the app |
|
363 | + * @throws \Exception |
|
364 | + * @return void |
|
365 | + * |
|
366 | + * This function set an app as enabled in appconfig. |
|
367 | + */ |
|
368 | + public function enable($appId, |
|
369 | + $groups = null) { |
|
370 | + self::$enabledAppsCache = []; // flush |
|
371 | + |
|
372 | + // Check if app is already downloaded |
|
373 | + $installer = new Installer( |
|
374 | + \OC::$server->getAppFetcher(), |
|
375 | + \OC::$server->getHTTPClientService(), |
|
376 | + \OC::$server->getTempManager(), |
|
377 | + \OC::$server->getLogger(), |
|
378 | + \OC::$server->getConfig() |
|
379 | + ); |
|
380 | + $isDownloaded = $installer->isDownloaded($appId); |
|
381 | + |
|
382 | + if(!$isDownloaded) { |
|
383 | + $installer->downloadApp($appId); |
|
384 | + } |
|
385 | + |
|
386 | + $installer->installApp($appId); |
|
387 | + |
|
388 | + $appManager = \OC::$server->getAppManager(); |
|
389 | + if (!is_null($groups)) { |
|
390 | + $groupManager = \OC::$server->getGroupManager(); |
|
391 | + $groupsList = []; |
|
392 | + foreach ($groups as $group) { |
|
393 | + $groupItem = $groupManager->get($group); |
|
394 | + if ($groupItem instanceof \OCP\IGroup) { |
|
395 | + $groupsList[] = $groupManager->get($group); |
|
396 | + } |
|
397 | + } |
|
398 | + $appManager->enableAppForGroups($appId, $groupsList); |
|
399 | + } else { |
|
400 | + $appManager->enableApp($appId); |
|
401 | + } |
|
402 | + } |
|
403 | + |
|
404 | + /** |
|
405 | + * @param string $app |
|
406 | + * @return bool |
|
407 | + */ |
|
408 | + public static function removeApp($app) { |
|
409 | + if (\OC::$server->getAppManager()->isShipped($app)) { |
|
410 | + return false; |
|
411 | + } |
|
412 | + |
|
413 | + $installer = new Installer( |
|
414 | + \OC::$server->getAppFetcher(), |
|
415 | + \OC::$server->getHTTPClientService(), |
|
416 | + \OC::$server->getTempManager(), |
|
417 | + \OC::$server->getLogger(), |
|
418 | + \OC::$server->getConfig() |
|
419 | + ); |
|
420 | + return $installer->removeApp($app); |
|
421 | + } |
|
422 | + |
|
423 | + /** |
|
424 | + * This function set an app as disabled in appconfig. |
|
425 | + * |
|
426 | + * @param string $app app |
|
427 | + * @throws Exception |
|
428 | + */ |
|
429 | + public static function disable($app) { |
|
430 | + // flush |
|
431 | + self::$enabledAppsCache = array(); |
|
432 | + |
|
433 | + // run uninstall steps |
|
434 | + $appData = OC_App::getAppInfo($app); |
|
435 | + if (!is_null($appData)) { |
|
436 | + OC_App::executeRepairSteps($app, $appData['repair-steps']['uninstall']); |
|
437 | + } |
|
438 | + |
|
439 | + // emit disable hook - needed anymore ? |
|
440 | + \OC_Hook::emit('OC_App', 'pre_disable', array('app' => $app)); |
|
441 | + |
|
442 | + // finally disable it |
|
443 | + $appManager = \OC::$server->getAppManager(); |
|
444 | + $appManager->disableApp($app); |
|
445 | + } |
|
446 | + |
|
447 | + // This is private as well. It simply works, so don't ask for more details |
|
448 | + private static function proceedNavigation($list) { |
|
449 | + usort($list, function($a, $b) { |
|
450 | + if (isset($a['order']) && isset($b['order'])) { |
|
451 | + return ($a['order'] < $b['order']) ? -1 : 1; |
|
452 | + } else if (isset($a['order']) || isset($b['order'])) { |
|
453 | + return isset($a['order']) ? -1 : 1; |
|
454 | + } else { |
|
455 | + return ($a['name'] < $b['name']) ? -1 : 1; |
|
456 | + } |
|
457 | + }); |
|
458 | + |
|
459 | + $activeApp = OC::$server->getNavigationManager()->getActiveEntry(); |
|
460 | + foreach ($list as $index => &$navEntry) { |
|
461 | + if ($navEntry['id'] == $activeApp) { |
|
462 | + $navEntry['active'] = true; |
|
463 | + } else { |
|
464 | + $navEntry['active'] = false; |
|
465 | + } |
|
466 | + } |
|
467 | + unset($navEntry); |
|
468 | + |
|
469 | + return $list; |
|
470 | + } |
|
471 | + |
|
472 | + /** |
|
473 | + * Get the path where to install apps |
|
474 | + * |
|
475 | + * @return string|false |
|
476 | + */ |
|
477 | + public static function getInstallPath() { |
|
478 | + if (\OC::$server->getSystemConfig()->getValue('appstoreenabled', true) == false) { |
|
479 | + return false; |
|
480 | + } |
|
481 | + |
|
482 | + foreach (OC::$APPSROOTS as $dir) { |
|
483 | + if (isset($dir['writable']) && $dir['writable'] === true) { |
|
484 | + return $dir['path']; |
|
485 | + } |
|
486 | + } |
|
487 | + |
|
488 | + \OCP\Util::writeLog('core', 'No application directories are marked as writable.', \OCP\Util::ERROR); |
|
489 | + return null; |
|
490 | + } |
|
491 | + |
|
492 | + |
|
493 | + /** |
|
494 | + * search for an app in all app-directories |
|
495 | + * |
|
496 | + * @param string $appId |
|
497 | + * @return false|string |
|
498 | + */ |
|
499 | + public static function findAppInDirectories($appId) { |
|
500 | + $sanitizedAppId = self::cleanAppId($appId); |
|
501 | + if($sanitizedAppId !== $appId) { |
|
502 | + return false; |
|
503 | + } |
|
504 | + static $app_dir = array(); |
|
505 | + |
|
506 | + if (isset($app_dir[$appId])) { |
|
507 | + return $app_dir[$appId]; |
|
508 | + } |
|
509 | + |
|
510 | + $possibleApps = array(); |
|
511 | + foreach (OC::$APPSROOTS as $dir) { |
|
512 | + if (file_exists($dir['path'] . '/' . $appId)) { |
|
513 | + $possibleApps[] = $dir; |
|
514 | + } |
|
515 | + } |
|
516 | + |
|
517 | + if (empty($possibleApps)) { |
|
518 | + return false; |
|
519 | + } elseif (count($possibleApps) === 1) { |
|
520 | + $dir = array_shift($possibleApps); |
|
521 | + $app_dir[$appId] = $dir; |
|
522 | + return $dir; |
|
523 | + } else { |
|
524 | + $versionToLoad = array(); |
|
525 | + foreach ($possibleApps as $possibleApp) { |
|
526 | + $version = self::getAppVersionByPath($possibleApp['path']); |
|
527 | + if (empty($versionToLoad) || version_compare($version, $versionToLoad['version'], '>')) { |
|
528 | + $versionToLoad = array( |
|
529 | + 'dir' => $possibleApp, |
|
530 | + 'version' => $version, |
|
531 | + ); |
|
532 | + } |
|
533 | + } |
|
534 | + $app_dir[$appId] = $versionToLoad['dir']; |
|
535 | + return $versionToLoad['dir']; |
|
536 | + //TODO - write test |
|
537 | + } |
|
538 | + } |
|
539 | + |
|
540 | + /** |
|
541 | + * Get the directory for the given app. |
|
542 | + * If the app is defined in multiple directories, the first one is taken. (false if not found) |
|
543 | + * |
|
544 | + * @param string $appId |
|
545 | + * @return string|false |
|
546 | + */ |
|
547 | + public static function getAppPath($appId) { |
|
548 | + if ($appId === null || trim($appId) === '') { |
|
549 | + return false; |
|
550 | + } |
|
551 | + |
|
552 | + if (($dir = self::findAppInDirectories($appId)) != false) { |
|
553 | + return $dir['path'] . '/' . $appId; |
|
554 | + } |
|
555 | + return false; |
|
556 | + } |
|
557 | + |
|
558 | + /** |
|
559 | + * Get the path for the given app on the access |
|
560 | + * If the app is defined in multiple directories, the first one is taken. (false if not found) |
|
561 | + * |
|
562 | + * @param string $appId |
|
563 | + * @return string|false |
|
564 | + */ |
|
565 | + public static function getAppWebPath($appId) { |
|
566 | + if (($dir = self::findAppInDirectories($appId)) != false) { |
|
567 | + return OC::$WEBROOT . $dir['url'] . '/' . $appId; |
|
568 | + } |
|
569 | + return false; |
|
570 | + } |
|
571 | + |
|
572 | + /** |
|
573 | + * get the last version of the app from appinfo/info.xml |
|
574 | + * |
|
575 | + * @param string $appId |
|
576 | + * @param bool $useCache |
|
577 | + * @return string |
|
578 | + */ |
|
579 | + public static function getAppVersion($appId, $useCache = true) { |
|
580 | + if($useCache && isset(self::$appVersion[$appId])) { |
|
581 | + return self::$appVersion[$appId]; |
|
582 | + } |
|
583 | + |
|
584 | + $file = self::getAppPath($appId); |
|
585 | + self::$appVersion[$appId] = ($file !== false) ? self::getAppVersionByPath($file) : '0'; |
|
586 | + return self::$appVersion[$appId]; |
|
587 | + } |
|
588 | + |
|
589 | + /** |
|
590 | + * get app's version based on it's path |
|
591 | + * |
|
592 | + * @param string $path |
|
593 | + * @return string |
|
594 | + */ |
|
595 | + public static function getAppVersionByPath($path) { |
|
596 | + $infoFile = $path . '/appinfo/info.xml'; |
|
597 | + $appData = self::getAppInfo($infoFile, true); |
|
598 | + return isset($appData['version']) ? $appData['version'] : ''; |
|
599 | + } |
|
600 | + |
|
601 | + |
|
602 | + /** |
|
603 | + * Read all app metadata from the info.xml file |
|
604 | + * |
|
605 | + * @param string $appId id of the app or the path of the info.xml file |
|
606 | + * @param bool $path |
|
607 | + * @param string $lang |
|
608 | + * @return array|null |
|
609 | + * @note all data is read from info.xml, not just pre-defined fields |
|
610 | + */ |
|
611 | + public static function getAppInfo($appId, $path = false, $lang = null) { |
|
612 | + if ($path) { |
|
613 | + $file = $appId; |
|
614 | + } else { |
|
615 | + if ($lang === null && isset(self::$appInfo[$appId])) { |
|
616 | + return self::$appInfo[$appId]; |
|
617 | + } |
|
618 | + $appPath = self::getAppPath($appId); |
|
619 | + if($appPath === false) { |
|
620 | + return null; |
|
621 | + } |
|
622 | + $file = $appPath . '/appinfo/info.xml'; |
|
623 | + } |
|
624 | + |
|
625 | + $parser = new InfoParser(\OC::$server->getMemCacheFactory()->createLocal('core.appinfo')); |
|
626 | + $data = $parser->parse($file); |
|
627 | + |
|
628 | + if (is_array($data)) { |
|
629 | + $data = OC_App::parseAppInfo($data, $lang); |
|
630 | + } |
|
631 | + if(isset($data['ocsid'])) { |
|
632 | + $storedId = \OC::$server->getConfig()->getAppValue($appId, 'ocsid'); |
|
633 | + if($storedId !== '' && $storedId !== $data['ocsid']) { |
|
634 | + $data['ocsid'] = $storedId; |
|
635 | + } |
|
636 | + } |
|
637 | + |
|
638 | + if ($lang === null) { |
|
639 | + self::$appInfo[$appId] = $data; |
|
640 | + } |
|
641 | + |
|
642 | + return $data; |
|
643 | + } |
|
644 | + |
|
645 | + /** |
|
646 | + * Returns the navigation |
|
647 | + * |
|
648 | + * @return array |
|
649 | + * |
|
650 | + * This function returns an array containing all entries added. The |
|
651 | + * entries are sorted by the key 'order' ascending. Additional to the keys |
|
652 | + * given for each app the following keys exist: |
|
653 | + * - active: boolean, signals if the user is on this navigation entry |
|
654 | + */ |
|
655 | + public static function getNavigation() { |
|
656 | + $entries = OC::$server->getNavigationManager()->getAll(); |
|
657 | + return self::proceedNavigation($entries); |
|
658 | + } |
|
659 | + |
|
660 | + /** |
|
661 | + * Returns the Settings Navigation |
|
662 | + * |
|
663 | + * @return string[] |
|
664 | + * |
|
665 | + * This function returns an array containing all settings pages added. The |
|
666 | + * entries are sorted by the key 'order' ascending. |
|
667 | + */ |
|
668 | + public static function getSettingsNavigation() { |
|
669 | + $entries = OC::$server->getNavigationManager()->getAll('settings'); |
|
670 | + return self::proceedNavigation($entries); |
|
671 | + } |
|
672 | + |
|
673 | + /** |
|
674 | + * get the id of loaded app |
|
675 | + * |
|
676 | + * @return string |
|
677 | + */ |
|
678 | + public static function getCurrentApp() { |
|
679 | + $request = \OC::$server->getRequest(); |
|
680 | + $script = substr($request->getScriptName(), strlen(OC::$WEBROOT) + 1); |
|
681 | + $topFolder = substr($script, 0, strpos($script, '/')); |
|
682 | + if (empty($topFolder)) { |
|
683 | + $path_info = $request->getPathInfo(); |
|
684 | + if ($path_info) { |
|
685 | + $topFolder = substr($path_info, 1, strpos($path_info, '/', 1) - 1); |
|
686 | + } |
|
687 | + } |
|
688 | + if ($topFolder == 'apps') { |
|
689 | + $length = strlen($topFolder); |
|
690 | + return substr($script, $length + 1, strpos($script, '/', $length + 1) - $length - 1); |
|
691 | + } else { |
|
692 | + return $topFolder; |
|
693 | + } |
|
694 | + } |
|
695 | + |
|
696 | + /** |
|
697 | + * @param string $type |
|
698 | + * @return array |
|
699 | + */ |
|
700 | + public static function getForms($type) { |
|
701 | + $forms = array(); |
|
702 | + switch ($type) { |
|
703 | + case 'admin': |
|
704 | + $source = self::$adminForms; |
|
705 | + break; |
|
706 | + case 'personal': |
|
707 | + $source = self::$personalForms; |
|
708 | + break; |
|
709 | + default: |
|
710 | + return array(); |
|
711 | + } |
|
712 | + foreach ($source as $form) { |
|
713 | + $forms[] = include $form; |
|
714 | + } |
|
715 | + return $forms; |
|
716 | + } |
|
717 | + |
|
718 | + /** |
|
719 | + * register an admin form to be shown |
|
720 | + * |
|
721 | + * @param string $app |
|
722 | + * @param string $page |
|
723 | + */ |
|
724 | + public static function registerAdmin($app, $page) { |
|
725 | + self::$adminForms[] = $app . '/' . $page . '.php'; |
|
726 | + } |
|
727 | + |
|
728 | + /** |
|
729 | + * register a personal form to be shown |
|
730 | + * @param string $app |
|
731 | + * @param string $page |
|
732 | + */ |
|
733 | + public static function registerPersonal($app, $page) { |
|
734 | + self::$personalForms[] = $app . '/' . $page . '.php'; |
|
735 | + } |
|
736 | + |
|
737 | + /** |
|
738 | + * @param array $entry |
|
739 | + */ |
|
740 | + public static function registerLogIn(array $entry) { |
|
741 | + self::$altLogin[] = $entry; |
|
742 | + } |
|
743 | + |
|
744 | + /** |
|
745 | + * @return array |
|
746 | + */ |
|
747 | + public static function getAlternativeLogIns() { |
|
748 | + return self::$altLogin; |
|
749 | + } |
|
750 | + |
|
751 | + /** |
|
752 | + * get a list of all apps in the apps folder |
|
753 | + * |
|
754 | + * @return array an array of app names (string IDs) |
|
755 | + * @todo: change the name of this method to getInstalledApps, which is more accurate |
|
756 | + */ |
|
757 | + public static function getAllApps() { |
|
758 | + |
|
759 | + $apps = array(); |
|
760 | + |
|
761 | + foreach (OC::$APPSROOTS as $apps_dir) { |
|
762 | + if (!is_readable($apps_dir['path'])) { |
|
763 | + \OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], \OCP\Util::WARN); |
|
764 | + continue; |
|
765 | + } |
|
766 | + $dh = opendir($apps_dir['path']); |
|
767 | + |
|
768 | + if (is_resource($dh)) { |
|
769 | + while (($file = readdir($dh)) !== false) { |
|
770 | + |
|
771 | + if ($file[0] != '.' and is_dir($apps_dir['path'] . '/' . $file) and is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')) { |
|
772 | + |
|
773 | + $apps[] = $file; |
|
774 | + } |
|
775 | + } |
|
776 | + } |
|
777 | + } |
|
778 | + |
|
779 | + $apps = array_unique($apps); |
|
780 | + |
|
781 | + return $apps; |
|
782 | + } |
|
783 | + |
|
784 | + /** |
|
785 | + * List all apps, this is used in apps.php |
|
786 | + * |
|
787 | + * @return array |
|
788 | + */ |
|
789 | + public function listAllApps() { |
|
790 | + $installedApps = OC_App::getAllApps(); |
|
791 | + |
|
792 | + $appManager = \OC::$server->getAppManager(); |
|
793 | + //we don't want to show configuration for these |
|
794 | + $blacklist = $appManager->getAlwaysEnabledApps(); |
|
795 | + $appList = array(); |
|
796 | + $langCode = \OC::$server->getL10N('core')->getLanguageCode(); |
|
797 | + $urlGenerator = \OC::$server->getURLGenerator(); |
|
798 | + |
|
799 | + foreach ($installedApps as $app) { |
|
800 | + if (array_search($app, $blacklist) === false) { |
|
801 | + |
|
802 | + $info = OC_App::getAppInfo($app, false, $langCode); |
|
803 | + if (!is_array($info)) { |
|
804 | + \OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', \OCP\Util::ERROR); |
|
805 | + continue; |
|
806 | + } |
|
807 | + |
|
808 | + if (!isset($info['name'])) { |
|
809 | + \OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', \OCP\Util::ERROR); |
|
810 | + continue; |
|
811 | + } |
|
812 | + |
|
813 | + $enabled = \OC::$server->getAppConfig()->getValue($app, 'enabled', 'no'); |
|
814 | + $info['groups'] = null; |
|
815 | + if ($enabled === 'yes') { |
|
816 | + $active = true; |
|
817 | + } else if ($enabled === 'no') { |
|
818 | + $active = false; |
|
819 | + } else { |
|
820 | + $active = true; |
|
821 | + $info['groups'] = $enabled; |
|
822 | + } |
|
823 | + |
|
824 | + $info['active'] = $active; |
|
825 | + |
|
826 | + if ($appManager->isShipped($app)) { |
|
827 | + $info['internal'] = true; |
|
828 | + $info['level'] = self::officialApp; |
|
829 | + $info['removable'] = false; |
|
830 | + } else { |
|
831 | + $info['internal'] = false; |
|
832 | + $info['removable'] = true; |
|
833 | + } |
|
834 | + |
|
835 | + $appPath = self::getAppPath($app); |
|
836 | + if($appPath !== false) { |
|
837 | + $appIcon = $appPath . '/img/' . $app . '.svg'; |
|
838 | + if (file_exists($appIcon)) { |
|
839 | + $info['preview'] = $urlGenerator->imagePath($app, $app . '.svg'); |
|
840 | + $info['previewAsIcon'] = true; |
|
841 | + } else { |
|
842 | + $appIcon = $appPath . '/img/app.svg'; |
|
843 | + if (file_exists($appIcon)) { |
|
844 | + $info['preview'] = $urlGenerator->imagePath($app, 'app.svg'); |
|
845 | + $info['previewAsIcon'] = true; |
|
846 | + } |
|
847 | + } |
|
848 | + } |
|
849 | + // fix documentation |
|
850 | + if (isset($info['documentation']) && is_array($info['documentation'])) { |
|
851 | + foreach ($info['documentation'] as $key => $url) { |
|
852 | + // If it is not an absolute URL we assume it is a key |
|
853 | + // i.e. admin-ldap will get converted to go.php?to=admin-ldap |
|
854 | + if (stripos($url, 'https://') !== 0 && stripos($url, 'http://') !== 0) { |
|
855 | + $url = $urlGenerator->linkToDocs($url); |
|
856 | + } |
|
857 | + |
|
858 | + $info['documentation'][$key] = $url; |
|
859 | + } |
|
860 | + } |
|
861 | + |
|
862 | + $info['version'] = OC_App::getAppVersion($app); |
|
863 | + $appList[] = $info; |
|
864 | + } |
|
865 | + } |
|
866 | + |
|
867 | + return $appList; |
|
868 | + } |
|
869 | + |
|
870 | + /** |
|
871 | + * Returns the internal app ID or false |
|
872 | + * @param string $ocsID |
|
873 | + * @return string|false |
|
874 | + */ |
|
875 | + public static function getInternalAppIdByOcs($ocsID) { |
|
876 | + if(is_numeric($ocsID)) { |
|
877 | + $idArray = \OC::$server->getAppConfig()->getValues(false, 'ocsid'); |
|
878 | + if(array_search($ocsID, $idArray)) { |
|
879 | + return array_search($ocsID, $idArray); |
|
880 | + } |
|
881 | + } |
|
882 | + return false; |
|
883 | + } |
|
884 | + |
|
885 | + public static function shouldUpgrade($app) { |
|
886 | + $versions = self::getAppVersions(); |
|
887 | + $currentVersion = OC_App::getAppVersion($app); |
|
888 | + if ($currentVersion && isset($versions[$app])) { |
|
889 | + $installedVersion = $versions[$app]; |
|
890 | + if (!version_compare($currentVersion, $installedVersion, '=')) { |
|
891 | + return true; |
|
892 | + } |
|
893 | + } |
|
894 | + return false; |
|
895 | + } |
|
896 | + |
|
897 | + /** |
|
898 | + * Adjust the number of version parts of $version1 to match |
|
899 | + * the number of version parts of $version2. |
|
900 | + * |
|
901 | + * @param string $version1 version to adjust |
|
902 | + * @param string $version2 version to take the number of parts from |
|
903 | + * @return string shortened $version1 |
|
904 | + */ |
|
905 | + private static function adjustVersionParts($version1, $version2) { |
|
906 | + $version1 = explode('.', $version1); |
|
907 | + $version2 = explode('.', $version2); |
|
908 | + // reduce $version1 to match the number of parts in $version2 |
|
909 | + while (count($version1) > count($version2)) { |
|
910 | + array_pop($version1); |
|
911 | + } |
|
912 | + // if $version1 does not have enough parts, add some |
|
913 | + while (count($version1) < count($version2)) { |
|
914 | + $version1[] = '0'; |
|
915 | + } |
|
916 | + return implode('.', $version1); |
|
917 | + } |
|
918 | + |
|
919 | + /** |
|
920 | + * Check whether the current ownCloud version matches the given |
|
921 | + * application's version requirements. |
|
922 | + * |
|
923 | + * The comparison is made based on the number of parts that the |
|
924 | + * app info version has. For example for ownCloud 6.0.3 if the |
|
925 | + * app info version is expecting version 6.0, the comparison is |
|
926 | + * made on the first two parts of the ownCloud version. |
|
927 | + * This means that it's possible to specify "requiremin" => 6 |
|
928 | + * and "requiremax" => 6 and it will still match ownCloud 6.0.3. |
|
929 | + * |
|
930 | + * @param string $ocVersion ownCloud version to check against |
|
931 | + * @param array $appInfo app info (from xml) |
|
932 | + * |
|
933 | + * @return boolean true if compatible, otherwise false |
|
934 | + */ |
|
935 | + public static function isAppCompatible($ocVersion, $appInfo) { |
|
936 | + $requireMin = ''; |
|
937 | + $requireMax = ''; |
|
938 | + if (isset($appInfo['dependencies']['nextcloud']['@attributes']['min-version'])) { |
|
939 | + $requireMin = $appInfo['dependencies']['nextcloud']['@attributes']['min-version']; |
|
940 | + } elseif (isset($appInfo['dependencies']['owncloud']['@attributes']['min-version'])) { |
|
941 | + $requireMin = $appInfo['dependencies']['owncloud']['@attributes']['min-version']; |
|
942 | + } else if (isset($appInfo['requiremin'])) { |
|
943 | + $requireMin = $appInfo['requiremin']; |
|
944 | + } else if (isset($appInfo['require'])) { |
|
945 | + $requireMin = $appInfo['require']; |
|
946 | + } |
|
947 | + |
|
948 | + if (isset($appInfo['dependencies']['nextcloud']['@attributes']['max-version'])) { |
|
949 | + $requireMax = $appInfo['dependencies']['nextcloud']['@attributes']['max-version']; |
|
950 | + } elseif (isset($appInfo['dependencies']['owncloud']['@attributes']['max-version'])) { |
|
951 | + $requireMax = $appInfo['dependencies']['owncloud']['@attributes']['max-version']; |
|
952 | + } else if (isset($appInfo['requiremax'])) { |
|
953 | + $requireMax = $appInfo['requiremax']; |
|
954 | + } |
|
955 | + |
|
956 | + if (is_array($ocVersion)) { |
|
957 | + $ocVersion = implode('.', $ocVersion); |
|
958 | + } |
|
959 | + |
|
960 | + if (!empty($requireMin) |
|
961 | + && version_compare(self::adjustVersionParts($ocVersion, $requireMin), $requireMin, '<') |
|
962 | + ) { |
|
963 | + |
|
964 | + return false; |
|
965 | + } |
|
966 | + |
|
967 | + if (!empty($requireMax) |
|
968 | + && version_compare(self::adjustVersionParts($ocVersion, $requireMax), $requireMax, '>') |
|
969 | + ) { |
|
970 | + return false; |
|
971 | + } |
|
972 | + |
|
973 | + return true; |
|
974 | + } |
|
975 | + |
|
976 | + /** |
|
977 | + * get the installed version of all apps |
|
978 | + */ |
|
979 | + public static function getAppVersions() { |
|
980 | + static $versions; |
|
981 | + |
|
982 | + if(!$versions) { |
|
983 | + $appConfig = \OC::$server->getAppConfig(); |
|
984 | + $versions = $appConfig->getValues(false, 'installed_version'); |
|
985 | + } |
|
986 | + return $versions; |
|
987 | + } |
|
988 | + |
|
989 | + /** |
|
990 | + * @param string $app |
|
991 | + * @param \OCP\IConfig $config |
|
992 | + * @param \OCP\IL10N $l |
|
993 | + * @return bool |
|
994 | + * |
|
995 | + * @throws Exception if app is not compatible with this version of ownCloud |
|
996 | + * @throws Exception if no app-name was specified |
|
997 | + */ |
|
998 | + public function installApp($app, |
|
999 | + \OCP\IConfig $config, |
|
1000 | + \OCP\IL10N $l) { |
|
1001 | + if ($app !== false) { |
|
1002 | + // check if the app is compatible with this version of ownCloud |
|
1003 | + $info = self::getAppInfo($app); |
|
1004 | + if(!is_array($info)) { |
|
1005 | + throw new \Exception( |
|
1006 | + $l->t('App "%s" cannot be installed because appinfo file cannot be read.', |
|
1007 | + [$info['name']] |
|
1008 | + ) |
|
1009 | + ); |
|
1010 | + } |
|
1011 | + |
|
1012 | + $version = \OCP\Util::getVersion(); |
|
1013 | + if (!self::isAppCompatible($version, $info)) { |
|
1014 | + throw new \Exception( |
|
1015 | + $l->t('App "%s" cannot be installed because it is not compatible with this version of the server.', |
|
1016 | + array($info['name']) |
|
1017 | + ) |
|
1018 | + ); |
|
1019 | + } |
|
1020 | + |
|
1021 | + // check for required dependencies |
|
1022 | + self::checkAppDependencies($config, $l, $info); |
|
1023 | + |
|
1024 | + $config->setAppValue($app, 'enabled', 'yes'); |
|
1025 | + if (isset($appData['id'])) { |
|
1026 | + $config->setAppValue($app, 'ocsid', $appData['id']); |
|
1027 | + } |
|
1028 | + |
|
1029 | + if(isset($info['settings']) && is_array($info['settings'])) { |
|
1030 | + $appPath = self::getAppPath($app); |
|
1031 | + self::registerAutoloading($app, $appPath); |
|
1032 | + \OC::$server->getSettingsManager()->setupSettings($info['settings']); |
|
1033 | + } |
|
1034 | + |
|
1035 | + \OC_Hook::emit('OC_App', 'post_enable', array('app' => $app)); |
|
1036 | + } else { |
|
1037 | + if(empty($appName) ) { |
|
1038 | + throw new \Exception($l->t("No app name specified")); |
|
1039 | + } else { |
|
1040 | + throw new \Exception($l->t("App '%s' could not be installed!", $appName)); |
|
1041 | + } |
|
1042 | + } |
|
1043 | + |
|
1044 | + return $app; |
|
1045 | + } |
|
1046 | + |
|
1047 | + /** |
|
1048 | + * update the database for the app and call the update script |
|
1049 | + * |
|
1050 | + * @param string $appId |
|
1051 | + * @return bool |
|
1052 | + */ |
|
1053 | + public static function updateApp($appId) { |
|
1054 | + $appPath = self::getAppPath($appId); |
|
1055 | + if($appPath === false) { |
|
1056 | + return false; |
|
1057 | + } |
|
1058 | + self::registerAutoloading($appId, $appPath); |
|
1059 | + |
|
1060 | + $appData = self::getAppInfo($appId); |
|
1061 | + self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']); |
|
1062 | + |
|
1063 | + if (file_exists($appPath . '/appinfo/database.xml')) { |
|
1064 | + OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml'); |
|
1065 | + } else { |
|
1066 | + $ms = new MigrationService($appId, \OC::$server->getDatabaseConnection()); |
|
1067 | + $ms->migrate(); |
|
1068 | + } |
|
1069 | + |
|
1070 | + self::executeRepairSteps($appId, $appData['repair-steps']['post-migration']); |
|
1071 | + self::setupLiveMigrations($appId, $appData['repair-steps']['live-migration']); |
|
1072 | + unset(self::$appVersion[$appId]); |
|
1073 | + |
|
1074 | + // run upgrade code |
|
1075 | + if (file_exists($appPath . '/appinfo/update.php')) { |
|
1076 | + self::loadApp($appId); |
|
1077 | + include $appPath . '/appinfo/update.php'; |
|
1078 | + } |
|
1079 | + self::setupBackgroundJobs($appData['background-jobs']); |
|
1080 | + if(isset($appData['settings']) && is_array($appData['settings'])) { |
|
1081 | + \OC::$server->getSettingsManager()->setupSettings($appData['settings']); |
|
1082 | + } |
|
1083 | + |
|
1084 | + //set remote/public handlers |
|
1085 | + if (array_key_exists('ocsid', $appData)) { |
|
1086 | + \OC::$server->getConfig()->setAppValue($appId, 'ocsid', $appData['ocsid']); |
|
1087 | + } elseif(\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) { |
|
1088 | + \OC::$server->getConfig()->deleteAppValue($appId, 'ocsid'); |
|
1089 | + } |
|
1090 | + foreach ($appData['remote'] as $name => $path) { |
|
1091 | + \OC::$server->getConfig()->setAppValue('core', 'remote_' . $name, $appId . '/' . $path); |
|
1092 | + } |
|
1093 | + foreach ($appData['public'] as $name => $path) { |
|
1094 | + \OC::$server->getConfig()->setAppValue('core', 'public_' . $name, $appId . '/' . $path); |
|
1095 | + } |
|
1096 | + |
|
1097 | + self::setAppTypes($appId); |
|
1098 | + |
|
1099 | + $version = \OC_App::getAppVersion($appId); |
|
1100 | + \OC::$server->getAppConfig()->setValue($appId, 'installed_version', $version); |
|
1101 | + |
|
1102 | + \OC::$server->getEventDispatcher()->dispatch(ManagerEvent::EVENT_APP_UPDATE, new ManagerEvent( |
|
1103 | + ManagerEvent::EVENT_APP_UPDATE, $appId |
|
1104 | + )); |
|
1105 | + |
|
1106 | + return true; |
|
1107 | + } |
|
1108 | + |
|
1109 | + /** |
|
1110 | + * @param string $appId |
|
1111 | + * @param string[] $steps |
|
1112 | + * @throws \OC\NeedsUpdateException |
|
1113 | + */ |
|
1114 | + public static function executeRepairSteps($appId, array $steps) { |
|
1115 | + if (empty($steps)) { |
|
1116 | + return; |
|
1117 | + } |
|
1118 | + // load the app |
|
1119 | + self::loadApp($appId); |
|
1120 | + |
|
1121 | + $dispatcher = OC::$server->getEventDispatcher(); |
|
1122 | + |
|
1123 | + // load the steps |
|
1124 | + $r = new Repair([], $dispatcher); |
|
1125 | + foreach ($steps as $step) { |
|
1126 | + try { |
|
1127 | + $r->addStep($step); |
|
1128 | + } catch (Exception $ex) { |
|
1129 | + $r->emit('\OC\Repair', 'error', [$ex->getMessage()]); |
|
1130 | + \OC::$server->getLogger()->logException($ex); |
|
1131 | + } |
|
1132 | + } |
|
1133 | + // run the steps |
|
1134 | + $r->run(); |
|
1135 | + } |
|
1136 | + |
|
1137 | + public static function setupBackgroundJobs(array $jobs) { |
|
1138 | + $queue = \OC::$server->getJobList(); |
|
1139 | + foreach ($jobs as $job) { |
|
1140 | + $queue->add($job); |
|
1141 | + } |
|
1142 | + } |
|
1143 | + |
|
1144 | + /** |
|
1145 | + * @param string $appId |
|
1146 | + * @param string[] $steps |
|
1147 | + */ |
|
1148 | + private static function setupLiveMigrations($appId, array $steps) { |
|
1149 | + $queue = \OC::$server->getJobList(); |
|
1150 | + foreach ($steps as $step) { |
|
1151 | + $queue->add('OC\Migration\BackgroundRepair', [ |
|
1152 | + 'app' => $appId, |
|
1153 | + 'step' => $step]); |
|
1154 | + } |
|
1155 | + } |
|
1156 | + |
|
1157 | + /** |
|
1158 | + * @param string $appId |
|
1159 | + * @return \OC\Files\View|false |
|
1160 | + */ |
|
1161 | + public static function getStorage($appId) { |
|
1162 | + if (OC_App::isEnabled($appId)) { //sanity check |
|
1163 | + if (\OC::$server->getUserSession()->isLoggedIn()) { |
|
1164 | + $view = new \OC\Files\View('/' . OC_User::getUser()); |
|
1165 | + if (!$view->file_exists($appId)) { |
|
1166 | + $view->mkdir($appId); |
|
1167 | + } |
|
1168 | + return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId); |
|
1169 | + } else { |
|
1170 | + \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', \OCP\Util::ERROR); |
|
1171 | + return false; |
|
1172 | + } |
|
1173 | + } else { |
|
1174 | + \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', \OCP\Util::ERROR); |
|
1175 | + return false; |
|
1176 | + } |
|
1177 | + } |
|
1178 | + |
|
1179 | + protected static function findBestL10NOption($options, $lang) { |
|
1180 | + $fallback = $similarLangFallback = $englishFallback = false; |
|
1181 | + |
|
1182 | + $lang = strtolower($lang); |
|
1183 | + $similarLang = $lang; |
|
1184 | + if (strpos($similarLang, '_')) { |
|
1185 | + // For "de_DE" we want to find "de" and the other way around |
|
1186 | + $similarLang = substr($lang, 0, strpos($lang, '_')); |
|
1187 | + } |
|
1188 | + |
|
1189 | + foreach ($options as $option) { |
|
1190 | + if (is_array($option)) { |
|
1191 | + if ($fallback === false) { |
|
1192 | + $fallback = $option['@value']; |
|
1193 | + } |
|
1194 | + |
|
1195 | + if (!isset($option['@attributes']['lang'])) { |
|
1196 | + continue; |
|
1197 | + } |
|
1198 | + |
|
1199 | + $attributeLang = strtolower($option['@attributes']['lang']); |
|
1200 | + if ($attributeLang === $lang) { |
|
1201 | + return $option['@value']; |
|
1202 | + } |
|
1203 | + |
|
1204 | + if ($attributeLang === $similarLang) { |
|
1205 | + $similarLangFallback = $option['@value']; |
|
1206 | + } else if (strpos($attributeLang, $similarLang . '_') === 0) { |
|
1207 | + if ($similarLangFallback === false) { |
|
1208 | + $similarLangFallback = $option['@value']; |
|
1209 | + } |
|
1210 | + } |
|
1211 | + } else { |
|
1212 | + $englishFallback = $option; |
|
1213 | + } |
|
1214 | + } |
|
1215 | + |
|
1216 | + if ($similarLangFallback !== false) { |
|
1217 | + return $similarLangFallback; |
|
1218 | + } else if ($englishFallback !== false) { |
|
1219 | + return $englishFallback; |
|
1220 | + } |
|
1221 | + return (string) $fallback; |
|
1222 | + } |
|
1223 | + |
|
1224 | + /** |
|
1225 | + * parses the app data array and enhanced the 'description' value |
|
1226 | + * |
|
1227 | + * @param array $data the app data |
|
1228 | + * @param string $lang |
|
1229 | + * @return array improved app data |
|
1230 | + */ |
|
1231 | + public static function parseAppInfo(array $data, $lang = null) { |
|
1232 | + |
|
1233 | + if ($lang && isset($data['name']) && is_array($data['name'])) { |
|
1234 | + $data['name'] = self::findBestL10NOption($data['name'], $lang); |
|
1235 | + } |
|
1236 | + if ($lang && isset($data['summary']) && is_array($data['summary'])) { |
|
1237 | + $data['summary'] = self::findBestL10NOption($data['summary'], $lang); |
|
1238 | + } |
|
1239 | + if ($lang && isset($data['description']) && is_array($data['description'])) { |
|
1240 | + $data['description'] = trim(self::findBestL10NOption($data['description'], $lang)); |
|
1241 | + } else if (isset($data['description']) && is_string($data['description'])) { |
|
1242 | + $data['description'] = trim($data['description']); |
|
1243 | + } else { |
|
1244 | + $data['description'] = ''; |
|
1245 | + } |
|
1246 | + |
|
1247 | + return $data; |
|
1248 | + } |
|
1249 | + |
|
1250 | + /** |
|
1251 | + * @param \OCP\IConfig $config |
|
1252 | + * @param \OCP\IL10N $l |
|
1253 | + * @param array $info |
|
1254 | + * @throws \Exception |
|
1255 | + */ |
|
1256 | + public static function checkAppDependencies($config, $l, $info) { |
|
1257 | + $dependencyAnalyzer = new DependencyAnalyzer(new Platform($config), $l); |
|
1258 | + $missing = $dependencyAnalyzer->analyze($info); |
|
1259 | + if (!empty($missing)) { |
|
1260 | + $missingMsg = implode(PHP_EOL, $missing); |
|
1261 | + throw new \Exception( |
|
1262 | + $l->t('App "%s" cannot be installed because the following dependencies are not fulfilled: %s', |
|
1263 | + [$info['name'], $missingMsg] |
|
1264 | + ) |
|
1265 | + ); |
|
1266 | + } |
|
1267 | + } |
|
1268 | 1268 | } |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | $apps = self::getEnabledApps(); |
112 | 112 | |
113 | 113 | // Add each apps' folder as allowed class path |
114 | - foreach($apps as $app) { |
|
114 | + foreach ($apps as $app) { |
|
115 | 115 | $path = self::getAppPath($app); |
116 | - if($path !== false) { |
|
116 | + if ($path !== false) { |
|
117 | 117 | self::registerAutoloading($app, $path); |
118 | 118 | } |
119 | 119 | } |
@@ -138,15 +138,15 @@ discard block |
||
138 | 138 | public static function loadApp($app) { |
139 | 139 | self::$loadedApps[] = $app; |
140 | 140 | $appPath = self::getAppPath($app); |
141 | - if($appPath === false) { |
|
141 | + if ($appPath === false) { |
|
142 | 142 | return; |
143 | 143 | } |
144 | 144 | |
145 | 145 | // in case someone calls loadApp() directly |
146 | 146 | self::registerAutoloading($app, $appPath); |
147 | 147 | |
148 | - if (is_file($appPath . '/appinfo/app.php')) { |
|
149 | - \OC::$server->getEventLogger()->start('load_app_' . $app, 'Load app: ' . $app); |
|
148 | + if (is_file($appPath.'/appinfo/app.php')) { |
|
149 | + \OC::$server->getEventLogger()->start('load_app_'.$app, 'Load app: '.$app); |
|
150 | 150 | self::requireAppFile($app); |
151 | 151 | if (self::isType($app, array('authentication'))) { |
152 | 152 | // since authentication apps affect the "is app enabled for group" check, |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | // enabled for groups |
156 | 156 | self::$enabledAppsCache = array(); |
157 | 157 | } |
158 | - \OC::$server->getEventLogger()->end('load_app_' . $app); |
|
158 | + \OC::$server->getEventLogger()->end('load_app_'.$app); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | $info = self::getAppInfo($app); |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $plugins = isset($info['collaboration']['plugins']['plugin']['@value']) ? |
180 | 180 | [$info['collaboration']['plugins']['plugin']] : $info['collaboration']['plugins']['plugin']; |
181 | 181 | foreach ($plugins as $plugin) { |
182 | - if($plugin['@attributes']['type'] === 'collaborator-search') { |
|
182 | + if ($plugin['@attributes']['type'] === 'collaborator-search') { |
|
183 | 183 | $pluginInfo = [ |
184 | 184 | 'shareType' => $plugin['@attributes']['share-type'], |
185 | 185 | 'class' => $plugin['@value'], |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | * @param string $path |
197 | 197 | */ |
198 | 198 | public static function registerAutoloading($app, $path) { |
199 | - $key = $app . '-' . $path; |
|
200 | - if(isset(self::$alreadyRegistered[$key])) { |
|
199 | + $key = $app.'-'.$path; |
|
200 | + if (isset(self::$alreadyRegistered[$key])) { |
|
201 | 201 | return; |
202 | 202 | } |
203 | 203 | |
@@ -207,17 +207,17 @@ discard block |
||
207 | 207 | $appNamespace = \OC\AppFramework\App::buildAppNamespace($app); |
208 | 208 | \OC::$server->registerNamespace($app, $appNamespace); |
209 | 209 | |
210 | - if (file_exists($path . '/composer/autoload.php')) { |
|
211 | - require_once $path . '/composer/autoload.php'; |
|
210 | + if (file_exists($path.'/composer/autoload.php')) { |
|
211 | + require_once $path.'/composer/autoload.php'; |
|
212 | 212 | } else { |
213 | - \OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true); |
|
213 | + \OC::$composerAutoloader->addPsr4($appNamespace.'\\', $path.'/lib/', true); |
|
214 | 214 | // Register on legacy autoloader |
215 | 215 | \OC::$loader->addValidRoot($path); |
216 | 216 | } |
217 | 217 | |
218 | 218 | // Register Test namespace only when testing |
219 | 219 | if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) { |
220 | - \OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true); |
|
220 | + \OC::$composerAutoloader->addPsr4($appNamespace.'\\Tests\\', $path.'/tests/', true); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | private static function requireAppFile($app) { |
230 | 230 | try { |
231 | 231 | // encapsulated here to avoid variable scope conflicts |
232 | - require_once $app . '/appinfo/app.php'; |
|
232 | + require_once $app.'/appinfo/app.php'; |
|
233 | 233 | } catch (Error $ex) { |
234 | 234 | \OC::$server->getLogger()->logException($ex); |
235 | 235 | $blacklist = \OC::$server->getAppManager()->getAlwaysEnabledApps(); |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | */ |
284 | 284 | public static function setAppTypes($app) { |
285 | 285 | $appData = self::getAppInfo($app); |
286 | - if(!is_array($appData)) { |
|
286 | + if (!is_array($appData)) { |
|
287 | 287 | return; |
288 | 288 | } |
289 | 289 | |
@@ -335,8 +335,8 @@ discard block |
||
335 | 335 | } else { |
336 | 336 | $apps = $appManager->getEnabledAppsForUser($user); |
337 | 337 | } |
338 | - $apps = array_filter($apps, function ($app) { |
|
339 | - return $app !== 'files';//we add this manually |
|
338 | + $apps = array_filter($apps, function($app) { |
|
339 | + return $app !== 'files'; //we add this manually |
|
340 | 340 | }); |
341 | 341 | sort($apps); |
342 | 342 | array_unshift($apps, 'files'); |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | ); |
380 | 380 | $isDownloaded = $installer->isDownloaded($appId); |
381 | 381 | |
382 | - if(!$isDownloaded) { |
|
382 | + if (!$isDownloaded) { |
|
383 | 383 | $installer->downloadApp($appId); |
384 | 384 | } |
385 | 385 | |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | */ |
499 | 499 | public static function findAppInDirectories($appId) { |
500 | 500 | $sanitizedAppId = self::cleanAppId($appId); |
501 | - if($sanitizedAppId !== $appId) { |
|
501 | + if ($sanitizedAppId !== $appId) { |
|
502 | 502 | return false; |
503 | 503 | } |
504 | 504 | static $app_dir = array(); |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | |
510 | 510 | $possibleApps = array(); |
511 | 511 | foreach (OC::$APPSROOTS as $dir) { |
512 | - if (file_exists($dir['path'] . '/' . $appId)) { |
|
512 | + if (file_exists($dir['path'].'/'.$appId)) { |
|
513 | 513 | $possibleApps[] = $dir; |
514 | 514 | } |
515 | 515 | } |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | } |
551 | 551 | |
552 | 552 | if (($dir = self::findAppInDirectories($appId)) != false) { |
553 | - return $dir['path'] . '/' . $appId; |
|
553 | + return $dir['path'].'/'.$appId; |
|
554 | 554 | } |
555 | 555 | return false; |
556 | 556 | } |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | */ |
565 | 565 | public static function getAppWebPath($appId) { |
566 | 566 | if (($dir = self::findAppInDirectories($appId)) != false) { |
567 | - return OC::$WEBROOT . $dir['url'] . '/' . $appId; |
|
567 | + return OC::$WEBROOT.$dir['url'].'/'.$appId; |
|
568 | 568 | } |
569 | 569 | return false; |
570 | 570 | } |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | * @return string |
578 | 578 | */ |
579 | 579 | public static function getAppVersion($appId, $useCache = true) { |
580 | - if($useCache && isset(self::$appVersion[$appId])) { |
|
580 | + if ($useCache && isset(self::$appVersion[$appId])) { |
|
581 | 581 | return self::$appVersion[$appId]; |
582 | 582 | } |
583 | 583 | |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | * @return string |
594 | 594 | */ |
595 | 595 | public static function getAppVersionByPath($path) { |
596 | - $infoFile = $path . '/appinfo/info.xml'; |
|
596 | + $infoFile = $path.'/appinfo/info.xml'; |
|
597 | 597 | $appData = self::getAppInfo($infoFile, true); |
598 | 598 | return isset($appData['version']) ? $appData['version'] : ''; |
599 | 599 | } |
@@ -616,10 +616,10 @@ discard block |
||
616 | 616 | return self::$appInfo[$appId]; |
617 | 617 | } |
618 | 618 | $appPath = self::getAppPath($appId); |
619 | - if($appPath === false) { |
|
619 | + if ($appPath === false) { |
|
620 | 620 | return null; |
621 | 621 | } |
622 | - $file = $appPath . '/appinfo/info.xml'; |
|
622 | + $file = $appPath.'/appinfo/info.xml'; |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | $parser = new InfoParser(\OC::$server->getMemCacheFactory()->createLocal('core.appinfo')); |
@@ -628,9 +628,9 @@ discard block |
||
628 | 628 | if (is_array($data)) { |
629 | 629 | $data = OC_App::parseAppInfo($data, $lang); |
630 | 630 | } |
631 | - if(isset($data['ocsid'])) { |
|
631 | + if (isset($data['ocsid'])) { |
|
632 | 632 | $storedId = \OC::$server->getConfig()->getAppValue($appId, 'ocsid'); |
633 | - if($storedId !== '' && $storedId !== $data['ocsid']) { |
|
633 | + if ($storedId !== '' && $storedId !== $data['ocsid']) { |
|
634 | 634 | $data['ocsid'] = $storedId; |
635 | 635 | } |
636 | 636 | } |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | * @param string $page |
723 | 723 | */ |
724 | 724 | public static function registerAdmin($app, $page) { |
725 | - self::$adminForms[] = $app . '/' . $page . '.php'; |
|
725 | + self::$adminForms[] = $app.'/'.$page.'.php'; |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | /** |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | * @param string $page |
732 | 732 | */ |
733 | 733 | public static function registerPersonal($app, $page) { |
734 | - self::$personalForms[] = $app . '/' . $page . '.php'; |
|
734 | + self::$personalForms[] = $app.'/'.$page.'.php'; |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | /** |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | |
761 | 761 | foreach (OC::$APPSROOTS as $apps_dir) { |
762 | 762 | if (!is_readable($apps_dir['path'])) { |
763 | - \OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], \OCP\Util::WARN); |
|
763 | + \OCP\Util::writeLog('core', 'unable to read app folder : '.$apps_dir['path'], \OCP\Util::WARN); |
|
764 | 764 | continue; |
765 | 765 | } |
766 | 766 | $dh = opendir($apps_dir['path']); |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | if (is_resource($dh)) { |
769 | 769 | while (($file = readdir($dh)) !== false) { |
770 | 770 | |
771 | - if ($file[0] != '.' and is_dir($apps_dir['path'] . '/' . $file) and is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')) { |
|
771 | + if ($file[0] != '.' and is_dir($apps_dir['path'].'/'.$file) and is_file($apps_dir['path'].'/'.$file.'/appinfo/info.xml')) { |
|
772 | 772 | |
773 | 773 | $apps[] = $file; |
774 | 774 | } |
@@ -801,12 +801,12 @@ discard block |
||
801 | 801 | |
802 | 802 | $info = OC_App::getAppInfo($app, false, $langCode); |
803 | 803 | if (!is_array($info)) { |
804 | - \OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', \OCP\Util::ERROR); |
|
804 | + \OCP\Util::writeLog('core', 'Could not read app info file for app "'.$app.'"', \OCP\Util::ERROR); |
|
805 | 805 | continue; |
806 | 806 | } |
807 | 807 | |
808 | 808 | if (!isset($info['name'])) { |
809 | - \OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', \OCP\Util::ERROR); |
|
809 | + \OCP\Util::writeLog('core', 'App id "'.$app.'" has no name in appinfo', \OCP\Util::ERROR); |
|
810 | 810 | continue; |
811 | 811 | } |
812 | 812 | |
@@ -833,13 +833,13 @@ discard block |
||
833 | 833 | } |
834 | 834 | |
835 | 835 | $appPath = self::getAppPath($app); |
836 | - if($appPath !== false) { |
|
837 | - $appIcon = $appPath . '/img/' . $app . '.svg'; |
|
836 | + if ($appPath !== false) { |
|
837 | + $appIcon = $appPath.'/img/'.$app.'.svg'; |
|
838 | 838 | if (file_exists($appIcon)) { |
839 | - $info['preview'] = $urlGenerator->imagePath($app, $app . '.svg'); |
|
839 | + $info['preview'] = $urlGenerator->imagePath($app, $app.'.svg'); |
|
840 | 840 | $info['previewAsIcon'] = true; |
841 | 841 | } else { |
842 | - $appIcon = $appPath . '/img/app.svg'; |
|
842 | + $appIcon = $appPath.'/img/app.svg'; |
|
843 | 843 | if (file_exists($appIcon)) { |
844 | 844 | $info['preview'] = $urlGenerator->imagePath($app, 'app.svg'); |
845 | 845 | $info['previewAsIcon'] = true; |
@@ -873,9 +873,9 @@ discard block |
||
873 | 873 | * @return string|false |
874 | 874 | */ |
875 | 875 | public static function getInternalAppIdByOcs($ocsID) { |
876 | - if(is_numeric($ocsID)) { |
|
876 | + if (is_numeric($ocsID)) { |
|
877 | 877 | $idArray = \OC::$server->getAppConfig()->getValues(false, 'ocsid'); |
878 | - if(array_search($ocsID, $idArray)) { |
|
878 | + if (array_search($ocsID, $idArray)) { |
|
879 | 879 | return array_search($ocsID, $idArray); |
880 | 880 | } |
881 | 881 | } |
@@ -979,7 +979,7 @@ discard block |
||
979 | 979 | public static function getAppVersions() { |
980 | 980 | static $versions; |
981 | 981 | |
982 | - if(!$versions) { |
|
982 | + if (!$versions) { |
|
983 | 983 | $appConfig = \OC::$server->getAppConfig(); |
984 | 984 | $versions = $appConfig->getValues(false, 'installed_version'); |
985 | 985 | } |
@@ -1001,7 +1001,7 @@ discard block |
||
1001 | 1001 | if ($app !== false) { |
1002 | 1002 | // check if the app is compatible with this version of ownCloud |
1003 | 1003 | $info = self::getAppInfo($app); |
1004 | - if(!is_array($info)) { |
|
1004 | + if (!is_array($info)) { |
|
1005 | 1005 | throw new \Exception( |
1006 | 1006 | $l->t('App "%s" cannot be installed because appinfo file cannot be read.', |
1007 | 1007 | [$info['name']] |
@@ -1026,7 +1026,7 @@ discard block |
||
1026 | 1026 | $config->setAppValue($app, 'ocsid', $appData['id']); |
1027 | 1027 | } |
1028 | 1028 | |
1029 | - if(isset($info['settings']) && is_array($info['settings'])) { |
|
1029 | + if (isset($info['settings']) && is_array($info['settings'])) { |
|
1030 | 1030 | $appPath = self::getAppPath($app); |
1031 | 1031 | self::registerAutoloading($app, $appPath); |
1032 | 1032 | \OC::$server->getSettingsManager()->setupSettings($info['settings']); |
@@ -1034,7 +1034,7 @@ discard block |
||
1034 | 1034 | |
1035 | 1035 | \OC_Hook::emit('OC_App', 'post_enable', array('app' => $app)); |
1036 | 1036 | } else { |
1037 | - if(empty($appName) ) { |
|
1037 | + if (empty($appName)) { |
|
1038 | 1038 | throw new \Exception($l->t("No app name specified")); |
1039 | 1039 | } else { |
1040 | 1040 | throw new \Exception($l->t("App '%s' could not be installed!", $appName)); |
@@ -1052,7 +1052,7 @@ discard block |
||
1052 | 1052 | */ |
1053 | 1053 | public static function updateApp($appId) { |
1054 | 1054 | $appPath = self::getAppPath($appId); |
1055 | - if($appPath === false) { |
|
1055 | + if ($appPath === false) { |
|
1056 | 1056 | return false; |
1057 | 1057 | } |
1058 | 1058 | self::registerAutoloading($appId, $appPath); |
@@ -1060,8 +1060,8 @@ discard block |
||
1060 | 1060 | $appData = self::getAppInfo($appId); |
1061 | 1061 | self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']); |
1062 | 1062 | |
1063 | - if (file_exists($appPath . '/appinfo/database.xml')) { |
|
1064 | - OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml'); |
|
1063 | + if (file_exists($appPath.'/appinfo/database.xml')) { |
|
1064 | + OC_DB::updateDbFromStructure($appPath.'/appinfo/database.xml'); |
|
1065 | 1065 | } else { |
1066 | 1066 | $ms = new MigrationService($appId, \OC::$server->getDatabaseConnection()); |
1067 | 1067 | $ms->migrate(); |
@@ -1072,26 +1072,26 @@ discard block |
||
1072 | 1072 | unset(self::$appVersion[$appId]); |
1073 | 1073 | |
1074 | 1074 | // run upgrade code |
1075 | - if (file_exists($appPath . '/appinfo/update.php')) { |
|
1075 | + if (file_exists($appPath.'/appinfo/update.php')) { |
|
1076 | 1076 | self::loadApp($appId); |
1077 | - include $appPath . '/appinfo/update.php'; |
|
1077 | + include $appPath.'/appinfo/update.php'; |
|
1078 | 1078 | } |
1079 | 1079 | self::setupBackgroundJobs($appData['background-jobs']); |
1080 | - if(isset($appData['settings']) && is_array($appData['settings'])) { |
|
1080 | + if (isset($appData['settings']) && is_array($appData['settings'])) { |
|
1081 | 1081 | \OC::$server->getSettingsManager()->setupSettings($appData['settings']); |
1082 | 1082 | } |
1083 | 1083 | |
1084 | 1084 | //set remote/public handlers |
1085 | 1085 | if (array_key_exists('ocsid', $appData)) { |
1086 | 1086 | \OC::$server->getConfig()->setAppValue($appId, 'ocsid', $appData['ocsid']); |
1087 | - } elseif(\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) { |
|
1087 | + } elseif (\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) { |
|
1088 | 1088 | \OC::$server->getConfig()->deleteAppValue($appId, 'ocsid'); |
1089 | 1089 | } |
1090 | 1090 | foreach ($appData['remote'] as $name => $path) { |
1091 | - \OC::$server->getConfig()->setAppValue('core', 'remote_' . $name, $appId . '/' . $path); |
|
1091 | + \OC::$server->getConfig()->setAppValue('core', 'remote_'.$name, $appId.'/'.$path); |
|
1092 | 1092 | } |
1093 | 1093 | foreach ($appData['public'] as $name => $path) { |
1094 | - \OC::$server->getConfig()->setAppValue('core', 'public_' . $name, $appId . '/' . $path); |
|
1094 | + \OC::$server->getConfig()->setAppValue('core', 'public_'.$name, $appId.'/'.$path); |
|
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | self::setAppTypes($appId); |
@@ -1161,17 +1161,17 @@ discard block |
||
1161 | 1161 | public static function getStorage($appId) { |
1162 | 1162 | if (OC_App::isEnabled($appId)) { //sanity check |
1163 | 1163 | if (\OC::$server->getUserSession()->isLoggedIn()) { |
1164 | - $view = new \OC\Files\View('/' . OC_User::getUser()); |
|
1164 | + $view = new \OC\Files\View('/'.OC_User::getUser()); |
|
1165 | 1165 | if (!$view->file_exists($appId)) { |
1166 | 1166 | $view->mkdir($appId); |
1167 | 1167 | } |
1168 | - return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId); |
|
1168 | + return new \OC\Files\View('/'.OC_User::getUser().'/'.$appId); |
|
1169 | 1169 | } else { |
1170 | - \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', \OCP\Util::ERROR); |
|
1170 | + \OCP\Util::writeLog('core', 'Can\'t get app storage, app '.$appId.', user not logged in', \OCP\Util::ERROR); |
|
1171 | 1171 | return false; |
1172 | 1172 | } |
1173 | 1173 | } else { |
1174 | - \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', \OCP\Util::ERROR); |
|
1174 | + \OCP\Util::writeLog('core', 'Can\'t get app storage, app '.$appId.' not enabled', \OCP\Util::ERROR); |
|
1175 | 1175 | return false; |
1176 | 1176 | } |
1177 | 1177 | } |
@@ -1203,9 +1203,9 @@ discard block |
||
1203 | 1203 | |
1204 | 1204 | if ($attributeLang === $similarLang) { |
1205 | 1205 | $similarLangFallback = $option['@value']; |
1206 | - } else if (strpos($attributeLang, $similarLang . '_') === 0) { |
|
1206 | + } else if (strpos($attributeLang, $similarLang.'_') === 0) { |
|
1207 | 1207 | if ($similarLangFallback === false) { |
1208 | - $similarLangFallback = $option['@value']; |
|
1208 | + $similarLangFallback = $option['@value']; |
|
1209 | 1209 | } |
1210 | 1210 | } |
1211 | 1211 | } else { |
@@ -1240,7 +1240,7 @@ discard block |
||
1240 | 1240 | $data['description'] = trim(self::findBestL10NOption($data['description'], $lang)); |
1241 | 1241 | } else if (isset($data['description']) && is_string($data['description'])) { |
1242 | 1242 | $data['description'] = trim($data['description']); |
1243 | - } else { |
|
1243 | + } else { |
|
1244 | 1244 | $data['description'] = ''; |
1245 | 1245 | } |
1246 | 1246 |