Completed
Pull Request — master (#4077)
by Joas
10:46
created
core/templates/layout.user.php 3 patches
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -111,8 +111,11 @@
 block discarded – undo
111 111
 								<?php foreach($_['navigation'] as $entry): ?>
112 112
 									<?php if($entry['showInHeader']): ?>
113 113
 										<li data-id="<?php p($entry['id']); ?>" class="in-header">
114
-									<?php else: ?>
115
-										<li data-id="<?php p($entry['id']); ?>">
114
+									<?php else {
115
+    : ?>
116
+										<li data-id="<?php p($entry['id']);
117
+}
118
+?>">
116 119
 									<?php endif; ?>
117 120
 									<a href="<?php print_unescaped($entry['href']); ?>" tabindex="3"
118 121
 										<?php if( $entry['active'] ): ?> class="active"<?php endif; ?>>
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -4,9 +4,9 @@
 block discarded – undo
4 4
 		<meta charset="utf-8">
5 5
 		<title>
6 6
 			<?php
7
-				p(!empty($_['application'])?$_['application'].' - ':'');
8
-				p($theme->getTitle());
9
-			?>
7
+                p(!empty($_['application'])?$_['application'].' - ':'');
8
+                p($theme->getTitle());
9
+            ?>
10 10
 		</title>
11 11
 		<meta http-equiv="X-UA-Compatible" content="IE=edge">
12 12
 		<meta name="referrer" content="never">
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 		<meta charset="utf-8">
5 5
 		<title>
6 6
 			<?php
7
-				p(!empty($_['application'])?$_['application'].' - ':'');
7
+				p(!empty($_['application']) ? $_['application'].' - ' : '');
8 8
 				p($theme->getTitle());
9 9
 			?>
10 10
 		</title>
@@ -14,16 +14,16 @@  discard block
 block discarded – undo
14 14
 		<meta name="apple-itunes-app" content="app-id=<?php p($theme->getiTunesAppId()); ?>">
15 15
 		<meta name="apple-mobile-web-app-capable" content="yes">
16 16
 		<meta name="apple-mobile-web-app-status-bar-style" content="black">
17
-		<meta name="apple-mobile-web-app-title" content="<?php p((!empty($_['application']) && $_['appid']!='files')? $_['application']:$theme->getTitle()); ?>">
17
+		<meta name="apple-mobile-web-app-title" content="<?php p((!empty($_['application']) && $_['appid'] != 'files') ? $_['application'] : $theme->getTitle()); ?>">
18 18
 		<meta name="mobile-web-app-capable" content="yes">
19 19
 		<meta name="theme-color" content="<?php p($theme->getMailHeaderColor()); ?>">
20 20
 		<link rel="icon" href="<?php print_unescaped(image_path($_['appid'], 'favicon.ico')); /* IE11+ supports png */ ?>">
21 21
 		<link rel="apple-touch-icon-precomposed" href="<?php print_unescaped(image_path($_['appid'], 'favicon-touch.png')); ?>">
22 22
 		<link rel="mask-icon" sizes="any" href="<?php print_unescaped(image_path($_['appid'], 'favicon-mask.svg')); ?>" color="#0082c9">
23
-		<?php foreach($_['cssfiles'] as $cssfile): ?>
23
+		<?php foreach ($_['cssfiles'] as $cssfile): ?>
24 24
 			<link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>">
25 25
 		<?php endforeach; ?>
26
-		<?php foreach($_['printcssfiles'] as $cssfile): ?>
26
+		<?php foreach ($_['printcssfiles'] as $cssfile): ?>
27 27
 			<link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>" media="print">
28 28
 		<?php endforeach; ?>
29 29
 		<?php if (isset($_['inline_ocjs'])): ?>
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 				<?php print_unescaped($_['inline_ocjs']); ?>
32 32
 			</script>
33 33
 		<?php endif; ?>
34
-		<?php foreach($_['jsfiles'] as $jsfile): ?>
34
+		<?php foreach ($_['jsfiles'] as $jsfile): ?>
35 35
 			<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php print_unescaped($jsfile); ?>"></script>
36 36
 		<?php endforeach; ?>
37 37
 		<?php print_unescaped($_['headers']); ?>
38 38
 	</head>
39
-	<body id="<?php p($_['bodyid']);?>">
39
+	<body id="<?php p($_['bodyid']); ?>">
40 40
 	<?php include('layout.noscript.warning.php'); ?>
41 41
 	<div id="notification-container">
42 42
 		<div id="notification"></div>
@@ -54,18 +54,18 @@  discard block
 block discarded – undo
54 54
 
55 55
 				<a href="#" class="header-appname-container menutoggle" tabindex="2">
56 56
 					<h1 class="header-appname">
57
-						<?php p(!empty($_['application'])?$_['application']: $l->t('Apps')); ?>
57
+						<?php p(!empty($_['application']) ? $_['application'] : $l->t('Apps')); ?>
58 58
 					</h1>
59 59
 					<div class="icon-caret"></div>
60 60
 				</a>
61 61
 
62 62
 				<div id="appmenu">
63 63
 					<ul>
64
-						<?php foreach($_['headernavigation'] as $entry): ?>
64
+						<?php foreach ($_['headernavigation'] as $entry): ?>
65 65
 							<li data-id="<?php p($entry['id']); ?>">
66 66
 								<a href="<?php print_unescaped($entry['href']); ?>" tabindex="3"
67
-									<?php if( $entry['active'] ): ?> class="active"<?php endif; ?>>
68
-									<img src="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>"  class="app-icon" />
67
+									<?php if ($entry['active']): ?> class="active"<?php endif; ?>>
68
+									<img src="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>"  class="app-icon" />
69 69
 									<div class="icon-loading-dark" style="display:none;"></div>
70 70
 									<span>
71 71
 								<?php p($entry['name']); ?>
@@ -85,17 +85,17 @@  discard block
 block discarded – undo
85 85
 				<nav role="navigation"><div id="navigation">
86 86
 						<div id="apps">
87 87
 							<ul>
88
-								<?php foreach($_['navigation'] as $entry): ?>
89
-									<?php if($entry['showInHeader']): ?>
88
+								<?php foreach ($_['navigation'] as $entry): ?>
89
+									<?php if ($entry['showInHeader']): ?>
90 90
 										<li data-id="<?php p($entry['id']); ?>" class="in-header">
91 91
 									<?php else: ?>
92 92
 										<li data-id="<?php p($entry['id']); ?>">
93 93
 									<?php endif; ?>
94 94
 									<a href="<?php print_unescaped($entry['href']); ?>" tabindex="3"
95
-										<?php if( $entry['active'] ): ?> class="active"<?php endif; ?>>
95
+										<?php if ($entry['active']): ?> class="active"<?php endif; ?>>
96 96
 										<svg width="32" height="32" viewBox="0 0 32 32">
97 97
 											<defs><filter id="invert-<?php p($entry['id']); ?>"><feColorMatrix in="SourceGraphic" type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0"></feColorMatrix></filter></defs>
98
-											<image x="0" y="0" width="32" height="32" preserveAspectRatio="xMinYMin meet" filter="url(#invert-<?php p($entry['id']); ?>)" xlink:href="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>"  class="app-icon"></image>
98
+											<image x="0" y="0" width="32" height="32" preserveAspectRatio="xMinYMin meet" filter="url(#invert-<?php p($entry['id']); ?>)" xlink:href="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>"  class="app-icon"></image>
99 99
 										</svg>
100 100
 										<div class="icon-loading-dark" style="display:none;"></div>
101 101
 										<span>
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 			<div id="header-right">
114 114
 				<form class="searchbox" action="#" method="post" role="search" novalidate>
115 115
 					<label for="searchbox" class="hidden-visually">
116
-						<?php p($l->t('Search'));?>
116
+						<?php p($l->t('Search')); ?>
117 117
 					</label>
118 118
 					<input id="searchbox" type="search" name="query"
119 119
 						value="" required
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
 						<div class="avatardiv<?php if ($_['userAvatarSet']) { print_unescaped(' avatardiv-shown'); } else { print_unescaped('" style="display: none'); } ?>">
126 126
 							<?php if ($_['userAvatarSet']): ?>
127 127
 								<img alt="" width="32" height="32"
128
-								src="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 32, 'v' => $_['userAvatarVersion']]));?>"
129
-								srcset="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 64, 'v' => $_['userAvatarVersion']]));?> 2x, <?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 128, 'v' => $_['userAvatarVersion']]));?> 4x"
128
+								src="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 32, 'v' => $_['userAvatarVersion']])); ?>"
129
+								srcset="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 64, 'v' => $_['userAvatarVersion']])); ?> 2x, <?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 128, 'v' => $_['userAvatarVersion']])); ?> 4x"
130 130
 								>
131 131
 							<?php endif; ?>
132 132
 						</div>
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 					</div>
136 136
 					<div id="expanddiv">
137 137
 					<ul>
138
-					<?php foreach($_['settingsnavigation'] as $entry):?>
138
+					<?php foreach ($_['settingsnavigation'] as $entry):?>
139 139
 						<li>
140 140
 							<a href="<?php print_unescaped($entry['href']); ?>"
141
-								<?php if( $entry["active"] ): ?> class="active"<?php endif; ?>>
142
-								<img alt="" src="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>">
141
+								<?php if ($entry["active"]): ?> class="active"<?php endif; ?>>
142
+								<img alt="" src="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>">
143 143
 								<?php p($entry['name']) ?>
144 144
 							</a>
145 145
 						</li>
Please login to merge, or discard this patch.
lib/private/TemplateLayout.php 1 patch
Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -41,233 +41,233 @@
 block discarded – undo
41 41
 
42 42
 class TemplateLayout extends \OC_Template {
43 43
 
44
-	private static $versionHash = '';
44
+    private static $versionHash = '';
45 45
 
46
-	/**
47
-	 * @var \OCP\IConfig
48
-	 */
49
-	private $config;
46
+    /**
47
+     * @var \OCP\IConfig
48
+     */
49
+    private $config;
50 50
 
51
-	/**
52
-	 * @param string $renderAs
53
-	 * @param string $appId application id
54
-	 */
55
-	public function __construct( $renderAs, $appId = '' ) {
51
+    /**
52
+     * @param string $renderAs
53
+     * @param string $appId application id
54
+     */
55
+    public function __construct( $renderAs, $appId = '' ) {
56 56
 
57
-		// yes - should be injected ....
58
-		$this->config = \OC::$server->getConfig();
57
+        // yes - should be injected ....
58
+        $this->config = \OC::$server->getConfig();
59 59
 
60
-		// Decide which page we show
61
-		if($renderAs == 'user') {
62
-			parent::__construct( 'core', 'layout.user' );
63
-			if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
64
-				$this->assign('bodyid', 'body-settings');
65
-			}else{
66
-				$this->assign('bodyid', 'body-user');
67
-			}
60
+        // Decide which page we show
61
+        if($renderAs == 'user') {
62
+            parent::__construct( 'core', 'layout.user' );
63
+            if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
64
+                $this->assign('bodyid', 'body-settings');
65
+            }else{
66
+                $this->assign('bodyid', 'body-user');
67
+            }
68 68
 
69
-			// Code integrity notification
70
-			$integrityChecker = \OC::$server->getIntegrityCodeChecker();
71
-			if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) {
72
-				\OCP\Util::addScript('core', 'integritycheck-failed-notification');
73
-			}
69
+            // Code integrity notification
70
+            $integrityChecker = \OC::$server->getIntegrityCodeChecker();
71
+            if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) {
72
+                \OCP\Util::addScript('core', 'integritycheck-failed-notification');
73
+            }
74 74
 
75
-			// Add navigation entry
76
-			$this->assign( 'application', '');
77
-			$this->assign( 'appid', $appId );
78
-			$navigation = \OC_App::getNavigation();
79
-			$this->assign( 'navigation', $navigation);
80
-			$navigation = \OC_App::getHeaderNavigation();
81
-			$this->assign( 'headernavigation', $navigation);
82
-			$settingsNavigation = \OC_App::getSettingsNavigation();
83
-			$this->assign( 'settingsnavigation', $settingsNavigation);
84
-			foreach($navigation as $entry) {
85
-				if ($entry['active']) {
86
-					$this->assign( 'application', $entry['name'] );
87
-					break;
88
-				}
89
-			}
75
+            // Add navigation entry
76
+            $this->assign( 'application', '');
77
+            $this->assign( 'appid', $appId );
78
+            $navigation = \OC_App::getNavigation();
79
+            $this->assign( 'navigation', $navigation);
80
+            $navigation = \OC_App::getHeaderNavigation();
81
+            $this->assign( 'headernavigation', $navigation);
82
+            $settingsNavigation = \OC_App::getSettingsNavigation();
83
+            $this->assign( 'settingsnavigation', $settingsNavigation);
84
+            foreach($navigation as $entry) {
85
+                if ($entry['active']) {
86
+                    $this->assign( 'application', $entry['name'] );
87
+                    break;
88
+                }
89
+            }
90 90
 			
91
-			foreach($settingsNavigation as $entry) {
92
-				if ($entry['active']) {
93
-					$this->assign( 'application', $entry['name'] );
94
-					break;
95
-				}
96
-			}
97
-			$userDisplayName = \OC_User::getDisplayName();
98
-			$this->assign('user_displayname', $userDisplayName);
99
-			$this->assign('user_uid', \OC_User::getUser());
91
+            foreach($settingsNavigation as $entry) {
92
+                if ($entry['active']) {
93
+                    $this->assign( 'application', $entry['name'] );
94
+                    break;
95
+                }
96
+            }
97
+            $userDisplayName = \OC_User::getDisplayName();
98
+            $this->assign('user_displayname', $userDisplayName);
99
+            $this->assign('user_uid', \OC_User::getUser());
100 100
 
101
-			if (\OC_User::getUser() === false) {
102
-				$this->assign('userAvatarSet', false);
103
-			} else {
104
-				$this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists());
105
-				$this->assign('userAvatarVersion', \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0));
106
-			}
101
+            if (\OC_User::getUser() === false) {
102
+                $this->assign('userAvatarSet', false);
103
+            } else {
104
+                $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists());
105
+                $this->assign('userAvatarVersion', \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0));
106
+            }
107 107
 
108
-		} else if ($renderAs == 'error') {
109
-			parent::__construct('core', 'layout.guest', '', false);
110
-			$this->assign('bodyid', 'body-login');
111
-		} else if ($renderAs == 'guest') {
112
-			parent::__construct('core', 'layout.guest');
113
-			$this->assign('bodyid', 'body-login');
114
-		} else {
115
-			parent::__construct('core', 'layout.base');
108
+        } else if ($renderAs == 'error') {
109
+            parent::__construct('core', 'layout.guest', '', false);
110
+            $this->assign('bodyid', 'body-login');
111
+        } else if ($renderAs == 'guest') {
112
+            parent::__construct('core', 'layout.guest');
113
+            $this->assign('bodyid', 'body-login');
114
+        } else {
115
+            parent::__construct('core', 'layout.base');
116 116
 
117
-		}
118
-		// Send the language to our layouts
119
-		$this->assign('language', \OC::$server->getL10NFactory()->findLanguage());
117
+        }
118
+        // Send the language to our layouts
119
+        $this->assign('language', \OC::$server->getL10NFactory()->findLanguage());
120 120
 
121
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
122
-			if (empty(self::$versionHash)) {
123
-				$v = \OC_App::getAppVersions();
124
-				$v['core'] = implode('.', \OCP\Util::getVersion());
125
-				self::$versionHash = md5(implode(',', $v));
126
-			}
127
-		} else {
128
-			self::$versionHash = md5('not installed');
129
-		}
121
+        if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
122
+            if (empty(self::$versionHash)) {
123
+                $v = \OC_App::getAppVersions();
124
+                $v['core'] = implode('.', \OCP\Util::getVersion());
125
+                self::$versionHash = md5(implode(',', $v));
126
+            }
127
+        } else {
128
+            self::$versionHash = md5('not installed');
129
+        }
130 130
 
131
-		// Add the js files
132
-		$jsFiles = self::findJavascriptFiles(\OC_Util::$scripts);
133
-		$this->assign('jsfiles', array());
134
-		if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') {
135
-			if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) {
136
-				$jsConfigHelper = new JSConfigHelper(
137
-					\OC::$server->getL10N('core'),
138
-					\OC::$server->getThemingDefaults(),
139
-					\OC::$server->getAppManager(),
140
-					\OC::$server->getSession(),
141
-					\OC::$server->getUserSession()->getUser(),
142
-					\OC::$server->getConfig(),
143
-					\OC::$server->getGroupManager(),
144
-					\OC::$server->getIniWrapper(),
145
-					\OC::$server->getURLGenerator()
146
-				);
147
-				$this->assign('inline_ocjs', $jsConfigHelper->getConfig());
148
-			} else {
149
-				$this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
150
-			}
151
-		}
152
-		foreach($jsFiles as $info) {
153
-			$web = $info[1];
154
-			$file = $info[2];
155
-			$this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
156
-		}
131
+        // Add the js files
132
+        $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts);
133
+        $this->assign('jsfiles', array());
134
+        if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') {
135
+            if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) {
136
+                $jsConfigHelper = new JSConfigHelper(
137
+                    \OC::$server->getL10N('core'),
138
+                    \OC::$server->getThemingDefaults(),
139
+                    \OC::$server->getAppManager(),
140
+                    \OC::$server->getSession(),
141
+                    \OC::$server->getUserSession()->getUser(),
142
+                    \OC::$server->getConfig(),
143
+                    \OC::$server->getGroupManager(),
144
+                    \OC::$server->getIniWrapper(),
145
+                    \OC::$server->getURLGenerator()
146
+                );
147
+                $this->assign('inline_ocjs', $jsConfigHelper->getConfig());
148
+            } else {
149
+                $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
150
+            }
151
+        }
152
+        foreach($jsFiles as $info) {
153
+            $web = $info[1];
154
+            $file = $info[2];
155
+            $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
156
+        }
157 157
 
158
-		try {
159
-			$pathInfo = \OC::$server->getRequest()->getPathInfo();
160
-		} catch (\Exception $e) {
161
-			$pathInfo = '';
162
-		}
158
+        try {
159
+            $pathInfo = \OC::$server->getRequest()->getPathInfo();
160
+        } catch (\Exception $e) {
161
+            $pathInfo = '';
162
+        }
163 163
 
164
-		// Do not initialise scss appdata until we have a fully installed instance
165
-		// Do not load scss for update, errors, installation or login page
166
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)
167
-			&& !\OCP\Util::needUpgrade()
168
-			&& $pathInfo !== ''
169
-			&& !preg_match('/^\/login/', $pathInfo)) {
170
-			$cssFiles = self::findStylesheetFiles(\OC_Util::$styles);
171
-		} else {
172
-			// If we ignore the scss compiler,
173
-			// we need to load the guest css fallback
174
-			\OC_Util::addStyle('guest');
175
-			$cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false);
176
-		}
164
+        // Do not initialise scss appdata until we have a fully installed instance
165
+        // Do not load scss for update, errors, installation or login page
166
+        if(\OC::$server->getSystemConfig()->getValue('installed', false)
167
+            && !\OCP\Util::needUpgrade()
168
+            && $pathInfo !== ''
169
+            && !preg_match('/^\/login/', $pathInfo)) {
170
+            $cssFiles = self::findStylesheetFiles(\OC_Util::$styles);
171
+        } else {
172
+            // If we ignore the scss compiler,
173
+            // we need to load the guest css fallback
174
+            \OC_Util::addStyle('guest');
175
+            $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false);
176
+        }
177 177
 
178
-		$this->assign('cssfiles', array());
179
-		$this->assign('printcssfiles', []);
180
-		$this->assign('versionHash', self::$versionHash);
181
-		foreach($cssFiles as $info) {
182
-			$web = $info[1];
183
-			$file = $info[2];
178
+        $this->assign('cssfiles', array());
179
+        $this->assign('printcssfiles', []);
180
+        $this->assign('versionHash', self::$versionHash);
181
+        foreach($cssFiles as $info) {
182
+            $web = $info[1];
183
+            $file = $info[2];
184 184
 
185
-			if (substr($file, -strlen('print.css')) === 'print.css') {
186
-				$this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
187
-			} else {
188
-				$this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix()  );
189
-			}
190
-		}
191
-	}
185
+            if (substr($file, -strlen('print.css')) === 'print.css') {
186
+                $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
187
+            } else {
188
+                $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix()  );
189
+            }
190
+        }
191
+    }
192 192
 
193
-	protected function getVersionHashSuffix() {
194
-		if(\OC::$server->getConfig()->getSystemValue('debug', false)) {
195
-			// allows chrome workspace mapping in debug mode
196
-			return "";
197
-		}
193
+    protected function getVersionHashSuffix() {
194
+        if(\OC::$server->getConfig()->getSystemValue('debug', false)) {
195
+            // allows chrome workspace mapping in debug mode
196
+            return "";
197
+        }
198 198
 
199
-		return '?v=' . self::$versionHash;
200
-	}
199
+        return '?v=' . self::$versionHash;
200
+    }
201 201
 
202
-	/**
203
-	 * @param array $styles
204
-	 * @return array
205
-	 */
206
-	static public function findStylesheetFiles($styles, $compileScss = true) {
207
-		// Read the selected theme from the config file
208
-		$theme = \OC_Util::getTheme();
202
+    /**
203
+     * @param array $styles
204
+     * @return array
205
+     */
206
+    static public function findStylesheetFiles($styles, $compileScss = true) {
207
+        // Read the selected theme from the config file
208
+        $theme = \OC_Util::getTheme();
209 209
 
210
-		if($compileScss) {
211
-			/** @var \OC\Memcache\Factory $cache */
212
-			$cache = \OC::$server->query('MemCacheFactory');
213
-			$SCSSCacher = new SCSSCacher(
214
-				\OC::$server->getLogger(),
215
-				\OC::$server->getAppDataDir('css'),
216
-				\OC::$server->getURLGenerator(),
217
-				\OC::$server->getConfig(),
218
-				\OC::$SERVERROOT,
219
-				$cache->createLocal('SCSS')
220
-			);
221
-		} else {
222
-			$SCSSCacher = null;
223
-		}
210
+        if($compileScss) {
211
+            /** @var \OC\Memcache\Factory $cache */
212
+            $cache = \OC::$server->query('MemCacheFactory');
213
+            $SCSSCacher = new SCSSCacher(
214
+                \OC::$server->getLogger(),
215
+                \OC::$server->getAppDataDir('css'),
216
+                \OC::$server->getURLGenerator(),
217
+                \OC::$server->getConfig(),
218
+                \OC::$SERVERROOT,
219
+                $cache->createLocal('SCSS')
220
+            );
221
+        } else {
222
+            $SCSSCacher = null;
223
+        }
224 224
 
225
-		$locator = new \OC\Template\CSSResourceLocator(
226
-			\OC::$server->getLogger(),
227
-			$theme,
228
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
229
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
230
-			$SCSSCacher);
231
-		$locator->find($styles);
232
-		return $locator->getResources();
233
-	}
225
+        $locator = new \OC\Template\CSSResourceLocator(
226
+            \OC::$server->getLogger(),
227
+            $theme,
228
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
229
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
230
+            $SCSSCacher);
231
+        $locator->find($styles);
232
+        return $locator->getResources();
233
+    }
234 234
 
235
-	/**
236
-	 * @param array $scripts
237
-	 * @return array
238
-	 */
239
-	static public function findJavascriptFiles($scripts) {
240
-		// Read the selected theme from the config file
241
-		$theme = \OC_Util::getTheme();
235
+    /**
236
+     * @param array $scripts
237
+     * @return array
238
+     */
239
+    static public function findJavascriptFiles($scripts) {
240
+        // Read the selected theme from the config file
241
+        $theme = \OC_Util::getTheme();
242 242
 
243
-		$locator = new \OC\Template\JSResourceLocator(
244
-			\OC::$server->getLogger(),
245
-			$theme,
246
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
247
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
248
-			new JSCombiner(
249
-				\OC::$server->getAppDataDir('js'),
250
-				\OC::$server->getURLGenerator(),
251
-				\OC::$server->getMemCacheFactory()->create('JS'),
252
-				\OC::$server->getSystemConfig()
253
-			)
254
-			);
255
-		$locator->find($scripts);
256
-		return $locator->getResources();
257
-	}
243
+        $locator = new \OC\Template\JSResourceLocator(
244
+            \OC::$server->getLogger(),
245
+            $theme,
246
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
247
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
248
+            new JSCombiner(
249
+                \OC::$server->getAppDataDir('js'),
250
+                \OC::$server->getURLGenerator(),
251
+                \OC::$server->getMemCacheFactory()->create('JS'),
252
+                \OC::$server->getSystemConfig()
253
+            )
254
+            );
255
+        $locator->find($scripts);
256
+        return $locator->getResources();
257
+    }
258 258
 
259
-	/**
260
-	 * Converts the absolute file path to a relative path from \OC::$SERVERROOT
261
-	 * @param string $filePath Absolute path
262
-	 * @return string Relative path
263
-	 * @throws \Exception If $filePath is not under \OC::$SERVERROOT
264
-	 */
265
-	public static function convertToRelativePath($filePath) {
266
-		$relativePath = explode(\OC::$SERVERROOT, $filePath);
267
-		if(count($relativePath) !== 2) {
268
-			throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
269
-		}
259
+    /**
260
+     * Converts the absolute file path to a relative path from \OC::$SERVERROOT
261
+     * @param string $filePath Absolute path
262
+     * @return string Relative path
263
+     * @throws \Exception If $filePath is not under \OC::$SERVERROOT
264
+     */
265
+    public static function convertToRelativePath($filePath) {
266
+        $relativePath = explode(\OC::$SERVERROOT, $filePath);
267
+        if(count($relativePath) !== 2) {
268
+            throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
269
+        }
270 270
 
271
-		return $relativePath[1];
272
-	}
271
+        return $relativePath[1];
272
+    }
273 273
 }
Please login to merge, or discard this patch.
apps/files/lib/App.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -27,30 +27,30 @@
 block discarded – undo
27 27
 namespace OCA\Files;
28 28
 
29 29
 class App {
30
-	/**
31
-	 * @var \OCP\INavigationManager
32
-	 */
33
-	private static $navigationManager;
30
+    /**
31
+     * @var \OCP\INavigationManager
32
+     */
33
+    private static $navigationManager;
34 34
 
35
-	/**
36
-	 * Returns the app's navigation manager
37
-	 *
38
-	 * @return \OCP\INavigationManager
39
-	 */
40
-	public static function getNavigationManager() {
41
-		// TODO: move this into a service in the Application class
42
-		if (self::$navigationManager === null) {
43
-			self::$navigationManager = new \OC\NavigationManager(
44
-				\OC::$server->getAppManager(),
45
-				\OC::$server->getURLGenerator(),
46
-				\OC::$server->getL10NFactory(),
47
-				\OC::$server->getUserSession(),
48
-				\OC::$server->getGroupManager(),
49
-				\OC::$server->getConfig()
50
-			);
51
-			self::$navigationManager->noDefaultLinks();
52
-		}
53
-		return self::$navigationManager;
54
-	}
35
+    /**
36
+     * Returns the app's navigation manager
37
+     *
38
+     * @return \OCP\INavigationManager
39
+     */
40
+    public static function getNavigationManager() {
41
+        // TODO: move this into a service in the Application class
42
+        if (self::$navigationManager === null) {
43
+            self::$navigationManager = new \OC\NavigationManager(
44
+                \OC::$server->getAppManager(),
45
+                \OC::$server->getURLGenerator(),
46
+                \OC::$server->getL10NFactory(),
47
+                \OC::$server->getUserSession(),
48
+                \OC::$server->getGroupManager(),
49
+                \OC::$server->getConfig()
50
+            );
51
+            self::$navigationManager->noDefaultLinks();
52
+        }
53
+        return self::$navigationManager;
54
+    }
55 55
 
56 56
 }
Please login to merge, or discard this patch.
lib/private/legacy/app.php 2 patches
Indentation   +1268 added lines, -1268 removed lines patch added patch discarded remove patch
@@ -61,1272 +61,1272 @@
 block discarded – undo
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
-	}
178
-
179
-	/**
180
-	 * @internal
181
-	 * @param string $app
182
-	 * @param string $path
183
-	 */
184
-	public static function registerAutoloading($app, $path) {
185
-		$key = $app . '-' . $path;
186
-		if(isset(self::$alreadyRegistered[$key])) {
187
-			return;
188
-		}
189
-		self::$alreadyRegistered[$key] = true;
190
-		// Register on PSR-4 composer autoloader
191
-		$appNamespace = \OC\AppFramework\App::buildAppNamespace($app);
192
-		\OC::$server->registerNamespace($app, $appNamespace);
193
-		\OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true);
194
-		if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) {
195
-			\OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true);
196
-		}
197
-
198
-		// Register on legacy autoloader
199
-		\OC::$loader->addValidRoot($path);
200
-	}
201
-
202
-	/**
203
-	 * Load app.php from the given app
204
-	 *
205
-	 * @param string $app app name
206
-	 */
207
-	private static function requireAppFile($app) {
208
-		try {
209
-			// encapsulated here to avoid variable scope conflicts
210
-			require_once $app . '/appinfo/app.php';
211
-		} catch (Error $ex) {
212
-			\OC::$server->getLogger()->logException($ex);
213
-			$blacklist = \OC::$server->getAppManager()->getAlwaysEnabledApps();
214
-			if (!in_array($app, $blacklist)) {
215
-				self::disable($app);
216
-			}
217
-		}
218
-	}
219
-
220
-	/**
221
-	 * check if an app is of a specific type
222
-	 *
223
-	 * @param string $app
224
-	 * @param string|array $types
225
-	 * @return bool
226
-	 */
227
-	public static function isType($app, $types) {
228
-		if (is_string($types)) {
229
-			$types = array($types);
230
-		}
231
-		$appTypes = self::getAppTypes($app);
232
-		foreach ($types as $type) {
233
-			if (array_search($type, $appTypes) !== false) {
234
-				return true;
235
-			}
236
-		}
237
-		return false;
238
-	}
239
-
240
-	/**
241
-	 * get the types of an app
242
-	 *
243
-	 * @param string $app
244
-	 * @return array
245
-	 */
246
-	private static function getAppTypes($app) {
247
-		//load the cache
248
-		if (count(self::$appTypes) == 0) {
249
-			self::$appTypes = \OC::$server->getAppConfig()->getValues(false, 'types');
250
-		}
251
-
252
-		if (isset(self::$appTypes[$app])) {
253
-			return explode(',', self::$appTypes[$app]);
254
-		} else {
255
-			return array();
256
-		}
257
-	}
258
-
259
-	/**
260
-	 * read app types from info.xml and cache them in the database
261
-	 */
262
-	public static function setAppTypes($app) {
263
-		$appData = self::getAppInfo($app);
264
-		if(!is_array($appData)) {
265
-			return;
266
-		}
267
-
268
-		if (isset($appData['types'])) {
269
-			$appTypes = implode(',', $appData['types']);
270
-		} else {
271
-			$appTypes = '';
272
-			$appData['types'] = [];
273
-		}
274
-
275
-		\OC::$server->getAppConfig()->setValue($app, 'types', $appTypes);
276
-
277
-		if (\OC::$server->getAppManager()->hasProtectedAppType($appData['types'])) {
278
-			$enabled = \OC::$server->getAppConfig()->getValue($app, 'enabled', 'yes');
279
-			if ($enabled !== 'yes' && $enabled !== 'no') {
280
-				\OC::$server->getAppConfig()->setValue($app, 'enabled', 'yes');
281
-			}
282
-		}
283
-	}
284
-
285
-	/**
286
-	 * check if app is shipped
287
-	 *
288
-	 * @param string $appId the id of the app to check
289
-	 * @return bool
290
-	 *
291
-	 * Check if an app that is installed is a shipped app or installed from the appstore.
292
-	 */
293
-	public static function isShipped($appId) {
294
-		return \OC::$server->getAppManager()->isShipped($appId);
295
-	}
296
-
297
-	/**
298
-	 * get all enabled apps
299
-	 */
300
-	protected static $enabledAppsCache = array();
301
-
302
-	/**
303
-	 * Returns apps enabled for the current user.
304
-	 *
305
-	 * @param bool $forceRefresh whether to refresh the cache
306
-	 * @param bool $all whether to return apps for all users, not only the
307
-	 * currently logged in one
308
-	 * @return string[]
309
-	 */
310
-	public static function getEnabledApps($forceRefresh = false, $all = false) {
311
-		if (!\OC::$server->getSystemConfig()->getValue('installed', false)) {
312
-			return array();
313
-		}
314
-		// in incognito mode or when logged out, $user will be false,
315
-		// which is also the case during an upgrade
316
-		$appManager = \OC::$server->getAppManager();
317
-		if ($all) {
318
-			$user = null;
319
-		} else {
320
-			$user = \OC::$server->getUserSession()->getUser();
321
-		}
322
-
323
-		if (is_null($user)) {
324
-			$apps = $appManager->getInstalledApps();
325
-		} else {
326
-			$apps = $appManager->getEnabledAppsForUser($user);
327
-		}
328
-		$apps = array_filter($apps, function ($app) {
329
-			return $app !== 'files';//we add this manually
330
-		});
331
-		sort($apps);
332
-		array_unshift($apps, 'files');
333
-		return $apps;
334
-	}
335
-
336
-	/**
337
-	 * checks whether or not an app is enabled
338
-	 *
339
-	 * @param string $app app
340
-	 * @return bool
341
-	 *
342
-	 * This function checks whether or not an app is enabled.
343
-	 */
344
-	public static function isEnabled($app) {
345
-		return \OC::$server->getAppManager()->isEnabledForUser($app);
346
-	}
347
-
348
-	/**
349
-	 * enables an app
350
-	 *
351
-	 * @param string $appId
352
-	 * @param array $groups (optional) when set, only these groups will have access to the app
353
-	 * @throws \Exception
354
-	 * @return void
355
-	 *
356
-	 * This function set an app as enabled in appconfig.
357
-	 */
358
-	public function enable($appId,
359
-						   $groups = null) {
360
-		self::$enabledAppsCache = []; // flush
361
-		$l = \OC::$server->getL10N('core');
362
-		$config = \OC::$server->getConfig();
363
-
364
-		// Check if app is already downloaded
365
-		$installer = new Installer(
366
-			\OC::$server->getAppFetcher(),
367
-			\OC::$server->getHTTPClientService(),
368
-			\OC::$server->getTempManager(),
369
-			\OC::$server->getLogger()
370
-		);
371
-		$isDownloaded = $installer->isDownloaded($appId);
372
-
373
-		if(!$isDownloaded) {
374
-			$installer->downloadApp($appId);
375
-		}
376
-
377
-		if (!Installer::isInstalled($appId)) {
378
-			$appId = self::installApp(
379
-				$appId,
380
-				$config,
381
-				$l
382
-			);
383
-			$appPath = self::getAppPath($appId);
384
-			self::registerAutoloading($appId, $appPath);
385
-			$installer->installApp($appId);
386
-		} else {
387
-			// check for required dependencies
388
-			$info = self::getAppInfo($appId);
389
-			self::checkAppDependencies($config, $l, $info);
390
-			$appPath = self::getAppPath($appId);
391
-			self::registerAutoloading($appId, $appPath);
392
-			$installer->installApp($appId);
393
-		}
394
-
395
-		$appManager = \OC::$server->getAppManager();
396
-		if (!is_null($groups)) {
397
-			$groupManager = \OC::$server->getGroupManager();
398
-			$groupsList = [];
399
-			foreach ($groups as $group) {
400
-				$groupItem = $groupManager->get($group);
401
-				if ($groupItem instanceof \OCP\IGroup) {
402
-					$groupsList[] = $groupManager->get($group);
403
-				}
404
-			}
405
-			$appManager->enableAppForGroups($appId, $groupsList);
406
-		} else {
407
-			$appManager->enableApp($appId);
408
-		}
409
-
410
-		$info = self::getAppInfo($appId);
411
-		if(isset($info['settings']) && is_array($info['settings'])) {
412
-			$appPath = self::getAppPath($appId);
413
-			self::registerAutoloading($appId, $appPath);
414
-			\OC::$server->getSettingsManager()->setupSettings($info['settings']);
415
-		}
416
-	}
417
-
418
-	/**
419
-	 * @param string $app
420
-	 * @return bool
421
-	 */
422
-	public static function removeApp($app) {
423
-		if (self::isShipped($app)) {
424
-			return false;
425
-		}
426
-
427
-		$installer = new Installer(
428
-			\OC::$server->getAppFetcher(),
429
-			\OC::$server->getHTTPClientService(),
430
-			\OC::$server->getTempManager(),
431
-			\OC::$server->getLogger()
432
-		);
433
-		return $installer->removeApp($app);
434
-	}
435
-
436
-	/**
437
-	 * This function set an app as disabled in appconfig.
438
-	 *
439
-	 * @param string $app app
440
-	 * @throws Exception
441
-	 */
442
-	public static function disable($app) {
443
-		// flush
444
-		self::$enabledAppsCache = array();
445
-
446
-		// run uninstall steps
447
-		$appData = OC_App::getAppInfo($app);
448
-		if (!is_null($appData)) {
449
-			OC_App::executeRepairSteps($app, $appData['repair-steps']['uninstall']);
450
-		}
451
-
452
-		// emit disable hook - needed anymore ?
453
-		\OC_Hook::emit('OC_App', 'pre_disable', array('app' => $app));
454
-
455
-		// finally disable it
456
-		$appManager = \OC::$server->getAppManager();
457
-		$appManager->disableApp($app);
458
-	}
459
-
460
-	// This is private as well. It simply works, so don't ask for more details
461
-	private static function proceedNavigation($list) {
462
-		$headerIconCount = 8;
463
-		usort($list, function($a, $b) {
464
-			if (isset($a['order']) && isset($b['order'])) {
465
-				return ($a['order'] < $b['order']) ? -1 : 1;
466
-			} else if (isset($a['order']) || isset($b['order'])) {
467
-				return isset($a['order']) ? -1 : 1;
468
-			} else {
469
-				return ($a['name'] < $b['name']) ? -1 : 1;
470
-			}
471
-		});
472
-
473
-		$activeAppIndex = -1;
474
-		$activeApp = OC::$server->getNavigationManager()->getActiveEntry();
475
-		foreach ($list as $index => &$navEntry) {
476
-			if ($navEntry['id'] == $activeApp) {
477
-				$navEntry['active'] = true;
478
-				$activeAppIndex = $index;
479
-			} else {
480
-				$navEntry['active'] = false;
481
-			}
482
-		}
483
-		unset($navEntry);
484
-
485
-		if($activeAppIndex > ($headerIconCount-1)) {
486
-			$active = $list[$activeAppIndex];
487
-			$lastInHeader = $list[$headerIconCount-1];
488
-			$list[$headerIconCount-1] = $active;
489
-			$list[$activeAppIndex] = $lastInHeader;
490
-		}
491
-
492
-		foreach ($list as $index => &$navEntry) {
493
-			$navEntry['showInHeader'] = false;
494
-			if($index < $headerIconCount) {
495
-				$navEntry['showInHeader'] = true;
496
-			}
497
-		}
498
-
499
-
500
-
501
-		return $list;
502
-	}
503
-
504
-	public static function proceedAppNavigation($entries) {
505
-		$headerIconCount = 8;
506
-		$activeAppIndex = -1;
507
-		$list = self::proceedNavigation($entries);
508
-
509
-		$activeApp = OC::$server->getNavigationManager()->getActiveEntry();
510
-		foreach ($list as $index => &$navEntry) {
511
-			if ($navEntry['id'] == $activeApp) {
512
-				$navEntry['active'] = true;
513
-				$activeAppIndex = $index;
514
-			} else {
515
-				$navEntry['active'] = false;
516
-			}
517
-		}
518
-		// move active item to last position
519
-		if($activeAppIndex > ($headerIconCount-1)) {
520
-			$active = $list[$activeAppIndex];
521
-			$lastInHeader = $list[$headerIconCount-1];
522
-			$list[$headerIconCount-1] = $active;
523
-			$list[$activeAppIndex] = $lastInHeader;
524
-		}
525
-		$list = array_slice($list, 0, $headerIconCount);
526
-
527
-		return $list;
528
-	}
529
-
530
-	/**
531
-	 * Get the path where to install apps
532
-	 *
533
-	 * @return string|false
534
-	 */
535
-	public static function getInstallPath() {
536
-		if (\OC::$server->getSystemConfig()->getValue('appstoreenabled', true) == false) {
537
-			return false;
538
-		}
539
-
540
-		foreach (OC::$APPSROOTS as $dir) {
541
-			if (isset($dir['writable']) && $dir['writable'] === true) {
542
-				return $dir['path'];
543
-			}
544
-		}
545
-
546
-		\OCP\Util::writeLog('core', 'No application directories are marked as writable.', \OCP\Util::ERROR);
547
-		return null;
548
-	}
549
-
550
-
551
-	/**
552
-	 * search for an app in all app-directories
553
-	 *
554
-	 * @param string $appId
555
-	 * @return false|string
556
-	 */
557
-	public static function findAppInDirectories($appId) {
558
-		$sanitizedAppId = self::cleanAppId($appId);
559
-		if($sanitizedAppId !== $appId) {
560
-			return false;
561
-		}
562
-		static $app_dir = array();
563
-
564
-		if (isset($app_dir[$appId])) {
565
-			return $app_dir[$appId];
566
-		}
567
-
568
-		$possibleApps = array();
569
-		foreach (OC::$APPSROOTS as $dir) {
570
-			if (file_exists($dir['path'] . '/' . $appId)) {
571
-				$possibleApps[] = $dir;
572
-			}
573
-		}
574
-
575
-		if (empty($possibleApps)) {
576
-			return false;
577
-		} elseif (count($possibleApps) === 1) {
578
-			$dir = array_shift($possibleApps);
579
-			$app_dir[$appId] = $dir;
580
-			return $dir;
581
-		} else {
582
-			$versionToLoad = array();
583
-			foreach ($possibleApps as $possibleApp) {
584
-				$version = self::getAppVersionByPath($possibleApp['path']);
585
-				if (empty($versionToLoad) || version_compare($version, $versionToLoad['version'], '>')) {
586
-					$versionToLoad = array(
587
-						'dir' => $possibleApp,
588
-						'version' => $version,
589
-					);
590
-				}
591
-			}
592
-			$app_dir[$appId] = $versionToLoad['dir'];
593
-			return $versionToLoad['dir'];
594
-			//TODO - write test
595
-		}
596
-	}
597
-
598
-	/**
599
-	 * Get the directory for the given app.
600
-	 * If the app is defined in multiple directories, the first one is taken. (false if not found)
601
-	 *
602
-	 * @param string $appId
603
-	 * @return string|false
604
-	 */
605
-	public static function getAppPath($appId) {
606
-		if ($appId === null || trim($appId) === '') {
607
-			return false;
608
-		}
609
-
610
-		if (($dir = self::findAppInDirectories($appId)) != false) {
611
-			return $dir['path'] . '/' . $appId;
612
-		}
613
-		return false;
614
-	}
615
-
616
-	/**
617
-	 * Get the path for the given app on the access
618
-	 * If the app is defined in multiple directories, the first one is taken. (false if not found)
619
-	 *
620
-	 * @param string $appId
621
-	 * @return string|false
622
-	 */
623
-	public static function getAppWebPath($appId) {
624
-		if (($dir = self::findAppInDirectories($appId)) != false) {
625
-			return OC::$WEBROOT . $dir['url'] . '/' . $appId;
626
-		}
627
-		return false;
628
-	}
629
-
630
-	/**
631
-	 * get the last version of the app from appinfo/info.xml
632
-	 *
633
-	 * @param string $appId
634
-	 * @param bool $useCache
635
-	 * @return string
636
-	 */
637
-	public static function getAppVersion($appId, $useCache = true) {
638
-		if($useCache && isset(self::$appVersion[$appId])) {
639
-			return self::$appVersion[$appId];
640
-		}
641
-
642
-		$file = self::getAppPath($appId);
643
-		self::$appVersion[$appId] = ($file !== false) ? self::getAppVersionByPath($file) : '0';
644
-		return self::$appVersion[$appId];
645
-	}
646
-
647
-	/**
648
-	 * get app's version based on it's path
649
-	 *
650
-	 * @param string $path
651
-	 * @return string
652
-	 */
653
-	public static function getAppVersionByPath($path) {
654
-		$infoFile = $path . '/appinfo/info.xml';
655
-		$appData = self::getAppInfo($infoFile, true);
656
-		return isset($appData['version']) ? $appData['version'] : '';
657
-	}
658
-
659
-
660
-	/**
661
-	 * Read all app metadata from the info.xml file
662
-	 *
663
-	 * @param string $appId id of the app or the path of the info.xml file
664
-	 * @param bool $path
665
-	 * @param string $lang
666
-	 * @return array|null
667
-	 * @note all data is read from info.xml, not just pre-defined fields
668
-	 */
669
-	public static function getAppInfo($appId, $path = false, $lang = null) {
670
-		if ($path) {
671
-			$file = $appId;
672
-		} else {
673
-			if ($lang === null && isset(self::$appInfo[$appId])) {
674
-				return self::$appInfo[$appId];
675
-			}
676
-			$appPath = self::getAppPath($appId);
677
-			if($appPath === false) {
678
-				return null;
679
-			}
680
-			$file = $appPath . '/appinfo/info.xml';
681
-		}
682
-
683
-		$parser = new InfoParser(\OC::$server->getMemCacheFactory()->create('core.appinfo'));
684
-		$data = $parser->parse($file);
685
-
686
-		if (is_array($data)) {
687
-			$data = OC_App::parseAppInfo($data, $lang);
688
-		}
689
-		if(isset($data['ocsid'])) {
690
-			$storedId = \OC::$server->getConfig()->getAppValue($appId, 'ocsid');
691
-			if($storedId !== '' && $storedId !== $data['ocsid']) {
692
-				$data['ocsid'] = $storedId;
693
-			}
694
-		}
695
-
696
-		if ($lang === null) {
697
-			self::$appInfo[$appId] = $data;
698
-		}
699
-
700
-		return $data;
701
-	}
702
-
703
-	/**
704
-	 * Returns the navigation
705
-	 *
706
-	 * @return array
707
-	 *
708
-	 * This function returns an array containing all entries added. The
709
-	 * entries are sorted by the key 'order' ascending. Additional to the keys
710
-	 * given for each app the following keys exist:
711
-	 *   - active: boolean, signals if the user is on this navigation entry
712
-	 */
713
-	public static function getNavigation() {
714
-		$entries = OC::$server->getNavigationManager()->getAll();
715
-		return self::proceedNavigation($entries);
716
-	}
717
-
718
-	/**
719
-	 * Returns the navigation inside the header bar
720
-	 *
721
-	 * @return array
722
-	 *
723
-	 * This function returns an array containing all entries added. The
724
-	 * entries are sorted by the key 'order' ascending. Additional to the keys
725
-	 * given for each app the following keys exist:
726
-	 *   - active: boolean, signals if the user is on this navigation entry
727
-	 */
728
-	public static function getHeaderNavigation() {
729
-		$entries = OC::$server->getNavigationManager()->getAll();
730
-		return self::proceedAppNavigation($entries);
731
-	}
732
-
733
-	/**
734
-	 * Returns the Settings Navigation
735
-	 *
736
-	 * @return string[]
737
-	 *
738
-	 * This function returns an array containing all settings pages added. The
739
-	 * entries are sorted by the key 'order' ascending.
740
-	 */
741
-	public static function getSettingsNavigation() {
742
-		$entries = OC::$server->getNavigationManager()->getAll('settings');
743
-		return self::proceedNavigation($entries);
744
-	}
745
-
746
-	/**
747
-	 * get the id of loaded app
748
-	 *
749
-	 * @return string
750
-	 */
751
-	public static function getCurrentApp() {
752
-		$request = \OC::$server->getRequest();
753
-		$script = substr($request->getScriptName(), strlen(OC::$WEBROOT) + 1);
754
-		$topFolder = substr($script, 0, strpos($script, '/'));
755
-		if (empty($topFolder)) {
756
-			$path_info = $request->getPathInfo();
757
-			if ($path_info) {
758
-				$topFolder = substr($path_info, 1, strpos($path_info, '/', 1) - 1);
759
-			}
760
-		}
761
-		if ($topFolder == 'apps') {
762
-			$length = strlen($topFolder);
763
-			return substr($script, $length + 1, strpos($script, '/', $length + 1) - $length - 1);
764
-		} else {
765
-			return $topFolder;
766
-		}
767
-	}
768
-
769
-	/**
770
-	 * @param string $type
771
-	 * @return array
772
-	 */
773
-	public static function getForms($type) {
774
-		$forms = array();
775
-		switch ($type) {
776
-			case 'admin':
777
-				$source = self::$adminForms;
778
-				break;
779
-			case 'personal':
780
-				$source = self::$personalForms;
781
-				break;
782
-			default:
783
-				return array();
784
-		}
785
-		foreach ($source as $form) {
786
-			$forms[] = include $form;
787
-		}
788
-		return $forms;
789
-	}
790
-
791
-	/**
792
-	 * register an admin form to be shown
793
-	 *
794
-	 * @param string $app
795
-	 * @param string $page
796
-	 */
797
-	public static function registerAdmin($app, $page) {
798
-		self::$adminForms[] = $app . '/' . $page . '.php';
799
-	}
800
-
801
-	/**
802
-	 * register a personal form to be shown
803
-	 * @param string $app
804
-	 * @param string $page
805
-	 */
806
-	public static function registerPersonal($app, $page) {
807
-		self::$personalForms[] = $app . '/' . $page . '.php';
808
-	}
809
-
810
-	/**
811
-	 * @param array $entry
812
-	 */
813
-	public static function registerLogIn(array $entry) {
814
-		self::$altLogin[] = $entry;
815
-	}
816
-
817
-	/**
818
-	 * @return array
819
-	 */
820
-	public static function getAlternativeLogIns() {
821
-		return self::$altLogin;
822
-	}
823
-
824
-	/**
825
-	 * get a list of all apps in the apps folder
826
-	 *
827
-	 * @return array an array of app names (string IDs)
828
-	 * @todo: change the name of this method to getInstalledApps, which is more accurate
829
-	 */
830
-	public static function getAllApps() {
831
-
832
-		$apps = array();
833
-
834
-		foreach (OC::$APPSROOTS as $apps_dir) {
835
-			if (!is_readable($apps_dir['path'])) {
836
-				\OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], \OCP\Util::WARN);
837
-				continue;
838
-			}
839
-			$dh = opendir($apps_dir['path']);
840
-
841
-			if (is_resource($dh)) {
842
-				while (($file = readdir($dh)) !== false) {
843
-
844
-					if ($file[0] != '.' and is_dir($apps_dir['path'] . '/' . $file) and is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')) {
845
-
846
-						$apps[] = $file;
847
-					}
848
-				}
849
-			}
850
-		}
851
-
852
-		return $apps;
853
-	}
854
-
855
-	/**
856
-	 * List all apps, this is used in apps.php
857
-	 *
858
-	 * @return array
859
-	 */
860
-	public function listAllApps() {
861
-		$installedApps = OC_App::getAllApps();
862
-
863
-		//we don't want to show configuration for these
864
-		$blacklist = \OC::$server->getAppManager()->getAlwaysEnabledApps();
865
-		$appList = array();
866
-		$langCode = \OC::$server->getL10N('core')->getLanguageCode();
867
-		$urlGenerator = \OC::$server->getURLGenerator();
868
-
869
-		foreach ($installedApps as $app) {
870
-			if (array_search($app, $blacklist) === false) {
871
-
872
-				$info = OC_App::getAppInfo($app, false, $langCode);
873
-				if (!is_array($info)) {
874
-					\OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', \OCP\Util::ERROR);
875
-					continue;
876
-				}
877
-
878
-				if (!isset($info['name'])) {
879
-					\OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', \OCP\Util::ERROR);
880
-					continue;
881
-				}
882
-
883
-				$enabled = \OC::$server->getAppConfig()->getValue($app, 'enabled', 'no');
884
-				$info['groups'] = null;
885
-				if ($enabled === 'yes') {
886
-					$active = true;
887
-				} else if ($enabled === 'no') {
888
-					$active = false;
889
-				} else {
890
-					$active = true;
891
-					$info['groups'] = $enabled;
892
-				}
893
-
894
-				$info['active'] = $active;
895
-
896
-				if (self::isShipped($app)) {
897
-					$info['internal'] = true;
898
-					$info['level'] = self::officialApp;
899
-					$info['removable'] = false;
900
-				} else {
901
-					$info['internal'] = false;
902
-					$info['removable'] = true;
903
-				}
904
-
905
-				$appPath = self::getAppPath($app);
906
-				if($appPath !== false) {
907
-					$appIcon = $appPath . '/img/' . $app . '.svg';
908
-					if (file_exists($appIcon)) {
909
-						$info['preview'] = \OC::$server->getURLGenerator()->imagePath($app, $app . '.svg');
910
-						$info['previewAsIcon'] = true;
911
-					} else {
912
-						$appIcon = $appPath . '/img/app.svg';
913
-						if (file_exists($appIcon)) {
914
-							$info['preview'] = \OC::$server->getURLGenerator()->imagePath($app, 'app.svg');
915
-							$info['previewAsIcon'] = true;
916
-						}
917
-					}
918
-				}
919
-				// fix documentation
920
-				if (isset($info['documentation']) && is_array($info['documentation'])) {
921
-					foreach ($info['documentation'] as $key => $url) {
922
-						// If it is not an absolute URL we assume it is a key
923
-						// i.e. admin-ldap will get converted to go.php?to=admin-ldap
924
-						if (stripos($url, 'https://') !== 0 && stripos($url, 'http://') !== 0) {
925
-							$url = $urlGenerator->linkToDocs($url);
926
-						}
927
-
928
-						$info['documentation'][$key] = $url;
929
-					}
930
-				}
931
-
932
-				$info['version'] = OC_App::getAppVersion($app);
933
-				$appList[] = $info;
934
-			}
935
-		}
936
-
937
-		return $appList;
938
-	}
939
-
940
-	/**
941
-	 * Returns the internal app ID or false
942
-	 * @param string $ocsID
943
-	 * @return string|false
944
-	 */
945
-	public static function getInternalAppIdByOcs($ocsID) {
946
-		if(is_numeric($ocsID)) {
947
-			$idArray = \OC::$server->getAppConfig()->getValues(false, 'ocsid');
948
-			if(array_search($ocsID, $idArray)) {
949
-				return array_search($ocsID, $idArray);
950
-			}
951
-		}
952
-		return false;
953
-	}
954
-
955
-	public static function shouldUpgrade($app) {
956
-		$versions = self::getAppVersions();
957
-		$currentVersion = OC_App::getAppVersion($app);
958
-		if ($currentVersion && isset($versions[$app])) {
959
-			$installedVersion = $versions[$app];
960
-			if (!version_compare($currentVersion, $installedVersion, '=')) {
961
-				return true;
962
-			}
963
-		}
964
-		return false;
965
-	}
966
-
967
-	/**
968
-	 * Adjust the number of version parts of $version1 to match
969
-	 * the number of version parts of $version2.
970
-	 *
971
-	 * @param string $version1 version to adjust
972
-	 * @param string $version2 version to take the number of parts from
973
-	 * @return string shortened $version1
974
-	 */
975
-	private static function adjustVersionParts($version1, $version2) {
976
-		$version1 = explode('.', $version1);
977
-		$version2 = explode('.', $version2);
978
-		// reduce $version1 to match the number of parts in $version2
979
-		while (count($version1) > count($version2)) {
980
-			array_pop($version1);
981
-		}
982
-		// if $version1 does not have enough parts, add some
983
-		while (count($version1) < count($version2)) {
984
-			$version1[] = '0';
985
-		}
986
-		return implode('.', $version1);
987
-	}
988
-
989
-	/**
990
-	 * Check whether the current ownCloud version matches the given
991
-	 * application's version requirements.
992
-	 *
993
-	 * The comparison is made based on the number of parts that the
994
-	 * app info version has. For example for ownCloud 6.0.3 if the
995
-	 * app info version is expecting version 6.0, the comparison is
996
-	 * made on the first two parts of the ownCloud version.
997
-	 * This means that it's possible to specify "requiremin" => 6
998
-	 * and "requiremax" => 6 and it will still match ownCloud 6.0.3.
999
-	 *
1000
-	 * @param string $ocVersion ownCloud version to check against
1001
-	 * @param array $appInfo app info (from xml)
1002
-	 *
1003
-	 * @return boolean true if compatible, otherwise false
1004
-	 */
1005
-	public static function isAppCompatible($ocVersion, $appInfo) {
1006
-		$requireMin = '';
1007
-		$requireMax = '';
1008
-		if (isset($appInfo['dependencies']['nextcloud']['@attributes']['min-version'])) {
1009
-			$requireMin = $appInfo['dependencies']['nextcloud']['@attributes']['min-version'];
1010
-		} elseif (isset($appInfo['dependencies']['owncloud']['@attributes']['min-version'])) {
1011
-			$requireMin = $appInfo['dependencies']['owncloud']['@attributes']['min-version'];
1012
-		} else if (isset($appInfo['requiremin'])) {
1013
-			$requireMin = $appInfo['requiremin'];
1014
-		} else if (isset($appInfo['require'])) {
1015
-			$requireMin = $appInfo['require'];
1016
-		}
1017
-
1018
-		if (isset($appInfo['dependencies']['nextcloud']['@attributes']['max-version'])) {
1019
-			$requireMax = $appInfo['dependencies']['nextcloud']['@attributes']['max-version'];
1020
-		} elseif (isset($appInfo['dependencies']['owncloud']['@attributes']['max-version'])) {
1021
-			$requireMax = $appInfo['dependencies']['owncloud']['@attributes']['max-version'];
1022
-		} else if (isset($appInfo['requiremax'])) {
1023
-			$requireMax = $appInfo['requiremax'];
1024
-		}
1025
-
1026
-		if (is_array($ocVersion)) {
1027
-			$ocVersion = implode('.', $ocVersion);
1028
-		}
1029
-
1030
-		if (!empty($requireMin)
1031
-			&& version_compare(self::adjustVersionParts($ocVersion, $requireMin), $requireMin, '<')
1032
-		) {
1033
-
1034
-			return false;
1035
-		}
1036
-
1037
-		if (!empty($requireMax)
1038
-			&& version_compare(self::adjustVersionParts($ocVersion, $requireMax), $requireMax, '>')
1039
-		) {
1040
-			return false;
1041
-		}
1042
-
1043
-		return true;
1044
-	}
1045
-
1046
-	/**
1047
-	 * get the installed version of all apps
1048
-	 */
1049
-	public static function getAppVersions() {
1050
-		static $versions;
1051
-
1052
-		if(!$versions) {
1053
-			$appConfig = \OC::$server->getAppConfig();
1054
-			$versions = $appConfig->getValues(false, 'installed_version');
1055
-		}
1056
-		return $versions;
1057
-	}
1058
-
1059
-	/**
1060
-	 * @param string $app
1061
-	 * @param \OCP\IConfig $config
1062
-	 * @param \OCP\IL10N $l
1063
-	 * @return bool
1064
-	 *
1065
-	 * @throws Exception if app is not compatible with this version of ownCloud
1066
-	 * @throws Exception if no app-name was specified
1067
-	 */
1068
-	public function installApp($app,
1069
-							   \OCP\IConfig $config,
1070
-							   \OCP\IL10N $l) {
1071
-		if ($app !== false) {
1072
-			// check if the app is compatible with this version of ownCloud
1073
-			$info = self::getAppInfo($app);
1074
-			if(!is_array($info)) {
1075
-				throw new \Exception(
1076
-					$l->t('App "%s" cannot be installed because appinfo file cannot be read.',
1077
-						[$info['name']]
1078
-					)
1079
-				);
1080
-			}
1081
-
1082
-			$version = \OCP\Util::getVersion();
1083
-			if (!self::isAppCompatible($version, $info)) {
1084
-				throw new \Exception(
1085
-					$l->t('App "%s" cannot be installed because it is not compatible with this version of the server.',
1086
-						array($info['name'])
1087
-					)
1088
-				);
1089
-			}
1090
-
1091
-			// check for required dependencies
1092
-			self::checkAppDependencies($config, $l, $info);
1093
-
1094
-			$config->setAppValue($app, 'enabled', 'yes');
1095
-			if (isset($appData['id'])) {
1096
-				$config->setAppValue($app, 'ocsid', $appData['id']);
1097
-			}
1098
-
1099
-			if(isset($info['settings']) && is_array($info['settings'])) {
1100
-				$appPath = self::getAppPath($app);
1101
-				self::registerAutoloading($app, $appPath);
1102
-				\OC::$server->getSettingsManager()->setupSettings($info['settings']);
1103
-			}
1104
-
1105
-			\OC_Hook::emit('OC_App', 'post_enable', array('app' => $app));
1106
-		} else {
1107
-			if(empty($appName) ) {
1108
-				throw new \Exception($l->t("No app name specified"));
1109
-			} else {
1110
-				throw new \Exception($l->t("App '%s' could not be installed!", $appName));
1111
-			}
1112
-		}
1113
-
1114
-		return $app;
1115
-	}
1116
-
1117
-	/**
1118
-	 * update the database for the app and call the update script
1119
-	 *
1120
-	 * @param string $appId
1121
-	 * @return bool
1122
-	 */
1123
-	public static function updateApp($appId) {
1124
-		$appPath = self::getAppPath($appId);
1125
-		if($appPath === false) {
1126
-			return false;
1127
-		}
1128
-		$appData = self::getAppInfo($appId);
1129
-		self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']);
1130
-		if (file_exists($appPath . '/appinfo/database.xml')) {
1131
-			OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml');
1132
-		}
1133
-		self::executeRepairSteps($appId, $appData['repair-steps']['post-migration']);
1134
-		self::setupLiveMigrations($appId, $appData['repair-steps']['live-migration']);
1135
-		unset(self::$appVersion[$appId]);
1136
-		// run upgrade code
1137
-		if (file_exists($appPath . '/appinfo/update.php')) {
1138
-			self::loadApp($appId);
1139
-			include $appPath . '/appinfo/update.php';
1140
-		}
1141
-		self::setupBackgroundJobs($appData['background-jobs']);
1142
-		if(isset($appData['settings']) && is_array($appData['settings'])) {
1143
-			$appPath = self::getAppPath($appId);
1144
-			self::registerAutoloading($appId, $appPath);
1145
-			\OC::$server->getSettingsManager()->setupSettings($appData['settings']);
1146
-		}
1147
-
1148
-		//set remote/public handlers
1149
-		if (array_key_exists('ocsid', $appData)) {
1150
-			\OC::$server->getConfig()->setAppValue($appId, 'ocsid', $appData['ocsid']);
1151
-		} elseif(\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) {
1152
-			\OC::$server->getConfig()->deleteAppValue($appId, 'ocsid');
1153
-		}
1154
-		foreach ($appData['remote'] as $name => $path) {
1155
-			\OC::$server->getConfig()->setAppValue('core', 'remote_' . $name, $appId . '/' . $path);
1156
-		}
1157
-		foreach ($appData['public'] as $name => $path) {
1158
-			\OC::$server->getConfig()->setAppValue('core', 'public_' . $name, $appId . '/' . $path);
1159
-		}
1160
-
1161
-		self::setAppTypes($appId);
1162
-
1163
-		$version = \OC_App::getAppVersion($appId);
1164
-		\OC::$server->getAppConfig()->setValue($appId, 'installed_version', $version);
1165
-
1166
-		\OC::$server->getEventDispatcher()->dispatch(ManagerEvent::EVENT_APP_UPDATE, new ManagerEvent(
1167
-			ManagerEvent::EVENT_APP_UPDATE, $appId
1168
-		));
1169
-
1170
-		return true;
1171
-	}
1172
-
1173
-	/**
1174
-	 * @param string $appId
1175
-	 * @param string[] $steps
1176
-	 * @throws \OC\NeedsUpdateException
1177
-	 */
1178
-	public static function executeRepairSteps($appId, array $steps) {
1179
-		if (empty($steps)) {
1180
-			return;
1181
-		}
1182
-		// load the app
1183
-		self::loadApp($appId);
1184
-
1185
-		$dispatcher = OC::$server->getEventDispatcher();
1186
-
1187
-		// load the steps
1188
-		$r = new Repair([], $dispatcher);
1189
-		foreach ($steps as $step) {
1190
-			try {
1191
-				$r->addStep($step);
1192
-			} catch (Exception $ex) {
1193
-				$r->emit('\OC\Repair', 'error', [$ex->getMessage()]);
1194
-				\OC::$server->getLogger()->logException($ex);
1195
-			}
1196
-		}
1197
-		// run the steps
1198
-		$r->run();
1199
-	}
1200
-
1201
-	public static function setupBackgroundJobs(array $jobs) {
1202
-		$queue = \OC::$server->getJobList();
1203
-		foreach ($jobs as $job) {
1204
-			$queue->add($job);
1205
-		}
1206
-	}
1207
-
1208
-	/**
1209
-	 * @param string $appId
1210
-	 * @param string[] $steps
1211
-	 */
1212
-	private static function setupLiveMigrations($appId, array $steps) {
1213
-		$queue = \OC::$server->getJobList();
1214
-		foreach ($steps as $step) {
1215
-			$queue->add('OC\Migration\BackgroundRepair', [
1216
-				'app' => $appId,
1217
-				'step' => $step]);
1218
-		}
1219
-	}
1220
-
1221
-	/**
1222
-	 * @param string $appId
1223
-	 * @return \OC\Files\View|false
1224
-	 */
1225
-	public static function getStorage($appId) {
1226
-		if (OC_App::isEnabled($appId)) { //sanity check
1227
-			if (\OC::$server->getUserSession()->isLoggedIn()) {
1228
-				$view = new \OC\Files\View('/' . OC_User::getUser());
1229
-				if (!$view->file_exists($appId)) {
1230
-					$view->mkdir($appId);
1231
-				}
1232
-				return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId);
1233
-			} else {
1234
-				\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', \OCP\Util::ERROR);
1235
-				return false;
1236
-			}
1237
-		} else {
1238
-			\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', \OCP\Util::ERROR);
1239
-			return false;
1240
-		}
1241
-	}
1242
-
1243
-	protected static function findBestL10NOption($options, $lang) {
1244
-		$fallback = $similarLangFallback = $englishFallback = false;
1245
-
1246
-		$lang = strtolower($lang);
1247
-		$similarLang = $lang;
1248
-		if (strpos($similarLang, '_')) {
1249
-			// For "de_DE" we want to find "de" and the other way around
1250
-			$similarLang = substr($lang, 0, strpos($lang, '_'));
1251
-		}
1252
-
1253
-		foreach ($options as $option) {
1254
-			if (is_array($option)) {
1255
-				if ($fallback === false) {
1256
-					$fallback = $option['@value'];
1257
-				}
1258
-
1259
-				if (!isset($option['@attributes']['lang'])) {
1260
-					continue;
1261
-				}
1262
-
1263
-				$attributeLang = strtolower($option['@attributes']['lang']);
1264
-				if ($attributeLang === $lang) {
1265
-					return $option['@value'];
1266
-				}
1267
-
1268
-				if ($attributeLang === $similarLang) {
1269
-					$similarLangFallback = $option['@value'];
1270
-				} else if (strpos($attributeLang, $similarLang . '_') === 0) {
1271
-					if ($similarLangFallback === false) {
1272
-						$similarLangFallback =  $option['@value'];
1273
-					}
1274
-				}
1275
-			} else {
1276
-				$englishFallback = $option;
1277
-			}
1278
-		}
1279
-
1280
-		if ($similarLangFallback !== false) {
1281
-			return $similarLangFallback;
1282
-		} else if ($englishFallback !== false) {
1283
-			return $englishFallback;
1284
-		}
1285
-		return (string) $fallback;
1286
-	}
1287
-
1288
-	/**
1289
-	 * parses the app data array and enhanced the 'description' value
1290
-	 *
1291
-	 * @param array $data the app data
1292
-	 * @param string $lang
1293
-	 * @return array improved app data
1294
-	 */
1295
-	public static function parseAppInfo(array $data, $lang = null) {
1296
-
1297
-		if ($lang && isset($data['name']) && is_array($data['name'])) {
1298
-			$data['name'] = self::findBestL10NOption($data['name'], $lang);
1299
-		}
1300
-		if ($lang && isset($data['summary']) && is_array($data['summary'])) {
1301
-			$data['summary'] = self::findBestL10NOption($data['summary'], $lang);
1302
-		}
1303
-		if ($lang && isset($data['description']) && is_array($data['description'])) {
1304
-			$data['description'] = trim(self::findBestL10NOption($data['description'], $lang));
1305
-		} else if (isset($data['description']) && is_string($data['description'])) {
1306
-			$data['description'] = trim($data['description']);
1307
-		} else  {
1308
-			$data['description'] = '';
1309
-		}
1310
-
1311
-		return $data;
1312
-	}
1313
-
1314
-	/**
1315
-	 * @param \OCP\IConfig $config
1316
-	 * @param \OCP\IL10N $l
1317
-	 * @param array $info
1318
-	 * @throws \Exception
1319
-	 */
1320
-	protected static function checkAppDependencies($config, $l, $info) {
1321
-		$dependencyAnalyzer = new DependencyAnalyzer(new Platform($config), $l);
1322
-		$missing = $dependencyAnalyzer->analyze($info);
1323
-		if (!empty($missing)) {
1324
-			$missingMsg = join(PHP_EOL, $missing);
1325
-			throw new \Exception(
1326
-				$l->t('App "%s" cannot be installed because the following dependencies are not fulfilled: %s',
1327
-					[$info['name'], $missingMsg]
1328
-				)
1329
-			);
1330
-		}
1331
-	}
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
+    }
178
+
179
+    /**
180
+     * @internal
181
+     * @param string $app
182
+     * @param string $path
183
+     */
184
+    public static function registerAutoloading($app, $path) {
185
+        $key = $app . '-' . $path;
186
+        if(isset(self::$alreadyRegistered[$key])) {
187
+            return;
188
+        }
189
+        self::$alreadyRegistered[$key] = true;
190
+        // Register on PSR-4 composer autoloader
191
+        $appNamespace = \OC\AppFramework\App::buildAppNamespace($app);
192
+        \OC::$server->registerNamespace($app, $appNamespace);
193
+        \OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true);
194
+        if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) {
195
+            \OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true);
196
+        }
197
+
198
+        // Register on legacy autoloader
199
+        \OC::$loader->addValidRoot($path);
200
+    }
201
+
202
+    /**
203
+     * Load app.php from the given app
204
+     *
205
+     * @param string $app app name
206
+     */
207
+    private static function requireAppFile($app) {
208
+        try {
209
+            // encapsulated here to avoid variable scope conflicts
210
+            require_once $app . '/appinfo/app.php';
211
+        } catch (Error $ex) {
212
+            \OC::$server->getLogger()->logException($ex);
213
+            $blacklist = \OC::$server->getAppManager()->getAlwaysEnabledApps();
214
+            if (!in_array($app, $blacklist)) {
215
+                self::disable($app);
216
+            }
217
+        }
218
+    }
219
+
220
+    /**
221
+     * check if an app is of a specific type
222
+     *
223
+     * @param string $app
224
+     * @param string|array $types
225
+     * @return bool
226
+     */
227
+    public static function isType($app, $types) {
228
+        if (is_string($types)) {
229
+            $types = array($types);
230
+        }
231
+        $appTypes = self::getAppTypes($app);
232
+        foreach ($types as $type) {
233
+            if (array_search($type, $appTypes) !== false) {
234
+                return true;
235
+            }
236
+        }
237
+        return false;
238
+    }
239
+
240
+    /**
241
+     * get the types of an app
242
+     *
243
+     * @param string $app
244
+     * @return array
245
+     */
246
+    private static function getAppTypes($app) {
247
+        //load the cache
248
+        if (count(self::$appTypes) == 0) {
249
+            self::$appTypes = \OC::$server->getAppConfig()->getValues(false, 'types');
250
+        }
251
+
252
+        if (isset(self::$appTypes[$app])) {
253
+            return explode(',', self::$appTypes[$app]);
254
+        } else {
255
+            return array();
256
+        }
257
+    }
258
+
259
+    /**
260
+     * read app types from info.xml and cache them in the database
261
+     */
262
+    public static function setAppTypes($app) {
263
+        $appData = self::getAppInfo($app);
264
+        if(!is_array($appData)) {
265
+            return;
266
+        }
267
+
268
+        if (isset($appData['types'])) {
269
+            $appTypes = implode(',', $appData['types']);
270
+        } else {
271
+            $appTypes = '';
272
+            $appData['types'] = [];
273
+        }
274
+
275
+        \OC::$server->getAppConfig()->setValue($app, 'types', $appTypes);
276
+
277
+        if (\OC::$server->getAppManager()->hasProtectedAppType($appData['types'])) {
278
+            $enabled = \OC::$server->getAppConfig()->getValue($app, 'enabled', 'yes');
279
+            if ($enabled !== 'yes' && $enabled !== 'no') {
280
+                \OC::$server->getAppConfig()->setValue($app, 'enabled', 'yes');
281
+            }
282
+        }
283
+    }
284
+
285
+    /**
286
+     * check if app is shipped
287
+     *
288
+     * @param string $appId the id of the app to check
289
+     * @return bool
290
+     *
291
+     * Check if an app that is installed is a shipped app or installed from the appstore.
292
+     */
293
+    public static function isShipped($appId) {
294
+        return \OC::$server->getAppManager()->isShipped($appId);
295
+    }
296
+
297
+    /**
298
+     * get all enabled apps
299
+     */
300
+    protected static $enabledAppsCache = array();
301
+
302
+    /**
303
+     * Returns apps enabled for the current user.
304
+     *
305
+     * @param bool $forceRefresh whether to refresh the cache
306
+     * @param bool $all whether to return apps for all users, not only the
307
+     * currently logged in one
308
+     * @return string[]
309
+     */
310
+    public static function getEnabledApps($forceRefresh = false, $all = false) {
311
+        if (!\OC::$server->getSystemConfig()->getValue('installed', false)) {
312
+            return array();
313
+        }
314
+        // in incognito mode or when logged out, $user will be false,
315
+        // which is also the case during an upgrade
316
+        $appManager = \OC::$server->getAppManager();
317
+        if ($all) {
318
+            $user = null;
319
+        } else {
320
+            $user = \OC::$server->getUserSession()->getUser();
321
+        }
322
+
323
+        if (is_null($user)) {
324
+            $apps = $appManager->getInstalledApps();
325
+        } else {
326
+            $apps = $appManager->getEnabledAppsForUser($user);
327
+        }
328
+        $apps = array_filter($apps, function ($app) {
329
+            return $app !== 'files';//we add this manually
330
+        });
331
+        sort($apps);
332
+        array_unshift($apps, 'files');
333
+        return $apps;
334
+    }
335
+
336
+    /**
337
+     * checks whether or not an app is enabled
338
+     *
339
+     * @param string $app app
340
+     * @return bool
341
+     *
342
+     * This function checks whether or not an app is enabled.
343
+     */
344
+    public static function isEnabled($app) {
345
+        return \OC::$server->getAppManager()->isEnabledForUser($app);
346
+    }
347
+
348
+    /**
349
+     * enables an app
350
+     *
351
+     * @param string $appId
352
+     * @param array $groups (optional) when set, only these groups will have access to the app
353
+     * @throws \Exception
354
+     * @return void
355
+     *
356
+     * This function set an app as enabled in appconfig.
357
+     */
358
+    public function enable($appId,
359
+                            $groups = null) {
360
+        self::$enabledAppsCache = []; // flush
361
+        $l = \OC::$server->getL10N('core');
362
+        $config = \OC::$server->getConfig();
363
+
364
+        // Check if app is already downloaded
365
+        $installer = new Installer(
366
+            \OC::$server->getAppFetcher(),
367
+            \OC::$server->getHTTPClientService(),
368
+            \OC::$server->getTempManager(),
369
+            \OC::$server->getLogger()
370
+        );
371
+        $isDownloaded = $installer->isDownloaded($appId);
372
+
373
+        if(!$isDownloaded) {
374
+            $installer->downloadApp($appId);
375
+        }
376
+
377
+        if (!Installer::isInstalled($appId)) {
378
+            $appId = self::installApp(
379
+                $appId,
380
+                $config,
381
+                $l
382
+            );
383
+            $appPath = self::getAppPath($appId);
384
+            self::registerAutoloading($appId, $appPath);
385
+            $installer->installApp($appId);
386
+        } else {
387
+            // check for required dependencies
388
+            $info = self::getAppInfo($appId);
389
+            self::checkAppDependencies($config, $l, $info);
390
+            $appPath = self::getAppPath($appId);
391
+            self::registerAutoloading($appId, $appPath);
392
+            $installer->installApp($appId);
393
+        }
394
+
395
+        $appManager = \OC::$server->getAppManager();
396
+        if (!is_null($groups)) {
397
+            $groupManager = \OC::$server->getGroupManager();
398
+            $groupsList = [];
399
+            foreach ($groups as $group) {
400
+                $groupItem = $groupManager->get($group);
401
+                if ($groupItem instanceof \OCP\IGroup) {
402
+                    $groupsList[] = $groupManager->get($group);
403
+                }
404
+            }
405
+            $appManager->enableAppForGroups($appId, $groupsList);
406
+        } else {
407
+            $appManager->enableApp($appId);
408
+        }
409
+
410
+        $info = self::getAppInfo($appId);
411
+        if(isset($info['settings']) && is_array($info['settings'])) {
412
+            $appPath = self::getAppPath($appId);
413
+            self::registerAutoloading($appId, $appPath);
414
+            \OC::$server->getSettingsManager()->setupSettings($info['settings']);
415
+        }
416
+    }
417
+
418
+    /**
419
+     * @param string $app
420
+     * @return bool
421
+     */
422
+    public static function removeApp($app) {
423
+        if (self::isShipped($app)) {
424
+            return false;
425
+        }
426
+
427
+        $installer = new Installer(
428
+            \OC::$server->getAppFetcher(),
429
+            \OC::$server->getHTTPClientService(),
430
+            \OC::$server->getTempManager(),
431
+            \OC::$server->getLogger()
432
+        );
433
+        return $installer->removeApp($app);
434
+    }
435
+
436
+    /**
437
+     * This function set an app as disabled in appconfig.
438
+     *
439
+     * @param string $app app
440
+     * @throws Exception
441
+     */
442
+    public static function disable($app) {
443
+        // flush
444
+        self::$enabledAppsCache = array();
445
+
446
+        // run uninstall steps
447
+        $appData = OC_App::getAppInfo($app);
448
+        if (!is_null($appData)) {
449
+            OC_App::executeRepairSteps($app, $appData['repair-steps']['uninstall']);
450
+        }
451
+
452
+        // emit disable hook - needed anymore ?
453
+        \OC_Hook::emit('OC_App', 'pre_disable', array('app' => $app));
454
+
455
+        // finally disable it
456
+        $appManager = \OC::$server->getAppManager();
457
+        $appManager->disableApp($app);
458
+    }
459
+
460
+    // This is private as well. It simply works, so don't ask for more details
461
+    private static function proceedNavigation($list) {
462
+        $headerIconCount = 8;
463
+        usort($list, function($a, $b) {
464
+            if (isset($a['order']) && isset($b['order'])) {
465
+                return ($a['order'] < $b['order']) ? -1 : 1;
466
+            } else if (isset($a['order']) || isset($b['order'])) {
467
+                return isset($a['order']) ? -1 : 1;
468
+            } else {
469
+                return ($a['name'] < $b['name']) ? -1 : 1;
470
+            }
471
+        });
472
+
473
+        $activeAppIndex = -1;
474
+        $activeApp = OC::$server->getNavigationManager()->getActiveEntry();
475
+        foreach ($list as $index => &$navEntry) {
476
+            if ($navEntry['id'] == $activeApp) {
477
+                $navEntry['active'] = true;
478
+                $activeAppIndex = $index;
479
+            } else {
480
+                $navEntry['active'] = false;
481
+            }
482
+        }
483
+        unset($navEntry);
484
+
485
+        if($activeAppIndex > ($headerIconCount-1)) {
486
+            $active = $list[$activeAppIndex];
487
+            $lastInHeader = $list[$headerIconCount-1];
488
+            $list[$headerIconCount-1] = $active;
489
+            $list[$activeAppIndex] = $lastInHeader;
490
+        }
491
+
492
+        foreach ($list as $index => &$navEntry) {
493
+            $navEntry['showInHeader'] = false;
494
+            if($index < $headerIconCount) {
495
+                $navEntry['showInHeader'] = true;
496
+            }
497
+        }
498
+
499
+
500
+
501
+        return $list;
502
+    }
503
+
504
+    public static function proceedAppNavigation($entries) {
505
+        $headerIconCount = 8;
506
+        $activeAppIndex = -1;
507
+        $list = self::proceedNavigation($entries);
508
+
509
+        $activeApp = OC::$server->getNavigationManager()->getActiveEntry();
510
+        foreach ($list as $index => &$navEntry) {
511
+            if ($navEntry['id'] == $activeApp) {
512
+                $navEntry['active'] = true;
513
+                $activeAppIndex = $index;
514
+            } else {
515
+                $navEntry['active'] = false;
516
+            }
517
+        }
518
+        // move active item to last position
519
+        if($activeAppIndex > ($headerIconCount-1)) {
520
+            $active = $list[$activeAppIndex];
521
+            $lastInHeader = $list[$headerIconCount-1];
522
+            $list[$headerIconCount-1] = $active;
523
+            $list[$activeAppIndex] = $lastInHeader;
524
+        }
525
+        $list = array_slice($list, 0, $headerIconCount);
526
+
527
+        return $list;
528
+    }
529
+
530
+    /**
531
+     * Get the path where to install apps
532
+     *
533
+     * @return string|false
534
+     */
535
+    public static function getInstallPath() {
536
+        if (\OC::$server->getSystemConfig()->getValue('appstoreenabled', true) == false) {
537
+            return false;
538
+        }
539
+
540
+        foreach (OC::$APPSROOTS as $dir) {
541
+            if (isset($dir['writable']) && $dir['writable'] === true) {
542
+                return $dir['path'];
543
+            }
544
+        }
545
+
546
+        \OCP\Util::writeLog('core', 'No application directories are marked as writable.', \OCP\Util::ERROR);
547
+        return null;
548
+    }
549
+
550
+
551
+    /**
552
+     * search for an app in all app-directories
553
+     *
554
+     * @param string $appId
555
+     * @return false|string
556
+     */
557
+    public static function findAppInDirectories($appId) {
558
+        $sanitizedAppId = self::cleanAppId($appId);
559
+        if($sanitizedAppId !== $appId) {
560
+            return false;
561
+        }
562
+        static $app_dir = array();
563
+
564
+        if (isset($app_dir[$appId])) {
565
+            return $app_dir[$appId];
566
+        }
567
+
568
+        $possibleApps = array();
569
+        foreach (OC::$APPSROOTS as $dir) {
570
+            if (file_exists($dir['path'] . '/' . $appId)) {
571
+                $possibleApps[] = $dir;
572
+            }
573
+        }
574
+
575
+        if (empty($possibleApps)) {
576
+            return false;
577
+        } elseif (count($possibleApps) === 1) {
578
+            $dir = array_shift($possibleApps);
579
+            $app_dir[$appId] = $dir;
580
+            return $dir;
581
+        } else {
582
+            $versionToLoad = array();
583
+            foreach ($possibleApps as $possibleApp) {
584
+                $version = self::getAppVersionByPath($possibleApp['path']);
585
+                if (empty($versionToLoad) || version_compare($version, $versionToLoad['version'], '>')) {
586
+                    $versionToLoad = array(
587
+                        'dir' => $possibleApp,
588
+                        'version' => $version,
589
+                    );
590
+                }
591
+            }
592
+            $app_dir[$appId] = $versionToLoad['dir'];
593
+            return $versionToLoad['dir'];
594
+            //TODO - write test
595
+        }
596
+    }
597
+
598
+    /**
599
+     * Get the directory for the given app.
600
+     * If the app is defined in multiple directories, the first one is taken. (false if not found)
601
+     *
602
+     * @param string $appId
603
+     * @return string|false
604
+     */
605
+    public static function getAppPath($appId) {
606
+        if ($appId === null || trim($appId) === '') {
607
+            return false;
608
+        }
609
+
610
+        if (($dir = self::findAppInDirectories($appId)) != false) {
611
+            return $dir['path'] . '/' . $appId;
612
+        }
613
+        return false;
614
+    }
615
+
616
+    /**
617
+     * Get the path for the given app on the access
618
+     * If the app is defined in multiple directories, the first one is taken. (false if not found)
619
+     *
620
+     * @param string $appId
621
+     * @return string|false
622
+     */
623
+    public static function getAppWebPath($appId) {
624
+        if (($dir = self::findAppInDirectories($appId)) != false) {
625
+            return OC::$WEBROOT . $dir['url'] . '/' . $appId;
626
+        }
627
+        return false;
628
+    }
629
+
630
+    /**
631
+     * get the last version of the app from appinfo/info.xml
632
+     *
633
+     * @param string $appId
634
+     * @param bool $useCache
635
+     * @return string
636
+     */
637
+    public static function getAppVersion($appId, $useCache = true) {
638
+        if($useCache && isset(self::$appVersion[$appId])) {
639
+            return self::$appVersion[$appId];
640
+        }
641
+
642
+        $file = self::getAppPath($appId);
643
+        self::$appVersion[$appId] = ($file !== false) ? self::getAppVersionByPath($file) : '0';
644
+        return self::$appVersion[$appId];
645
+    }
646
+
647
+    /**
648
+     * get app's version based on it's path
649
+     *
650
+     * @param string $path
651
+     * @return string
652
+     */
653
+    public static function getAppVersionByPath($path) {
654
+        $infoFile = $path . '/appinfo/info.xml';
655
+        $appData = self::getAppInfo($infoFile, true);
656
+        return isset($appData['version']) ? $appData['version'] : '';
657
+    }
658
+
659
+
660
+    /**
661
+     * Read all app metadata from the info.xml file
662
+     *
663
+     * @param string $appId id of the app or the path of the info.xml file
664
+     * @param bool $path
665
+     * @param string $lang
666
+     * @return array|null
667
+     * @note all data is read from info.xml, not just pre-defined fields
668
+     */
669
+    public static function getAppInfo($appId, $path = false, $lang = null) {
670
+        if ($path) {
671
+            $file = $appId;
672
+        } else {
673
+            if ($lang === null && isset(self::$appInfo[$appId])) {
674
+                return self::$appInfo[$appId];
675
+            }
676
+            $appPath = self::getAppPath($appId);
677
+            if($appPath === false) {
678
+                return null;
679
+            }
680
+            $file = $appPath . '/appinfo/info.xml';
681
+        }
682
+
683
+        $parser = new InfoParser(\OC::$server->getMemCacheFactory()->create('core.appinfo'));
684
+        $data = $parser->parse($file);
685
+
686
+        if (is_array($data)) {
687
+            $data = OC_App::parseAppInfo($data, $lang);
688
+        }
689
+        if(isset($data['ocsid'])) {
690
+            $storedId = \OC::$server->getConfig()->getAppValue($appId, 'ocsid');
691
+            if($storedId !== '' && $storedId !== $data['ocsid']) {
692
+                $data['ocsid'] = $storedId;
693
+            }
694
+        }
695
+
696
+        if ($lang === null) {
697
+            self::$appInfo[$appId] = $data;
698
+        }
699
+
700
+        return $data;
701
+    }
702
+
703
+    /**
704
+     * Returns the navigation
705
+     *
706
+     * @return array
707
+     *
708
+     * This function returns an array containing all entries added. The
709
+     * entries are sorted by the key 'order' ascending. Additional to the keys
710
+     * given for each app the following keys exist:
711
+     *   - active: boolean, signals if the user is on this navigation entry
712
+     */
713
+    public static function getNavigation() {
714
+        $entries = OC::$server->getNavigationManager()->getAll();
715
+        return self::proceedNavigation($entries);
716
+    }
717
+
718
+    /**
719
+     * Returns the navigation inside the header bar
720
+     *
721
+     * @return array
722
+     *
723
+     * This function returns an array containing all entries added. The
724
+     * entries are sorted by the key 'order' ascending. Additional to the keys
725
+     * given for each app the following keys exist:
726
+     *   - active: boolean, signals if the user is on this navigation entry
727
+     */
728
+    public static function getHeaderNavigation() {
729
+        $entries = OC::$server->getNavigationManager()->getAll();
730
+        return self::proceedAppNavigation($entries);
731
+    }
732
+
733
+    /**
734
+     * Returns the Settings Navigation
735
+     *
736
+     * @return string[]
737
+     *
738
+     * This function returns an array containing all settings pages added. The
739
+     * entries are sorted by the key 'order' ascending.
740
+     */
741
+    public static function getSettingsNavigation() {
742
+        $entries = OC::$server->getNavigationManager()->getAll('settings');
743
+        return self::proceedNavigation($entries);
744
+    }
745
+
746
+    /**
747
+     * get the id of loaded app
748
+     *
749
+     * @return string
750
+     */
751
+    public static function getCurrentApp() {
752
+        $request = \OC::$server->getRequest();
753
+        $script = substr($request->getScriptName(), strlen(OC::$WEBROOT) + 1);
754
+        $topFolder = substr($script, 0, strpos($script, '/'));
755
+        if (empty($topFolder)) {
756
+            $path_info = $request->getPathInfo();
757
+            if ($path_info) {
758
+                $topFolder = substr($path_info, 1, strpos($path_info, '/', 1) - 1);
759
+            }
760
+        }
761
+        if ($topFolder == 'apps') {
762
+            $length = strlen($topFolder);
763
+            return substr($script, $length + 1, strpos($script, '/', $length + 1) - $length - 1);
764
+        } else {
765
+            return $topFolder;
766
+        }
767
+    }
768
+
769
+    /**
770
+     * @param string $type
771
+     * @return array
772
+     */
773
+    public static function getForms($type) {
774
+        $forms = array();
775
+        switch ($type) {
776
+            case 'admin':
777
+                $source = self::$adminForms;
778
+                break;
779
+            case 'personal':
780
+                $source = self::$personalForms;
781
+                break;
782
+            default:
783
+                return array();
784
+        }
785
+        foreach ($source as $form) {
786
+            $forms[] = include $form;
787
+        }
788
+        return $forms;
789
+    }
790
+
791
+    /**
792
+     * register an admin form to be shown
793
+     *
794
+     * @param string $app
795
+     * @param string $page
796
+     */
797
+    public static function registerAdmin($app, $page) {
798
+        self::$adminForms[] = $app . '/' . $page . '.php';
799
+    }
800
+
801
+    /**
802
+     * register a personal form to be shown
803
+     * @param string $app
804
+     * @param string $page
805
+     */
806
+    public static function registerPersonal($app, $page) {
807
+        self::$personalForms[] = $app . '/' . $page . '.php';
808
+    }
809
+
810
+    /**
811
+     * @param array $entry
812
+     */
813
+    public static function registerLogIn(array $entry) {
814
+        self::$altLogin[] = $entry;
815
+    }
816
+
817
+    /**
818
+     * @return array
819
+     */
820
+    public static function getAlternativeLogIns() {
821
+        return self::$altLogin;
822
+    }
823
+
824
+    /**
825
+     * get a list of all apps in the apps folder
826
+     *
827
+     * @return array an array of app names (string IDs)
828
+     * @todo: change the name of this method to getInstalledApps, which is more accurate
829
+     */
830
+    public static function getAllApps() {
831
+
832
+        $apps = array();
833
+
834
+        foreach (OC::$APPSROOTS as $apps_dir) {
835
+            if (!is_readable($apps_dir['path'])) {
836
+                \OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], \OCP\Util::WARN);
837
+                continue;
838
+            }
839
+            $dh = opendir($apps_dir['path']);
840
+
841
+            if (is_resource($dh)) {
842
+                while (($file = readdir($dh)) !== false) {
843
+
844
+                    if ($file[0] != '.' and is_dir($apps_dir['path'] . '/' . $file) and is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')) {
845
+
846
+                        $apps[] = $file;
847
+                    }
848
+                }
849
+            }
850
+        }
851
+
852
+        return $apps;
853
+    }
854
+
855
+    /**
856
+     * List all apps, this is used in apps.php
857
+     *
858
+     * @return array
859
+     */
860
+    public function listAllApps() {
861
+        $installedApps = OC_App::getAllApps();
862
+
863
+        //we don't want to show configuration for these
864
+        $blacklist = \OC::$server->getAppManager()->getAlwaysEnabledApps();
865
+        $appList = array();
866
+        $langCode = \OC::$server->getL10N('core')->getLanguageCode();
867
+        $urlGenerator = \OC::$server->getURLGenerator();
868
+
869
+        foreach ($installedApps as $app) {
870
+            if (array_search($app, $blacklist) === false) {
871
+
872
+                $info = OC_App::getAppInfo($app, false, $langCode);
873
+                if (!is_array($info)) {
874
+                    \OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', \OCP\Util::ERROR);
875
+                    continue;
876
+                }
877
+
878
+                if (!isset($info['name'])) {
879
+                    \OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', \OCP\Util::ERROR);
880
+                    continue;
881
+                }
882
+
883
+                $enabled = \OC::$server->getAppConfig()->getValue($app, 'enabled', 'no');
884
+                $info['groups'] = null;
885
+                if ($enabled === 'yes') {
886
+                    $active = true;
887
+                } else if ($enabled === 'no') {
888
+                    $active = false;
889
+                } else {
890
+                    $active = true;
891
+                    $info['groups'] = $enabled;
892
+                }
893
+
894
+                $info['active'] = $active;
895
+
896
+                if (self::isShipped($app)) {
897
+                    $info['internal'] = true;
898
+                    $info['level'] = self::officialApp;
899
+                    $info['removable'] = false;
900
+                } else {
901
+                    $info['internal'] = false;
902
+                    $info['removable'] = true;
903
+                }
904
+
905
+                $appPath = self::getAppPath($app);
906
+                if($appPath !== false) {
907
+                    $appIcon = $appPath . '/img/' . $app . '.svg';
908
+                    if (file_exists($appIcon)) {
909
+                        $info['preview'] = \OC::$server->getURLGenerator()->imagePath($app, $app . '.svg');
910
+                        $info['previewAsIcon'] = true;
911
+                    } else {
912
+                        $appIcon = $appPath . '/img/app.svg';
913
+                        if (file_exists($appIcon)) {
914
+                            $info['preview'] = \OC::$server->getURLGenerator()->imagePath($app, 'app.svg');
915
+                            $info['previewAsIcon'] = true;
916
+                        }
917
+                    }
918
+                }
919
+                // fix documentation
920
+                if (isset($info['documentation']) && is_array($info['documentation'])) {
921
+                    foreach ($info['documentation'] as $key => $url) {
922
+                        // If it is not an absolute URL we assume it is a key
923
+                        // i.e. admin-ldap will get converted to go.php?to=admin-ldap
924
+                        if (stripos($url, 'https://') !== 0 && stripos($url, 'http://') !== 0) {
925
+                            $url = $urlGenerator->linkToDocs($url);
926
+                        }
927
+
928
+                        $info['documentation'][$key] = $url;
929
+                    }
930
+                }
931
+
932
+                $info['version'] = OC_App::getAppVersion($app);
933
+                $appList[] = $info;
934
+            }
935
+        }
936
+
937
+        return $appList;
938
+    }
939
+
940
+    /**
941
+     * Returns the internal app ID or false
942
+     * @param string $ocsID
943
+     * @return string|false
944
+     */
945
+    public static function getInternalAppIdByOcs($ocsID) {
946
+        if(is_numeric($ocsID)) {
947
+            $idArray = \OC::$server->getAppConfig()->getValues(false, 'ocsid');
948
+            if(array_search($ocsID, $idArray)) {
949
+                return array_search($ocsID, $idArray);
950
+            }
951
+        }
952
+        return false;
953
+    }
954
+
955
+    public static function shouldUpgrade($app) {
956
+        $versions = self::getAppVersions();
957
+        $currentVersion = OC_App::getAppVersion($app);
958
+        if ($currentVersion && isset($versions[$app])) {
959
+            $installedVersion = $versions[$app];
960
+            if (!version_compare($currentVersion, $installedVersion, '=')) {
961
+                return true;
962
+            }
963
+        }
964
+        return false;
965
+    }
966
+
967
+    /**
968
+     * Adjust the number of version parts of $version1 to match
969
+     * the number of version parts of $version2.
970
+     *
971
+     * @param string $version1 version to adjust
972
+     * @param string $version2 version to take the number of parts from
973
+     * @return string shortened $version1
974
+     */
975
+    private static function adjustVersionParts($version1, $version2) {
976
+        $version1 = explode('.', $version1);
977
+        $version2 = explode('.', $version2);
978
+        // reduce $version1 to match the number of parts in $version2
979
+        while (count($version1) > count($version2)) {
980
+            array_pop($version1);
981
+        }
982
+        // if $version1 does not have enough parts, add some
983
+        while (count($version1) < count($version2)) {
984
+            $version1[] = '0';
985
+        }
986
+        return implode('.', $version1);
987
+    }
988
+
989
+    /**
990
+     * Check whether the current ownCloud version matches the given
991
+     * application's version requirements.
992
+     *
993
+     * The comparison is made based on the number of parts that the
994
+     * app info version has. For example for ownCloud 6.0.3 if the
995
+     * app info version is expecting version 6.0, the comparison is
996
+     * made on the first two parts of the ownCloud version.
997
+     * This means that it's possible to specify "requiremin" => 6
998
+     * and "requiremax" => 6 and it will still match ownCloud 6.0.3.
999
+     *
1000
+     * @param string $ocVersion ownCloud version to check against
1001
+     * @param array $appInfo app info (from xml)
1002
+     *
1003
+     * @return boolean true if compatible, otherwise false
1004
+     */
1005
+    public static function isAppCompatible($ocVersion, $appInfo) {
1006
+        $requireMin = '';
1007
+        $requireMax = '';
1008
+        if (isset($appInfo['dependencies']['nextcloud']['@attributes']['min-version'])) {
1009
+            $requireMin = $appInfo['dependencies']['nextcloud']['@attributes']['min-version'];
1010
+        } elseif (isset($appInfo['dependencies']['owncloud']['@attributes']['min-version'])) {
1011
+            $requireMin = $appInfo['dependencies']['owncloud']['@attributes']['min-version'];
1012
+        } else if (isset($appInfo['requiremin'])) {
1013
+            $requireMin = $appInfo['requiremin'];
1014
+        } else if (isset($appInfo['require'])) {
1015
+            $requireMin = $appInfo['require'];
1016
+        }
1017
+
1018
+        if (isset($appInfo['dependencies']['nextcloud']['@attributes']['max-version'])) {
1019
+            $requireMax = $appInfo['dependencies']['nextcloud']['@attributes']['max-version'];
1020
+        } elseif (isset($appInfo['dependencies']['owncloud']['@attributes']['max-version'])) {
1021
+            $requireMax = $appInfo['dependencies']['owncloud']['@attributes']['max-version'];
1022
+        } else if (isset($appInfo['requiremax'])) {
1023
+            $requireMax = $appInfo['requiremax'];
1024
+        }
1025
+
1026
+        if (is_array($ocVersion)) {
1027
+            $ocVersion = implode('.', $ocVersion);
1028
+        }
1029
+
1030
+        if (!empty($requireMin)
1031
+            && version_compare(self::adjustVersionParts($ocVersion, $requireMin), $requireMin, '<')
1032
+        ) {
1033
+
1034
+            return false;
1035
+        }
1036
+
1037
+        if (!empty($requireMax)
1038
+            && version_compare(self::adjustVersionParts($ocVersion, $requireMax), $requireMax, '>')
1039
+        ) {
1040
+            return false;
1041
+        }
1042
+
1043
+        return true;
1044
+    }
1045
+
1046
+    /**
1047
+     * get the installed version of all apps
1048
+     */
1049
+    public static function getAppVersions() {
1050
+        static $versions;
1051
+
1052
+        if(!$versions) {
1053
+            $appConfig = \OC::$server->getAppConfig();
1054
+            $versions = $appConfig->getValues(false, 'installed_version');
1055
+        }
1056
+        return $versions;
1057
+    }
1058
+
1059
+    /**
1060
+     * @param string $app
1061
+     * @param \OCP\IConfig $config
1062
+     * @param \OCP\IL10N $l
1063
+     * @return bool
1064
+     *
1065
+     * @throws Exception if app is not compatible with this version of ownCloud
1066
+     * @throws Exception if no app-name was specified
1067
+     */
1068
+    public function installApp($app,
1069
+                                \OCP\IConfig $config,
1070
+                                \OCP\IL10N $l) {
1071
+        if ($app !== false) {
1072
+            // check if the app is compatible with this version of ownCloud
1073
+            $info = self::getAppInfo($app);
1074
+            if(!is_array($info)) {
1075
+                throw new \Exception(
1076
+                    $l->t('App "%s" cannot be installed because appinfo file cannot be read.',
1077
+                        [$info['name']]
1078
+                    )
1079
+                );
1080
+            }
1081
+
1082
+            $version = \OCP\Util::getVersion();
1083
+            if (!self::isAppCompatible($version, $info)) {
1084
+                throw new \Exception(
1085
+                    $l->t('App "%s" cannot be installed because it is not compatible with this version of the server.',
1086
+                        array($info['name'])
1087
+                    )
1088
+                );
1089
+            }
1090
+
1091
+            // check for required dependencies
1092
+            self::checkAppDependencies($config, $l, $info);
1093
+
1094
+            $config->setAppValue($app, 'enabled', 'yes');
1095
+            if (isset($appData['id'])) {
1096
+                $config->setAppValue($app, 'ocsid', $appData['id']);
1097
+            }
1098
+
1099
+            if(isset($info['settings']) && is_array($info['settings'])) {
1100
+                $appPath = self::getAppPath($app);
1101
+                self::registerAutoloading($app, $appPath);
1102
+                \OC::$server->getSettingsManager()->setupSettings($info['settings']);
1103
+            }
1104
+
1105
+            \OC_Hook::emit('OC_App', 'post_enable', array('app' => $app));
1106
+        } else {
1107
+            if(empty($appName) ) {
1108
+                throw new \Exception($l->t("No app name specified"));
1109
+            } else {
1110
+                throw new \Exception($l->t("App '%s' could not be installed!", $appName));
1111
+            }
1112
+        }
1113
+
1114
+        return $app;
1115
+    }
1116
+
1117
+    /**
1118
+     * update the database for the app and call the update script
1119
+     *
1120
+     * @param string $appId
1121
+     * @return bool
1122
+     */
1123
+    public static function updateApp($appId) {
1124
+        $appPath = self::getAppPath($appId);
1125
+        if($appPath === false) {
1126
+            return false;
1127
+        }
1128
+        $appData = self::getAppInfo($appId);
1129
+        self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']);
1130
+        if (file_exists($appPath . '/appinfo/database.xml')) {
1131
+            OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml');
1132
+        }
1133
+        self::executeRepairSteps($appId, $appData['repair-steps']['post-migration']);
1134
+        self::setupLiveMigrations($appId, $appData['repair-steps']['live-migration']);
1135
+        unset(self::$appVersion[$appId]);
1136
+        // run upgrade code
1137
+        if (file_exists($appPath . '/appinfo/update.php')) {
1138
+            self::loadApp($appId);
1139
+            include $appPath . '/appinfo/update.php';
1140
+        }
1141
+        self::setupBackgroundJobs($appData['background-jobs']);
1142
+        if(isset($appData['settings']) && is_array($appData['settings'])) {
1143
+            $appPath = self::getAppPath($appId);
1144
+            self::registerAutoloading($appId, $appPath);
1145
+            \OC::$server->getSettingsManager()->setupSettings($appData['settings']);
1146
+        }
1147
+
1148
+        //set remote/public handlers
1149
+        if (array_key_exists('ocsid', $appData)) {
1150
+            \OC::$server->getConfig()->setAppValue($appId, 'ocsid', $appData['ocsid']);
1151
+        } elseif(\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) {
1152
+            \OC::$server->getConfig()->deleteAppValue($appId, 'ocsid');
1153
+        }
1154
+        foreach ($appData['remote'] as $name => $path) {
1155
+            \OC::$server->getConfig()->setAppValue('core', 'remote_' . $name, $appId . '/' . $path);
1156
+        }
1157
+        foreach ($appData['public'] as $name => $path) {
1158
+            \OC::$server->getConfig()->setAppValue('core', 'public_' . $name, $appId . '/' . $path);
1159
+        }
1160
+
1161
+        self::setAppTypes($appId);
1162
+
1163
+        $version = \OC_App::getAppVersion($appId);
1164
+        \OC::$server->getAppConfig()->setValue($appId, 'installed_version', $version);
1165
+
1166
+        \OC::$server->getEventDispatcher()->dispatch(ManagerEvent::EVENT_APP_UPDATE, new ManagerEvent(
1167
+            ManagerEvent::EVENT_APP_UPDATE, $appId
1168
+        ));
1169
+
1170
+        return true;
1171
+    }
1172
+
1173
+    /**
1174
+     * @param string $appId
1175
+     * @param string[] $steps
1176
+     * @throws \OC\NeedsUpdateException
1177
+     */
1178
+    public static function executeRepairSteps($appId, array $steps) {
1179
+        if (empty($steps)) {
1180
+            return;
1181
+        }
1182
+        // load the app
1183
+        self::loadApp($appId);
1184
+
1185
+        $dispatcher = OC::$server->getEventDispatcher();
1186
+
1187
+        // load the steps
1188
+        $r = new Repair([], $dispatcher);
1189
+        foreach ($steps as $step) {
1190
+            try {
1191
+                $r->addStep($step);
1192
+            } catch (Exception $ex) {
1193
+                $r->emit('\OC\Repair', 'error', [$ex->getMessage()]);
1194
+                \OC::$server->getLogger()->logException($ex);
1195
+            }
1196
+        }
1197
+        // run the steps
1198
+        $r->run();
1199
+    }
1200
+
1201
+    public static function setupBackgroundJobs(array $jobs) {
1202
+        $queue = \OC::$server->getJobList();
1203
+        foreach ($jobs as $job) {
1204
+            $queue->add($job);
1205
+        }
1206
+    }
1207
+
1208
+    /**
1209
+     * @param string $appId
1210
+     * @param string[] $steps
1211
+     */
1212
+    private static function setupLiveMigrations($appId, array $steps) {
1213
+        $queue = \OC::$server->getJobList();
1214
+        foreach ($steps as $step) {
1215
+            $queue->add('OC\Migration\BackgroundRepair', [
1216
+                'app' => $appId,
1217
+                'step' => $step]);
1218
+        }
1219
+    }
1220
+
1221
+    /**
1222
+     * @param string $appId
1223
+     * @return \OC\Files\View|false
1224
+     */
1225
+    public static function getStorage($appId) {
1226
+        if (OC_App::isEnabled($appId)) { //sanity check
1227
+            if (\OC::$server->getUserSession()->isLoggedIn()) {
1228
+                $view = new \OC\Files\View('/' . OC_User::getUser());
1229
+                if (!$view->file_exists($appId)) {
1230
+                    $view->mkdir($appId);
1231
+                }
1232
+                return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId);
1233
+            } else {
1234
+                \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', \OCP\Util::ERROR);
1235
+                return false;
1236
+            }
1237
+        } else {
1238
+            \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', \OCP\Util::ERROR);
1239
+            return false;
1240
+        }
1241
+    }
1242
+
1243
+    protected static function findBestL10NOption($options, $lang) {
1244
+        $fallback = $similarLangFallback = $englishFallback = false;
1245
+
1246
+        $lang = strtolower($lang);
1247
+        $similarLang = $lang;
1248
+        if (strpos($similarLang, '_')) {
1249
+            // For "de_DE" we want to find "de" and the other way around
1250
+            $similarLang = substr($lang, 0, strpos($lang, '_'));
1251
+        }
1252
+
1253
+        foreach ($options as $option) {
1254
+            if (is_array($option)) {
1255
+                if ($fallback === false) {
1256
+                    $fallback = $option['@value'];
1257
+                }
1258
+
1259
+                if (!isset($option['@attributes']['lang'])) {
1260
+                    continue;
1261
+                }
1262
+
1263
+                $attributeLang = strtolower($option['@attributes']['lang']);
1264
+                if ($attributeLang === $lang) {
1265
+                    return $option['@value'];
1266
+                }
1267
+
1268
+                if ($attributeLang === $similarLang) {
1269
+                    $similarLangFallback = $option['@value'];
1270
+                } else if (strpos($attributeLang, $similarLang . '_') === 0) {
1271
+                    if ($similarLangFallback === false) {
1272
+                        $similarLangFallback =  $option['@value'];
1273
+                    }
1274
+                }
1275
+            } else {
1276
+                $englishFallback = $option;
1277
+            }
1278
+        }
1279
+
1280
+        if ($similarLangFallback !== false) {
1281
+            return $similarLangFallback;
1282
+        } else if ($englishFallback !== false) {
1283
+            return $englishFallback;
1284
+        }
1285
+        return (string) $fallback;
1286
+    }
1287
+
1288
+    /**
1289
+     * parses the app data array and enhanced the 'description' value
1290
+     *
1291
+     * @param array $data the app data
1292
+     * @param string $lang
1293
+     * @return array improved app data
1294
+     */
1295
+    public static function parseAppInfo(array $data, $lang = null) {
1296
+
1297
+        if ($lang && isset($data['name']) && is_array($data['name'])) {
1298
+            $data['name'] = self::findBestL10NOption($data['name'], $lang);
1299
+        }
1300
+        if ($lang && isset($data['summary']) && is_array($data['summary'])) {
1301
+            $data['summary'] = self::findBestL10NOption($data['summary'], $lang);
1302
+        }
1303
+        if ($lang && isset($data['description']) && is_array($data['description'])) {
1304
+            $data['description'] = trim(self::findBestL10NOption($data['description'], $lang));
1305
+        } else if (isset($data['description']) && is_string($data['description'])) {
1306
+            $data['description'] = trim($data['description']);
1307
+        } else  {
1308
+            $data['description'] = '';
1309
+        }
1310
+
1311
+        return $data;
1312
+    }
1313
+
1314
+    /**
1315
+     * @param \OCP\IConfig $config
1316
+     * @param \OCP\IL10N $l
1317
+     * @param array $info
1318
+     * @throws \Exception
1319
+     */
1320
+    protected static function checkAppDependencies($config, $l, $info) {
1321
+        $dependencyAnalyzer = new DependencyAnalyzer(new Platform($config), $l);
1322
+        $missing = $dependencyAnalyzer->analyze($info);
1323
+        if (!empty($missing)) {
1324
+            $missingMsg = join(PHP_EOL, $missing);
1325
+            throw new \Exception(
1326
+                $l->t('App "%s" cannot be installed because the following dependencies are not fulfilled: %s',
1327
+                    [$info['name'], $missingMsg]
1328
+                )
1329
+            );
1330
+        }
1331
+    }
1332 1332
 }
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
@@ -182,17 +182,17 @@  discard block
 block discarded – undo
182 182
 	 * @param string $path
183 183
 	 */
184 184
 	public static function registerAutoloading($app, $path) {
185
-		$key = $app . '-' . $path;
186
-		if(isset(self::$alreadyRegistered[$key])) {
185
+		$key = $app.'-'.$path;
186
+		if (isset(self::$alreadyRegistered[$key])) {
187 187
 			return;
188 188
 		}
189 189
 		self::$alreadyRegistered[$key] = true;
190 190
 		// Register on PSR-4 composer autoloader
191 191
 		$appNamespace = \OC\AppFramework\App::buildAppNamespace($app);
192 192
 		\OC::$server->registerNamespace($app, $appNamespace);
193
-		\OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true);
193
+		\OC::$composerAutoloader->addPsr4($appNamespace.'\\', $path.'/lib/', true);
194 194
 		if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) {
195
-			\OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true);
195
+			\OC::$composerAutoloader->addPsr4($appNamespace.'\\Tests\\', $path.'/tests/', true);
196 196
 		}
197 197
 
198 198
 		// Register on legacy autoloader
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	private static function requireAppFile($app) {
208 208
 		try {
209 209
 			// encapsulated here to avoid variable scope conflicts
210
-			require_once $app . '/appinfo/app.php';
210
+			require_once $app.'/appinfo/app.php';
211 211
 		} catch (Error $ex) {
212 212
 			\OC::$server->getLogger()->logException($ex);
213 213
 			$blacklist = \OC::$server->getAppManager()->getAlwaysEnabledApps();
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 */
262 262
 	public static function setAppTypes($app) {
263 263
 		$appData = self::getAppInfo($app);
264
-		if(!is_array($appData)) {
264
+		if (!is_array($appData)) {
265 265
 			return;
266 266
 		}
267 267
 
@@ -325,8 +325,8 @@  discard block
 block discarded – undo
325 325
 		} else {
326 326
 			$apps = $appManager->getEnabledAppsForUser($user);
327 327
 		}
328
-		$apps = array_filter($apps, function ($app) {
329
-			return $app !== 'files';//we add this manually
328
+		$apps = array_filter($apps, function($app) {
329
+			return $app !== 'files'; //we add this manually
330 330
 		});
331 331
 		sort($apps);
332 332
 		array_unshift($apps, 'files');
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 		);
371 371
 		$isDownloaded = $installer->isDownloaded($appId);
372 372
 
373
-		if(!$isDownloaded) {
373
+		if (!$isDownloaded) {
374 374
 			$installer->downloadApp($appId);
375 375
 		}
376 376
 
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 		}
409 409
 
410 410
 		$info = self::getAppInfo($appId);
411
-		if(isset($info['settings']) && is_array($info['settings'])) {
411
+		if (isset($info['settings']) && is_array($info['settings'])) {
412 412
 			$appPath = self::getAppPath($appId);
413 413
 			self::registerAutoloading($appId, $appPath);
414 414
 			\OC::$server->getSettingsManager()->setupSettings($info['settings']);
@@ -482,16 +482,16 @@  discard block
 block discarded – undo
482 482
 		}
483 483
 		unset($navEntry);
484 484
 
485
-		if($activeAppIndex > ($headerIconCount-1)) {
485
+		if ($activeAppIndex > ($headerIconCount - 1)) {
486 486
 			$active = $list[$activeAppIndex];
487
-			$lastInHeader = $list[$headerIconCount-1];
488
-			$list[$headerIconCount-1] = $active;
487
+			$lastInHeader = $list[$headerIconCount - 1];
488
+			$list[$headerIconCount - 1] = $active;
489 489
 			$list[$activeAppIndex] = $lastInHeader;
490 490
 		}
491 491
 
492 492
 		foreach ($list as $index => &$navEntry) {
493 493
 			$navEntry['showInHeader'] = false;
494
-			if($index < $headerIconCount) {
494
+			if ($index < $headerIconCount) {
495 495
 				$navEntry['showInHeader'] = true;
496 496
 			}
497 497
 		}
@@ -516,10 +516,10 @@  discard block
 block discarded – undo
516 516
 			}
517 517
 		}
518 518
 		// move active item to last position
519
-		if($activeAppIndex > ($headerIconCount-1)) {
519
+		if ($activeAppIndex > ($headerIconCount - 1)) {
520 520
 			$active = $list[$activeAppIndex];
521
-			$lastInHeader = $list[$headerIconCount-1];
522
-			$list[$headerIconCount-1] = $active;
521
+			$lastInHeader = $list[$headerIconCount - 1];
522
+			$list[$headerIconCount - 1] = $active;
523 523
 			$list[$activeAppIndex] = $lastInHeader;
524 524
 		}
525 525
 		$list = array_slice($list, 0, $headerIconCount);
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 	 */
557 557
 	public static function findAppInDirectories($appId) {
558 558
 		$sanitizedAppId = self::cleanAppId($appId);
559
-		if($sanitizedAppId !== $appId) {
559
+		if ($sanitizedAppId !== $appId) {
560 560
 			return false;
561 561
 		}
562 562
 		static $app_dir = array();
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 
568 568
 		$possibleApps = array();
569 569
 		foreach (OC::$APPSROOTS as $dir) {
570
-			if (file_exists($dir['path'] . '/' . $appId)) {
570
+			if (file_exists($dir['path'].'/'.$appId)) {
571 571
 				$possibleApps[] = $dir;
572 572
 			}
573 573
 		}
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 		}
609 609
 
610 610
 		if (($dir = self::findAppInDirectories($appId)) != false) {
611
-			return $dir['path'] . '/' . $appId;
611
+			return $dir['path'].'/'.$appId;
612 612
 		}
613 613
 		return false;
614 614
 	}
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 	 */
623 623
 	public static function getAppWebPath($appId) {
624 624
 		if (($dir = self::findAppInDirectories($appId)) != false) {
625
-			return OC::$WEBROOT . $dir['url'] . '/' . $appId;
625
+			return OC::$WEBROOT.$dir['url'].'/'.$appId;
626 626
 		}
627 627
 		return false;
628 628
 	}
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 	 * @return string
636 636
 	 */
637 637
 	public static function getAppVersion($appId, $useCache = true) {
638
-		if($useCache && isset(self::$appVersion[$appId])) {
638
+		if ($useCache && isset(self::$appVersion[$appId])) {
639 639
 			return self::$appVersion[$appId];
640 640
 		}
641 641
 
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 	 * @return string
652 652
 	 */
653 653
 	public static function getAppVersionByPath($path) {
654
-		$infoFile = $path . '/appinfo/info.xml';
654
+		$infoFile = $path.'/appinfo/info.xml';
655 655
 		$appData = self::getAppInfo($infoFile, true);
656 656
 		return isset($appData['version']) ? $appData['version'] : '';
657 657
 	}
@@ -674,10 +674,10 @@  discard block
 block discarded – undo
674 674
 				return self::$appInfo[$appId];
675 675
 			}
676 676
 			$appPath = self::getAppPath($appId);
677
-			if($appPath === false) {
677
+			if ($appPath === false) {
678 678
 				return null;
679 679
 			}
680
-			$file = $appPath . '/appinfo/info.xml';
680
+			$file = $appPath.'/appinfo/info.xml';
681 681
 		}
682 682
 
683 683
 		$parser = new InfoParser(\OC::$server->getMemCacheFactory()->create('core.appinfo'));
@@ -686,9 +686,9 @@  discard block
 block discarded – undo
686 686
 		if (is_array($data)) {
687 687
 			$data = OC_App::parseAppInfo($data, $lang);
688 688
 		}
689
-		if(isset($data['ocsid'])) {
689
+		if (isset($data['ocsid'])) {
690 690
 			$storedId = \OC::$server->getConfig()->getAppValue($appId, 'ocsid');
691
-			if($storedId !== '' && $storedId !== $data['ocsid']) {
691
+			if ($storedId !== '' && $storedId !== $data['ocsid']) {
692 692
 				$data['ocsid'] = $storedId;
693 693
 			}
694 694
 		}
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 	 * @param string $page
796 796
 	 */
797 797
 	public static function registerAdmin($app, $page) {
798
-		self::$adminForms[] = $app . '/' . $page . '.php';
798
+		self::$adminForms[] = $app.'/'.$page.'.php';
799 799
 	}
800 800
 
801 801
 	/**
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 	 * @param string $page
805 805
 	 */
806 806
 	public static function registerPersonal($app, $page) {
807
-		self::$personalForms[] = $app . '/' . $page . '.php';
807
+		self::$personalForms[] = $app.'/'.$page.'.php';
808 808
 	}
809 809
 
810 810
 	/**
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 
834 834
 		foreach (OC::$APPSROOTS as $apps_dir) {
835 835
 			if (!is_readable($apps_dir['path'])) {
836
-				\OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], \OCP\Util::WARN);
836
+				\OCP\Util::writeLog('core', 'unable to read app folder : '.$apps_dir['path'], \OCP\Util::WARN);
837 837
 				continue;
838 838
 			}
839 839
 			$dh = opendir($apps_dir['path']);
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 			if (is_resource($dh)) {
842 842
 				while (($file = readdir($dh)) !== false) {
843 843
 
844
-					if ($file[0] != '.' and is_dir($apps_dir['path'] . '/' . $file) and is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')) {
844
+					if ($file[0] != '.' and is_dir($apps_dir['path'].'/'.$file) and is_file($apps_dir['path'].'/'.$file.'/appinfo/info.xml')) {
845 845
 
846 846
 						$apps[] = $file;
847 847
 					}
@@ -871,12 +871,12 @@  discard block
 block discarded – undo
871 871
 
872 872
 				$info = OC_App::getAppInfo($app, false, $langCode);
873 873
 				if (!is_array($info)) {
874
-					\OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', \OCP\Util::ERROR);
874
+					\OCP\Util::writeLog('core', 'Could not read app info file for app "'.$app.'"', \OCP\Util::ERROR);
875 875
 					continue;
876 876
 				}
877 877
 
878 878
 				if (!isset($info['name'])) {
879
-					\OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', \OCP\Util::ERROR);
879
+					\OCP\Util::writeLog('core', 'App id "'.$app.'" has no name in appinfo', \OCP\Util::ERROR);
880 880
 					continue;
881 881
 				}
882 882
 
@@ -903,13 +903,13 @@  discard block
 block discarded – undo
903 903
 				}
904 904
 
905 905
 				$appPath = self::getAppPath($app);
906
-				if($appPath !== false) {
907
-					$appIcon = $appPath . '/img/' . $app . '.svg';
906
+				if ($appPath !== false) {
907
+					$appIcon = $appPath.'/img/'.$app.'.svg';
908 908
 					if (file_exists($appIcon)) {
909
-						$info['preview'] = \OC::$server->getURLGenerator()->imagePath($app, $app . '.svg');
909
+						$info['preview'] = \OC::$server->getURLGenerator()->imagePath($app, $app.'.svg');
910 910
 						$info['previewAsIcon'] = true;
911 911
 					} else {
912
-						$appIcon = $appPath . '/img/app.svg';
912
+						$appIcon = $appPath.'/img/app.svg';
913 913
 						if (file_exists($appIcon)) {
914 914
 							$info['preview'] = \OC::$server->getURLGenerator()->imagePath($app, 'app.svg');
915 915
 							$info['previewAsIcon'] = true;
@@ -943,9 +943,9 @@  discard block
 block discarded – undo
943 943
 	 * @return string|false
944 944
 	 */
945 945
 	public static function getInternalAppIdByOcs($ocsID) {
946
-		if(is_numeric($ocsID)) {
946
+		if (is_numeric($ocsID)) {
947 947
 			$idArray = \OC::$server->getAppConfig()->getValues(false, 'ocsid');
948
-			if(array_search($ocsID, $idArray)) {
948
+			if (array_search($ocsID, $idArray)) {
949 949
 				return array_search($ocsID, $idArray);
950 950
 			}
951 951
 		}
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 	public static function getAppVersions() {
1050 1050
 		static $versions;
1051 1051
 
1052
-		if(!$versions) {
1052
+		if (!$versions) {
1053 1053
 			$appConfig = \OC::$server->getAppConfig();
1054 1054
 			$versions = $appConfig->getValues(false, 'installed_version');
1055 1055
 		}
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
 		if ($app !== false) {
1072 1072
 			// check if the app is compatible with this version of ownCloud
1073 1073
 			$info = self::getAppInfo($app);
1074
-			if(!is_array($info)) {
1074
+			if (!is_array($info)) {
1075 1075
 				throw new \Exception(
1076 1076
 					$l->t('App "%s" cannot be installed because appinfo file cannot be read.',
1077 1077
 						[$info['name']]
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
 				$config->setAppValue($app, 'ocsid', $appData['id']);
1097 1097
 			}
1098 1098
 
1099
-			if(isset($info['settings']) && is_array($info['settings'])) {
1099
+			if (isset($info['settings']) && is_array($info['settings'])) {
1100 1100
 				$appPath = self::getAppPath($app);
1101 1101
 				self::registerAutoloading($app, $appPath);
1102 1102
 				\OC::$server->getSettingsManager()->setupSettings($info['settings']);
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 
1105 1105
 			\OC_Hook::emit('OC_App', 'post_enable', array('app' => $app));
1106 1106
 		} else {
1107
-			if(empty($appName) ) {
1107
+			if (empty($appName)) {
1108 1108
 				throw new \Exception($l->t("No app name specified"));
1109 1109
 			} else {
1110 1110
 				throw new \Exception($l->t("App '%s' could not be installed!", $appName));
@@ -1122,24 +1122,24 @@  discard block
 block discarded – undo
1122 1122
 	 */
1123 1123
 	public static function updateApp($appId) {
1124 1124
 		$appPath = self::getAppPath($appId);
1125
-		if($appPath === false) {
1125
+		if ($appPath === false) {
1126 1126
 			return false;
1127 1127
 		}
1128 1128
 		$appData = self::getAppInfo($appId);
1129 1129
 		self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']);
1130
-		if (file_exists($appPath . '/appinfo/database.xml')) {
1131
-			OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml');
1130
+		if (file_exists($appPath.'/appinfo/database.xml')) {
1131
+			OC_DB::updateDbFromStructure($appPath.'/appinfo/database.xml');
1132 1132
 		}
1133 1133
 		self::executeRepairSteps($appId, $appData['repair-steps']['post-migration']);
1134 1134
 		self::setupLiveMigrations($appId, $appData['repair-steps']['live-migration']);
1135 1135
 		unset(self::$appVersion[$appId]);
1136 1136
 		// run upgrade code
1137
-		if (file_exists($appPath . '/appinfo/update.php')) {
1137
+		if (file_exists($appPath.'/appinfo/update.php')) {
1138 1138
 			self::loadApp($appId);
1139
-			include $appPath . '/appinfo/update.php';
1139
+			include $appPath.'/appinfo/update.php';
1140 1140
 		}
1141 1141
 		self::setupBackgroundJobs($appData['background-jobs']);
1142
-		if(isset($appData['settings']) && is_array($appData['settings'])) {
1142
+		if (isset($appData['settings']) && is_array($appData['settings'])) {
1143 1143
 			$appPath = self::getAppPath($appId);
1144 1144
 			self::registerAutoloading($appId, $appPath);
1145 1145
 			\OC::$server->getSettingsManager()->setupSettings($appData['settings']);
@@ -1148,14 +1148,14 @@  discard block
 block discarded – undo
1148 1148
 		//set remote/public handlers
1149 1149
 		if (array_key_exists('ocsid', $appData)) {
1150 1150
 			\OC::$server->getConfig()->setAppValue($appId, 'ocsid', $appData['ocsid']);
1151
-		} elseif(\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) {
1151
+		} elseif (\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) {
1152 1152
 			\OC::$server->getConfig()->deleteAppValue($appId, 'ocsid');
1153 1153
 		}
1154 1154
 		foreach ($appData['remote'] as $name => $path) {
1155
-			\OC::$server->getConfig()->setAppValue('core', 'remote_' . $name, $appId . '/' . $path);
1155
+			\OC::$server->getConfig()->setAppValue('core', 'remote_'.$name, $appId.'/'.$path);
1156 1156
 		}
1157 1157
 		foreach ($appData['public'] as $name => $path) {
1158
-			\OC::$server->getConfig()->setAppValue('core', 'public_' . $name, $appId . '/' . $path);
1158
+			\OC::$server->getConfig()->setAppValue('core', 'public_'.$name, $appId.'/'.$path);
1159 1159
 		}
1160 1160
 
1161 1161
 		self::setAppTypes($appId);
@@ -1225,17 +1225,17 @@  discard block
 block discarded – undo
1225 1225
 	public static function getStorage($appId) {
1226 1226
 		if (OC_App::isEnabled($appId)) { //sanity check
1227 1227
 			if (\OC::$server->getUserSession()->isLoggedIn()) {
1228
-				$view = new \OC\Files\View('/' . OC_User::getUser());
1228
+				$view = new \OC\Files\View('/'.OC_User::getUser());
1229 1229
 				if (!$view->file_exists($appId)) {
1230 1230
 					$view->mkdir($appId);
1231 1231
 				}
1232
-				return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId);
1232
+				return new \OC\Files\View('/'.OC_User::getUser().'/'.$appId);
1233 1233
 			} else {
1234
-				\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', \OCP\Util::ERROR);
1234
+				\OCP\Util::writeLog('core', 'Can\'t get app storage, app '.$appId.', user not logged in', \OCP\Util::ERROR);
1235 1235
 				return false;
1236 1236
 			}
1237 1237
 		} else {
1238
-			\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', \OCP\Util::ERROR);
1238
+			\OCP\Util::writeLog('core', 'Can\'t get app storage, app '.$appId.' not enabled', \OCP\Util::ERROR);
1239 1239
 			return false;
1240 1240
 		}
1241 1241
 	}
@@ -1267,9 +1267,9 @@  discard block
 block discarded – undo
1267 1267
 
1268 1268
 				if ($attributeLang === $similarLang) {
1269 1269
 					$similarLangFallback = $option['@value'];
1270
-				} else if (strpos($attributeLang, $similarLang . '_') === 0) {
1270
+				} else if (strpos($attributeLang, $similarLang.'_') === 0) {
1271 1271
 					if ($similarLangFallback === false) {
1272
-						$similarLangFallback =  $option['@value'];
1272
+						$similarLangFallback = $option['@value'];
1273 1273
 					}
1274 1274
 				}
1275 1275
 			} else {
@@ -1304,7 +1304,7 @@  discard block
 block discarded – undo
1304 1304
 			$data['description'] = trim(self::findBestL10NOption($data['description'], $lang));
1305 1305
 		} else if (isset($data['description']) && is_string($data['description'])) {
1306 1306
 			$data['description'] = trim($data['description']);
1307
-		} else  {
1307
+		} else {
1308 1308
 			$data['description'] = '';
1309 1309
 		}
1310 1310
 
Please login to merge, or discard this patch.
lib/private/NavigationManager.php 2 patches
Indentation   +236 added lines, -236 removed lines patch added patch discarded remove patch
@@ -41,261 +41,261 @@
 block discarded – undo
41 41
  */
42 42
 
43 43
 class NavigationManager implements INavigationManager {
44
-	protected $entries = [];
45
-	protected $closureEntries = [];
46
-	protected $activeEntry;
47
-	/** @var bool */
48
-	protected $init = false;
49
-	/** @var IAppManager|AppManager */
50
-	protected $appManager;
51
-	/** @var IURLGenerator */
52
-	private $urlGenerator;
53
-	/** @var IFactory */
54
-	private $l10nFac;
55
-	/** @var IUserSession */
56
-	private $userSession;
57
-	/** @var IGroupManager|Manager */
58
-	private $groupManager;
59
-	/** @var IConfig */
60
-	private $config;
44
+    protected $entries = [];
45
+    protected $closureEntries = [];
46
+    protected $activeEntry;
47
+    /** @var bool */
48
+    protected $init = false;
49
+    /** @var IAppManager|AppManager */
50
+    protected $appManager;
51
+    /** @var IURLGenerator */
52
+    private $urlGenerator;
53
+    /** @var IFactory */
54
+    private $l10nFac;
55
+    /** @var IUserSession */
56
+    private $userSession;
57
+    /** @var IGroupManager|Manager */
58
+    private $groupManager;
59
+    /** @var IConfig */
60
+    private $config;
61 61
 
62
-	public function __construct(IAppManager $appManager,
63
-						 IURLGenerator $urlGenerator,
64
-						 IFactory $l10nFac,
65
-						 IUserSession $userSession,
66
-						 IGroupManager $groupManager,
67
-						 IConfig $config) {
68
-		$this->appManager = $appManager;
69
-		$this->urlGenerator = $urlGenerator;
70
-		$this->l10nFac = $l10nFac;
71
-		$this->userSession = $userSession;
72
-		$this->groupManager = $groupManager;
73
-		$this->config = $config;
74
-	}
62
+    public function __construct(IAppManager $appManager,
63
+                            IURLGenerator $urlGenerator,
64
+                            IFactory $l10nFac,
65
+                            IUserSession $userSession,
66
+                            IGroupManager $groupManager,
67
+                            IConfig $config) {
68
+        $this->appManager = $appManager;
69
+        $this->urlGenerator = $urlGenerator;
70
+        $this->l10nFac = $l10nFac;
71
+        $this->userSession = $userSession;
72
+        $this->groupManager = $groupManager;
73
+        $this->config = $config;
74
+    }
75 75
 
76
-	/**
77
-	 * Creates a new navigation entry
78
-	 *
79
-	 * @param array|\Closure $entry Array containing: id, name, order, icon and href key
80
-	 *					The use of a closure is preferred, because it will avoid
81
-	 * 					loading the routing of your app, unless required.
82
-	 * @return void
83
-	 */
84
-	public function add($entry) {
85
-		if ($entry instanceof \Closure) {
86
-			$this->closureEntries[] = $entry;
87
-			return;
88
-		}
76
+    /**
77
+     * Creates a new navigation entry
78
+     *
79
+     * @param array|\Closure $entry Array containing: id, name, order, icon and href key
80
+     *					The use of a closure is preferred, because it will avoid
81
+     * 					loading the routing of your app, unless required.
82
+     * @return void
83
+     */
84
+    public function add($entry) {
85
+        if ($entry instanceof \Closure) {
86
+            $this->closureEntries[] = $entry;
87
+            return;
88
+        }
89 89
 
90
-		$entry['active'] = false;
91
-		if(!isset($entry['icon'])) {
92
-			$entry['icon'] = '';
93
-		}
94
-		if(!isset($entry['type'])) {
95
-			$entry['type'] = 'link';
96
-		}
97
-		$this->entries[] = $entry;
98
-	}
90
+        $entry['active'] = false;
91
+        if(!isset($entry['icon'])) {
92
+            $entry['icon'] = '';
93
+        }
94
+        if(!isset($entry['type'])) {
95
+            $entry['type'] = 'link';
96
+        }
97
+        $this->entries[] = $entry;
98
+    }
99 99
 
100
-	/**
101
-	 * returns all the added Menu entries
102
-	 * @param string $type
103
-	 * @return array an array of the added entries
104
-	 */
105
-	public function getAll($type = 'link') {
106
-		$this->init();
107
-		foreach ($this->closureEntries as $c) {
108
-			$this->add($c());
109
-		}
110
-		$this->closureEntries = array();
100
+    /**
101
+     * returns all the added Menu entries
102
+     * @param string $type
103
+     * @return array an array of the added entries
104
+     */
105
+    public function getAll($type = 'link') {
106
+        $this->init();
107
+        foreach ($this->closureEntries as $c) {
108
+            $this->add($c());
109
+        }
110
+        $this->closureEntries = array();
111 111
 
112
-		if ($type === 'all') {
113
-			return $this->entries;
114
-		}
112
+        if ($type === 'all') {
113
+            return $this->entries;
114
+        }
115 115
 
116
-		return array_filter($this->entries, function($entry) use ($type) {
117
-			return $entry['type'] === $type;
118
-		});
119
-	}
116
+        return array_filter($this->entries, function($entry) use ($type) {
117
+            return $entry['type'] === $type;
118
+        });
119
+    }
120 120
 
121
-	/**
122
-	 * Do not load the default links
123
-	 * This is just a hack for the files app
124
-	 * @internal
125
-	 */
126
-	public function noDefaultLinks() {
127
-		$this->entries = [];
128
-		$this->closureEntries = [];
129
-		$this->init = true;
130
-	}
121
+    /**
122
+     * Do not load the default links
123
+     * This is just a hack for the files app
124
+     * @internal
125
+     */
126
+    public function noDefaultLinks() {
127
+        $this->entries = [];
128
+        $this->closureEntries = [];
129
+        $this->init = true;
130
+    }
131 131
 
132
-	/**
133
-	 * removes all the entries
134
-	 */
135
-	public function clear() {
136
-		$this->entries = [];
137
-		$this->closureEntries = [];
138
-		$this->init = false;
139
-	}
132
+    /**
133
+     * removes all the entries
134
+     */
135
+    public function clear() {
136
+        $this->entries = [];
137
+        $this->closureEntries = [];
138
+        $this->init = false;
139
+    }
140 140
 
141
-	/**
142
-	 * Sets the current navigation entry of the currently running app
143
-	 * @param string $id of the app entry to activate (from added $entry)
144
-	 */
145
-	public function setActiveEntry($id) {
146
-		$this->activeEntry = $id;
147
-	}
141
+    /**
142
+     * Sets the current navigation entry of the currently running app
143
+     * @param string $id of the app entry to activate (from added $entry)
144
+     */
145
+    public function setActiveEntry($id) {
146
+        $this->activeEntry = $id;
147
+    }
148 148
 
149
-	/**
150
-	 * gets the active Menu entry
151
-	 * @return string id or empty string
152
-	 *
153
-	 * This function returns the id of the active navigation entry (set by
154
-	 * setActiveEntry
155
-	 */
156
-	public function getActiveEntry() {
157
-		return $this->activeEntry;
158
-	}
149
+    /**
150
+     * gets the active Menu entry
151
+     * @return string id or empty string
152
+     *
153
+     * This function returns the id of the active navigation entry (set by
154
+     * setActiveEntry
155
+     */
156
+    public function getActiveEntry() {
157
+        return $this->activeEntry;
158
+    }
159 159
 
160
-	private function init() {
161
-		if ($this->init) {
162
-			return;
163
-		}
164
-		$this->init = true;
160
+    private function init() {
161
+        if ($this->init) {
162
+            return;
163
+        }
164
+        $this->init = true;
165 165
 
166
-		if ($this->config->getSystemValue('knowledgebaseenabled', true)) {
167
-			$l = $this->l10nFac->get('lib');
168
-			$this->add([
169
-				'type' => 'settings',
170
-				'id' => 'help',
171
-				'order' => 4,
172
-				'href' => $this->urlGenerator->linkToRoute('settings_help'),
173
-				'name' => $l->t('Help'),
174
-				'icon' => $this->urlGenerator->imagePath('settings', 'help.svg'),
175
-			]);
176
-		}
166
+        if ($this->config->getSystemValue('knowledgebaseenabled', true)) {
167
+            $l = $this->l10nFac->get('lib');
168
+            $this->add([
169
+                'type' => 'settings',
170
+                'id' => 'help',
171
+                'order' => 4,
172
+                'href' => $this->urlGenerator->linkToRoute('settings_help'),
173
+                'name' => $l->t('Help'),
174
+                'icon' => $this->urlGenerator->imagePath('settings', 'help.svg'),
175
+            ]);
176
+        }
177 177
 
178
-		if ($this->userSession->isLoggedIn()) {
179
-			if ($this->isAdmin()) {
180
-				$l = $this->l10nFac->get('settings');
181
-				// App management
182
-				$this->add([
183
-					'id' => 'core_apps',
184
-					'order' => 9999,
185
-					'href' => $this->urlGenerator->linkToRoute('settings.AppSettings.viewApps'),
186
-					'icon' => $this->urlGenerator->imagePath('settings', 'apps.svg'),
187
-					'name' => $l->t('Apps'),
188
-				]);
189
-			}
178
+        if ($this->userSession->isLoggedIn()) {
179
+            if ($this->isAdmin()) {
180
+                $l = $this->l10nFac->get('settings');
181
+                // App management
182
+                $this->add([
183
+                    'id' => 'core_apps',
184
+                    'order' => 9999,
185
+                    'href' => $this->urlGenerator->linkToRoute('settings.AppSettings.viewApps'),
186
+                    'icon' => $this->urlGenerator->imagePath('settings', 'apps.svg'),
187
+                    'name' => $l->t('Apps'),
188
+                ]);
189
+            }
190 190
 
191
-			$l = $this->l10nFac->get('lib');
192
-			// Personal settings
193
-			$this->add([
194
-				'type' => 'settings',
195
-				'id' => 'personal',
196
-				'order' => 1,
197
-				'href' => $this->urlGenerator->linkToRoute('settings_personal'),
198
-				'name' => $l->t('Personal'),
199
-				'icon' => $this->urlGenerator->imagePath('settings', 'personal.svg'),
200
-			]);
191
+            $l = $this->l10nFac->get('lib');
192
+            // Personal settings
193
+            $this->add([
194
+                'type' => 'settings',
195
+                'id' => 'personal',
196
+                'order' => 1,
197
+                'href' => $this->urlGenerator->linkToRoute('settings_personal'),
198
+                'name' => $l->t('Personal'),
199
+                'icon' => $this->urlGenerator->imagePath('settings', 'personal.svg'),
200
+            ]);
201 201
 
202
-			// Logout
203
-			$this->add([
204
-				'type' => 'settings',
205
-				'id' => 'logout',
206
-				'order' => 99999,
207
-				'href' => $this->urlGenerator->linkToRouteAbsolute(
208
-					'core.login.logout',
209
-					['requesttoken' => \OCP\Util::callRegister()]
210
-				),
211
-				'name' => $l->t('Log out'),
212
-				'icon' => $this->urlGenerator->imagePath('core', 'actions/logout.svg'),
213
-			]);
202
+            // Logout
203
+            $this->add([
204
+                'type' => 'settings',
205
+                'id' => 'logout',
206
+                'order' => 99999,
207
+                'href' => $this->urlGenerator->linkToRouteAbsolute(
208
+                    'core.login.logout',
209
+                    ['requesttoken' => \OCP\Util::callRegister()]
210
+                ),
211
+                'name' => $l->t('Log out'),
212
+                'icon' => $this->urlGenerator->imagePath('core', 'actions/logout.svg'),
213
+            ]);
214 214
 
215
-			if ($this->isSubadmin()) {
216
-				// User management
217
-				$this->add([
218
-					'type' => 'settings',
219
-					'id' => 'core_users',
220
-					'order' => 3,
221
-					'href' => $this->urlGenerator->linkToRoute('settings_users'),
222
-					'name' => $l->t('Users'),
223
-					'icon' => $this->urlGenerator->imagePath('settings', 'users.svg'),
224
-				]);
225
-			}
215
+            if ($this->isSubadmin()) {
216
+                // User management
217
+                $this->add([
218
+                    'type' => 'settings',
219
+                    'id' => 'core_users',
220
+                    'order' => 3,
221
+                    'href' => $this->urlGenerator->linkToRoute('settings_users'),
222
+                    'name' => $l->t('Users'),
223
+                    'icon' => $this->urlGenerator->imagePath('settings', 'users.svg'),
224
+                ]);
225
+            }
226 226
 
227
-			if ($this->isAdmin()) {
228
-				// Admin settings
229
-				$this->add([
230
-					'type' => 'settings',
231
-					'id' => 'admin',
232
-					'order' => 2,
233
-					'href' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index'),
234
-					'name' => $l->t('Admin'),
235
-					'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'),
236
-				]);
237
-			}
238
-		}
227
+            if ($this->isAdmin()) {
228
+                // Admin settings
229
+                $this->add([
230
+                    'type' => 'settings',
231
+                    'id' => 'admin',
232
+                    'order' => 2,
233
+                    'href' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index'),
234
+                    'name' => $l->t('Admin'),
235
+                    'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'),
236
+                ]);
237
+            }
238
+        }
239 239
 
240
-		if ($this->appManager === 'null') {
241
-			return;
242
-		}
243
-		foreach ($this->appManager->getInstalledApps() as $app) {
244
-			// load plugins and collections from info.xml
245
-			$info = $this->appManager->getAppInfo($app);
246
-			if (!isset($info['navigation'])) {
247
-				continue;
248
-			}
249
-			$nav = $info['navigation'];
250
-			if (!isset($nav['name'])) {
251
-				continue;
252
-			}
253
-			if (!isset($nav['route'])) {
254
-				continue;
255
-			}
256
-			$role = isset($nav['@attributes']['role']) ? $nav['@attributes']['role'] : 'all';
257
-			if ($role === 'admin' && !$this->isAdmin()) {
258
-				continue;
259
-			}
260
-			$l = $this->l10nFac->get($app);
261
-			$order = isset($nav['order']) ? $nav['order'] : 100;
262
-			$route = $this->urlGenerator->linkToRoute($nav['route']);
263
-			$icon = isset($nav['icon']) ? $nav['icon'] : 'app.svg';
264
-			foreach ([$icon, "$app.svg"] as $i) {
265
-				try {
266
-					$icon = $this->urlGenerator->imagePath($app, $i);
267
-					break;
268
-				} catch (\RuntimeException $ex) {
269
-					// no icon? - ignore it then
270
-				}
271
-			}
272
-			if ($icon === null) {
273
-				$icon = $this->urlGenerator->imagePath('core', 'default-app-icon');
274
-			}
240
+        if ($this->appManager === 'null') {
241
+            return;
242
+        }
243
+        foreach ($this->appManager->getInstalledApps() as $app) {
244
+            // load plugins and collections from info.xml
245
+            $info = $this->appManager->getAppInfo($app);
246
+            if (!isset($info['navigation'])) {
247
+                continue;
248
+            }
249
+            $nav = $info['navigation'];
250
+            if (!isset($nav['name'])) {
251
+                continue;
252
+            }
253
+            if (!isset($nav['route'])) {
254
+                continue;
255
+            }
256
+            $role = isset($nav['@attributes']['role']) ? $nav['@attributes']['role'] : 'all';
257
+            if ($role === 'admin' && !$this->isAdmin()) {
258
+                continue;
259
+            }
260
+            $l = $this->l10nFac->get($app);
261
+            $order = isset($nav['order']) ? $nav['order'] : 100;
262
+            $route = $this->urlGenerator->linkToRoute($nav['route']);
263
+            $icon = isset($nav['icon']) ? $nav['icon'] : 'app.svg';
264
+            foreach ([$icon, "$app.svg"] as $i) {
265
+                try {
266
+                    $icon = $this->urlGenerator->imagePath($app, $i);
267
+                    break;
268
+                } catch (\RuntimeException $ex) {
269
+                    // no icon? - ignore it then
270
+                }
271
+            }
272
+            if ($icon === null) {
273
+                $icon = $this->urlGenerator->imagePath('core', 'default-app-icon');
274
+            }
275 275
 
276
-			$this->add([
277
-				'id' => $app,
278
-				'order' => $order,
279
-				'href' => $route,
280
-				'icon' => $icon,
281
-				'name' => $l->t($nav['name']),
282
-			]);
283
-		}
284
-	}
276
+            $this->add([
277
+                'id' => $app,
278
+                'order' => $order,
279
+                'href' => $route,
280
+                'icon' => $icon,
281
+                'name' => $l->t($nav['name']),
282
+            ]);
283
+        }
284
+    }
285 285
 
286
-	private function isAdmin() {
287
-		$user = $this->userSession->getUser();
288
-		if ($user !== null) {
289
-			return $this->groupManager->isAdmin($user->getUID());
290
-		}
291
-		return false;
292
-	}
286
+    private function isAdmin() {
287
+        $user = $this->userSession->getUser();
288
+        if ($user !== null) {
289
+            return $this->groupManager->isAdmin($user->getUID());
290
+        }
291
+        return false;
292
+    }
293 293
 
294
-	private function isSubadmin() {
295
-		$user = $this->userSession->getUser();
296
-		if ($user !== null) {
297
-			return $this->groupManager->getSubAdmin()->isSubAdmin($user);
298
-		}
299
-		return false;
300
-	}
294
+    private function isSubadmin() {
295
+        $user = $this->userSession->getUser();
296
+        if ($user !== null) {
297
+            return $this->groupManager->getSubAdmin()->isSubAdmin($user);
298
+        }
299
+        return false;
300
+    }
301 301
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -88,10 +88,10 @@
 block discarded – undo
88 88
 		}
89 89
 
90 90
 		$entry['active'] = false;
91
-		if(!isset($entry['icon'])) {
91
+		if (!isset($entry['icon'])) {
92 92
 			$entry['icon'] = '';
93 93
 		}
94
-		if(!isset($entry['type'])) {
94
+		if (!isset($entry['type'])) {
95 95
 			$entry['type'] = 'link';
96 96
 		}
97 97
 		$this->entries[] = $entry;
Please login to merge, or discard this patch.
lib/private/Server.php 2 patches
Indentation   +1579 added lines, -1579 removed lines patch added patch discarded remove patch
@@ -115,1588 +115,1588 @@
 block discarded – undo
115 115
  * TODO: hookup all manager classes
116 116
  */
117 117
 class Server extends ServerContainer implements IServerContainer {
118
-	/** @var string */
119
-	private $webRoot;
120
-
121
-	/**
122
-	 * @param string $webRoot
123
-	 * @param \OC\Config $config
124
-	 */
125
-	public function __construct($webRoot, \OC\Config $config) {
126
-		parent::__construct();
127
-		$this->webRoot = $webRoot;
128
-
129
-		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
130
-		$this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
131
-
132
-		$this->registerService(\OCP\IPreview::class, function (Server $c) {
133
-			return new PreviewManager(
134
-				$c->getConfig(),
135
-				$c->getRootFolder(),
136
-				$c->getAppDataDir('preview'),
137
-				$c->getEventDispatcher(),
138
-				$c->getSession()->get('user_id')
139
-			);
140
-		});
141
-		$this->registerAlias('PreviewManager', \OCP\IPreview::class);
142
-
143
-		$this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
144
-			return new \OC\Preview\Watcher(
145
-				$c->getAppDataDir('preview')
146
-			);
147
-		});
148
-
149
-		$this->registerService('EncryptionManager', function (Server $c) {
150
-			$view = new View();
151
-			$util = new Encryption\Util(
152
-				$view,
153
-				$c->getUserManager(),
154
-				$c->getGroupManager(),
155
-				$c->getConfig()
156
-			);
157
-			return new Encryption\Manager(
158
-				$c->getConfig(),
159
-				$c->getLogger(),
160
-				$c->getL10N('core'),
161
-				new View(),
162
-				$util,
163
-				new ArrayCache()
164
-			);
165
-		});
166
-
167
-		$this->registerService('EncryptionFileHelper', function (Server $c) {
168
-			$util = new Encryption\Util(
169
-				new View(),
170
-				$c->getUserManager(),
171
-				$c->getGroupManager(),
172
-				$c->getConfig()
173
-			);
174
-			return new Encryption\File($util);
175
-		});
176
-
177
-		$this->registerService('EncryptionKeyStorage', function (Server $c) {
178
-			$view = new View();
179
-			$util = new Encryption\Util(
180
-				$view,
181
-				$c->getUserManager(),
182
-				$c->getGroupManager(),
183
-				$c->getConfig()
184
-			);
185
-
186
-			return new Encryption\Keys\Storage($view, $util);
187
-		});
188
-		$this->registerService('TagMapper', function (Server $c) {
189
-			return new TagMapper($c->getDatabaseConnection());
190
-		});
191
-
192
-		$this->registerService(\OCP\ITagManager::class, function (Server $c) {
193
-			$tagMapper = $c->query('TagMapper');
194
-			return new TagManager($tagMapper, $c->getUserSession());
195
-		});
196
-		$this->registerAlias('TagManager', \OCP\ITagManager::class);
197
-
198
-		$this->registerService('SystemTagManagerFactory', function (Server $c) {
199
-			$config = $c->getConfig();
200
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
201
-			/** @var \OC\SystemTag\ManagerFactory $factory */
202
-			$factory = new $factoryClass($this);
203
-			return $factory;
204
-		});
205
-		$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
206
-			return $c->query('SystemTagManagerFactory')->getManager();
207
-		});
208
-		$this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
209
-
210
-		$this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
211
-			return $c->query('SystemTagManagerFactory')->getObjectMapper();
212
-		});
213
-		$this->registerService('RootFolder', function (Server $c) {
214
-			$manager = \OC\Files\Filesystem::getMountManager(null);
215
-			$view = new View();
216
-			$root = new Root(
217
-				$manager,
218
-				$view,
219
-				null,
220
-				$c->getUserMountCache(),
221
-				$this->getLogger(),
222
-				$this->getUserManager()
223
-			);
224
-			$connector = new HookConnector($root, $view);
225
-			$connector->viewToNode();
226
-
227
-			$previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
228
-			$previewConnector->connectWatcher();
229
-
230
-			return $root;
231
-		});
232
-		$this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
233
-
234
-		$this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) {
235
-			return new LazyRoot(function() use ($c) {
236
-				return $c->query('RootFolder');
237
-			});
238
-		});
239
-		$this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
240
-
241
-		$this->registerService(\OCP\IUserManager::class, function (Server $c) {
242
-			$config = $c->getConfig();
243
-			return new \OC\User\Manager($config);
244
-		});
245
-		$this->registerAlias('UserManager', \OCP\IUserManager::class);
246
-
247
-		$this->registerService(\OCP\IGroupManager::class, function (Server $c) {
248
-			$groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
249
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
250
-				\OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
251
-			});
252
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
253
-				\OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
254
-			});
255
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
256
-				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
257
-			});
258
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
259
-				\OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
260
-			});
261
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
262
-				\OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
263
-			});
264
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
265
-				\OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
266
-				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
267
-				\OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
268
-			});
269
-			return $groupManager;
270
-		});
271
-		$this->registerAlias('GroupManager', \OCP\IGroupManager::class);
272
-
273
-		$this->registerService(Store::class, function(Server $c) {
274
-			$session = $c->getSession();
275
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
276
-				$tokenProvider = $c->query('OC\Authentication\Token\IProvider');
277
-			} else {
278
-				$tokenProvider = null;
279
-			}
280
-			$logger = $c->getLogger();
281
-			return new Store($session, $logger, $tokenProvider);
282
-		});
283
-		$this->registerAlias(IStore::class, Store::class);
284
-		$this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
285
-			$dbConnection = $c->getDatabaseConnection();
286
-			return new Authentication\Token\DefaultTokenMapper($dbConnection);
287
-		});
288
-		$this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
289
-			$mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
290
-			$crypto = $c->getCrypto();
291
-			$config = $c->getConfig();
292
-			$logger = $c->getLogger();
293
-			$timeFactory = new TimeFactory();
294
-			return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
295
-		});
296
-		$this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
297
-
298
-		$this->registerService(\OCP\IUserSession::class, function (Server $c) {
299
-			$manager = $c->getUserManager();
300
-			$session = new \OC\Session\Memory('');
301
-			$timeFactory = new TimeFactory();
302
-			// Token providers might require a working database. This code
303
-			// might however be called when ownCloud is not yet setup.
304
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
305
-				$defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
306
-			} else {
307
-				$defaultTokenProvider = null;
308
-			}
309
-
310
-			$userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom());
311
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
312
-				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
313
-			});
314
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
315
-				/** @var $user \OC\User\User */
316
-				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
317
-			});
318
-			$userSession->listen('\OC\User', 'preDelete', function ($user) {
319
-				/** @var $user \OC\User\User */
320
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
321
-			});
322
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
323
-				/** @var $user \OC\User\User */
324
-				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
325
-			});
326
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
327
-				/** @var $user \OC\User\User */
328
-				\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
329
-			});
330
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
331
-				/** @var $user \OC\User\User */
332
-				\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
333
-			});
334
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
335
-				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
336
-			});
337
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
338
-				/** @var $user \OC\User\User */
339
-				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
340
-			});
341
-			$userSession->listen('\OC\User', 'logout', function () {
342
-				\OC_Hook::emit('OC_User', 'logout', array());
343
-			});
344
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) {
345
-				/** @var $user \OC\User\User */
346
-				\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value));
347
-			});
348
-			return $userSession;
349
-		});
350
-		$this->registerAlias('UserSession', \OCP\IUserSession::class);
351
-
352
-		$this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
353
-			return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger());
354
-		});
355
-
356
-		$this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
357
-		$this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
358
-
359
-		$this->registerService(\OC\AllConfig::class, function (Server $c) {
360
-			return new \OC\AllConfig(
361
-				$c->getSystemConfig()
362
-			);
363
-		});
364
-		$this->registerAlias('AllConfig', \OC\AllConfig::class);
365
-		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
366
-
367
-		$this->registerService('SystemConfig', function ($c) use ($config) {
368
-			return new \OC\SystemConfig($config);
369
-		});
370
-
371
-		$this->registerService(\OC\AppConfig::class, function (Server $c) {
372
-			return new \OC\AppConfig($c->getDatabaseConnection());
373
-		});
374
-		$this->registerAlias('AppConfig', \OC\AppConfig::class);
375
-		$this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
376
-
377
-		$this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
378
-			return new \OC\L10N\Factory(
379
-				$c->getConfig(),
380
-				$c->getRequest(),
381
-				$c->getUserSession(),
382
-				\OC::$SERVERROOT
383
-			);
384
-		});
385
-		$this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
386
-
387
-		$this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
388
-			$config = $c->getConfig();
389
-			$cacheFactory = $c->getMemCacheFactory();
390
-			return new \OC\URLGenerator(
391
-				$config,
392
-				$cacheFactory
393
-			);
394
-		});
395
-		$this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
396
-
397
-		$this->registerService('AppHelper', function ($c) {
398
-			return new \OC\AppHelper();
399
-		});
400
-		$this->registerService('AppFetcher', function ($c) {
401
-			return new AppFetcher(
402
-				$this->getAppDataDir('appstore'),
403
-				$this->getHTTPClientService(),
404
-				$this->query(TimeFactory::class),
405
-				$this->getConfig()
406
-			);
407
-		});
408
-		$this->registerService('CategoryFetcher', function ($c) {
409
-			return new CategoryFetcher(
410
-				$this->getAppDataDir('appstore'),
411
-				$this->getHTTPClientService(),
412
-				$this->query(TimeFactory::class),
413
-				$this->getConfig()
414
-			);
415
-		});
416
-
417
-		$this->registerService(\OCP\ICache::class, function ($c) {
418
-			return new Cache\File();
419
-		});
420
-		$this->registerAlias('UserCache', \OCP\ICache::class);
421
-
422
-		$this->registerService(Factory::class, function (Server $c) {
423
-			$config = $c->getConfig();
424
-
425
-			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
426
-				$v = \OC_App::getAppVersions();
427
-				$v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php'));
428
-				$version = implode(',', $v);
429
-				$instanceId = \OC_Util::getInstanceId();
430
-				$path = \OC::$SERVERROOT;
431
-				$prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT);
432
-				return new \OC\Memcache\Factory($prefix, $c->getLogger(),
433
-					$config->getSystemValue('memcache.local', null),
434
-					$config->getSystemValue('memcache.distributed', null),
435
-					$config->getSystemValue('memcache.locking', null)
436
-				);
437
-			}
438
-
439
-			return new \OC\Memcache\Factory('', $c->getLogger(),
440
-				'\\OC\\Memcache\\ArrayCache',
441
-				'\\OC\\Memcache\\ArrayCache',
442
-				'\\OC\\Memcache\\ArrayCache'
443
-			);
444
-		});
445
-		$this->registerAlias('MemCacheFactory', Factory::class);
446
-		$this->registerAlias(ICacheFactory::class, Factory::class);
447
-
448
-		$this->registerService('RedisFactory', function (Server $c) {
449
-			$systemConfig = $c->getSystemConfig();
450
-			return new RedisFactory($systemConfig);
451
-		});
452
-
453
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
454
-			return new \OC\Activity\Manager(
455
-				$c->getRequest(),
456
-				$c->getUserSession(),
457
-				$c->getConfig(),
458
-				$c->query(IValidator::class)
459
-			);
460
-		});
461
-		$this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
462
-
463
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
464
-			return new \OC\Activity\EventMerger(
465
-				$c->getL10N('lib')
466
-			);
467
-		});
468
-		$this->registerAlias(IValidator::class, Validator::class);
469
-
470
-		$this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
471
-			return new AvatarManager(
472
-				$c->getUserManager(),
473
-				$c->getAppDataDir('avatar'),
474
-				$c->getL10N('lib'),
475
-				$c->getLogger(),
476
-				$c->getConfig()
477
-			);
478
-		});
479
-		$this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
480
-
481
-		$this->registerService(\OCP\ILogger::class, function (Server $c) {
482
-			$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
483
-			$logger = Log::getLogClass($logType);
484
-			call_user_func(array($logger, 'init'));
485
-
486
-			return new Log($logger);
487
-		});
488
-		$this->registerAlias('Logger', \OCP\ILogger::class);
489
-
490
-		$this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
491
-			$config = $c->getConfig();
492
-			return new \OC\BackgroundJob\JobList(
493
-				$c->getDatabaseConnection(),
494
-				$config,
495
-				new TimeFactory()
496
-			);
497
-		});
498
-		$this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
499
-
500
-		$this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
501
-			$cacheFactory = $c->getMemCacheFactory();
502
-			$logger = $c->getLogger();
503
-			if ($cacheFactory->isAvailable()) {
504
-				$router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger);
505
-			} else {
506
-				$router = new \OC\Route\Router($logger);
507
-			}
508
-			return $router;
509
-		});
510
-		$this->registerAlias('Router', \OCP\Route\IRouter::class);
511
-
512
-		$this->registerService(\OCP\ISearch::class, function ($c) {
513
-			return new Search();
514
-		});
515
-		$this->registerAlias('Search', \OCP\ISearch::class);
516
-
517
-		$this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
518
-			return new SecureRandom();
519
-		});
520
-		$this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
521
-
522
-		$this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
523
-			return new Crypto($c->getConfig(), $c->getSecureRandom());
524
-		});
525
-		$this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
526
-
527
-		$this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
528
-			return new Hasher($c->getConfig());
529
-		});
530
-		$this->registerAlias('Hasher', \OCP\Security\IHasher::class);
531
-
532
-		$this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
533
-			return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
534
-		});
535
-		$this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
536
-
537
-		$this->registerService(IDBConnection::class, function (Server $c) {
538
-			$systemConfig = $c->getSystemConfig();
539
-			$factory = new \OC\DB\ConnectionFactory($systemConfig);
540
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
541
-			if (!$factory->isValidType($type)) {
542
-				throw new \OC\DatabaseException('Invalid database type');
543
-			}
544
-			$connectionParams = $factory->createConnectionParams();
545
-			$connection = $factory->getConnection($type, $connectionParams);
546
-			$connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
547
-			return $connection;
548
-		});
549
-		$this->registerAlias('DatabaseConnection', IDBConnection::class);
550
-
551
-		$this->registerService('HTTPHelper', function (Server $c) {
552
-			$config = $c->getConfig();
553
-			return new HTTPHelper(
554
-				$config,
555
-				$c->getHTTPClientService()
556
-			);
557
-		});
558
-
559
-		$this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
560
-			$user = \OC_User::getUser();
561
-			$uid = $user ? $user : null;
562
-			return new ClientService(
563
-				$c->getConfig(),
564
-				new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger())
565
-			);
566
-		});
567
-		$this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
568
-
569
-		$this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
570
-			if ($c->getSystemConfig()->getValue('debug', false)) {
571
-				return new EventLogger();
572
-			} else {
573
-				return new NullEventLogger();
574
-			}
575
-		});
576
-		$this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
577
-
578
-		$this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
579
-			if ($c->getSystemConfig()->getValue('debug', false)) {
580
-				return new QueryLogger();
581
-			} else {
582
-				return new NullQueryLogger();
583
-			}
584
-		});
585
-		$this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
586
-
587
-		$this->registerService(TempManager::class, function (Server $c) {
588
-			return new TempManager(
589
-				$c->getLogger(),
590
-				$c->getConfig()
591
-			);
592
-		});
593
-		$this->registerAlias('TempManager', TempManager::class);
594
-		$this->registerAlias(ITempManager::class, TempManager::class);
595
-
596
-		$this->registerService(AppManager::class, function (Server $c) {
597
-			return new \OC\App\AppManager(
598
-				$c->getUserSession(),
599
-				$c->getAppConfig(),
600
-				$c->getGroupManager(),
601
-				$c->getMemCacheFactory(),
602
-				$c->getEventDispatcher()
603
-			);
604
-		});
605
-		$this->registerAlias('AppManager', AppManager::class);
606
-		$this->registerAlias(IAppManager::class, AppManager::class);
607
-
608
-		$this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
609
-			return new DateTimeZone(
610
-				$c->getConfig(),
611
-				$c->getSession()
612
-			);
613
-		});
614
-		$this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
615
-
616
-		$this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
617
-			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
618
-
619
-			return new DateTimeFormatter(
620
-				$c->getDateTimeZone()->getTimeZone(),
621
-				$c->getL10N('lib', $language)
622
-			);
623
-		});
624
-		$this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
625
-
626
-		$this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
627
-			$mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
628
-			$listener = new UserMountCacheListener($mountCache);
629
-			$listener->listen($c->getUserManager());
630
-			return $mountCache;
631
-		});
632
-		$this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
633
-
634
-		$this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
635
-			$loader = \OC\Files\Filesystem::getLoader();
636
-			$mountCache = $c->query('UserMountCache');
637
-			$manager =  new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
638
-
639
-			// builtin providers
640
-
641
-			$config = $c->getConfig();
642
-			$manager->registerProvider(new CacheMountProvider($config));
643
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
644
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
645
-
646
-			return $manager;
647
-		});
648
-		$this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
649
-
650
-		$this->registerService('IniWrapper', function ($c) {
651
-			return new IniGetWrapper();
652
-		});
653
-		$this->registerService('AsyncCommandBus', function (Server $c) {
654
-			$jobList = $c->getJobList();
655
-			return new AsyncBus($jobList);
656
-		});
657
-		$this->registerService('TrustedDomainHelper', function ($c) {
658
-			return new TrustedDomainHelper($this->getConfig());
659
-		});
660
-		$this->registerService('Throttler', function(Server $c) {
661
-			return new Throttler(
662
-				$c->getDatabaseConnection(),
663
-				new TimeFactory(),
664
-				$c->getLogger(),
665
-				$c->getConfig()
666
-			);
667
-		});
668
-		$this->registerService('IntegrityCodeChecker', function (Server $c) {
669
-			// IConfig and IAppManager requires a working database. This code
670
-			// might however be called when ownCloud is not yet setup.
671
-			if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
672
-				$config = $c->getConfig();
673
-				$appManager = $c->getAppManager();
674
-			} else {
675
-				$config = null;
676
-				$appManager = null;
677
-			}
678
-
679
-			return new Checker(
680
-					new EnvironmentHelper(),
681
-					new FileAccessHelper(),
682
-					new AppLocator(),
683
-					$config,
684
-					$c->getMemCacheFactory(),
685
-					$appManager,
686
-					$c->getTempManager()
687
-			);
688
-		});
689
-		$this->registerService(\OCP\IRequest::class, function ($c) {
690
-			if (isset($this['urlParams'])) {
691
-				$urlParams = $this['urlParams'];
692
-			} else {
693
-				$urlParams = [];
694
-			}
695
-
696
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
697
-				&& in_array('fakeinput', stream_get_wrappers())
698
-			) {
699
-				$stream = 'fakeinput://data';
700
-			} else {
701
-				$stream = 'php://input';
702
-			}
703
-
704
-			return new Request(
705
-				[
706
-					'get' => $_GET,
707
-					'post' => $_POST,
708
-					'files' => $_FILES,
709
-					'server' => $_SERVER,
710
-					'env' => $_ENV,
711
-					'cookies' => $_COOKIE,
712
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
713
-						? $_SERVER['REQUEST_METHOD']
714
-						: null,
715
-					'urlParams' => $urlParams,
716
-				],
717
-				$this->getSecureRandom(),
718
-				$this->getConfig(),
719
-				$this->getCsrfTokenManager(),
720
-				$stream
721
-			);
722
-		});
723
-		$this->registerAlias('Request', \OCP\IRequest::class);
724
-
725
-		$this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
726
-			return new Mailer(
727
-				$c->getConfig(),
728
-				$c->getLogger(),
729
-				$c->getThemingDefaults()
730
-			);
731
-		});
732
-		$this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
733
-
734
-		$this->registerService('LDAPProvider', function(Server $c) {
735
-			$config = $c->getConfig();
736
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
737
-			if(is_null($factoryClass)) {
738
-				throw new \Exception('ldapProviderFactory not set');
739
-			}
740
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
741
-			$factory = new $factoryClass($this);
742
-			return $factory->getLDAPProvider();
743
-		});
744
-		$this->registerService('LockingProvider', function (Server $c) {
745
-			$ini = $c->getIniWrapper();
746
-			$config = $c->getConfig();
747
-			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
748
-			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
749
-				/** @var \OC\Memcache\Factory $memcacheFactory */
750
-				$memcacheFactory = $c->getMemCacheFactory();
751
-				$memcache = $memcacheFactory->createLocking('lock');
752
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
753
-					return new MemcacheLockingProvider($memcache, $ttl);
754
-				}
755
-				return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
756
-			}
757
-			return new NoopLockingProvider();
758
-		});
759
-
760
-		$this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
761
-			return new \OC\Files\Mount\Manager();
762
-		});
763
-		$this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
764
-
765
-		$this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
766
-			return new \OC\Files\Type\Detection(
767
-				$c->getURLGenerator(),
768
-				\OC::$configDir,
769
-				\OC::$SERVERROOT . '/resources/config/'
770
-			);
771
-		});
772
-		$this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
773
-
774
-		$this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
775
-			return new \OC\Files\Type\Loader(
776
-				$c->getDatabaseConnection()
777
-			);
778
-		});
779
-		$this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
780
-
781
-		$this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
782
-			return new Manager(
783
-				$c->query(IValidator::class)
784
-			);
785
-		});
786
-		$this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
787
-
788
-		$this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
789
-			$manager = new \OC\CapabilitiesManager($c->getLogger());
790
-			$manager->registerCapability(function () use ($c) {
791
-				return new \OC\OCS\CoreCapabilities($c->getConfig());
792
-			});
793
-			return $manager;
794
-		});
795
-		$this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
796
-
797
-		$this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) {
798
-			$config = $c->getConfig();
799
-			$factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
800
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
801
-			$factory = new $factoryClass($this);
802
-			return $factory->getManager();
803
-		});
804
-		$this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
805
-
806
-		$this->registerService('ThemingDefaults', function(Server $c) {
807
-			/*
118
+    /** @var string */
119
+    private $webRoot;
120
+
121
+    /**
122
+     * @param string $webRoot
123
+     * @param \OC\Config $config
124
+     */
125
+    public function __construct($webRoot, \OC\Config $config) {
126
+        parent::__construct();
127
+        $this->webRoot = $webRoot;
128
+
129
+        $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
130
+        $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
131
+
132
+        $this->registerService(\OCP\IPreview::class, function (Server $c) {
133
+            return new PreviewManager(
134
+                $c->getConfig(),
135
+                $c->getRootFolder(),
136
+                $c->getAppDataDir('preview'),
137
+                $c->getEventDispatcher(),
138
+                $c->getSession()->get('user_id')
139
+            );
140
+        });
141
+        $this->registerAlias('PreviewManager', \OCP\IPreview::class);
142
+
143
+        $this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
144
+            return new \OC\Preview\Watcher(
145
+                $c->getAppDataDir('preview')
146
+            );
147
+        });
148
+
149
+        $this->registerService('EncryptionManager', function (Server $c) {
150
+            $view = new View();
151
+            $util = new Encryption\Util(
152
+                $view,
153
+                $c->getUserManager(),
154
+                $c->getGroupManager(),
155
+                $c->getConfig()
156
+            );
157
+            return new Encryption\Manager(
158
+                $c->getConfig(),
159
+                $c->getLogger(),
160
+                $c->getL10N('core'),
161
+                new View(),
162
+                $util,
163
+                new ArrayCache()
164
+            );
165
+        });
166
+
167
+        $this->registerService('EncryptionFileHelper', function (Server $c) {
168
+            $util = new Encryption\Util(
169
+                new View(),
170
+                $c->getUserManager(),
171
+                $c->getGroupManager(),
172
+                $c->getConfig()
173
+            );
174
+            return new Encryption\File($util);
175
+        });
176
+
177
+        $this->registerService('EncryptionKeyStorage', function (Server $c) {
178
+            $view = new View();
179
+            $util = new Encryption\Util(
180
+                $view,
181
+                $c->getUserManager(),
182
+                $c->getGroupManager(),
183
+                $c->getConfig()
184
+            );
185
+
186
+            return new Encryption\Keys\Storage($view, $util);
187
+        });
188
+        $this->registerService('TagMapper', function (Server $c) {
189
+            return new TagMapper($c->getDatabaseConnection());
190
+        });
191
+
192
+        $this->registerService(\OCP\ITagManager::class, function (Server $c) {
193
+            $tagMapper = $c->query('TagMapper');
194
+            return new TagManager($tagMapper, $c->getUserSession());
195
+        });
196
+        $this->registerAlias('TagManager', \OCP\ITagManager::class);
197
+
198
+        $this->registerService('SystemTagManagerFactory', function (Server $c) {
199
+            $config = $c->getConfig();
200
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
201
+            /** @var \OC\SystemTag\ManagerFactory $factory */
202
+            $factory = new $factoryClass($this);
203
+            return $factory;
204
+        });
205
+        $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
206
+            return $c->query('SystemTagManagerFactory')->getManager();
207
+        });
208
+        $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
209
+
210
+        $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
211
+            return $c->query('SystemTagManagerFactory')->getObjectMapper();
212
+        });
213
+        $this->registerService('RootFolder', function (Server $c) {
214
+            $manager = \OC\Files\Filesystem::getMountManager(null);
215
+            $view = new View();
216
+            $root = new Root(
217
+                $manager,
218
+                $view,
219
+                null,
220
+                $c->getUserMountCache(),
221
+                $this->getLogger(),
222
+                $this->getUserManager()
223
+            );
224
+            $connector = new HookConnector($root, $view);
225
+            $connector->viewToNode();
226
+
227
+            $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
228
+            $previewConnector->connectWatcher();
229
+
230
+            return $root;
231
+        });
232
+        $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
233
+
234
+        $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) {
235
+            return new LazyRoot(function() use ($c) {
236
+                return $c->query('RootFolder');
237
+            });
238
+        });
239
+        $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
240
+
241
+        $this->registerService(\OCP\IUserManager::class, function (Server $c) {
242
+            $config = $c->getConfig();
243
+            return new \OC\User\Manager($config);
244
+        });
245
+        $this->registerAlias('UserManager', \OCP\IUserManager::class);
246
+
247
+        $this->registerService(\OCP\IGroupManager::class, function (Server $c) {
248
+            $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
249
+            $groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
250
+                \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
251
+            });
252
+            $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
253
+                \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
254
+            });
255
+            $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
256
+                \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
257
+            });
258
+            $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
259
+                \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
260
+            });
261
+            $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
262
+                \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
263
+            });
264
+            $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
265
+                \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
266
+                //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
267
+                \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
268
+            });
269
+            return $groupManager;
270
+        });
271
+        $this->registerAlias('GroupManager', \OCP\IGroupManager::class);
272
+
273
+        $this->registerService(Store::class, function(Server $c) {
274
+            $session = $c->getSession();
275
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
276
+                $tokenProvider = $c->query('OC\Authentication\Token\IProvider');
277
+            } else {
278
+                $tokenProvider = null;
279
+            }
280
+            $logger = $c->getLogger();
281
+            return new Store($session, $logger, $tokenProvider);
282
+        });
283
+        $this->registerAlias(IStore::class, Store::class);
284
+        $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
285
+            $dbConnection = $c->getDatabaseConnection();
286
+            return new Authentication\Token\DefaultTokenMapper($dbConnection);
287
+        });
288
+        $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
289
+            $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
290
+            $crypto = $c->getCrypto();
291
+            $config = $c->getConfig();
292
+            $logger = $c->getLogger();
293
+            $timeFactory = new TimeFactory();
294
+            return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
295
+        });
296
+        $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
297
+
298
+        $this->registerService(\OCP\IUserSession::class, function (Server $c) {
299
+            $manager = $c->getUserManager();
300
+            $session = new \OC\Session\Memory('');
301
+            $timeFactory = new TimeFactory();
302
+            // Token providers might require a working database. This code
303
+            // might however be called when ownCloud is not yet setup.
304
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
305
+                $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
306
+            } else {
307
+                $defaultTokenProvider = null;
308
+            }
309
+
310
+            $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom());
311
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
312
+                \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
313
+            });
314
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
315
+                /** @var $user \OC\User\User */
316
+                \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
317
+            });
318
+            $userSession->listen('\OC\User', 'preDelete', function ($user) {
319
+                /** @var $user \OC\User\User */
320
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
321
+            });
322
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
323
+                /** @var $user \OC\User\User */
324
+                \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
325
+            });
326
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
327
+                /** @var $user \OC\User\User */
328
+                \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
329
+            });
330
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
331
+                /** @var $user \OC\User\User */
332
+                \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
333
+            });
334
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
335
+                \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
336
+            });
337
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
338
+                /** @var $user \OC\User\User */
339
+                \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
340
+            });
341
+            $userSession->listen('\OC\User', 'logout', function () {
342
+                \OC_Hook::emit('OC_User', 'logout', array());
343
+            });
344
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) {
345
+                /** @var $user \OC\User\User */
346
+                \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value));
347
+            });
348
+            return $userSession;
349
+        });
350
+        $this->registerAlias('UserSession', \OCP\IUserSession::class);
351
+
352
+        $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
353
+            return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger());
354
+        });
355
+
356
+        $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
357
+        $this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
358
+
359
+        $this->registerService(\OC\AllConfig::class, function (Server $c) {
360
+            return new \OC\AllConfig(
361
+                $c->getSystemConfig()
362
+            );
363
+        });
364
+        $this->registerAlias('AllConfig', \OC\AllConfig::class);
365
+        $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
366
+
367
+        $this->registerService('SystemConfig', function ($c) use ($config) {
368
+            return new \OC\SystemConfig($config);
369
+        });
370
+
371
+        $this->registerService(\OC\AppConfig::class, function (Server $c) {
372
+            return new \OC\AppConfig($c->getDatabaseConnection());
373
+        });
374
+        $this->registerAlias('AppConfig', \OC\AppConfig::class);
375
+        $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
376
+
377
+        $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
378
+            return new \OC\L10N\Factory(
379
+                $c->getConfig(),
380
+                $c->getRequest(),
381
+                $c->getUserSession(),
382
+                \OC::$SERVERROOT
383
+            );
384
+        });
385
+        $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
386
+
387
+        $this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
388
+            $config = $c->getConfig();
389
+            $cacheFactory = $c->getMemCacheFactory();
390
+            return new \OC\URLGenerator(
391
+                $config,
392
+                $cacheFactory
393
+            );
394
+        });
395
+        $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
396
+
397
+        $this->registerService('AppHelper', function ($c) {
398
+            return new \OC\AppHelper();
399
+        });
400
+        $this->registerService('AppFetcher', function ($c) {
401
+            return new AppFetcher(
402
+                $this->getAppDataDir('appstore'),
403
+                $this->getHTTPClientService(),
404
+                $this->query(TimeFactory::class),
405
+                $this->getConfig()
406
+            );
407
+        });
408
+        $this->registerService('CategoryFetcher', function ($c) {
409
+            return new CategoryFetcher(
410
+                $this->getAppDataDir('appstore'),
411
+                $this->getHTTPClientService(),
412
+                $this->query(TimeFactory::class),
413
+                $this->getConfig()
414
+            );
415
+        });
416
+
417
+        $this->registerService(\OCP\ICache::class, function ($c) {
418
+            return new Cache\File();
419
+        });
420
+        $this->registerAlias('UserCache', \OCP\ICache::class);
421
+
422
+        $this->registerService(Factory::class, function (Server $c) {
423
+            $config = $c->getConfig();
424
+
425
+            if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
426
+                $v = \OC_App::getAppVersions();
427
+                $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php'));
428
+                $version = implode(',', $v);
429
+                $instanceId = \OC_Util::getInstanceId();
430
+                $path = \OC::$SERVERROOT;
431
+                $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT);
432
+                return new \OC\Memcache\Factory($prefix, $c->getLogger(),
433
+                    $config->getSystemValue('memcache.local', null),
434
+                    $config->getSystemValue('memcache.distributed', null),
435
+                    $config->getSystemValue('memcache.locking', null)
436
+                );
437
+            }
438
+
439
+            return new \OC\Memcache\Factory('', $c->getLogger(),
440
+                '\\OC\\Memcache\\ArrayCache',
441
+                '\\OC\\Memcache\\ArrayCache',
442
+                '\\OC\\Memcache\\ArrayCache'
443
+            );
444
+        });
445
+        $this->registerAlias('MemCacheFactory', Factory::class);
446
+        $this->registerAlias(ICacheFactory::class, Factory::class);
447
+
448
+        $this->registerService('RedisFactory', function (Server $c) {
449
+            $systemConfig = $c->getSystemConfig();
450
+            return new RedisFactory($systemConfig);
451
+        });
452
+
453
+        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
454
+            return new \OC\Activity\Manager(
455
+                $c->getRequest(),
456
+                $c->getUserSession(),
457
+                $c->getConfig(),
458
+                $c->query(IValidator::class)
459
+            );
460
+        });
461
+        $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
462
+
463
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
464
+            return new \OC\Activity\EventMerger(
465
+                $c->getL10N('lib')
466
+            );
467
+        });
468
+        $this->registerAlias(IValidator::class, Validator::class);
469
+
470
+        $this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
471
+            return new AvatarManager(
472
+                $c->getUserManager(),
473
+                $c->getAppDataDir('avatar'),
474
+                $c->getL10N('lib'),
475
+                $c->getLogger(),
476
+                $c->getConfig()
477
+            );
478
+        });
479
+        $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
480
+
481
+        $this->registerService(\OCP\ILogger::class, function (Server $c) {
482
+            $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
483
+            $logger = Log::getLogClass($logType);
484
+            call_user_func(array($logger, 'init'));
485
+
486
+            return new Log($logger);
487
+        });
488
+        $this->registerAlias('Logger', \OCP\ILogger::class);
489
+
490
+        $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
491
+            $config = $c->getConfig();
492
+            return new \OC\BackgroundJob\JobList(
493
+                $c->getDatabaseConnection(),
494
+                $config,
495
+                new TimeFactory()
496
+            );
497
+        });
498
+        $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
499
+
500
+        $this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
501
+            $cacheFactory = $c->getMemCacheFactory();
502
+            $logger = $c->getLogger();
503
+            if ($cacheFactory->isAvailable()) {
504
+                $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger);
505
+            } else {
506
+                $router = new \OC\Route\Router($logger);
507
+            }
508
+            return $router;
509
+        });
510
+        $this->registerAlias('Router', \OCP\Route\IRouter::class);
511
+
512
+        $this->registerService(\OCP\ISearch::class, function ($c) {
513
+            return new Search();
514
+        });
515
+        $this->registerAlias('Search', \OCP\ISearch::class);
516
+
517
+        $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
518
+            return new SecureRandom();
519
+        });
520
+        $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
521
+
522
+        $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
523
+            return new Crypto($c->getConfig(), $c->getSecureRandom());
524
+        });
525
+        $this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
526
+
527
+        $this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
528
+            return new Hasher($c->getConfig());
529
+        });
530
+        $this->registerAlias('Hasher', \OCP\Security\IHasher::class);
531
+
532
+        $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
533
+            return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
534
+        });
535
+        $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
536
+
537
+        $this->registerService(IDBConnection::class, function (Server $c) {
538
+            $systemConfig = $c->getSystemConfig();
539
+            $factory = new \OC\DB\ConnectionFactory($systemConfig);
540
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
541
+            if (!$factory->isValidType($type)) {
542
+                throw new \OC\DatabaseException('Invalid database type');
543
+            }
544
+            $connectionParams = $factory->createConnectionParams();
545
+            $connection = $factory->getConnection($type, $connectionParams);
546
+            $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
547
+            return $connection;
548
+        });
549
+        $this->registerAlias('DatabaseConnection', IDBConnection::class);
550
+
551
+        $this->registerService('HTTPHelper', function (Server $c) {
552
+            $config = $c->getConfig();
553
+            return new HTTPHelper(
554
+                $config,
555
+                $c->getHTTPClientService()
556
+            );
557
+        });
558
+
559
+        $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
560
+            $user = \OC_User::getUser();
561
+            $uid = $user ? $user : null;
562
+            return new ClientService(
563
+                $c->getConfig(),
564
+                new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger())
565
+            );
566
+        });
567
+        $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
568
+
569
+        $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
570
+            if ($c->getSystemConfig()->getValue('debug', false)) {
571
+                return new EventLogger();
572
+            } else {
573
+                return new NullEventLogger();
574
+            }
575
+        });
576
+        $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
577
+
578
+        $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
579
+            if ($c->getSystemConfig()->getValue('debug', false)) {
580
+                return new QueryLogger();
581
+            } else {
582
+                return new NullQueryLogger();
583
+            }
584
+        });
585
+        $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
586
+
587
+        $this->registerService(TempManager::class, function (Server $c) {
588
+            return new TempManager(
589
+                $c->getLogger(),
590
+                $c->getConfig()
591
+            );
592
+        });
593
+        $this->registerAlias('TempManager', TempManager::class);
594
+        $this->registerAlias(ITempManager::class, TempManager::class);
595
+
596
+        $this->registerService(AppManager::class, function (Server $c) {
597
+            return new \OC\App\AppManager(
598
+                $c->getUserSession(),
599
+                $c->getAppConfig(),
600
+                $c->getGroupManager(),
601
+                $c->getMemCacheFactory(),
602
+                $c->getEventDispatcher()
603
+            );
604
+        });
605
+        $this->registerAlias('AppManager', AppManager::class);
606
+        $this->registerAlias(IAppManager::class, AppManager::class);
607
+
608
+        $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
609
+            return new DateTimeZone(
610
+                $c->getConfig(),
611
+                $c->getSession()
612
+            );
613
+        });
614
+        $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
615
+
616
+        $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
617
+            $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
618
+
619
+            return new DateTimeFormatter(
620
+                $c->getDateTimeZone()->getTimeZone(),
621
+                $c->getL10N('lib', $language)
622
+            );
623
+        });
624
+        $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
625
+
626
+        $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
627
+            $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
628
+            $listener = new UserMountCacheListener($mountCache);
629
+            $listener->listen($c->getUserManager());
630
+            return $mountCache;
631
+        });
632
+        $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
633
+
634
+        $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
635
+            $loader = \OC\Files\Filesystem::getLoader();
636
+            $mountCache = $c->query('UserMountCache');
637
+            $manager =  new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
638
+
639
+            // builtin providers
640
+
641
+            $config = $c->getConfig();
642
+            $manager->registerProvider(new CacheMountProvider($config));
643
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
644
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
645
+
646
+            return $manager;
647
+        });
648
+        $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
649
+
650
+        $this->registerService('IniWrapper', function ($c) {
651
+            return new IniGetWrapper();
652
+        });
653
+        $this->registerService('AsyncCommandBus', function (Server $c) {
654
+            $jobList = $c->getJobList();
655
+            return new AsyncBus($jobList);
656
+        });
657
+        $this->registerService('TrustedDomainHelper', function ($c) {
658
+            return new TrustedDomainHelper($this->getConfig());
659
+        });
660
+        $this->registerService('Throttler', function(Server $c) {
661
+            return new Throttler(
662
+                $c->getDatabaseConnection(),
663
+                new TimeFactory(),
664
+                $c->getLogger(),
665
+                $c->getConfig()
666
+            );
667
+        });
668
+        $this->registerService('IntegrityCodeChecker', function (Server $c) {
669
+            // IConfig and IAppManager requires a working database. This code
670
+            // might however be called when ownCloud is not yet setup.
671
+            if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
672
+                $config = $c->getConfig();
673
+                $appManager = $c->getAppManager();
674
+            } else {
675
+                $config = null;
676
+                $appManager = null;
677
+            }
678
+
679
+            return new Checker(
680
+                    new EnvironmentHelper(),
681
+                    new FileAccessHelper(),
682
+                    new AppLocator(),
683
+                    $config,
684
+                    $c->getMemCacheFactory(),
685
+                    $appManager,
686
+                    $c->getTempManager()
687
+            );
688
+        });
689
+        $this->registerService(\OCP\IRequest::class, function ($c) {
690
+            if (isset($this['urlParams'])) {
691
+                $urlParams = $this['urlParams'];
692
+            } else {
693
+                $urlParams = [];
694
+            }
695
+
696
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
697
+                && in_array('fakeinput', stream_get_wrappers())
698
+            ) {
699
+                $stream = 'fakeinput://data';
700
+            } else {
701
+                $stream = 'php://input';
702
+            }
703
+
704
+            return new Request(
705
+                [
706
+                    'get' => $_GET,
707
+                    'post' => $_POST,
708
+                    'files' => $_FILES,
709
+                    'server' => $_SERVER,
710
+                    'env' => $_ENV,
711
+                    'cookies' => $_COOKIE,
712
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
713
+                        ? $_SERVER['REQUEST_METHOD']
714
+                        : null,
715
+                    'urlParams' => $urlParams,
716
+                ],
717
+                $this->getSecureRandom(),
718
+                $this->getConfig(),
719
+                $this->getCsrfTokenManager(),
720
+                $stream
721
+            );
722
+        });
723
+        $this->registerAlias('Request', \OCP\IRequest::class);
724
+
725
+        $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
726
+            return new Mailer(
727
+                $c->getConfig(),
728
+                $c->getLogger(),
729
+                $c->getThemingDefaults()
730
+            );
731
+        });
732
+        $this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
733
+
734
+        $this->registerService('LDAPProvider', function(Server $c) {
735
+            $config = $c->getConfig();
736
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
737
+            if(is_null($factoryClass)) {
738
+                throw new \Exception('ldapProviderFactory not set');
739
+            }
740
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
741
+            $factory = new $factoryClass($this);
742
+            return $factory->getLDAPProvider();
743
+        });
744
+        $this->registerService('LockingProvider', function (Server $c) {
745
+            $ini = $c->getIniWrapper();
746
+            $config = $c->getConfig();
747
+            $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
748
+            if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
749
+                /** @var \OC\Memcache\Factory $memcacheFactory */
750
+                $memcacheFactory = $c->getMemCacheFactory();
751
+                $memcache = $memcacheFactory->createLocking('lock');
752
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
753
+                    return new MemcacheLockingProvider($memcache, $ttl);
754
+                }
755
+                return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
756
+            }
757
+            return new NoopLockingProvider();
758
+        });
759
+
760
+        $this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
761
+            return new \OC\Files\Mount\Manager();
762
+        });
763
+        $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
764
+
765
+        $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
766
+            return new \OC\Files\Type\Detection(
767
+                $c->getURLGenerator(),
768
+                \OC::$configDir,
769
+                \OC::$SERVERROOT . '/resources/config/'
770
+            );
771
+        });
772
+        $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
773
+
774
+        $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
775
+            return new \OC\Files\Type\Loader(
776
+                $c->getDatabaseConnection()
777
+            );
778
+        });
779
+        $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
780
+
781
+        $this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
782
+            return new Manager(
783
+                $c->query(IValidator::class)
784
+            );
785
+        });
786
+        $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
787
+
788
+        $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
789
+            $manager = new \OC\CapabilitiesManager($c->getLogger());
790
+            $manager->registerCapability(function () use ($c) {
791
+                return new \OC\OCS\CoreCapabilities($c->getConfig());
792
+            });
793
+            return $manager;
794
+        });
795
+        $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
796
+
797
+        $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) {
798
+            $config = $c->getConfig();
799
+            $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
800
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
801
+            $factory = new $factoryClass($this);
802
+            return $factory->getManager();
803
+        });
804
+        $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
805
+
806
+        $this->registerService('ThemingDefaults', function(Server $c) {
807
+            /*
808 808
 			 * Dark magic for autoloader.
809 809
 			 * If we do a class_exists it will try to load the class which will
810 810
 			 * make composer cache the result. Resulting in errors when enabling
811 811
 			 * the theming app.
812 812
 			 */
813
-			$prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
814
-			if (isset($prefixes['OCA\\Theming\\'])) {
815
-				$classExists = true;
816
-			} else {
817
-				$classExists = false;
818
-			}
819
-
820
-			if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) {
821
-				return new ThemingDefaults(
822
-					$c->getConfig(),
823
-					$c->getL10N('theming'),
824
-					$c->getURLGenerator(),
825
-					new \OC_Defaults(),
826
-					$c->getLazyRootFolder(),
827
-					$c->getMemCacheFactory()
828
-				);
829
-			}
830
-			return new \OC_Defaults();
831
-		});
832
-		$this->registerService(EventDispatcher::class, function () {
833
-			return new EventDispatcher();
834
-		});
835
-		$this->registerAlias('EventDispatcher', EventDispatcher::class);
836
-		$this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class);
837
-
838
-		$this->registerService('CryptoWrapper', function (Server $c) {
839
-			// FIXME: Instantiiated here due to cyclic dependency
840
-			$request = new Request(
841
-				[
842
-					'get' => $_GET,
843
-					'post' => $_POST,
844
-					'files' => $_FILES,
845
-					'server' => $_SERVER,
846
-					'env' => $_ENV,
847
-					'cookies' => $_COOKIE,
848
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
849
-						? $_SERVER['REQUEST_METHOD']
850
-						: null,
851
-				],
852
-				$c->getSecureRandom(),
853
-				$c->getConfig()
854
-			);
855
-
856
-			return new CryptoWrapper(
857
-				$c->getConfig(),
858
-				$c->getCrypto(),
859
-				$c->getSecureRandom(),
860
-				$request
861
-			);
862
-		});
863
-		$this->registerService('CsrfTokenManager', function (Server $c) {
864
-			$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
865
-
866
-			return new CsrfTokenManager(
867
-				$tokenGenerator,
868
-				$c->query(SessionStorage::class)
869
-			);
870
-		});
871
-		$this->registerService(SessionStorage::class, function (Server $c) {
872
-			return new SessionStorage($c->getSession());
873
-		});
874
-		$this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) {
875
-			return new ContentSecurityPolicyManager();
876
-		});
877
-		$this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class);
878
-
879
-		$this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) {
880
-			return new ContentSecurityPolicyNonceManager(
881
-				$c->getCsrfTokenManager(),
882
-				$c->getRequest()
883
-			);
884
-		});
885
-
886
-		$this->registerService(\OCP\Share\IManager::class, function(Server $c) {
887
-			$config = $c->getConfig();
888
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
889
-			/** @var \OCP\Share\IProviderFactory $factory */
890
-			$factory = new $factoryClass($this);
891
-
892
-			$manager = new \OC\Share20\Manager(
893
-				$c->getLogger(),
894
-				$c->getConfig(),
895
-				$c->getSecureRandom(),
896
-				$c->getHasher(),
897
-				$c->getMountManager(),
898
-				$c->getGroupManager(),
899
-				$c->getL10N('core'),
900
-				$factory,
901
-				$c->getUserManager(),
902
-				$c->getLazyRootFolder(),
903
-				$c->getEventDispatcher()
904
-			);
905
-
906
-			return $manager;
907
-		});
908
-		$this->registerAlias('ShareManager', \OCP\Share\IManager::class);
909
-
910
-		$this->registerService('SettingsManager', function(Server $c) {
911
-			$manager = new \OC\Settings\Manager(
912
-				$c->getLogger(),
913
-				$c->getDatabaseConnection(),
914
-				$c->getL10N('lib'),
915
-				$c->getConfig(),
916
-				$c->getEncryptionManager(),
917
-				$c->getUserManager(),
918
-				$c->getLockingProvider(),
919
-				$c->getRequest(),
920
-				new \OC\Settings\Mapper($c->getDatabaseConnection()),
921
-				$c->getURLGenerator()
922
-			);
923
-			return $manager;
924
-		});
925
-		$this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
926
-			return new \OC\Files\AppData\Factory(
927
-				$c->getRootFolder(),
928
-				$c->getSystemConfig()
929
-			);
930
-		});
931
-
932
-		$this->registerService('LockdownManager', function (Server $c) {
933
-			return new LockdownManager();
934
-		});
935
-
936
-		$this->registerService(ICloudIdManager::class, function (Server $c) {
937
-			return new CloudIdManager();
938
-		});
939
-
940
-		/* To trick DI since we don't extend the DIContainer here */
941
-		$this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
942
-			return new CleanPreviewsBackgroundJob(
943
-				$c->getRootFolder(),
944
-				$c->getLogger(),
945
-				$c->getJobList(),
946
-				new TimeFactory()
947
-			);
948
-		});
949
-
950
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
951
-		$this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
952
-
953
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
954
-		$this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
955
-
956
-		$this->registerService(\OCP\ISession::class, function(SimpleContainer $c) {
957
-			return $c->query(\OCP\IUserSession::class)->getSession();
958
-		});
959
-	}
960
-
961
-	/**
962
-	 * @return \OCP\Contacts\IManager
963
-	 */
964
-	public function getContactsManager() {
965
-		return $this->query('ContactsManager');
966
-	}
967
-
968
-	/**
969
-	 * @return \OC\Encryption\Manager
970
-	 */
971
-	public function getEncryptionManager() {
972
-		return $this->query('EncryptionManager');
973
-	}
974
-
975
-	/**
976
-	 * @return \OC\Encryption\File
977
-	 */
978
-	public function getEncryptionFilesHelper() {
979
-		return $this->query('EncryptionFileHelper');
980
-	}
981
-
982
-	/**
983
-	 * @return \OCP\Encryption\Keys\IStorage
984
-	 */
985
-	public function getEncryptionKeyStorage() {
986
-		return $this->query('EncryptionKeyStorage');
987
-	}
988
-
989
-	/**
990
-	 * The current request object holding all information about the request
991
-	 * currently being processed is returned from this method.
992
-	 * In case the current execution was not initiated by a web request null is returned
993
-	 *
994
-	 * @return \OCP\IRequest
995
-	 */
996
-	public function getRequest() {
997
-		return $this->query('Request');
998
-	}
999
-
1000
-	/**
1001
-	 * Returns the preview manager which can create preview images for a given file
1002
-	 *
1003
-	 * @return \OCP\IPreview
1004
-	 */
1005
-	public function getPreviewManager() {
1006
-		return $this->query('PreviewManager');
1007
-	}
1008
-
1009
-	/**
1010
-	 * Returns the tag manager which can get and set tags for different object types
1011
-	 *
1012
-	 * @see \OCP\ITagManager::load()
1013
-	 * @return \OCP\ITagManager
1014
-	 */
1015
-	public function getTagManager() {
1016
-		return $this->query('TagManager');
1017
-	}
1018
-
1019
-	/**
1020
-	 * Returns the system-tag manager
1021
-	 *
1022
-	 * @return \OCP\SystemTag\ISystemTagManager
1023
-	 *
1024
-	 * @since 9.0.0
1025
-	 */
1026
-	public function getSystemTagManager() {
1027
-		return $this->query('SystemTagManager');
1028
-	}
1029
-
1030
-	/**
1031
-	 * Returns the system-tag object mapper
1032
-	 *
1033
-	 * @return \OCP\SystemTag\ISystemTagObjectMapper
1034
-	 *
1035
-	 * @since 9.0.0
1036
-	 */
1037
-	public function getSystemTagObjectMapper() {
1038
-		return $this->query('SystemTagObjectMapper');
1039
-	}
1040
-
1041
-	/**
1042
-	 * Returns the avatar manager, used for avatar functionality
1043
-	 *
1044
-	 * @return \OCP\IAvatarManager
1045
-	 */
1046
-	public function getAvatarManager() {
1047
-		return $this->query('AvatarManager');
1048
-	}
1049
-
1050
-	/**
1051
-	 * Returns the root folder of ownCloud's data directory
1052
-	 *
1053
-	 * @return \OCP\Files\IRootFolder
1054
-	 */
1055
-	public function getRootFolder() {
1056
-		return $this->query('LazyRootFolder');
1057
-	}
1058
-
1059
-	/**
1060
-	 * Returns the root folder of ownCloud's data directory
1061
-	 * This is the lazy variant so this gets only initialized once it
1062
-	 * is actually used.
1063
-	 *
1064
-	 * @return \OCP\Files\IRootFolder
1065
-	 */
1066
-	public function getLazyRootFolder() {
1067
-		return $this->query('LazyRootFolder');
1068
-	}
1069
-
1070
-	/**
1071
-	 * Returns a view to ownCloud's files folder
1072
-	 *
1073
-	 * @param string $userId user ID
1074
-	 * @return \OCP\Files\Folder|null
1075
-	 */
1076
-	public function getUserFolder($userId = null) {
1077
-		if ($userId === null) {
1078
-			$user = $this->getUserSession()->getUser();
1079
-			if (!$user) {
1080
-				return null;
1081
-			}
1082
-			$userId = $user->getUID();
1083
-		}
1084
-		$root = $this->getRootFolder();
1085
-		return $root->getUserFolder($userId);
1086
-	}
1087
-
1088
-	/**
1089
-	 * Returns an app-specific view in ownClouds data directory
1090
-	 *
1091
-	 * @return \OCP\Files\Folder
1092
-	 * @deprecated since 9.2.0 use IAppData
1093
-	 */
1094
-	public function getAppFolder() {
1095
-		$dir = '/' . \OC_App::getCurrentApp();
1096
-		$root = $this->getRootFolder();
1097
-		if (!$root->nodeExists($dir)) {
1098
-			$folder = $root->newFolder($dir);
1099
-		} else {
1100
-			$folder = $root->get($dir);
1101
-		}
1102
-		return $folder;
1103
-	}
1104
-
1105
-	/**
1106
-	 * @return \OC\User\Manager
1107
-	 */
1108
-	public function getUserManager() {
1109
-		return $this->query('UserManager');
1110
-	}
1111
-
1112
-	/**
1113
-	 * @return \OC\Group\Manager
1114
-	 */
1115
-	public function getGroupManager() {
1116
-		return $this->query('GroupManager');
1117
-	}
1118
-
1119
-	/**
1120
-	 * @return \OC\User\Session
1121
-	 */
1122
-	public function getUserSession() {
1123
-		return $this->query('UserSession');
1124
-	}
1125
-
1126
-	/**
1127
-	 * @return \OCP\ISession
1128
-	 */
1129
-	public function getSession() {
1130
-		return $this->query('UserSession')->getSession();
1131
-	}
1132
-
1133
-	/**
1134
-	 * @param \OCP\ISession $session
1135
-	 */
1136
-	public function setSession(\OCP\ISession $session) {
1137
-		$this->query(SessionStorage::class)->setSession($session);
1138
-		$this->query('UserSession')->setSession($session);
1139
-		$this->query(Store::class)->setSession($session);
1140
-	}
1141
-
1142
-	/**
1143
-	 * @return \OC\Authentication\TwoFactorAuth\Manager
1144
-	 */
1145
-	public function getTwoFactorAuthManager() {
1146
-		return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1147
-	}
1148
-
1149
-	/**
1150
-	 * @return \OC\NavigationManager
1151
-	 */
1152
-	public function getNavigationManager() {
1153
-		return $this->query('NavigationManager');
1154
-	}
1155
-
1156
-	/**
1157
-	 * @return \OCP\IConfig
1158
-	 */
1159
-	public function getConfig() {
1160
-		return $this->query('AllConfig');
1161
-	}
1162
-
1163
-	/**
1164
-	 * @internal For internal use only
1165
-	 * @return \OC\SystemConfig
1166
-	 */
1167
-	public function getSystemConfig() {
1168
-		return $this->query('SystemConfig');
1169
-	}
1170
-
1171
-	/**
1172
-	 * Returns the app config manager
1173
-	 *
1174
-	 * @return \OCP\IAppConfig
1175
-	 */
1176
-	public function getAppConfig() {
1177
-		return $this->query('AppConfig');
1178
-	}
1179
-
1180
-	/**
1181
-	 * @return \OCP\L10N\IFactory
1182
-	 */
1183
-	public function getL10NFactory() {
1184
-		return $this->query('L10NFactory');
1185
-	}
1186
-
1187
-	/**
1188
-	 * get an L10N instance
1189
-	 *
1190
-	 * @param string $app appid
1191
-	 * @param string $lang
1192
-	 * @return IL10N
1193
-	 */
1194
-	public function getL10N($app, $lang = null) {
1195
-		return $this->getL10NFactory()->get($app, $lang);
1196
-	}
1197
-
1198
-	/**
1199
-	 * @return \OCP\IURLGenerator
1200
-	 */
1201
-	public function getURLGenerator() {
1202
-		return $this->query('URLGenerator');
1203
-	}
1204
-
1205
-	/**
1206
-	 * @return \OCP\IHelper
1207
-	 */
1208
-	public function getHelper() {
1209
-		return $this->query('AppHelper');
1210
-	}
1211
-
1212
-	/**
1213
-	 * @return AppFetcher
1214
-	 */
1215
-	public function getAppFetcher() {
1216
-		return $this->query('AppFetcher');
1217
-	}
1218
-
1219
-	/**
1220
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1221
-	 * getMemCacheFactory() instead.
1222
-	 *
1223
-	 * @return \OCP\ICache
1224
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1225
-	 */
1226
-	public function getCache() {
1227
-		return $this->query('UserCache');
1228
-	}
1229
-
1230
-	/**
1231
-	 * Returns an \OCP\CacheFactory instance
1232
-	 *
1233
-	 * @return \OCP\ICacheFactory
1234
-	 */
1235
-	public function getMemCacheFactory() {
1236
-		return $this->query('MemCacheFactory');
1237
-	}
1238
-
1239
-	/**
1240
-	 * Returns an \OC\RedisFactory instance
1241
-	 *
1242
-	 * @return \OC\RedisFactory
1243
-	 */
1244
-	public function getGetRedisFactory() {
1245
-		return $this->query('RedisFactory');
1246
-	}
1247
-
1248
-
1249
-	/**
1250
-	 * Returns the current session
1251
-	 *
1252
-	 * @return \OCP\IDBConnection
1253
-	 */
1254
-	public function getDatabaseConnection() {
1255
-		return $this->query('DatabaseConnection');
1256
-	}
1257
-
1258
-	/**
1259
-	 * Returns the activity manager
1260
-	 *
1261
-	 * @return \OCP\Activity\IManager
1262
-	 */
1263
-	public function getActivityManager() {
1264
-		return $this->query('ActivityManager');
1265
-	}
1266
-
1267
-	/**
1268
-	 * Returns an job list for controlling background jobs
1269
-	 *
1270
-	 * @return \OCP\BackgroundJob\IJobList
1271
-	 */
1272
-	public function getJobList() {
1273
-		return $this->query('JobList');
1274
-	}
1275
-
1276
-	/**
1277
-	 * Returns a logger instance
1278
-	 *
1279
-	 * @return \OCP\ILogger
1280
-	 */
1281
-	public function getLogger() {
1282
-		return $this->query('Logger');
1283
-	}
1284
-
1285
-	/**
1286
-	 * Returns a router for generating and matching urls
1287
-	 *
1288
-	 * @return \OCP\Route\IRouter
1289
-	 */
1290
-	public function getRouter() {
1291
-		return $this->query('Router');
1292
-	}
1293
-
1294
-	/**
1295
-	 * Returns a search instance
1296
-	 *
1297
-	 * @return \OCP\ISearch
1298
-	 */
1299
-	public function getSearch() {
1300
-		return $this->query('Search');
1301
-	}
1302
-
1303
-	/**
1304
-	 * Returns a SecureRandom instance
1305
-	 *
1306
-	 * @return \OCP\Security\ISecureRandom
1307
-	 */
1308
-	public function getSecureRandom() {
1309
-		return $this->query('SecureRandom');
1310
-	}
1311
-
1312
-	/**
1313
-	 * Returns a Crypto instance
1314
-	 *
1315
-	 * @return \OCP\Security\ICrypto
1316
-	 */
1317
-	public function getCrypto() {
1318
-		return $this->query('Crypto');
1319
-	}
1320
-
1321
-	/**
1322
-	 * Returns a Hasher instance
1323
-	 *
1324
-	 * @return \OCP\Security\IHasher
1325
-	 */
1326
-	public function getHasher() {
1327
-		return $this->query('Hasher');
1328
-	}
1329
-
1330
-	/**
1331
-	 * Returns a CredentialsManager instance
1332
-	 *
1333
-	 * @return \OCP\Security\ICredentialsManager
1334
-	 */
1335
-	public function getCredentialsManager() {
1336
-		return $this->query('CredentialsManager');
1337
-	}
1338
-
1339
-	/**
1340
-	 * Returns an instance of the HTTP helper class
1341
-	 *
1342
-	 * @deprecated Use getHTTPClientService()
1343
-	 * @return \OC\HTTPHelper
1344
-	 */
1345
-	public function getHTTPHelper() {
1346
-		return $this->query('HTTPHelper');
1347
-	}
1348
-
1349
-	/**
1350
-	 * Get the certificate manager for the user
1351
-	 *
1352
-	 * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1353
-	 * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1354
-	 */
1355
-	public function getCertificateManager($userId = '') {
1356
-		if ($userId === '') {
1357
-			$userSession = $this->getUserSession();
1358
-			$user = $userSession->getUser();
1359
-			if (is_null($user)) {
1360
-				return null;
1361
-			}
1362
-			$userId = $user->getUID();
1363
-		}
1364
-		return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger());
1365
-	}
1366
-
1367
-	/**
1368
-	 * Returns an instance of the HTTP client service
1369
-	 *
1370
-	 * @return \OCP\Http\Client\IClientService
1371
-	 */
1372
-	public function getHTTPClientService() {
1373
-		return $this->query('HttpClientService');
1374
-	}
1375
-
1376
-	/**
1377
-	 * Create a new event source
1378
-	 *
1379
-	 * @return \OCP\IEventSource
1380
-	 */
1381
-	public function createEventSource() {
1382
-		return new \OC_EventSource();
1383
-	}
1384
-
1385
-	/**
1386
-	 * Get the active event logger
1387
-	 *
1388
-	 * The returned logger only logs data when debug mode is enabled
1389
-	 *
1390
-	 * @return \OCP\Diagnostics\IEventLogger
1391
-	 */
1392
-	public function getEventLogger() {
1393
-		return $this->query('EventLogger');
1394
-	}
1395
-
1396
-	/**
1397
-	 * Get the active query logger
1398
-	 *
1399
-	 * The returned logger only logs data when debug mode is enabled
1400
-	 *
1401
-	 * @return \OCP\Diagnostics\IQueryLogger
1402
-	 */
1403
-	public function getQueryLogger() {
1404
-		return $this->query('QueryLogger');
1405
-	}
1406
-
1407
-	/**
1408
-	 * Get the manager for temporary files and folders
1409
-	 *
1410
-	 * @return \OCP\ITempManager
1411
-	 */
1412
-	public function getTempManager() {
1413
-		return $this->query('TempManager');
1414
-	}
1415
-
1416
-	/**
1417
-	 * Get the app manager
1418
-	 *
1419
-	 * @return \OCP\App\IAppManager
1420
-	 */
1421
-	public function getAppManager() {
1422
-		return $this->query('AppManager');
1423
-	}
1424
-
1425
-	/**
1426
-	 * Creates a new mailer
1427
-	 *
1428
-	 * @return \OCP\Mail\IMailer
1429
-	 */
1430
-	public function getMailer() {
1431
-		return $this->query('Mailer');
1432
-	}
1433
-
1434
-	/**
1435
-	 * Get the webroot
1436
-	 *
1437
-	 * @return string
1438
-	 */
1439
-	public function getWebRoot() {
1440
-		return $this->webRoot;
1441
-	}
1442
-
1443
-	/**
1444
-	 * @return \OC\OCSClient
1445
-	 */
1446
-	public function getOcsClient() {
1447
-		return $this->query('OcsClient');
1448
-	}
1449
-
1450
-	/**
1451
-	 * @return \OCP\IDateTimeZone
1452
-	 */
1453
-	public function getDateTimeZone() {
1454
-		return $this->query('DateTimeZone');
1455
-	}
1456
-
1457
-	/**
1458
-	 * @return \OCP\IDateTimeFormatter
1459
-	 */
1460
-	public function getDateTimeFormatter() {
1461
-		return $this->query('DateTimeFormatter');
1462
-	}
1463
-
1464
-	/**
1465
-	 * @return \OCP\Files\Config\IMountProviderCollection
1466
-	 */
1467
-	public function getMountProviderCollection() {
1468
-		return $this->query('MountConfigManager');
1469
-	}
1470
-
1471
-	/**
1472
-	 * Get the IniWrapper
1473
-	 *
1474
-	 * @return IniGetWrapper
1475
-	 */
1476
-	public function getIniWrapper() {
1477
-		return $this->query('IniWrapper');
1478
-	}
1479
-
1480
-	/**
1481
-	 * @return \OCP\Command\IBus
1482
-	 */
1483
-	public function getCommandBus() {
1484
-		return $this->query('AsyncCommandBus');
1485
-	}
1486
-
1487
-	/**
1488
-	 * Get the trusted domain helper
1489
-	 *
1490
-	 * @return TrustedDomainHelper
1491
-	 */
1492
-	public function getTrustedDomainHelper() {
1493
-		return $this->query('TrustedDomainHelper');
1494
-	}
1495
-
1496
-	/**
1497
-	 * Get the locking provider
1498
-	 *
1499
-	 * @return \OCP\Lock\ILockingProvider
1500
-	 * @since 8.1.0
1501
-	 */
1502
-	public function getLockingProvider() {
1503
-		return $this->query('LockingProvider');
1504
-	}
1505
-
1506
-	/**
1507
-	 * @return \OCP\Files\Mount\IMountManager
1508
-	 **/
1509
-	function getMountManager() {
1510
-		return $this->query('MountManager');
1511
-	}
1512
-
1513
-	/** @return \OCP\Files\Config\IUserMountCache */
1514
-	function getUserMountCache() {
1515
-		return $this->query('UserMountCache');
1516
-	}
1517
-
1518
-	/**
1519
-	 * Get the MimeTypeDetector
1520
-	 *
1521
-	 * @return \OCP\Files\IMimeTypeDetector
1522
-	 */
1523
-	public function getMimeTypeDetector() {
1524
-		return $this->query('MimeTypeDetector');
1525
-	}
1526
-
1527
-	/**
1528
-	 * Get the MimeTypeLoader
1529
-	 *
1530
-	 * @return \OCP\Files\IMimeTypeLoader
1531
-	 */
1532
-	public function getMimeTypeLoader() {
1533
-		return $this->query('MimeTypeLoader');
1534
-	}
1535
-
1536
-	/**
1537
-	 * Get the manager of all the capabilities
1538
-	 *
1539
-	 * @return \OC\CapabilitiesManager
1540
-	 */
1541
-	public function getCapabilitiesManager() {
1542
-		return $this->query('CapabilitiesManager');
1543
-	}
1544
-
1545
-	/**
1546
-	 * Get the EventDispatcher
1547
-	 *
1548
-	 * @return EventDispatcherInterface
1549
-	 * @since 8.2.0
1550
-	 */
1551
-	public function getEventDispatcher() {
1552
-		return $this->query('EventDispatcher');
1553
-	}
1554
-
1555
-	/**
1556
-	 * Get the Notification Manager
1557
-	 *
1558
-	 * @return \OCP\Notification\IManager
1559
-	 * @since 8.2.0
1560
-	 */
1561
-	public function getNotificationManager() {
1562
-		return $this->query('NotificationManager');
1563
-	}
1564
-
1565
-	/**
1566
-	 * @return \OCP\Comments\ICommentsManager
1567
-	 */
1568
-	public function getCommentsManager() {
1569
-		return $this->query('CommentsManager');
1570
-	}
1571
-
1572
-	/**
1573
-	 * @return \OC_Defaults
1574
-	 */
1575
-	public function getThemingDefaults() {
1576
-		return $this->query('ThemingDefaults');
1577
-	}
1578
-
1579
-	/**
1580
-	 * @return \OC\IntegrityCheck\Checker
1581
-	 */
1582
-	public function getIntegrityCodeChecker() {
1583
-		return $this->query('IntegrityCodeChecker');
1584
-	}
1585
-
1586
-	/**
1587
-	 * @return \OC\Session\CryptoWrapper
1588
-	 */
1589
-	public function getSessionCryptoWrapper() {
1590
-		return $this->query('CryptoWrapper');
1591
-	}
1592
-
1593
-	/**
1594
-	 * @return CsrfTokenManager
1595
-	 */
1596
-	public function getCsrfTokenManager() {
1597
-		return $this->query('CsrfTokenManager');
1598
-	}
1599
-
1600
-	/**
1601
-	 * @return Throttler
1602
-	 */
1603
-	public function getBruteForceThrottler() {
1604
-		return $this->query('Throttler');
1605
-	}
1606
-
1607
-	/**
1608
-	 * @return IContentSecurityPolicyManager
1609
-	 */
1610
-	public function getContentSecurityPolicyManager() {
1611
-		return $this->query('ContentSecurityPolicyManager');
1612
-	}
1613
-
1614
-	/**
1615
-	 * @return ContentSecurityPolicyNonceManager
1616
-	 */
1617
-	public function getContentSecurityPolicyNonceManager() {
1618
-		return $this->query('ContentSecurityPolicyNonceManager');
1619
-	}
1620
-
1621
-	/**
1622
-	 * Not a public API as of 8.2, wait for 9.0
1623
-	 *
1624
-	 * @return \OCA\Files_External\Service\BackendService
1625
-	 */
1626
-	public function getStoragesBackendService() {
1627
-		return $this->query('OCA\\Files_External\\Service\\BackendService');
1628
-	}
1629
-
1630
-	/**
1631
-	 * Not a public API as of 8.2, wait for 9.0
1632
-	 *
1633
-	 * @return \OCA\Files_External\Service\GlobalStoragesService
1634
-	 */
1635
-	public function getGlobalStoragesService() {
1636
-		return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1637
-	}
1638
-
1639
-	/**
1640
-	 * Not a public API as of 8.2, wait for 9.0
1641
-	 *
1642
-	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
1643
-	 */
1644
-	public function getUserGlobalStoragesService() {
1645
-		return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1646
-	}
1647
-
1648
-	/**
1649
-	 * Not a public API as of 8.2, wait for 9.0
1650
-	 *
1651
-	 * @return \OCA\Files_External\Service\UserStoragesService
1652
-	 */
1653
-	public function getUserStoragesService() {
1654
-		return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1655
-	}
1656
-
1657
-	/**
1658
-	 * @return \OCP\Share\IManager
1659
-	 */
1660
-	public function getShareManager() {
1661
-		return $this->query('ShareManager');
1662
-	}
1663
-
1664
-	/**
1665
-	 * Returns the LDAP Provider
1666
-	 *
1667
-	 * @return \OCP\LDAP\ILDAPProvider
1668
-	 */
1669
-	public function getLDAPProvider() {
1670
-		return $this->query('LDAPProvider');
1671
-	}
1672
-
1673
-	/**
1674
-	 * @return \OCP\Settings\IManager
1675
-	 */
1676
-	public function getSettingsManager() {
1677
-		return $this->query('SettingsManager');
1678
-	}
1679
-
1680
-	/**
1681
-	 * @return \OCP\Files\IAppData
1682
-	 */
1683
-	public function getAppDataDir($app) {
1684
-		/** @var \OC\Files\AppData\Factory $factory */
1685
-		$factory = $this->query(\OC\Files\AppData\Factory::class);
1686
-		return $factory->get($app);
1687
-	}
1688
-
1689
-	/**
1690
-	 * @return \OCP\Lockdown\ILockdownManager
1691
-	 */
1692
-	public function getLockdownManager() {
1693
-		return $this->query('LockdownManager');
1694
-	}
1695
-
1696
-	/**
1697
-	 * @return \OCP\Federation\ICloudIdManager
1698
-	 */
1699
-	public function getCloudIdManager() {
1700
-		return $this->query(ICloudIdManager::class);
1701
-	}
813
+            $prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
814
+            if (isset($prefixes['OCA\\Theming\\'])) {
815
+                $classExists = true;
816
+            } else {
817
+                $classExists = false;
818
+            }
819
+
820
+            if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) {
821
+                return new ThemingDefaults(
822
+                    $c->getConfig(),
823
+                    $c->getL10N('theming'),
824
+                    $c->getURLGenerator(),
825
+                    new \OC_Defaults(),
826
+                    $c->getLazyRootFolder(),
827
+                    $c->getMemCacheFactory()
828
+                );
829
+            }
830
+            return new \OC_Defaults();
831
+        });
832
+        $this->registerService(EventDispatcher::class, function () {
833
+            return new EventDispatcher();
834
+        });
835
+        $this->registerAlias('EventDispatcher', EventDispatcher::class);
836
+        $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class);
837
+
838
+        $this->registerService('CryptoWrapper', function (Server $c) {
839
+            // FIXME: Instantiiated here due to cyclic dependency
840
+            $request = new Request(
841
+                [
842
+                    'get' => $_GET,
843
+                    'post' => $_POST,
844
+                    'files' => $_FILES,
845
+                    'server' => $_SERVER,
846
+                    'env' => $_ENV,
847
+                    'cookies' => $_COOKIE,
848
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
849
+                        ? $_SERVER['REQUEST_METHOD']
850
+                        : null,
851
+                ],
852
+                $c->getSecureRandom(),
853
+                $c->getConfig()
854
+            );
855
+
856
+            return new CryptoWrapper(
857
+                $c->getConfig(),
858
+                $c->getCrypto(),
859
+                $c->getSecureRandom(),
860
+                $request
861
+            );
862
+        });
863
+        $this->registerService('CsrfTokenManager', function (Server $c) {
864
+            $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
865
+
866
+            return new CsrfTokenManager(
867
+                $tokenGenerator,
868
+                $c->query(SessionStorage::class)
869
+            );
870
+        });
871
+        $this->registerService(SessionStorage::class, function (Server $c) {
872
+            return new SessionStorage($c->getSession());
873
+        });
874
+        $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) {
875
+            return new ContentSecurityPolicyManager();
876
+        });
877
+        $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class);
878
+
879
+        $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) {
880
+            return new ContentSecurityPolicyNonceManager(
881
+                $c->getCsrfTokenManager(),
882
+                $c->getRequest()
883
+            );
884
+        });
885
+
886
+        $this->registerService(\OCP\Share\IManager::class, function(Server $c) {
887
+            $config = $c->getConfig();
888
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
889
+            /** @var \OCP\Share\IProviderFactory $factory */
890
+            $factory = new $factoryClass($this);
891
+
892
+            $manager = new \OC\Share20\Manager(
893
+                $c->getLogger(),
894
+                $c->getConfig(),
895
+                $c->getSecureRandom(),
896
+                $c->getHasher(),
897
+                $c->getMountManager(),
898
+                $c->getGroupManager(),
899
+                $c->getL10N('core'),
900
+                $factory,
901
+                $c->getUserManager(),
902
+                $c->getLazyRootFolder(),
903
+                $c->getEventDispatcher()
904
+            );
905
+
906
+            return $manager;
907
+        });
908
+        $this->registerAlias('ShareManager', \OCP\Share\IManager::class);
909
+
910
+        $this->registerService('SettingsManager', function(Server $c) {
911
+            $manager = new \OC\Settings\Manager(
912
+                $c->getLogger(),
913
+                $c->getDatabaseConnection(),
914
+                $c->getL10N('lib'),
915
+                $c->getConfig(),
916
+                $c->getEncryptionManager(),
917
+                $c->getUserManager(),
918
+                $c->getLockingProvider(),
919
+                $c->getRequest(),
920
+                new \OC\Settings\Mapper($c->getDatabaseConnection()),
921
+                $c->getURLGenerator()
922
+            );
923
+            return $manager;
924
+        });
925
+        $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
926
+            return new \OC\Files\AppData\Factory(
927
+                $c->getRootFolder(),
928
+                $c->getSystemConfig()
929
+            );
930
+        });
931
+
932
+        $this->registerService('LockdownManager', function (Server $c) {
933
+            return new LockdownManager();
934
+        });
935
+
936
+        $this->registerService(ICloudIdManager::class, function (Server $c) {
937
+            return new CloudIdManager();
938
+        });
939
+
940
+        /* To trick DI since we don't extend the DIContainer here */
941
+        $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
942
+            return new CleanPreviewsBackgroundJob(
943
+                $c->getRootFolder(),
944
+                $c->getLogger(),
945
+                $c->getJobList(),
946
+                new TimeFactory()
947
+            );
948
+        });
949
+
950
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
951
+        $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
952
+
953
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
954
+        $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
955
+
956
+        $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) {
957
+            return $c->query(\OCP\IUserSession::class)->getSession();
958
+        });
959
+    }
960
+
961
+    /**
962
+     * @return \OCP\Contacts\IManager
963
+     */
964
+    public function getContactsManager() {
965
+        return $this->query('ContactsManager');
966
+    }
967
+
968
+    /**
969
+     * @return \OC\Encryption\Manager
970
+     */
971
+    public function getEncryptionManager() {
972
+        return $this->query('EncryptionManager');
973
+    }
974
+
975
+    /**
976
+     * @return \OC\Encryption\File
977
+     */
978
+    public function getEncryptionFilesHelper() {
979
+        return $this->query('EncryptionFileHelper');
980
+    }
981
+
982
+    /**
983
+     * @return \OCP\Encryption\Keys\IStorage
984
+     */
985
+    public function getEncryptionKeyStorage() {
986
+        return $this->query('EncryptionKeyStorage');
987
+    }
988
+
989
+    /**
990
+     * The current request object holding all information about the request
991
+     * currently being processed is returned from this method.
992
+     * In case the current execution was not initiated by a web request null is returned
993
+     *
994
+     * @return \OCP\IRequest
995
+     */
996
+    public function getRequest() {
997
+        return $this->query('Request');
998
+    }
999
+
1000
+    /**
1001
+     * Returns the preview manager which can create preview images for a given file
1002
+     *
1003
+     * @return \OCP\IPreview
1004
+     */
1005
+    public function getPreviewManager() {
1006
+        return $this->query('PreviewManager');
1007
+    }
1008
+
1009
+    /**
1010
+     * Returns the tag manager which can get and set tags for different object types
1011
+     *
1012
+     * @see \OCP\ITagManager::load()
1013
+     * @return \OCP\ITagManager
1014
+     */
1015
+    public function getTagManager() {
1016
+        return $this->query('TagManager');
1017
+    }
1018
+
1019
+    /**
1020
+     * Returns the system-tag manager
1021
+     *
1022
+     * @return \OCP\SystemTag\ISystemTagManager
1023
+     *
1024
+     * @since 9.0.0
1025
+     */
1026
+    public function getSystemTagManager() {
1027
+        return $this->query('SystemTagManager');
1028
+    }
1029
+
1030
+    /**
1031
+     * Returns the system-tag object mapper
1032
+     *
1033
+     * @return \OCP\SystemTag\ISystemTagObjectMapper
1034
+     *
1035
+     * @since 9.0.0
1036
+     */
1037
+    public function getSystemTagObjectMapper() {
1038
+        return $this->query('SystemTagObjectMapper');
1039
+    }
1040
+
1041
+    /**
1042
+     * Returns the avatar manager, used for avatar functionality
1043
+     *
1044
+     * @return \OCP\IAvatarManager
1045
+     */
1046
+    public function getAvatarManager() {
1047
+        return $this->query('AvatarManager');
1048
+    }
1049
+
1050
+    /**
1051
+     * Returns the root folder of ownCloud's data directory
1052
+     *
1053
+     * @return \OCP\Files\IRootFolder
1054
+     */
1055
+    public function getRootFolder() {
1056
+        return $this->query('LazyRootFolder');
1057
+    }
1058
+
1059
+    /**
1060
+     * Returns the root folder of ownCloud's data directory
1061
+     * This is the lazy variant so this gets only initialized once it
1062
+     * is actually used.
1063
+     *
1064
+     * @return \OCP\Files\IRootFolder
1065
+     */
1066
+    public function getLazyRootFolder() {
1067
+        return $this->query('LazyRootFolder');
1068
+    }
1069
+
1070
+    /**
1071
+     * Returns a view to ownCloud's files folder
1072
+     *
1073
+     * @param string $userId user ID
1074
+     * @return \OCP\Files\Folder|null
1075
+     */
1076
+    public function getUserFolder($userId = null) {
1077
+        if ($userId === null) {
1078
+            $user = $this->getUserSession()->getUser();
1079
+            if (!$user) {
1080
+                return null;
1081
+            }
1082
+            $userId = $user->getUID();
1083
+        }
1084
+        $root = $this->getRootFolder();
1085
+        return $root->getUserFolder($userId);
1086
+    }
1087
+
1088
+    /**
1089
+     * Returns an app-specific view in ownClouds data directory
1090
+     *
1091
+     * @return \OCP\Files\Folder
1092
+     * @deprecated since 9.2.0 use IAppData
1093
+     */
1094
+    public function getAppFolder() {
1095
+        $dir = '/' . \OC_App::getCurrentApp();
1096
+        $root = $this->getRootFolder();
1097
+        if (!$root->nodeExists($dir)) {
1098
+            $folder = $root->newFolder($dir);
1099
+        } else {
1100
+            $folder = $root->get($dir);
1101
+        }
1102
+        return $folder;
1103
+    }
1104
+
1105
+    /**
1106
+     * @return \OC\User\Manager
1107
+     */
1108
+    public function getUserManager() {
1109
+        return $this->query('UserManager');
1110
+    }
1111
+
1112
+    /**
1113
+     * @return \OC\Group\Manager
1114
+     */
1115
+    public function getGroupManager() {
1116
+        return $this->query('GroupManager');
1117
+    }
1118
+
1119
+    /**
1120
+     * @return \OC\User\Session
1121
+     */
1122
+    public function getUserSession() {
1123
+        return $this->query('UserSession');
1124
+    }
1125
+
1126
+    /**
1127
+     * @return \OCP\ISession
1128
+     */
1129
+    public function getSession() {
1130
+        return $this->query('UserSession')->getSession();
1131
+    }
1132
+
1133
+    /**
1134
+     * @param \OCP\ISession $session
1135
+     */
1136
+    public function setSession(\OCP\ISession $session) {
1137
+        $this->query(SessionStorage::class)->setSession($session);
1138
+        $this->query('UserSession')->setSession($session);
1139
+        $this->query(Store::class)->setSession($session);
1140
+    }
1141
+
1142
+    /**
1143
+     * @return \OC\Authentication\TwoFactorAuth\Manager
1144
+     */
1145
+    public function getTwoFactorAuthManager() {
1146
+        return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1147
+    }
1148
+
1149
+    /**
1150
+     * @return \OC\NavigationManager
1151
+     */
1152
+    public function getNavigationManager() {
1153
+        return $this->query('NavigationManager');
1154
+    }
1155
+
1156
+    /**
1157
+     * @return \OCP\IConfig
1158
+     */
1159
+    public function getConfig() {
1160
+        return $this->query('AllConfig');
1161
+    }
1162
+
1163
+    /**
1164
+     * @internal For internal use only
1165
+     * @return \OC\SystemConfig
1166
+     */
1167
+    public function getSystemConfig() {
1168
+        return $this->query('SystemConfig');
1169
+    }
1170
+
1171
+    /**
1172
+     * Returns the app config manager
1173
+     *
1174
+     * @return \OCP\IAppConfig
1175
+     */
1176
+    public function getAppConfig() {
1177
+        return $this->query('AppConfig');
1178
+    }
1179
+
1180
+    /**
1181
+     * @return \OCP\L10N\IFactory
1182
+     */
1183
+    public function getL10NFactory() {
1184
+        return $this->query('L10NFactory');
1185
+    }
1186
+
1187
+    /**
1188
+     * get an L10N instance
1189
+     *
1190
+     * @param string $app appid
1191
+     * @param string $lang
1192
+     * @return IL10N
1193
+     */
1194
+    public function getL10N($app, $lang = null) {
1195
+        return $this->getL10NFactory()->get($app, $lang);
1196
+    }
1197
+
1198
+    /**
1199
+     * @return \OCP\IURLGenerator
1200
+     */
1201
+    public function getURLGenerator() {
1202
+        return $this->query('URLGenerator');
1203
+    }
1204
+
1205
+    /**
1206
+     * @return \OCP\IHelper
1207
+     */
1208
+    public function getHelper() {
1209
+        return $this->query('AppHelper');
1210
+    }
1211
+
1212
+    /**
1213
+     * @return AppFetcher
1214
+     */
1215
+    public function getAppFetcher() {
1216
+        return $this->query('AppFetcher');
1217
+    }
1218
+
1219
+    /**
1220
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1221
+     * getMemCacheFactory() instead.
1222
+     *
1223
+     * @return \OCP\ICache
1224
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1225
+     */
1226
+    public function getCache() {
1227
+        return $this->query('UserCache');
1228
+    }
1229
+
1230
+    /**
1231
+     * Returns an \OCP\CacheFactory instance
1232
+     *
1233
+     * @return \OCP\ICacheFactory
1234
+     */
1235
+    public function getMemCacheFactory() {
1236
+        return $this->query('MemCacheFactory');
1237
+    }
1238
+
1239
+    /**
1240
+     * Returns an \OC\RedisFactory instance
1241
+     *
1242
+     * @return \OC\RedisFactory
1243
+     */
1244
+    public function getGetRedisFactory() {
1245
+        return $this->query('RedisFactory');
1246
+    }
1247
+
1248
+
1249
+    /**
1250
+     * Returns the current session
1251
+     *
1252
+     * @return \OCP\IDBConnection
1253
+     */
1254
+    public function getDatabaseConnection() {
1255
+        return $this->query('DatabaseConnection');
1256
+    }
1257
+
1258
+    /**
1259
+     * Returns the activity manager
1260
+     *
1261
+     * @return \OCP\Activity\IManager
1262
+     */
1263
+    public function getActivityManager() {
1264
+        return $this->query('ActivityManager');
1265
+    }
1266
+
1267
+    /**
1268
+     * Returns an job list for controlling background jobs
1269
+     *
1270
+     * @return \OCP\BackgroundJob\IJobList
1271
+     */
1272
+    public function getJobList() {
1273
+        return $this->query('JobList');
1274
+    }
1275
+
1276
+    /**
1277
+     * Returns a logger instance
1278
+     *
1279
+     * @return \OCP\ILogger
1280
+     */
1281
+    public function getLogger() {
1282
+        return $this->query('Logger');
1283
+    }
1284
+
1285
+    /**
1286
+     * Returns a router for generating and matching urls
1287
+     *
1288
+     * @return \OCP\Route\IRouter
1289
+     */
1290
+    public function getRouter() {
1291
+        return $this->query('Router');
1292
+    }
1293
+
1294
+    /**
1295
+     * Returns a search instance
1296
+     *
1297
+     * @return \OCP\ISearch
1298
+     */
1299
+    public function getSearch() {
1300
+        return $this->query('Search');
1301
+    }
1302
+
1303
+    /**
1304
+     * Returns a SecureRandom instance
1305
+     *
1306
+     * @return \OCP\Security\ISecureRandom
1307
+     */
1308
+    public function getSecureRandom() {
1309
+        return $this->query('SecureRandom');
1310
+    }
1311
+
1312
+    /**
1313
+     * Returns a Crypto instance
1314
+     *
1315
+     * @return \OCP\Security\ICrypto
1316
+     */
1317
+    public function getCrypto() {
1318
+        return $this->query('Crypto');
1319
+    }
1320
+
1321
+    /**
1322
+     * Returns a Hasher instance
1323
+     *
1324
+     * @return \OCP\Security\IHasher
1325
+     */
1326
+    public function getHasher() {
1327
+        return $this->query('Hasher');
1328
+    }
1329
+
1330
+    /**
1331
+     * Returns a CredentialsManager instance
1332
+     *
1333
+     * @return \OCP\Security\ICredentialsManager
1334
+     */
1335
+    public function getCredentialsManager() {
1336
+        return $this->query('CredentialsManager');
1337
+    }
1338
+
1339
+    /**
1340
+     * Returns an instance of the HTTP helper class
1341
+     *
1342
+     * @deprecated Use getHTTPClientService()
1343
+     * @return \OC\HTTPHelper
1344
+     */
1345
+    public function getHTTPHelper() {
1346
+        return $this->query('HTTPHelper');
1347
+    }
1348
+
1349
+    /**
1350
+     * Get the certificate manager for the user
1351
+     *
1352
+     * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1353
+     * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1354
+     */
1355
+    public function getCertificateManager($userId = '') {
1356
+        if ($userId === '') {
1357
+            $userSession = $this->getUserSession();
1358
+            $user = $userSession->getUser();
1359
+            if (is_null($user)) {
1360
+                return null;
1361
+            }
1362
+            $userId = $user->getUID();
1363
+        }
1364
+        return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger());
1365
+    }
1366
+
1367
+    /**
1368
+     * Returns an instance of the HTTP client service
1369
+     *
1370
+     * @return \OCP\Http\Client\IClientService
1371
+     */
1372
+    public function getHTTPClientService() {
1373
+        return $this->query('HttpClientService');
1374
+    }
1375
+
1376
+    /**
1377
+     * Create a new event source
1378
+     *
1379
+     * @return \OCP\IEventSource
1380
+     */
1381
+    public function createEventSource() {
1382
+        return new \OC_EventSource();
1383
+    }
1384
+
1385
+    /**
1386
+     * Get the active event logger
1387
+     *
1388
+     * The returned logger only logs data when debug mode is enabled
1389
+     *
1390
+     * @return \OCP\Diagnostics\IEventLogger
1391
+     */
1392
+    public function getEventLogger() {
1393
+        return $this->query('EventLogger');
1394
+    }
1395
+
1396
+    /**
1397
+     * Get the active query logger
1398
+     *
1399
+     * The returned logger only logs data when debug mode is enabled
1400
+     *
1401
+     * @return \OCP\Diagnostics\IQueryLogger
1402
+     */
1403
+    public function getQueryLogger() {
1404
+        return $this->query('QueryLogger');
1405
+    }
1406
+
1407
+    /**
1408
+     * Get the manager for temporary files and folders
1409
+     *
1410
+     * @return \OCP\ITempManager
1411
+     */
1412
+    public function getTempManager() {
1413
+        return $this->query('TempManager');
1414
+    }
1415
+
1416
+    /**
1417
+     * Get the app manager
1418
+     *
1419
+     * @return \OCP\App\IAppManager
1420
+     */
1421
+    public function getAppManager() {
1422
+        return $this->query('AppManager');
1423
+    }
1424
+
1425
+    /**
1426
+     * Creates a new mailer
1427
+     *
1428
+     * @return \OCP\Mail\IMailer
1429
+     */
1430
+    public function getMailer() {
1431
+        return $this->query('Mailer');
1432
+    }
1433
+
1434
+    /**
1435
+     * Get the webroot
1436
+     *
1437
+     * @return string
1438
+     */
1439
+    public function getWebRoot() {
1440
+        return $this->webRoot;
1441
+    }
1442
+
1443
+    /**
1444
+     * @return \OC\OCSClient
1445
+     */
1446
+    public function getOcsClient() {
1447
+        return $this->query('OcsClient');
1448
+    }
1449
+
1450
+    /**
1451
+     * @return \OCP\IDateTimeZone
1452
+     */
1453
+    public function getDateTimeZone() {
1454
+        return $this->query('DateTimeZone');
1455
+    }
1456
+
1457
+    /**
1458
+     * @return \OCP\IDateTimeFormatter
1459
+     */
1460
+    public function getDateTimeFormatter() {
1461
+        return $this->query('DateTimeFormatter');
1462
+    }
1463
+
1464
+    /**
1465
+     * @return \OCP\Files\Config\IMountProviderCollection
1466
+     */
1467
+    public function getMountProviderCollection() {
1468
+        return $this->query('MountConfigManager');
1469
+    }
1470
+
1471
+    /**
1472
+     * Get the IniWrapper
1473
+     *
1474
+     * @return IniGetWrapper
1475
+     */
1476
+    public function getIniWrapper() {
1477
+        return $this->query('IniWrapper');
1478
+    }
1479
+
1480
+    /**
1481
+     * @return \OCP\Command\IBus
1482
+     */
1483
+    public function getCommandBus() {
1484
+        return $this->query('AsyncCommandBus');
1485
+    }
1486
+
1487
+    /**
1488
+     * Get the trusted domain helper
1489
+     *
1490
+     * @return TrustedDomainHelper
1491
+     */
1492
+    public function getTrustedDomainHelper() {
1493
+        return $this->query('TrustedDomainHelper');
1494
+    }
1495
+
1496
+    /**
1497
+     * Get the locking provider
1498
+     *
1499
+     * @return \OCP\Lock\ILockingProvider
1500
+     * @since 8.1.0
1501
+     */
1502
+    public function getLockingProvider() {
1503
+        return $this->query('LockingProvider');
1504
+    }
1505
+
1506
+    /**
1507
+     * @return \OCP\Files\Mount\IMountManager
1508
+     **/
1509
+    function getMountManager() {
1510
+        return $this->query('MountManager');
1511
+    }
1512
+
1513
+    /** @return \OCP\Files\Config\IUserMountCache */
1514
+    function getUserMountCache() {
1515
+        return $this->query('UserMountCache');
1516
+    }
1517
+
1518
+    /**
1519
+     * Get the MimeTypeDetector
1520
+     *
1521
+     * @return \OCP\Files\IMimeTypeDetector
1522
+     */
1523
+    public function getMimeTypeDetector() {
1524
+        return $this->query('MimeTypeDetector');
1525
+    }
1526
+
1527
+    /**
1528
+     * Get the MimeTypeLoader
1529
+     *
1530
+     * @return \OCP\Files\IMimeTypeLoader
1531
+     */
1532
+    public function getMimeTypeLoader() {
1533
+        return $this->query('MimeTypeLoader');
1534
+    }
1535
+
1536
+    /**
1537
+     * Get the manager of all the capabilities
1538
+     *
1539
+     * @return \OC\CapabilitiesManager
1540
+     */
1541
+    public function getCapabilitiesManager() {
1542
+        return $this->query('CapabilitiesManager');
1543
+    }
1544
+
1545
+    /**
1546
+     * Get the EventDispatcher
1547
+     *
1548
+     * @return EventDispatcherInterface
1549
+     * @since 8.2.0
1550
+     */
1551
+    public function getEventDispatcher() {
1552
+        return $this->query('EventDispatcher');
1553
+    }
1554
+
1555
+    /**
1556
+     * Get the Notification Manager
1557
+     *
1558
+     * @return \OCP\Notification\IManager
1559
+     * @since 8.2.0
1560
+     */
1561
+    public function getNotificationManager() {
1562
+        return $this->query('NotificationManager');
1563
+    }
1564
+
1565
+    /**
1566
+     * @return \OCP\Comments\ICommentsManager
1567
+     */
1568
+    public function getCommentsManager() {
1569
+        return $this->query('CommentsManager');
1570
+    }
1571
+
1572
+    /**
1573
+     * @return \OC_Defaults
1574
+     */
1575
+    public function getThemingDefaults() {
1576
+        return $this->query('ThemingDefaults');
1577
+    }
1578
+
1579
+    /**
1580
+     * @return \OC\IntegrityCheck\Checker
1581
+     */
1582
+    public function getIntegrityCodeChecker() {
1583
+        return $this->query('IntegrityCodeChecker');
1584
+    }
1585
+
1586
+    /**
1587
+     * @return \OC\Session\CryptoWrapper
1588
+     */
1589
+    public function getSessionCryptoWrapper() {
1590
+        return $this->query('CryptoWrapper');
1591
+    }
1592
+
1593
+    /**
1594
+     * @return CsrfTokenManager
1595
+     */
1596
+    public function getCsrfTokenManager() {
1597
+        return $this->query('CsrfTokenManager');
1598
+    }
1599
+
1600
+    /**
1601
+     * @return Throttler
1602
+     */
1603
+    public function getBruteForceThrottler() {
1604
+        return $this->query('Throttler');
1605
+    }
1606
+
1607
+    /**
1608
+     * @return IContentSecurityPolicyManager
1609
+     */
1610
+    public function getContentSecurityPolicyManager() {
1611
+        return $this->query('ContentSecurityPolicyManager');
1612
+    }
1613
+
1614
+    /**
1615
+     * @return ContentSecurityPolicyNonceManager
1616
+     */
1617
+    public function getContentSecurityPolicyNonceManager() {
1618
+        return $this->query('ContentSecurityPolicyNonceManager');
1619
+    }
1620
+
1621
+    /**
1622
+     * Not a public API as of 8.2, wait for 9.0
1623
+     *
1624
+     * @return \OCA\Files_External\Service\BackendService
1625
+     */
1626
+    public function getStoragesBackendService() {
1627
+        return $this->query('OCA\\Files_External\\Service\\BackendService');
1628
+    }
1629
+
1630
+    /**
1631
+     * Not a public API as of 8.2, wait for 9.0
1632
+     *
1633
+     * @return \OCA\Files_External\Service\GlobalStoragesService
1634
+     */
1635
+    public function getGlobalStoragesService() {
1636
+        return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1637
+    }
1638
+
1639
+    /**
1640
+     * Not a public API as of 8.2, wait for 9.0
1641
+     *
1642
+     * @return \OCA\Files_External\Service\UserGlobalStoragesService
1643
+     */
1644
+    public function getUserGlobalStoragesService() {
1645
+        return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1646
+    }
1647
+
1648
+    /**
1649
+     * Not a public API as of 8.2, wait for 9.0
1650
+     *
1651
+     * @return \OCA\Files_External\Service\UserStoragesService
1652
+     */
1653
+    public function getUserStoragesService() {
1654
+        return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1655
+    }
1656
+
1657
+    /**
1658
+     * @return \OCP\Share\IManager
1659
+     */
1660
+    public function getShareManager() {
1661
+        return $this->query('ShareManager');
1662
+    }
1663
+
1664
+    /**
1665
+     * Returns the LDAP Provider
1666
+     *
1667
+     * @return \OCP\LDAP\ILDAPProvider
1668
+     */
1669
+    public function getLDAPProvider() {
1670
+        return $this->query('LDAPProvider');
1671
+    }
1672
+
1673
+    /**
1674
+     * @return \OCP\Settings\IManager
1675
+     */
1676
+    public function getSettingsManager() {
1677
+        return $this->query('SettingsManager');
1678
+    }
1679
+
1680
+    /**
1681
+     * @return \OCP\Files\IAppData
1682
+     */
1683
+    public function getAppDataDir($app) {
1684
+        /** @var \OC\Files\AppData\Factory $factory */
1685
+        $factory = $this->query(\OC\Files\AppData\Factory::class);
1686
+        return $factory->get($app);
1687
+    }
1688
+
1689
+    /**
1690
+     * @return \OCP\Lockdown\ILockdownManager
1691
+     */
1692
+    public function getLockdownManager() {
1693
+        return $this->query('LockdownManager');
1694
+    }
1695
+
1696
+    /**
1697
+     * @return \OCP\Federation\ICloudIdManager
1698
+     */
1699
+    public function getCloudIdManager() {
1700
+        return $this->query(ICloudIdManager::class);
1701
+    }
1702 1702
 }
Please login to merge, or discard this patch.
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
130 130
 		$this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
131 131
 
132
-		$this->registerService(\OCP\IPreview::class, function (Server $c) {
132
+		$this->registerService(\OCP\IPreview::class, function(Server $c) {
133 133
 			return new PreviewManager(
134 134
 				$c->getConfig(),
135 135
 				$c->getRootFolder(),
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
 		});
141 141
 		$this->registerAlias('PreviewManager', \OCP\IPreview::class);
142 142
 
143
-		$this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
143
+		$this->registerService(\OC\Preview\Watcher::class, function(Server $c) {
144 144
 			return new \OC\Preview\Watcher(
145 145
 				$c->getAppDataDir('preview')
146 146
 			);
147 147
 		});
148 148
 
149
-		$this->registerService('EncryptionManager', function (Server $c) {
149
+		$this->registerService('EncryptionManager', function(Server $c) {
150 150
 			$view = new View();
151 151
 			$util = new Encryption\Util(
152 152
 				$view,
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 			);
165 165
 		});
166 166
 
167
-		$this->registerService('EncryptionFileHelper', function (Server $c) {
167
+		$this->registerService('EncryptionFileHelper', function(Server $c) {
168 168
 			$util = new Encryption\Util(
169 169
 				new View(),
170 170
 				$c->getUserManager(),
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 			return new Encryption\File($util);
175 175
 		});
176 176
 
177
-		$this->registerService('EncryptionKeyStorage', function (Server $c) {
177
+		$this->registerService('EncryptionKeyStorage', function(Server $c) {
178 178
 			$view = new View();
179 179
 			$util = new Encryption\Util(
180 180
 				$view,
@@ -185,32 +185,32 @@  discard block
 block discarded – undo
185 185
 
186 186
 			return new Encryption\Keys\Storage($view, $util);
187 187
 		});
188
-		$this->registerService('TagMapper', function (Server $c) {
188
+		$this->registerService('TagMapper', function(Server $c) {
189 189
 			return new TagMapper($c->getDatabaseConnection());
190 190
 		});
191 191
 
192
-		$this->registerService(\OCP\ITagManager::class, function (Server $c) {
192
+		$this->registerService(\OCP\ITagManager::class, function(Server $c) {
193 193
 			$tagMapper = $c->query('TagMapper');
194 194
 			return new TagManager($tagMapper, $c->getUserSession());
195 195
 		});
196 196
 		$this->registerAlias('TagManager', \OCP\ITagManager::class);
197 197
 
198
-		$this->registerService('SystemTagManagerFactory', function (Server $c) {
198
+		$this->registerService('SystemTagManagerFactory', function(Server $c) {
199 199
 			$config = $c->getConfig();
200 200
 			$factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
201 201
 			/** @var \OC\SystemTag\ManagerFactory $factory */
202 202
 			$factory = new $factoryClass($this);
203 203
 			return $factory;
204 204
 		});
205
-		$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
205
+		$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function(Server $c) {
206 206
 			return $c->query('SystemTagManagerFactory')->getManager();
207 207
 		});
208 208
 		$this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
209 209
 
210
-		$this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
210
+		$this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function(Server $c) {
211 211
 			return $c->query('SystemTagManagerFactory')->getObjectMapper();
212 212
 		});
213
-		$this->registerService('RootFolder', function (Server $c) {
213
+		$this->registerService('RootFolder', function(Server $c) {
214 214
 			$manager = \OC\Files\Filesystem::getMountManager(null);
215 215
 			$view = new View();
216 216
 			$root = new Root(
@@ -238,30 +238,30 @@  discard block
 block discarded – undo
238 238
 		});
239 239
 		$this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
240 240
 
241
-		$this->registerService(\OCP\IUserManager::class, function (Server $c) {
241
+		$this->registerService(\OCP\IUserManager::class, function(Server $c) {
242 242
 			$config = $c->getConfig();
243 243
 			return new \OC\User\Manager($config);
244 244
 		});
245 245
 		$this->registerAlias('UserManager', \OCP\IUserManager::class);
246 246
 
247
-		$this->registerService(\OCP\IGroupManager::class, function (Server $c) {
247
+		$this->registerService(\OCP\IGroupManager::class, function(Server $c) {
248 248
 			$groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
249
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
249
+			$groupManager->listen('\OC\Group', 'preCreate', function($gid) {
250 250
 				\OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
251 251
 			});
252
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
252
+			$groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $gid) {
253 253
 				\OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
254 254
 			});
255
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
255
+			$groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) {
256 256
 				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
257 257
 			});
258
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
258
+			$groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) {
259 259
 				\OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
260 260
 			});
261
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
261
+			$groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) {
262 262
 				\OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
263 263
 			});
264
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
264
+			$groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) {
265 265
 				\OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
266 266
 				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
267 267
 				\OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
 			return new Store($session, $logger, $tokenProvider);
282 282
 		});
283 283
 		$this->registerAlias(IStore::class, Store::class);
284
-		$this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
284
+		$this->registerService('OC\Authentication\Token\DefaultTokenMapper', function(Server $c) {
285 285
 			$dbConnection = $c->getDatabaseConnection();
286 286
 			return new Authentication\Token\DefaultTokenMapper($dbConnection);
287 287
 		});
288
-		$this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
288
+		$this->registerService('OC\Authentication\Token\DefaultTokenProvider', function(Server $c) {
289 289
 			$mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
290 290
 			$crypto = $c->getCrypto();
291 291
 			$config = $c->getConfig();
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 		});
296 296
 		$this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
297 297
 
298
-		$this->registerService(\OCP\IUserSession::class, function (Server $c) {
298
+		$this->registerService(\OCP\IUserSession::class, function(Server $c) {
299 299
 			$manager = $c->getUserManager();
300 300
 			$session = new \OC\Session\Memory('');
301 301
 			$timeFactory = new TimeFactory();
@@ -308,40 +308,40 @@  discard block
 block discarded – undo
308 308
 			}
309 309
 
310 310
 			$userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom());
311
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
311
+			$userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) {
312 312
 				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
313 313
 			});
314
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
314
+			$userSession->listen('\OC\User', 'postCreateUser', function($user, $password) {
315 315
 				/** @var $user \OC\User\User */
316 316
 				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
317 317
 			});
318
-			$userSession->listen('\OC\User', 'preDelete', function ($user) {
318
+			$userSession->listen('\OC\User', 'preDelete', function($user) {
319 319
 				/** @var $user \OC\User\User */
320 320
 				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
321 321
 			});
322
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
322
+			$userSession->listen('\OC\User', 'postDelete', function($user) {
323 323
 				/** @var $user \OC\User\User */
324 324
 				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
325 325
 			});
326
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
326
+			$userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) {
327 327
 				/** @var $user \OC\User\User */
328 328
 				\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
329 329
 			});
330
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
330
+			$userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) {
331 331
 				/** @var $user \OC\User\User */
332 332
 				\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
333 333
 			});
334
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
334
+			$userSession->listen('\OC\User', 'preLogin', function($uid, $password) {
335 335
 				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
336 336
 			});
337
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
337
+			$userSession->listen('\OC\User', 'postLogin', function($user, $password) {
338 338
 				/** @var $user \OC\User\User */
339 339
 				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
340 340
 			});
341
-			$userSession->listen('\OC\User', 'logout', function () {
341
+			$userSession->listen('\OC\User', 'logout', function() {
342 342
 				\OC_Hook::emit('OC_User', 'logout', array());
343 343
 			});
344
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) {
344
+			$userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value) {
345 345
 				/** @var $user \OC\User\User */
346 346
 				\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value));
347 347
 			});
@@ -349,14 +349,14 @@  discard block
 block discarded – undo
349 349
 		});
350 350
 		$this->registerAlias('UserSession', \OCP\IUserSession::class);
351 351
 
352
-		$this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
352
+		$this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function(Server $c) {
353 353
 			return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger());
354 354
 		});
355 355
 
356 356
 		$this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
357 357
 		$this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
358 358
 
359
-		$this->registerService(\OC\AllConfig::class, function (Server $c) {
359
+		$this->registerService(\OC\AllConfig::class, function(Server $c) {
360 360
 			return new \OC\AllConfig(
361 361
 				$c->getSystemConfig()
362 362
 			);
@@ -364,17 +364,17 @@  discard block
 block discarded – undo
364 364
 		$this->registerAlias('AllConfig', \OC\AllConfig::class);
365 365
 		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
366 366
 
367
-		$this->registerService('SystemConfig', function ($c) use ($config) {
367
+		$this->registerService('SystemConfig', function($c) use ($config) {
368 368
 			return new \OC\SystemConfig($config);
369 369
 		});
370 370
 
371
-		$this->registerService(\OC\AppConfig::class, function (Server $c) {
371
+		$this->registerService(\OC\AppConfig::class, function(Server $c) {
372 372
 			return new \OC\AppConfig($c->getDatabaseConnection());
373 373
 		});
374 374
 		$this->registerAlias('AppConfig', \OC\AppConfig::class);
375 375
 		$this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
376 376
 
377
-		$this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
377
+		$this->registerService(\OCP\L10N\IFactory::class, function(Server $c) {
378 378
 			return new \OC\L10N\Factory(
379 379
 				$c->getConfig(),
380 380
 				$c->getRequest(),
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 		});
385 385
 		$this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
386 386
 
387
-		$this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
387
+		$this->registerService(\OCP\IURLGenerator::class, function(Server $c) {
388 388
 			$config = $c->getConfig();
389 389
 			$cacheFactory = $c->getMemCacheFactory();
390 390
 			return new \OC\URLGenerator(
@@ -394,10 +394,10 @@  discard block
 block discarded – undo
394 394
 		});
395 395
 		$this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
396 396
 
397
-		$this->registerService('AppHelper', function ($c) {
397
+		$this->registerService('AppHelper', function($c) {
398 398
 			return new \OC\AppHelper();
399 399
 		});
400
-		$this->registerService('AppFetcher', function ($c) {
400
+		$this->registerService('AppFetcher', function($c) {
401 401
 			return new AppFetcher(
402 402
 				$this->getAppDataDir('appstore'),
403 403
 				$this->getHTTPClientService(),
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 				$this->getConfig()
406 406
 			);
407 407
 		});
408
-		$this->registerService('CategoryFetcher', function ($c) {
408
+		$this->registerService('CategoryFetcher', function($c) {
409 409
 			return new CategoryFetcher(
410 410
 				$this->getAppDataDir('appstore'),
411 411
 				$this->getHTTPClientService(),
@@ -414,21 +414,21 @@  discard block
 block discarded – undo
414 414
 			);
415 415
 		});
416 416
 
417
-		$this->registerService(\OCP\ICache::class, function ($c) {
417
+		$this->registerService(\OCP\ICache::class, function($c) {
418 418
 			return new Cache\File();
419 419
 		});
420 420
 		$this->registerAlias('UserCache', \OCP\ICache::class);
421 421
 
422
-		$this->registerService(Factory::class, function (Server $c) {
422
+		$this->registerService(Factory::class, function(Server $c) {
423 423
 			$config = $c->getConfig();
424 424
 
425 425
 			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
426 426
 				$v = \OC_App::getAppVersions();
427
-				$v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php'));
427
+				$v['core'] = md5(file_get_contents(\OC::$SERVERROOT.'/version.php'));
428 428
 				$version = implode(',', $v);
429 429
 				$instanceId = \OC_Util::getInstanceId();
430 430
 				$path = \OC::$SERVERROOT;
431
-				$prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT);
431
+				$prefix = md5($instanceId.'-'.$version.'-'.$path.'-'.\OC::$WEBROOT);
432 432
 				return new \OC\Memcache\Factory($prefix, $c->getLogger(),
433 433
 					$config->getSystemValue('memcache.local', null),
434 434
 					$config->getSystemValue('memcache.distributed', null),
@@ -445,12 +445,12 @@  discard block
 block discarded – undo
445 445
 		$this->registerAlias('MemCacheFactory', Factory::class);
446 446
 		$this->registerAlias(ICacheFactory::class, Factory::class);
447 447
 
448
-		$this->registerService('RedisFactory', function (Server $c) {
448
+		$this->registerService('RedisFactory', function(Server $c) {
449 449
 			$systemConfig = $c->getSystemConfig();
450 450
 			return new RedisFactory($systemConfig);
451 451
 		});
452 452
 
453
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
453
+		$this->registerService(\OCP\Activity\IManager::class, function(Server $c) {
454 454
 			return new \OC\Activity\Manager(
455 455
 				$c->getRequest(),
456 456
 				$c->getUserSession(),
@@ -460,14 +460,14 @@  discard block
 block discarded – undo
460 460
 		});
461 461
 		$this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
462 462
 
463
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
463
+		$this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) {
464 464
 			return new \OC\Activity\EventMerger(
465 465
 				$c->getL10N('lib')
466 466
 			);
467 467
 		});
468 468
 		$this->registerAlias(IValidator::class, Validator::class);
469 469
 
470
-		$this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
470
+		$this->registerService(\OCP\IAvatarManager::class, function(Server $c) {
471 471
 			return new AvatarManager(
472 472
 				$c->getUserManager(),
473 473
 				$c->getAppDataDir('avatar'),
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 		});
479 479
 		$this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
480 480
 
481
-		$this->registerService(\OCP\ILogger::class, function (Server $c) {
481
+		$this->registerService(\OCP\ILogger::class, function(Server $c) {
482 482
 			$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
483 483
 			$logger = Log::getLogClass($logType);
484 484
 			call_user_func(array($logger, 'init'));
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 		});
488 488
 		$this->registerAlias('Logger', \OCP\ILogger::class);
489 489
 
490
-		$this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
490
+		$this->registerService(\OCP\BackgroundJob\IJobList::class, function(Server $c) {
491 491
 			$config = $c->getConfig();
492 492
 			return new \OC\BackgroundJob\JobList(
493 493
 				$c->getDatabaseConnection(),
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 		});
498 498
 		$this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
499 499
 
500
-		$this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
500
+		$this->registerService(\OCP\Route\IRouter::class, function(Server $c) {
501 501
 			$cacheFactory = $c->getMemCacheFactory();
502 502
 			$logger = $c->getLogger();
503 503
 			if ($cacheFactory->isAvailable()) {
@@ -509,32 +509,32 @@  discard block
 block discarded – undo
509 509
 		});
510 510
 		$this->registerAlias('Router', \OCP\Route\IRouter::class);
511 511
 
512
-		$this->registerService(\OCP\ISearch::class, function ($c) {
512
+		$this->registerService(\OCP\ISearch::class, function($c) {
513 513
 			return new Search();
514 514
 		});
515 515
 		$this->registerAlias('Search', \OCP\ISearch::class);
516 516
 
517
-		$this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
517
+		$this->registerService(\OCP\Security\ISecureRandom::class, function($c) {
518 518
 			return new SecureRandom();
519 519
 		});
520 520
 		$this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
521 521
 
522
-		$this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
522
+		$this->registerService(\OCP\Security\ICrypto::class, function(Server $c) {
523 523
 			return new Crypto($c->getConfig(), $c->getSecureRandom());
524 524
 		});
525 525
 		$this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
526 526
 
527
-		$this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
527
+		$this->registerService(\OCP\Security\IHasher::class, function(Server $c) {
528 528
 			return new Hasher($c->getConfig());
529 529
 		});
530 530
 		$this->registerAlias('Hasher', \OCP\Security\IHasher::class);
531 531
 
532
-		$this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
532
+		$this->registerService(\OCP\Security\ICredentialsManager::class, function(Server $c) {
533 533
 			return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
534 534
 		});
535 535
 		$this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
536 536
 
537
-		$this->registerService(IDBConnection::class, function (Server $c) {
537
+		$this->registerService(IDBConnection::class, function(Server $c) {
538 538
 			$systemConfig = $c->getSystemConfig();
539 539
 			$factory = new \OC\DB\ConnectionFactory($systemConfig);
540 540
 			$type = $systemConfig->getValue('dbtype', 'sqlite');
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 		});
549 549
 		$this->registerAlias('DatabaseConnection', IDBConnection::class);
550 550
 
551
-		$this->registerService('HTTPHelper', function (Server $c) {
551
+		$this->registerService('HTTPHelper', function(Server $c) {
552 552
 			$config = $c->getConfig();
553 553
 			return new HTTPHelper(
554 554
 				$config,
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 			);
557 557
 		});
558 558
 
559
-		$this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
559
+		$this->registerService(\OCP\Http\Client\IClientService::class, function(Server $c) {
560 560
 			$user = \OC_User::getUser();
561 561
 			$uid = $user ? $user : null;
562 562
 			return new ClientService(
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 		});
567 567
 		$this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
568 568
 
569
-		$this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
569
+		$this->registerService(\OCP\Diagnostics\IEventLogger::class, function(Server $c) {
570 570
 			if ($c->getSystemConfig()->getValue('debug', false)) {
571 571
 				return new EventLogger();
572 572
 			} else {
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 		});
576 576
 		$this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
577 577
 
578
-		$this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
578
+		$this->registerService(\OCP\Diagnostics\IQueryLogger::class, function(Server $c) {
579 579
 			if ($c->getSystemConfig()->getValue('debug', false)) {
580 580
 				return new QueryLogger();
581 581
 			} else {
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 		});
585 585
 		$this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
586 586
 
587
-		$this->registerService(TempManager::class, function (Server $c) {
587
+		$this->registerService(TempManager::class, function(Server $c) {
588 588
 			return new TempManager(
589 589
 				$c->getLogger(),
590 590
 				$c->getConfig()
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 		$this->registerAlias('TempManager', TempManager::class);
594 594
 		$this->registerAlias(ITempManager::class, TempManager::class);
595 595
 
596
-		$this->registerService(AppManager::class, function (Server $c) {
596
+		$this->registerService(AppManager::class, function(Server $c) {
597 597
 			return new \OC\App\AppManager(
598 598
 				$c->getUserSession(),
599 599
 				$c->getAppConfig(),
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 		$this->registerAlias('AppManager', AppManager::class);
606 606
 		$this->registerAlias(IAppManager::class, AppManager::class);
607 607
 
608
-		$this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
608
+		$this->registerService(\OCP\IDateTimeZone::class, function(Server $c) {
609 609
 			return new DateTimeZone(
610 610
 				$c->getConfig(),
611 611
 				$c->getSession()
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 		});
614 614
 		$this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
615 615
 
616
-		$this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
616
+		$this->registerService(\OCP\IDateTimeFormatter::class, function(Server $c) {
617 617
 			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
618 618
 
619 619
 			return new DateTimeFormatter(
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 		});
624 624
 		$this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
625 625
 
626
-		$this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
626
+		$this->registerService(\OCP\Files\Config\IUserMountCache::class, function(Server $c) {
627 627
 			$mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
628 628
 			$listener = new UserMountCacheListener($mountCache);
629 629
 			$listener->listen($c->getUserManager());
@@ -631,10 +631,10 @@  discard block
 block discarded – undo
631 631
 		});
632 632
 		$this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
633 633
 
634
-		$this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
634
+		$this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function(Server $c) {
635 635
 			$loader = \OC\Files\Filesystem::getLoader();
636 636
 			$mountCache = $c->query('UserMountCache');
637
-			$manager =  new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
637
+			$manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
638 638
 
639 639
 			// builtin providers
640 640
 
@@ -647,14 +647,14 @@  discard block
 block discarded – undo
647 647
 		});
648 648
 		$this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
649 649
 
650
-		$this->registerService('IniWrapper', function ($c) {
650
+		$this->registerService('IniWrapper', function($c) {
651 651
 			return new IniGetWrapper();
652 652
 		});
653
-		$this->registerService('AsyncCommandBus', function (Server $c) {
653
+		$this->registerService('AsyncCommandBus', function(Server $c) {
654 654
 			$jobList = $c->getJobList();
655 655
 			return new AsyncBus($jobList);
656 656
 		});
657
-		$this->registerService('TrustedDomainHelper', function ($c) {
657
+		$this->registerService('TrustedDomainHelper', function($c) {
658 658
 			return new TrustedDomainHelper($this->getConfig());
659 659
 		});
660 660
 		$this->registerService('Throttler', function(Server $c) {
@@ -665,10 +665,10 @@  discard block
 block discarded – undo
665 665
 				$c->getConfig()
666 666
 			);
667 667
 		});
668
-		$this->registerService('IntegrityCodeChecker', function (Server $c) {
668
+		$this->registerService('IntegrityCodeChecker', function(Server $c) {
669 669
 			// IConfig and IAppManager requires a working database. This code
670 670
 			// might however be called when ownCloud is not yet setup.
671
-			if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
671
+			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
672 672
 				$config = $c->getConfig();
673 673
 				$appManager = $c->getAppManager();
674 674
 			} else {
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 					$c->getTempManager()
687 687
 			);
688 688
 		});
689
-		$this->registerService(\OCP\IRequest::class, function ($c) {
689
+		$this->registerService(\OCP\IRequest::class, function($c) {
690 690
 			if (isset($this['urlParams'])) {
691 691
 				$urlParams = $this['urlParams'];
692 692
 			} else {
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 		});
723 723
 		$this->registerAlias('Request', \OCP\IRequest::class);
724 724
 
725
-		$this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
725
+		$this->registerService(\OCP\Mail\IMailer::class, function(Server $c) {
726 726
 			return new Mailer(
727 727
 				$c->getConfig(),
728 728
 				$c->getLogger(),
@@ -734,14 +734,14 @@  discard block
 block discarded – undo
734 734
 		$this->registerService('LDAPProvider', function(Server $c) {
735 735
 			$config = $c->getConfig();
736 736
 			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
737
-			if(is_null($factoryClass)) {
737
+			if (is_null($factoryClass)) {
738 738
 				throw new \Exception('ldapProviderFactory not set');
739 739
 			}
740 740
 			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
741 741
 			$factory = new $factoryClass($this);
742 742
 			return $factory->getLDAPProvider();
743 743
 		});
744
-		$this->registerService('LockingProvider', function (Server $c) {
744
+		$this->registerService('LockingProvider', function(Server $c) {
745 745
 			$ini = $c->getIniWrapper();
746 746
 			$config = $c->getConfig();
747 747
 			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
@@ -757,37 +757,37 @@  discard block
 block discarded – undo
757 757
 			return new NoopLockingProvider();
758 758
 		});
759 759
 
760
-		$this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
760
+		$this->registerService(\OCP\Files\Mount\IMountManager::class, function() {
761 761
 			return new \OC\Files\Mount\Manager();
762 762
 		});
763 763
 		$this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
764 764
 
765
-		$this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
765
+		$this->registerService(\OCP\Files\IMimeTypeDetector::class, function(Server $c) {
766 766
 			return new \OC\Files\Type\Detection(
767 767
 				$c->getURLGenerator(),
768 768
 				\OC::$configDir,
769
-				\OC::$SERVERROOT . '/resources/config/'
769
+				\OC::$SERVERROOT.'/resources/config/'
770 770
 			);
771 771
 		});
772 772
 		$this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
773 773
 
774
-		$this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
774
+		$this->registerService(\OCP\Files\IMimeTypeLoader::class, function(Server $c) {
775 775
 			return new \OC\Files\Type\Loader(
776 776
 				$c->getDatabaseConnection()
777 777
 			);
778 778
 		});
779 779
 		$this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
780 780
 
781
-		$this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
781
+		$this->registerService(\OCP\Notification\IManager::class, function(Server $c) {
782 782
 			return new Manager(
783 783
 				$c->query(IValidator::class)
784 784
 			);
785 785
 		});
786 786
 		$this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
787 787
 
788
-		$this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
788
+		$this->registerService(\OC\CapabilitiesManager::class, function(Server $c) {
789 789
 			$manager = new \OC\CapabilitiesManager($c->getLogger());
790
-			$manager->registerCapability(function () use ($c) {
790
+			$manager->registerCapability(function() use ($c) {
791 791
 				return new \OC\OCS\CoreCapabilities($c->getConfig());
792 792
 			});
793 793
 			return $manager;
@@ -829,13 +829,13 @@  discard block
 block discarded – undo
829 829
 			}
830 830
 			return new \OC_Defaults();
831 831
 		});
832
-		$this->registerService(EventDispatcher::class, function () {
832
+		$this->registerService(EventDispatcher::class, function() {
833 833
 			return new EventDispatcher();
834 834
 		});
835 835
 		$this->registerAlias('EventDispatcher', EventDispatcher::class);
836 836
 		$this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class);
837 837
 
838
-		$this->registerService('CryptoWrapper', function (Server $c) {
838
+		$this->registerService('CryptoWrapper', function(Server $c) {
839 839
 			// FIXME: Instantiiated here due to cyclic dependency
840 840
 			$request = new Request(
841 841
 				[
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 				$request
861 861
 			);
862 862
 		});
863
-		$this->registerService('CsrfTokenManager', function (Server $c) {
863
+		$this->registerService('CsrfTokenManager', function(Server $c) {
864 864
 			$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
865 865
 
866 866
 			return new CsrfTokenManager(
@@ -868,10 +868,10 @@  discard block
 block discarded – undo
868 868
 				$c->query(SessionStorage::class)
869 869
 			);
870 870
 		});
871
-		$this->registerService(SessionStorage::class, function (Server $c) {
871
+		$this->registerService(SessionStorage::class, function(Server $c) {
872 872
 			return new SessionStorage($c->getSession());
873 873
 		});
874
-		$this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) {
874
+		$this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function(Server $c) {
875 875
 			return new ContentSecurityPolicyManager();
876 876
 		});
877 877
 		$this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class);
@@ -922,23 +922,23 @@  discard block
 block discarded – undo
922 922
 			);
923 923
 			return $manager;
924 924
 		});
925
-		$this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
925
+		$this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) {
926 926
 			return new \OC\Files\AppData\Factory(
927 927
 				$c->getRootFolder(),
928 928
 				$c->getSystemConfig()
929 929
 			);
930 930
 		});
931 931
 
932
-		$this->registerService('LockdownManager', function (Server $c) {
932
+		$this->registerService('LockdownManager', function(Server $c) {
933 933
 			return new LockdownManager();
934 934
 		});
935 935
 
936
-		$this->registerService(ICloudIdManager::class, function (Server $c) {
936
+		$this->registerService(ICloudIdManager::class, function(Server $c) {
937 937
 			return new CloudIdManager();
938 938
 		});
939 939
 
940 940
 		/* To trick DI since we don't extend the DIContainer here */
941
-		$this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
941
+		$this->registerService(CleanPreviewsBackgroundJob::class, function(Server $c) {
942 942
 			return new CleanPreviewsBackgroundJob(
943 943
 				$c->getRootFolder(),
944 944
 				$c->getLogger(),
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
 	 * @deprecated since 9.2.0 use IAppData
1093 1093
 	 */
1094 1094
 	public function getAppFolder() {
1095
-		$dir = '/' . \OC_App::getCurrentApp();
1095
+		$dir = '/'.\OC_App::getCurrentApp();
1096 1096
 		$root = $this->getRootFolder();
1097 1097
 		if (!$root->nodeExists($dir)) {
1098 1098
 			$folder = $root->newFolder($dir);
Please login to merge, or discard this patch.