Completed
Pull Request — master (#6328)
by Blizzz
28:13 queued 13:30
created
lib/private/Installer.php 1 patch
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	public function installApp($appId) {
104 104
 		$app = \OC_App::findAppInDirectories($appId);
105
-		if($app === false) {
105
+		if ($app === false) {
106 106
 			throw new \Exception('App not found in any app directory');
107 107
 		}
108 108
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 
112 112
 		$l = \OC::$server->getL10N('core');
113 113
 
114
-		if(!is_array($info)) {
114
+		if (!is_array($info)) {
115 115
 			throw new \Exception(
116 116
 				$l->t('App "%s" cannot be installed because appinfo file cannot be read.',
117 117
 					[$info['name']]
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		\OC_App::registerAutoloading($appId, $basedir);
135 135
 
136 136
 		//install the database
137
-		if(is_file($basedir.'/appinfo/database.xml')) {
137
+		if (is_file($basedir.'/appinfo/database.xml')) {
138 138
 			if (\OC::$server->getAppConfig()->getValue($info['id'], 'installed_version') === null) {
139 139
 				OC_DB::createDbFromStructure($basedir.'/appinfo/database.xml');
140 140
 			} else {
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 		}
147 147
 
148 148
 		\OC_App::setupBackgroundJobs($info['background-jobs']);
149
-		if(isset($info['settings']) && is_array($info['settings'])) {
149
+		if (isset($info['settings']) && is_array($info['settings'])) {
150 150
 			\OC::$server->getSettingsManager()->setupSettings($info['settings']);
151 151
 		}
152 152
 
153 153
 		//run appinfo/install.php
154
-		if((!isset($data['noinstall']) or $data['noinstall']==false)) {
155
-			self::includeAppScript($basedir . '/appinfo/install.php');
154
+		if ((!isset($data['noinstall']) or $data['noinstall'] == false)) {
155
+			self::includeAppScript($basedir.'/appinfo/install.php');
156 156
 		}
157 157
 
158 158
 		$appData = OC_App::getAppInfo($appId);
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 		\OC::$server->getConfig()->setAppValue($info['id'], 'enabled', 'no');
164 164
 
165 165
 		//set remote/public handlers
166
-		foreach($info['remote'] as $name=>$path) {
166
+		foreach ($info['remote'] as $name=>$path) {
167 167
 			\OC::$server->getConfig()->setAppValue('core', 'remote_'.$name, $info['id'].'/'.$path);
168 168
 		}
169
-		foreach($info['public'] as $name=>$path) {
169
+		foreach ($info['public'] as $name=>$path) {
170 170
 			\OC::$server->getConfig()->setAppValue('core', 'public_'.$name, $info['id'].'/'.$path);
171 171
 		}
172 172
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 *
183 183
 	 * Checks whether or not an app is installed, i.e. registered in apps table.
184 184
 	 */
185
-	public static function isInstalled( $app ) {
185
+	public static function isInstalled($app) {
186 186
 		return (\OC::$server->getConfig()->getAppValue($app, "installed_version", null) !== null);
187 187
 	}
188 188
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 * @return bool
194 194
 	 */
195 195
 	public function updateAppstoreApp($appId) {
196
-		if(self::isUpdateAvailable($appId, $this->appFetcher)) {
196
+		if (self::isUpdateAvailable($appId, $this->appFetcher)) {
197 197
 			try {
198 198
 				$this->downloadApp($appId);
199 199
 			} catch (\Exception $e) {
@@ -217,18 +217,18 @@  discard block
 block discarded – undo
217 217
 		$appId = strtolower($appId);
218 218
 
219 219
 		$apps = $this->appFetcher->get();
220
-		foreach($apps as $app) {
221
-			if($app['id'] === $appId) {
220
+		foreach ($apps as $app) {
221
+			if ($app['id'] === $appId) {
222 222
 				// Load the certificate
223 223
 				$certificate = new X509();
224
-				$certificate->loadCA(file_get_contents(__DIR__ . '/../../resources/codesigning/root.crt'));
224
+				$certificate->loadCA(file_get_contents(__DIR__.'/../../resources/codesigning/root.crt'));
225 225
 				$loadedCertificate = $certificate->loadX509($app['certificate']);
226 226
 
227 227
 				// Verify if the certificate has been revoked
228 228
 				$crl = new X509();
229
-				$crl->loadCA(file_get_contents(__DIR__ . '/../../resources/codesigning/root.crt'));
230
-				$crl->loadCRL(file_get_contents(__DIR__ . '/../../resources/codesigning/root.crl'));
231
-				if($crl->validateSignature() !== true) {
229
+				$crl->loadCA(file_get_contents(__DIR__.'/../../resources/codesigning/root.crt'));
230
+				$crl->loadCRL(file_get_contents(__DIR__.'/../../resources/codesigning/root.crl'));
231
+				if ($crl->validateSignature() !== true) {
232 232
 					throw new \Exception('Could not validate CRL signature');
233 233
 				}
234 234
 				$csn = $loadedCertificate['tbsCertificate']['serialNumber']->toString();
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 				}
244 244
 
245 245
 				// Verify if the certificate has been issued by the Nextcloud Code Authority CA
246
-				if($certificate->validateSignature() !== true) {
246
+				if ($certificate->validateSignature() !== true) {
247 247
 					throw new \Exception(
248 248
 						sprintf(
249 249
 							'App with id %s has a certificate not issued by a trusted Code Signing Authority',
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 
255 255
 				// Verify if the certificate is issued for the requested app id
256 256
 				$certInfo = openssl_x509_parse($app['certificate']);
257
-				if(!isset($certInfo['subject']['CN'])) {
257
+				if (!isset($certInfo['subject']['CN'])) {
258 258
 					throw new \Exception(
259 259
 						sprintf(
260 260
 							'App with id %s has a cert with no CN',
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 						)
263 263
 					);
264 264
 				}
265
-				if($certInfo['subject']['CN'] !== $appId) {
265
+				if ($certInfo['subject']['CN'] !== $appId) {
266 266
 					throw new \Exception(
267 267
 						sprintf(
268 268
 							'App with id %s has a cert issued to %s',
@@ -279,15 +279,15 @@  discard block
 block discarded – undo
279 279
 
280 280
 				// Check if the signature actually matches the downloaded content
281 281
 				$certificate = openssl_get_publickey($app['certificate']);
282
-				$verified = (bool)openssl_verify(file_get_contents($tempFile), base64_decode($app['releases'][0]['signature']), $certificate, OPENSSL_ALGO_SHA512);
282
+				$verified = (bool) openssl_verify(file_get_contents($tempFile), base64_decode($app['releases'][0]['signature']), $certificate, OPENSSL_ALGO_SHA512);
283 283
 				openssl_free_key($certificate);
284 284
 
285
-				if($verified === true) {
285
+				if ($verified === true) {
286 286
 					// Seems to match, let's proceed
287 287
 					$extractDir = $this->tempManager->getTemporaryFolder();
288 288
 					$archive = new TAR($tempFile);
289 289
 
290
-					if($archive) {
290
+					if ($archive) {
291 291
 						if (!$archive->extract($extractDir)) {
292 292
 							throw new \Exception(
293 293
 								sprintf(
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 						$folders = array_diff($allFiles, ['.', '..']);
301 301
 						$folders = array_values($folders);
302 302
 
303
-						if(count($folders) > 1) {
303
+						if (count($folders) > 1) {
304 304
 							throw new \Exception(
305 305
 								sprintf(
306 306
 									'Extracted app %s has more than 1 folder',
@@ -311,22 +311,22 @@  discard block
 block discarded – undo
311 311
 
312 312
 						// Check if appinfo/info.xml has the same app ID as well
313 313
 						$loadEntities = libxml_disable_entity_loader(false);
314
-						$xml = simplexml_load_file($extractDir . '/' . $folders[0] . '/appinfo/info.xml');
314
+						$xml = simplexml_load_file($extractDir.'/'.$folders[0].'/appinfo/info.xml');
315 315
 						libxml_disable_entity_loader($loadEntities);
316
-						if((string)$xml->id !== $appId) {
316
+						if ((string) $xml->id !== $appId) {
317 317
 							throw new \Exception(
318 318
 								sprintf(
319 319
 									'App for id %s has a wrong app ID in info.xml: %s',
320 320
 									$appId,
321
-									(string)$xml->id
321
+									(string) $xml->id
322 322
 								)
323 323
 							);
324 324
 						}
325 325
 
326 326
 						// Check if the version is lower than before
327 327
 						$currentVersion = OC_App::getAppVersion($appId);
328
-						$newVersion = (string)$xml->version;
329
-						if(version_compare($currentVersion, $newVersion) === 1) {
328
+						$newVersion = (string) $xml->version;
329
+						if (version_compare($currentVersion, $newVersion) === 1) {
330 330
 							throw new \Exception(
331 331
 								sprintf(
332 332
 									'App for id %s has version %s and tried to update to lower version %s',
@@ -337,12 +337,12 @@  discard block
 block discarded – undo
337 337
 							);
338 338
 						}
339 339
 
340
-						$baseDir = OC_App::getInstallPath() . '/' . $appId;
340
+						$baseDir = OC_App::getInstallPath().'/'.$appId;
341 341
 						// Remove old app with the ID if existent
342 342
 						OC_Helper::rmdirr($baseDir);
343 343
 						// Move to app folder
344
-						if(@mkdir($baseDir)) {
345
-							$extractDir .= '/' . $folders[0];
344
+						if (@mkdir($baseDir)) {
345
+							$extractDir .= '/'.$folders[0];
346 346
 							OC_Helper::copyr($extractDir, $baseDir);
347 347
 						}
348 348
 						OC_Helper::copyr($extractDir, $baseDir);
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
 		}
403 403
 
404 404
 		$apps = $appFetcher->get();
405
-		foreach($apps as $app) {
406
-			if($app['id'] === $appId) {
405
+		foreach ($apps as $app) {
406
+			if ($app['id'] === $appId) {
407 407
 				$currentVersion = OC_App::getAppVersion($appId);
408 408
 				$newestVersion = $app['releases'][0]['version'];
409 409
 				if (version_compare($newestVersion, $currentVersion, '>')) {
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 	 * The function will check if the app is already downloaded in the apps repository
426 426
 	 */
427 427
 	public function isDownloaded($name) {
428
-		foreach(\OC::$APPSROOTS as $dir) {
428
+		foreach (\OC::$APPSROOTS as $dir) {
429 429
 			$dirToTest  = $dir['path'];
430 430
 			$dirToTest .= '/';
431 431
 			$dirToTest .= $name;
@@ -453,11 +453,11 @@  discard block
 block discarded – undo
453 453
 	 * this has to be done by the function oc_app_uninstall().
454 454
 	 */
455 455
 	public function removeApp($appId) {
456
-		if($this->isDownloaded( $appId )) {
457
-			$appDir = OC_App::getInstallPath() . '/' . $appId;
456
+		if ($this->isDownloaded($appId)) {
457
+			$appDir = OC_App::getInstallPath().'/'.$appId;
458 458
 			OC_Helper::rmdirr($appDir);
459 459
 			return true;
460
-		}else{
460
+		} else {
461 461
 			\OCP\Util::writeLog('core', 'can\'t remove app '.$appId.'. It is not installed.', \OCP\Util::ERROR);
462 462
 
463 463
 			return false;
@@ -473,8 +473,8 @@  discard block
 block discarded – undo
473 473
 	 */
474 474
 	public function installAppBundle(Bundle $bundle) {
475 475
 		$appIds = $bundle->getAppIdentifiers();
476
-		foreach($appIds as $appId) {
477
-			if(!$this->isDownloaded($appId)) {
476
+		foreach ($appIds as $appId) {
477
+			if (!$this->isDownloaded($appId)) {
478 478
 				$this->downloadApp($appId);
479 479
 			}
480 480
 			$this->installApp($appId);
@@ -496,13 +496,13 @@  discard block
 block discarded – undo
496 496
 	 */
497 497
 	public static function installShippedApps($softErrors = false) {
498 498
 		$errors = [];
499
-		foreach(\OC::$APPSROOTS as $app_dir) {
500
-			if($dir = opendir( $app_dir['path'] )) {
501
-				while( false !== ( $filename = readdir( $dir ))) {
502
-					if( substr( $filename, 0, 1 ) != '.' and is_dir($app_dir['path']."/$filename") ) {
503
-						if( file_exists( $app_dir['path']."/$filename/appinfo/info.xml" )) {
504
-							if(!Installer::isInstalled($filename)) {
505
-								$info=OC_App::getAppInfo($filename);
499
+		foreach (\OC::$APPSROOTS as $app_dir) {
500
+			if ($dir = opendir($app_dir['path'])) {
501
+				while (false !== ($filename = readdir($dir))) {
502
+					if (substr($filename, 0, 1) != '.' and is_dir($app_dir['path']."/$filename")) {
503
+						if (file_exists($app_dir['path']."/$filename/appinfo/info.xml")) {
504
+							if (!Installer::isInstalled($filename)) {
505
+								$info = OC_App::getAppInfo($filename);
506 506
 								$enabled = isset($info['default_enable']);
507 507
 								if (($enabled || in_array($filename, \OC::$server->getAppManager()->getAlwaysEnabledApps()))
508 508
 									  && \OC::$server->getConfig()->getAppValue($filename, 'enabled') !== 'no') {
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 						}
526 526
 					}
527 527
 				}
528
-				closedir( $dir );
528
+				closedir($dir);
529 529
 			}
530 530
 		}
531 531
 
@@ -542,12 +542,12 @@  discard block
 block discarded – undo
542 542
 		$appPath = OC_App::getAppPath($app);
543 543
 		\OC_App::registerAutoloading($app, $appPath);
544 544
 
545
-		if(is_file("$appPath/appinfo/database.xml")) {
545
+		if (is_file("$appPath/appinfo/database.xml")) {
546 546
 			try {
547 547
 				OC_DB::createDbFromStructure("$appPath/appinfo/database.xml");
548 548
 			} catch (TableExistsException $e) {
549 549
 				throw new HintException(
550
-					'Failed to enable app ' . $app,
550
+					'Failed to enable app '.$app,
551 551
 					'Please ask for help via one of our <a href="https://nextcloud.com/support/" target="_blank" rel="noreferrer">support channels</a>.',
552 552
 					0, $e
553 553
 				);
@@ -576,16 +576,16 @@  discard block
 block discarded – undo
576 576
 		}
577 577
 
578 578
 		//set remote/public handlers
579
-		foreach($info['remote'] as $name=>$path) {
579
+		foreach ($info['remote'] as $name=>$path) {
580 580
 			$config->setAppValue('core', 'remote_'.$name, $app.'/'.$path);
581 581
 		}
582
-		foreach($info['public'] as $name=>$path) {
582
+		foreach ($info['public'] as $name=>$path) {
583 583
 			$config->setAppValue('core', 'public_'.$name, $app.'/'.$path);
584 584
 		}
585 585
 
586 586
 		OC_App::setAppTypes($info['id']);
587 587
 
588
-		if(isset($info['settings']) && is_array($info['settings'])) {
588
+		if (isset($info['settings']) && is_array($info['settings'])) {
589 589
 			// requires that autoloading was registered for the app,
590 590
 			// as happens before running the install.php some lines above
591 591
 			\OC::$server->getSettingsManager()->setupSettings($info['settings']);
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 	 */
602 602
 	public static function checkCode($folder) {
603 603
 		// is the code checker enabled?
604
-		if(!\OC::$server->getConfig()->getSystemValue('appcodechecker', false)) {
604
+		if (!\OC::$server->getConfig()->getSystemValue('appcodechecker', false)) {
605 605
 			return true;
606 606
 		}
607 607
 
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 	 * @param string $script
616 616
 	 */
617 617
 	private static function includeAppScript($script) {
618
-		if ( file_exists($script) ){
618
+		if (file_exists($script)) {
619 619
 			include $script;
620 620
 		}
621 621
 	}
Please login to merge, or discard this patch.
lib/private/legacy/app.php 1 patch
Spacing   +58 added lines, -58 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);
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 			$plugins = isset($info['collaboration']['plugins']['plugin']['@value']) ?
180 180
 				[$info['collaboration']['plugins']['plugin']] : $info['collaboration']['plugins']['plugin'];
181 181
 			foreach ($plugins as $plugin) {
182
-				if($plugin['@attributes']['type'] === 'collaborator-search') {
182
+				if ($plugin['@attributes']['type'] === 'collaborator-search') {
183 183
 					$pluginInfo = [
184 184
 						'shareType' => $plugin['@attributes']['share-type'],
185 185
 						'class' => $plugin['@value'],
@@ -196,17 +196,17 @@  discard block
 block discarded – undo
196 196
 	 * @param string $path
197 197
 	 */
198 198
 	public static function registerAutoloading($app, $path) {
199
-		$key = $app . '-' . $path;
200
-		if(isset(self::$alreadyRegistered[$key])) {
199
+		$key = $app.'-'.$path;
200
+		if (isset(self::$alreadyRegistered[$key])) {
201 201
 			return;
202 202
 		}
203 203
 		self::$alreadyRegistered[$key] = true;
204 204
 		// Register on PSR-4 composer autoloader
205 205
 		$appNamespace = \OC\AppFramework\App::buildAppNamespace($app);
206 206
 		\OC::$server->registerNamespace($app, $appNamespace);
207
-		\OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true);
207
+		\OC::$composerAutoloader->addPsr4($appNamespace.'\\', $path.'/lib/', true);
208 208
 		if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) {
209
-			\OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true);
209
+			\OC::$composerAutoloader->addPsr4($appNamespace.'\\Tests\\', $path.'/tests/', true);
210 210
 		}
211 211
 
212 212
 		// Register on legacy autoloader
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	private static function requireAppFile($app) {
222 222
 		try {
223 223
 			// encapsulated here to avoid variable scope conflicts
224
-			require_once $app . '/appinfo/app.php';
224
+			require_once $app.'/appinfo/app.php';
225 225
 		} catch (Error $ex) {
226 226
 			\OC::$server->getLogger()->logException($ex);
227 227
 			$blacklist = \OC::$server->getAppManager()->getAlwaysEnabledApps();
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 	 */
276 276
 	public static function setAppTypes($app) {
277 277
 		$appData = self::getAppInfo($app);
278
-		if(!is_array($appData)) {
278
+		if (!is_array($appData)) {
279 279
 			return;
280 280
 		}
281 281
 
@@ -327,8 +327,8 @@  discard block
 block discarded – undo
327 327
 		} else {
328 328
 			$apps = $appManager->getEnabledAppsForUser($user);
329 329
 		}
330
-		$apps = array_filter($apps, function ($app) {
331
-			return $app !== 'files';//we add this manually
330
+		$apps = array_filter($apps, function($app) {
331
+			return $app !== 'files'; //we add this manually
332 332
 		});
333 333
 		sort($apps);
334 334
 		array_unshift($apps, 'files');
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 		);
372 372
 		$isDownloaded = $installer->isDownloaded($appId);
373 373
 
374
-		if(!$isDownloaded) {
374
+		if (!$isDownloaded) {
375 375
 			$installer->downloadApp($appId);
376 376
 		}
377 377
 
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 	 */
491 491
 	public static function findAppInDirectories($appId) {
492 492
 		$sanitizedAppId = self::cleanAppId($appId);
493
-		if($sanitizedAppId !== $appId) {
493
+		if ($sanitizedAppId !== $appId) {
494 494
 			return false;
495 495
 		}
496 496
 		static $app_dir = array();
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 
502 502
 		$possibleApps = array();
503 503
 		foreach (OC::$APPSROOTS as $dir) {
504
-			if (file_exists($dir['path'] . '/' . $appId)) {
504
+			if (file_exists($dir['path'].'/'.$appId)) {
505 505
 				$possibleApps[] = $dir;
506 506
 			}
507 507
 		}
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 		}
543 543
 
544 544
 		if (($dir = self::findAppInDirectories($appId)) != false) {
545
-			return $dir['path'] . '/' . $appId;
545
+			return $dir['path'].'/'.$appId;
546 546
 		}
547 547
 		return false;
548 548
 	}
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 	 */
557 557
 	public static function getAppWebPath($appId) {
558 558
 		if (($dir = self::findAppInDirectories($appId)) != false) {
559
-			return OC::$WEBROOT . $dir['url'] . '/' . $appId;
559
+			return OC::$WEBROOT.$dir['url'].'/'.$appId;
560 560
 		}
561 561
 		return false;
562 562
 	}
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 	 * @return string
570 570
 	 */
571 571
 	public static function getAppVersion($appId, $useCache = true) {
572
-		if($useCache && isset(self::$appVersion[$appId])) {
572
+		if ($useCache && isset(self::$appVersion[$appId])) {
573 573
 			return self::$appVersion[$appId];
574 574
 		}
575 575
 
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 	 * @return string
586 586
 	 */
587 587
 	public static function getAppVersionByPath($path) {
588
-		$infoFile = $path . '/appinfo/info.xml';
588
+		$infoFile = $path.'/appinfo/info.xml';
589 589
 		$appData = self::getAppInfo($infoFile, true);
590 590
 		return isset($appData['version']) ? $appData['version'] : '';
591 591
 	}
@@ -608,10 +608,10 @@  discard block
 block discarded – undo
608 608
 				return self::$appInfo[$appId];
609 609
 			}
610 610
 			$appPath = self::getAppPath($appId);
611
-			if($appPath === false) {
611
+			if ($appPath === false) {
612 612
 				return null;
613 613
 			}
614
-			$file = $appPath . '/appinfo/info.xml';
614
+			$file = $appPath.'/appinfo/info.xml';
615 615
 		}
616 616
 
617 617
 		$parser = new InfoParser(\OC::$server->getMemCacheFactory()->createLocal('core.appinfo'));
@@ -620,9 +620,9 @@  discard block
 block discarded – undo
620 620
 		if (is_array($data)) {
621 621
 			$data = OC_App::parseAppInfo($data, $lang);
622 622
 		}
623
-		if(isset($data['ocsid'])) {
623
+		if (isset($data['ocsid'])) {
624 624
 			$storedId = \OC::$server->getConfig()->getAppValue($appId, 'ocsid');
625
-			if($storedId !== '' && $storedId !== $data['ocsid']) {
625
+			if ($storedId !== '' && $storedId !== $data['ocsid']) {
626 626
 				$data['ocsid'] = $storedId;
627 627
 			}
628 628
 		}
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 	 * @param string $page
715 715
 	 */
716 716
 	public static function registerAdmin($app, $page) {
717
-		self::$adminForms[] = $app . '/' . $page . '.php';
717
+		self::$adminForms[] = $app.'/'.$page.'.php';
718 718
 	}
719 719
 
720 720
 	/**
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 	 * @param string $page
724 724
 	 */
725 725
 	public static function registerPersonal($app, $page) {
726
-		self::$personalForms[] = $app . '/' . $page . '.php';
726
+		self::$personalForms[] = $app.'/'.$page.'.php';
727 727
 	}
728 728
 
729 729
 	/**
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 
753 753
 		foreach (OC::$APPSROOTS as $apps_dir) {
754 754
 			if (!is_readable($apps_dir['path'])) {
755
-				\OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], \OCP\Util::WARN);
755
+				\OCP\Util::writeLog('core', 'unable to read app folder : '.$apps_dir['path'], \OCP\Util::WARN);
756 756
 				continue;
757 757
 			}
758 758
 			$dh = opendir($apps_dir['path']);
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 			if (is_resource($dh)) {
761 761
 				while (($file = readdir($dh)) !== false) {
762 762
 
763
-					if ($file[0] != '.' and is_dir($apps_dir['path'] . '/' . $file) and is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')) {
763
+					if ($file[0] != '.' and is_dir($apps_dir['path'].'/'.$file) and is_file($apps_dir['path'].'/'.$file.'/appinfo/info.xml')) {
764 764
 
765 765
 						$apps[] = $file;
766 766
 					}
@@ -791,12 +791,12 @@  discard block
 block discarded – undo
791 791
 
792 792
 				$info = OC_App::getAppInfo($app, false, $langCode);
793 793
 				if (!is_array($info)) {
794
-					\OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', \OCP\Util::ERROR);
794
+					\OCP\Util::writeLog('core', 'Could not read app info file for app "'.$app.'"', \OCP\Util::ERROR);
795 795
 					continue;
796 796
 				}
797 797
 
798 798
 				if (!isset($info['name'])) {
799
-					\OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', \OCP\Util::ERROR);
799
+					\OCP\Util::writeLog('core', 'App id "'.$app.'" has no name in appinfo', \OCP\Util::ERROR);
800 800
 					continue;
801 801
 				}
802 802
 
@@ -823,13 +823,13 @@  discard block
 block discarded – undo
823 823
 				}
824 824
 
825 825
 				$appPath = self::getAppPath($app);
826
-				if($appPath !== false) {
827
-					$appIcon = $appPath . '/img/' . $app . '.svg';
826
+				if ($appPath !== false) {
827
+					$appIcon = $appPath.'/img/'.$app.'.svg';
828 828
 					if (file_exists($appIcon)) {
829
-						$info['preview'] = $urlGenerator->imagePath($app, $app . '.svg');
829
+						$info['preview'] = $urlGenerator->imagePath($app, $app.'.svg');
830 830
 						$info['previewAsIcon'] = true;
831 831
 					} else {
832
-						$appIcon = $appPath . '/img/app.svg';
832
+						$appIcon = $appPath.'/img/app.svg';
833 833
 						if (file_exists($appIcon)) {
834 834
 							$info['preview'] = $urlGenerator->imagePath($app, 'app.svg');
835 835
 							$info['previewAsIcon'] = true;
@@ -863,9 +863,9 @@  discard block
 block discarded – undo
863 863
 	 * @return string|false
864 864
 	 */
865 865
 	public static function getInternalAppIdByOcs($ocsID) {
866
-		if(is_numeric($ocsID)) {
866
+		if (is_numeric($ocsID)) {
867 867
 			$idArray = \OC::$server->getAppConfig()->getValues(false, 'ocsid');
868
-			if(array_search($ocsID, $idArray)) {
868
+			if (array_search($ocsID, $idArray)) {
869 869
 				return array_search($ocsID, $idArray);
870 870
 			}
871 871
 		}
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
 	public static function getAppVersions() {
970 970
 		static $versions;
971 971
 
972
-		if(!$versions) {
972
+		if (!$versions) {
973 973
 			$appConfig = \OC::$server->getAppConfig();
974 974
 			$versions = $appConfig->getValues(false, 'installed_version');
975 975
 		}
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 		if ($app !== false) {
992 992
 			// check if the app is compatible with this version of ownCloud
993 993
 			$info = self::getAppInfo($app);
994
-			if(!is_array($info)) {
994
+			if (!is_array($info)) {
995 995
 				throw new \Exception(
996 996
 					$l->t('App "%s" cannot be installed because appinfo file cannot be read.',
997 997
 						[$info['name']]
@@ -1016,7 +1016,7 @@  discard block
 block discarded – undo
1016 1016
 				$config->setAppValue($app, 'ocsid', $appData['id']);
1017 1017
 			}
1018 1018
 
1019
-			if(isset($info['settings']) && is_array($info['settings'])) {
1019
+			if (isset($info['settings']) && is_array($info['settings'])) {
1020 1020
 				$appPath = self::getAppPath($app);
1021 1021
 				self::registerAutoloading($app, $appPath);
1022 1022
 				\OC::$server->getSettingsManager()->setupSettings($info['settings']);
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
 
1025 1025
 			\OC_Hook::emit('OC_App', 'post_enable', array('app' => $app));
1026 1026
 		} else {
1027
-			if(empty($appName) ) {
1027
+			if (empty($appName)) {
1028 1028
 				throw new \Exception($l->t("No app name specified"));
1029 1029
 			} else {
1030 1030
 				throw new \Exception($l->t("App '%s' could not be installed!", $appName));
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
 	 */
1043 1043
 	public static function updateApp($appId) {
1044 1044
 		$appPath = self::getAppPath($appId);
1045
-		if($appPath === false) {
1045
+		if ($appPath === false) {
1046 1046
 			return false;
1047 1047
 		}
1048 1048
 		self::registerAutoloading($appId, $appPath);
@@ -1050,8 +1050,8 @@  discard block
 block discarded – undo
1050 1050
 		$appData = self::getAppInfo($appId);
1051 1051
 		self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']);
1052 1052
 
1053
-		if (file_exists($appPath . '/appinfo/database.xml')) {
1054
-			OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml');
1053
+		if (file_exists($appPath.'/appinfo/database.xml')) {
1054
+			OC_DB::updateDbFromStructure($appPath.'/appinfo/database.xml');
1055 1055
 		} else {
1056 1056
 			$ms = new MigrationService($appId, \OC::$server->getDatabaseConnection());
1057 1057
 			$ms->migrate();
@@ -1062,26 +1062,26 @@  discard block
 block discarded – undo
1062 1062
 		unset(self::$appVersion[$appId]);
1063 1063
 
1064 1064
 		// run upgrade code
1065
-		if (file_exists($appPath . '/appinfo/update.php')) {
1065
+		if (file_exists($appPath.'/appinfo/update.php')) {
1066 1066
 			self::loadApp($appId);
1067
-			include $appPath . '/appinfo/update.php';
1067
+			include $appPath.'/appinfo/update.php';
1068 1068
 		}
1069 1069
 		self::setupBackgroundJobs($appData['background-jobs']);
1070
-		if(isset($appData['settings']) && is_array($appData['settings'])) {
1070
+		if (isset($appData['settings']) && is_array($appData['settings'])) {
1071 1071
 			\OC::$server->getSettingsManager()->setupSettings($appData['settings']);
1072 1072
 		}
1073 1073
 
1074 1074
 		//set remote/public handlers
1075 1075
 		if (array_key_exists('ocsid', $appData)) {
1076 1076
 			\OC::$server->getConfig()->setAppValue($appId, 'ocsid', $appData['ocsid']);
1077
-		} elseif(\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) {
1077
+		} elseif (\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) {
1078 1078
 			\OC::$server->getConfig()->deleteAppValue($appId, 'ocsid');
1079 1079
 		}
1080 1080
 		foreach ($appData['remote'] as $name => $path) {
1081
-			\OC::$server->getConfig()->setAppValue('core', 'remote_' . $name, $appId . '/' . $path);
1081
+			\OC::$server->getConfig()->setAppValue('core', 'remote_'.$name, $appId.'/'.$path);
1082 1082
 		}
1083 1083
 		foreach ($appData['public'] as $name => $path) {
1084
-			\OC::$server->getConfig()->setAppValue('core', 'public_' . $name, $appId . '/' . $path);
1084
+			\OC::$server->getConfig()->setAppValue('core', 'public_'.$name, $appId.'/'.$path);
1085 1085
 		}
1086 1086
 
1087 1087
 		self::setAppTypes($appId);
@@ -1151,17 +1151,17 @@  discard block
 block discarded – undo
1151 1151
 	public static function getStorage($appId) {
1152 1152
 		if (OC_App::isEnabled($appId)) { //sanity check
1153 1153
 			if (\OC::$server->getUserSession()->isLoggedIn()) {
1154
-				$view = new \OC\Files\View('/' . OC_User::getUser());
1154
+				$view = new \OC\Files\View('/'.OC_User::getUser());
1155 1155
 				if (!$view->file_exists($appId)) {
1156 1156
 					$view->mkdir($appId);
1157 1157
 				}
1158
-				return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId);
1158
+				return new \OC\Files\View('/'.OC_User::getUser().'/'.$appId);
1159 1159
 			} else {
1160
-				\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', \OCP\Util::ERROR);
1160
+				\OCP\Util::writeLog('core', 'Can\'t get app storage, app '.$appId.', user not logged in', \OCP\Util::ERROR);
1161 1161
 				return false;
1162 1162
 			}
1163 1163
 		} else {
1164
-			\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', \OCP\Util::ERROR);
1164
+			\OCP\Util::writeLog('core', 'Can\'t get app storage, app '.$appId.' not enabled', \OCP\Util::ERROR);
1165 1165
 			return false;
1166 1166
 		}
1167 1167
 	}
@@ -1193,9 +1193,9 @@  discard block
 block discarded – undo
1193 1193
 
1194 1194
 				if ($attributeLang === $similarLang) {
1195 1195
 					$similarLangFallback = $option['@value'];
1196
-				} else if (strpos($attributeLang, $similarLang . '_') === 0) {
1196
+				} else if (strpos($attributeLang, $similarLang.'_') === 0) {
1197 1197
 					if ($similarLangFallback === false) {
1198
-						$similarLangFallback =  $option['@value'];
1198
+						$similarLangFallback = $option['@value'];
1199 1199
 					}
1200 1200
 				}
1201 1201
 			} else {
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 			$data['description'] = trim(self::findBestL10NOption($data['description'], $lang));
1231 1231
 		} else if (isset($data['description']) && is_string($data['description'])) {
1232 1232
 			$data['description'] = trim($data['description']);
1233
-		} else  {
1233
+		} else {
1234 1234
 			$data['description'] = '';
1235 1235
 		}
1236 1236
 
Please login to merge, or discard this patch.