Completed
Pull Request — master (#3770)
by Thomas
38:05 queued 14:21
created
apps/admin_audit/lib/actions/action.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 						array $params,
48 48
 						array $elements,
49 49
 						$obfuscateParameters = false) {
50
-		foreach($elements as $element) {
51
-			if(!isset($params[$element])) {
50
+		foreach ($elements as $element) {
51
+			if (!isset($params[$element])) {
52 52
 				if ($obfuscateParameters) {
53 53
 					$this->logger->critical(
54 54
 						'$params["'.$element.'"] was missing.',
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 		}
69 69
 
70 70
 		$replaceArray = [];
71
-		foreach($elements as $element) {
72
-			if($params[$element] instanceof \DateTime) {
71
+		foreach ($elements as $element) {
72
+			if ($params[$element] instanceof \DateTime) {
73 73
 				$params[$element] = $params[$element]->format('Y-m-d H:i:s');
74 74
 			}
75 75
 			$replaceArray[] = $params[$element];
Please login to merge, or discard this patch.
apps/admin_audit/lib/actions/sharing.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @param array $params
36 36
 	 */
37 37
 	public function shared(array $params) {
38
-		if($params['shareType'] === Share::SHARE_TYPE_LINK) {
38
+		if ($params['shareType'] === Share::SHARE_TYPE_LINK) {
39 39
 			$this->log(
40 40
 				'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)',
41 41
 				$params,
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 					'id',
48 48
 				]
49 49
 			);
50
-		} elseif($params['shareType'] === Share::SHARE_TYPE_USER) {
50
+		} elseif ($params['shareType'] === Share::SHARE_TYPE_USER) {
51 51
 			$this->log(
52 52
 				'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s"  (Share ID: %s)',
53 53
 				$params,
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 					'id',
61 61
 				]
62 62
 			);
63
-		} elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) {
63
+		} elseif ($params['shareType'] === Share::SHARE_TYPE_GROUP) {
64 64
 			$this->log(
65 65
 				'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s"  (Share ID: %s)',
66 66
 				$params,
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 * @param array $params
83 83
 	 */
84 84
 	public function unshare(array $params) {
85
-		if($params['shareType'] === Share::SHARE_TYPE_LINK) {
85
+		if ($params['shareType'] === Share::SHARE_TYPE_LINK) {
86 86
 			$this->log(
87 87
 				'The %s "%s" with ID "%s" has been unshared (Share ID: %s)',
88 88
 				$params,
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 					'id',
94 94
 				]
95 95
 			);
96
-		} elseif($params['shareType'] === Share::SHARE_TYPE_USER) {
96
+		} elseif ($params['shareType'] === Share::SHARE_TYPE_USER) {
97 97
 			$this->log(
98 98
 				'The %s "%s" with ID "%s" has been unshared from the user "%s" (Share ID: %s)',
99 99
 				$params,
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 					'id',
106 106
 				]
107 107
 			);
108
-		} elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) {
108
+		} elseif ($params['shareType'] === Share::SHARE_TYPE_GROUP) {
109 109
 			$this->log(
110 110
 				'The %s "%s" with ID "%s" has been unshared from the group "%s" (Share ID: %s)',
111 111
 				$params,
Please login to merge, or discard this patch.
apps/files_versions/ajax/getVersions.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,15 +28,15 @@
 block discarded – undo
28 28
 OCP\JSON::callCheck();
29 29
 OCP\JSON::checkAppEnabled('files_versions');
30 30
 
31
-$source = (string)$_GET['source'];
32
-$start = (int)$_GET['start'];
31
+$source = (string) $_GET['source'];
32
+$start = (int) $_GET['start'];
33 33
 list ($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($source);
34 34
 $count = 5; //show the newest revisions
35 35
 $versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $source);
36
-if( $versions ) {
36
+if ($versions) {
37 37
 
38 38
 	$endReached = false;
39
-	if (count($versions) <= $start+$count) {
39
+	if (count($versions) <= $start + $count) {
40 40
 		$endReached = true;
41 41
 	}
42 42
 
Please login to merge, or discard this patch.
apps/files_versions/ajax/rollbackVersion.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,12 +30,12 @@
 block discarded – undo
30 30
 OCP\JSON::checkAppEnabled('files_versions');
31 31
 OCP\JSON::callCheck();
32 32
 
33
-$file = (string)$_GET['file'];
34
-$revision=(int)$_GET['revision'];
33
+$file = (string) $_GET['file'];
34
+$revision = (int) $_GET['revision'];
35 35
 
36
-if(OCA\Files_Versions\Storage::rollback( $file, $revision )) {
37
-	OCP\JSON::success(array("data" => array( "revision" => $revision, "file" => $file )));
38
-}else{
36
+if (OCA\Files_Versions\Storage::rollback($file, $revision)) {
37
+	OCP\JSON::success(array("data" => array("revision" => $revision, "file" => $file)));
38
+} else {
39 39
 	$l = \OC::$server->getL10N('files_versions');
40
-	OCP\JSON::error(array("data" => array( "message" => $l->t("Could not revert: %s", array($file) ))));
40
+	OCP\JSON::error(array("data" => array("message" => $l->t("Could not revert: %s", array($file)))));
41 41
 }
Please login to merge, or discard this patch.
apps/files_versions/lib/Storage.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 
54 54
 class Storage {
55 55
 
56
-	const DEFAULTENABLED=true;
57
-	const DEFAULTMAXSIZE=50; // unit: percentage; 50% of available disk space/quota
56
+	const DEFAULTENABLED = true;
57
+	const DEFAULTMAXSIZE = 50; // unit: percentage; 50% of available disk space/quota
58 58
 	const VERSIONS_ROOT = 'files_versions/';
59 59
 
60 60
 	const DELETE_TRIGGER_MASTER_REMOVED = 0;
@@ -68,17 +68,17 @@  discard block
 block discarded – undo
68 68
 
69 69
 	private static $max_versions_per_interval = array(
70 70
 		//first 10sec, one version every 2sec
71
-		1 => array('intervalEndsAfter' => 10,      'step' => 2),
71
+		1 => array('intervalEndsAfter' => 10, 'step' => 2),
72 72
 		//next minute, one version every 10sec
73
-		2 => array('intervalEndsAfter' => 60,      'step' => 10),
73
+		2 => array('intervalEndsAfter' => 60, 'step' => 10),
74 74
 		//next hour, one version every minute
75
-		3 => array('intervalEndsAfter' => 3600,    'step' => 60),
75
+		3 => array('intervalEndsAfter' => 3600, 'step' => 60),
76 76
 		//next 24h, one version every hour
77
-		4 => array('intervalEndsAfter' => 86400,   'step' => 3600),
77
+		4 => array('intervalEndsAfter' => 86400, 'step' => 3600),
78 78
 		//next 30days, one version per day
79 79
 		5 => array('intervalEndsAfter' => 2592000, 'step' => 86400),
80 80
 		//until the end one version per week
81
-		6 => array('intervalEndsAfter' => -1,      'step' => 604800),
81
+		6 => array('intervalEndsAfter' => -1, 'step' => 604800),
82 82
 	);
83 83
 
84 84
 	/** @var \OCA\Files_Versions\AppInfo\Application */
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 			$uid = User::getUser();
103 103
 		}
104 104
 		Filesystem::initMountPoints($uid);
105
-		if ( $uid != User::getUser() ) {
105
+		if ($uid != User::getUser()) {
106 106
 			$info = Filesystem::getFileInfo($filename);
107 107
 			$ownerView = new View('/'.$uid.'/files');
108 108
 			try {
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * @return int versions size
153 153
 	 */
154 154
 	private static function getVersionsSize($user) {
155
-		$view = new View('/' . $user);
155
+		$view = new View('/'.$user);
156 156
 		$fileInfo = $view->getFileInfo('/files_versions');
157 157
 		return isset($fileInfo['size']) ? $fileInfo['size'] : 0;
158 158
 	}
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 * store a new version of a file.
162 162
 	 */
163 163
 	public static function store($filename) {
164
-		if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
164
+		if (\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true') {
165 165
 
166 166
 			// if the file gets streamed we need to remove the .part extension
167 167
 			// to get the right target
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
 			}
172 172
 
173 173
 			// we only handle existing files
174
-			if (! Filesystem::file_exists($filename) || Filesystem::is_dir($filename)) {
174
+			if (!Filesystem::file_exists($filename) || Filesystem::is_dir($filename)) {
175 175
 				return false;
176 176
 			}
177 177
 
178 178
 			list($uid, $filename) = self::getUidAndFilename($filename);
179 179
 
180
-			$files_view = new View('/'.$uid .'/files');
180
+			$files_view = new View('/'.$uid.'/files');
181 181
 			$users_view = new View('/'.$uid);
182 182
 
183 183
 			// no use making versions for empty files
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
 			self::scheduleExpire($uid, $filename);
192 192
 
193 193
 			// store a new version of a file
194
-			$mtime = $users_view->filemtime('files/' . $filename);
195
-			$users_view->copy('files/' . $filename, 'files_versions/' . $filename . '.v' . $mtime);
194
+			$mtime = $users_view->filemtime('files/'.$filename);
195
+			$users_view->copy('files/'.$filename, 'files_versions/'.$filename.'.v'.$mtime);
196 196
 			// call getFileInfo to enforce a file cache entry for the new version
197
-			$users_view->getFileInfo('files_versions/' . $filename . '.v' . $mtime);
197
+			$users_view->getFileInfo('files_versions/'.$filename.'.v'.$mtime);
198 198
 		}
199 199
 	}
200 200
 
@@ -238,14 +238,14 @@  discard block
 block discarded – undo
238 238
 
239 239
 		if (!Filesystem::file_exists($path)) {
240 240
 
241
-			$view = new View('/' . $uid . '/files_versions');
241
+			$view = new View('/'.$uid.'/files_versions');
242 242
 
243 243
 			$versions = self::getVersions($uid, $filename);
244 244
 			if (!empty($versions)) {
245 245
 				foreach ($versions as $v) {
246
-					\OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $path . $v['version'], 'trigger' => self::DELETE_TRIGGER_MASTER_REMOVED));
247
-					self::deleteVersion($view, $filename . '.v' . $v['version']);
248
-					\OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path . $v['version'], 'trigger' => self::DELETE_TRIGGER_MASTER_REMOVED));
246
+					\OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $path.$v['version'], 'trigger' => self::DELETE_TRIGGER_MASTER_REMOVED));
247
+					self::deleteVersion($view, $filename.'.v'.$v['version']);
248
+					\OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path.$v['version'], 'trigger' => self::DELETE_TRIGGER_MASTER_REMOVED));
249 249
 				}
250 250
 			}
251 251
 		}
@@ -279,33 +279,33 @@  discard block
 block discarded – undo
279 279
 		$rootView = new View('');
280 280
 
281 281
 		// did we move a directory ?
282
-		if ($rootView->is_dir('/' . $targetOwner . '/files/' . $targetPath)) {
282
+		if ($rootView->is_dir('/'.$targetOwner.'/files/'.$targetPath)) {
283 283
 			// does the directory exists for versions too ?
284
-			if ($rootView->is_dir('/' . $sourceOwner . '/files_versions/' . $sourcePath)) {
284
+			if ($rootView->is_dir('/'.$sourceOwner.'/files_versions/'.$sourcePath)) {
285 285
 				// create missing dirs if necessary
286
-				self::createMissingDirectories($targetPath, new View('/'. $targetOwner));
286
+				self::createMissingDirectories($targetPath, new View('/'.$targetOwner));
287 287
 
288 288
 				// move the directory containing the versions
289 289
 				$rootView->$operation(
290
-					'/' . $sourceOwner . '/files_versions/' . $sourcePath,
291
-					'/' . $targetOwner . '/files_versions/' . $targetPath
290
+					'/'.$sourceOwner.'/files_versions/'.$sourcePath,
291
+					'/'.$targetOwner.'/files_versions/'.$targetPath
292 292
 				);
293 293
 			}
294
-		} else if ($versions = Storage::getVersions($sourceOwner, '/' . $sourcePath)) {
294
+		} else if ($versions = Storage::getVersions($sourceOwner, '/'.$sourcePath)) {
295 295
 			// create missing dirs if necessary
296
-			self::createMissingDirectories($targetPath, new View('/'. $targetOwner));
296
+			self::createMissingDirectories($targetPath, new View('/'.$targetOwner));
297 297
 
298 298
 			foreach ($versions as $v) {
299 299
 				// move each version one by one to the target directory
300 300
 				$rootView->$operation(
301
-					'/' . $sourceOwner . '/files_versions/' . $sourcePath.'.v' . $v['version'],
302
-					'/' . $targetOwner . '/files_versions/' . $targetPath.'.v'.$v['version']
301
+					'/'.$sourceOwner.'/files_versions/'.$sourcePath.'.v'.$v['version'],
302
+					'/'.$targetOwner.'/files_versions/'.$targetPath.'.v'.$v['version']
303 303
 				);
304 304
 			}
305 305
 		}
306 306
 
307 307
 		// if we moved versions directly for a file, schedule expiration check for that file
308
-		if (!$rootView->is_dir('/' . $targetOwner . '/files/' . $targetPath)) {
308
+		if (!$rootView->is_dir('/'.$targetOwner.'/files/'.$targetPath)) {
309 309
 			self::scheduleExpire($targetOwner, $targetPath);
310 310
 		}
311 311
 
@@ -320,16 +320,16 @@  discard block
 block discarded – undo
320 320
 	 */
321 321
 	public static function rollback($file, $revision) {
322 322
 
323
-		if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
323
+		if (\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true') {
324 324
 			// add expected leading slash
325
-			$file = '/' . ltrim($file, '/');
325
+			$file = '/'.ltrim($file, '/');
326 326
 			list($uid, $filename) = self::getUidAndFilename($file);
327 327
 			if ($uid === null || trim($filename, '/') === '') {
328 328
 				return false;
329 329
 			}
330 330
 
331 331
 			$users_view = new View('/'.$uid);
332
-			$files_view = new View('/'. User::getUser().'/files');
332
+			$files_view = new View('/'.User::getUser().'/files');
333 333
 
334 334
 			$versionCreated = false;
335 335
 
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 				$versionCreated = true;
348 348
 			}
349 349
 
350
-			$fileToRestore =  'files_versions' . $filename . '.v' . $revision;
350
+			$fileToRestore = 'files_versions'.$filename.'.v'.$revision;
351 351
 
352 352
 			// Restore encrypted version of the old file for the newly restored file
353 353
 			// This has to happen manually here since the file is manually copied below
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 			);
364 364
 
365 365
 			// rollback
366
-			if (self::copyFileContents($users_view, $fileToRestore, 'files' . $filename)) {
366
+			if (self::copyFileContents($users_view, $fileToRestore, 'files'.$filename)) {
367 367
 				$files_view->touch($file, $revision);
368 368
 				Storage::scheduleExpire($uid, $file);
369 369
 				\OC_Hook::emit('\OCP\Versions', 'rollback', array(
@@ -431,12 +431,12 @@  discard block
 block discarded – undo
431 431
 			return $versions;
432 432
 		}
433 433
 		// fetch for old versions
434
-		$view = new View('/' . $uid . '/');
434
+		$view = new View('/'.$uid.'/');
435 435
 
436 436
 		$pathinfo = pathinfo($filename);
437 437
 		$versionedFile = $pathinfo['basename'];
438 438
 
439
-		$dir = Filesystem::normalizePath(self::VERSIONS_ROOT . '/' . $pathinfo['dirname']);
439
+		$dir = Filesystem::normalizePath(self::VERSIONS_ROOT.'/'.$pathinfo['dirname']);
440 440
 
441 441
 		$dirContent = false;
442 442
 		if ($view->is_dir($dir)) {
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 						$pathparts = pathinfo($entryName);
457 457
 						$timestamp = substr($pathparts['extension'], 1);
458 458
 						$filename = $pathparts['filename'];
459
-						$key = $timestamp . '#' . $filename;
459
+						$key = $timestamp.'#'.$filename;
460 460
 						$versions[$key]['version'] = $timestamp;
461 461
 						$versions[$key]['humanReadableTimestamp'] = self::getHumanReadableTimestamp($timestamp);
462 462
 						if (empty($userFullPath)) {
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
 						} else {
465 465
 							$versions[$key]['preview'] = \OC::$server->getURLGenerator('files_version.Preview.getPreview', ['file' => $userFullPath, 'version' => $timestamp]);
466 466
 						}
467
-						$versions[$key]['path'] = Filesystem::normalizePath($pathinfo['dirname'] . '/' . $filename);
467
+						$versions[$key]['path'] = Filesystem::normalizePath($pathinfo['dirname'].'/'.$filename);
468 468
 						$versions[$key]['name'] = $versionedFile;
469
-						$versions[$key]['size'] = $view->filesize($dir . '/' . $entryName);
469
+						$versions[$key]['size'] = $view->filesize($dir.'/'.$entryName);
470 470
 						$versions[$key]['mimetype'] = \OC::$server->getMimeTypeDetector()->detectPath($versionedFile);
471 471
 					}
472 472
 				}
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 	 * Expire versions that older than max version retention time
485 485
 	 * @param string $uid
486 486
 	 */
487
-	public static function expireOlderThanMaxForUser($uid){
487
+	public static function expireOlderThanMaxForUser($uid) {
488 488
 		$expiration = self::getExpiration();
489 489
 		$threshold = $expiration->getMaxAgeAsTimestamp();
490 490
 		$versions = self::getAllVersions($uid);
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 
495 495
 		$toDelete = [];
496 496
 		foreach (array_reverse($versions['all']) as $key => $version) {
497
-			if (intval($version['version'])<$threshold) {
497
+			if (intval($version['version']) < $threshold) {
498 498
 				$toDelete[$key] = $version;
499 499
 			} else {
500 500
 				//Versions are sorted by time - nothing mo to iterate.
@@ -502,11 +502,11 @@  discard block
 block discarded – undo
502 502
 			}
503 503
 		}
504 504
 
505
-		$view = new View('/' . $uid . '/files_versions');
505
+		$view = new View('/'.$uid.'/files_versions');
506 506
 		if (!empty($toDelete)) {
507 507
 			foreach ($toDelete as $version) {
508 508
 				\OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_RETENTION_CONSTRAINT));
509
-				self::deleteVersion($view, $version['path'] . '.v' . $version['version']);
509
+				self::deleteVersion($view, $version['path'].'.v'.$version['version']);
510 510
 				\OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_RETENTION_CONSTRAINT));
511 511
 			}
512 512
 		}
@@ -522,19 +522,19 @@  discard block
 block discarded – undo
522 522
 		$diff = time() - $timestamp;
523 523
 
524 524
 		if ($diff < 60) { // first minute
525
-			return  $diff . " seconds ago";
525
+			return  $diff." seconds ago";
526 526
 		} elseif ($diff < 3600) { //first hour
527
-			return round($diff / 60) . " minutes ago";
527
+			return round($diff / 60)." minutes ago";
528 528
 		} elseif ($diff < 86400) { // first day
529
-			return round($diff / 3600) . " hours ago";
529
+			return round($diff / 3600)." hours ago";
530 530
 		} elseif ($diff < 604800) { //first week
531
-			return round($diff / 86400) . " days ago";
531
+			return round($diff / 86400)." days ago";
532 532
 		} elseif ($diff < 2419200) { //first month
533
-			return round($diff / 604800) . " weeks ago";
533
+			return round($diff / 604800)." weeks ago";
534 534
 		} elseif ($diff < 29030400) { // first year
535
-			return round($diff / 2419200) . " months ago";
535
+			return round($diff / 2419200)." months ago";
536 536
 		} else {
537
-			return round($diff / 29030400) . " years ago";
537
+			return round($diff / 29030400)." years ago";
538 538
 		}
539 539
 
540 540
 	}
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 	 * @return array with contains two arrays 'all' which contains all versions sorted by age and 'by_file' which contains all versions sorted by filename
546 546
 	 */
547 547
 	private static function getAllVersions($uid) {
548
-		$view = new View('/' . $uid . '/');
548
+		$view = new View('/'.$uid.'/');
549 549
 		$dirs = array(self::VERSIONS_ROOT);
550 550
 		$versions = array();
551 551
 
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 
556 556
 			foreach ($files as $file) {
557 557
 				$fileData = $file->getData();
558
-				$filePath = $dir . '/' . $fileData['name'];
558
+				$filePath = $dir.'/'.$fileData['name'];
559 559
 				if ($file['type'] === 'dir') {
560 560
 					array_push($dirs, $filePath);
561 561
 				} else {
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 					$relPathStart = strlen(self::VERSIONS_ROOT);
564 564
 					$version = substr($filePath, $versionsBegin + 2);
565 565
 					$relpath = substr($filePath, $relPathStart, $versionsBegin - $relPathStart);
566
-					$key = $version . '#' . $relpath;
566
+					$key = $version.'#'.$relpath;
567 567
 					$versions[$key] = array('path' => $relpath, 'timestamp' => $version);
568 568
 				}
569 569
 			}
@@ -604,13 +604,13 @@  discard block
 block discarded – undo
604 604
 			list($toDelete, $size) = self::getAutoExpireList($time, $versions);
605 605
 		} else {
606 606
 			$size = 0;
607
-			$toDelete = [];  // versions we want to delete
607
+			$toDelete = []; // versions we want to delete
608 608
 		}
609 609
 
610 610
 		foreach ($versions as $key => $version) {
611 611
 			if ($expiration->isExpired($version['version'], $quotaExceeded) && !isset($toDelete[$key])) {
612 612
 				$size += $version['size'];
613
-				$toDelete[$key] = $version['path'] . '.v' . $version['version'];
613
+				$toDelete[$key] = $version['path'].'.v'.$version['version'];
614 614
 			}
615 615
 		}
616 616
 
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 	 */
626 626
 	protected static function getAutoExpireList($time, $versions) {
627 627
 		$size = 0;
628
-		$toDelete = array();  // versions we want to delete
628
+		$toDelete = array(); // versions we want to delete
629 629
 
630 630
 		$interval = 1;
631 631
 		$step = Storage::$max_versions_per_interval[$interval]['step'];
@@ -647,9 +647,9 @@  discard block
 block discarded – undo
647 647
 				if ($nextInterval == -1 || $prevTimestamp > $nextInterval) {
648 648
 					if ($version['version'] > $nextVersion) {
649 649
 						//distance between two version too small, mark to delete
650
-						$toDelete[$key] = $version['path'] . '.v' . $version['version'];
650
+						$toDelete[$key] = $version['path'].'.v'.$version['version'];
651 651
 						$size += $version['size'];
652
-						\OCP\Util::writeLog('files_versions', 'Mark to expire '. $version['path'] .' next version should be ' . $nextVersion . " or smaller. (prevTimestamp: " . $prevTimestamp . "; step: " . $step, \OCP\Util::INFO);
652
+						\OCP\Util::writeLog('files_versions', 'Mark to expire '.$version['path'].' next version should be '.$nextVersion." or smaller. (prevTimestamp: ".$prevTimestamp."; step: ".$step, \OCP\Util::INFO);
653 653
 					} else {
654 654
 						$nextVersion = $version['version'] - $step;
655 655
 						$prevTimestamp = $version['version'];
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 		$config = \OC::$server->getConfig();
698 698
 		$expiration = self::getExpiration();
699 699
 
700
-		if($config->getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' && $expiration->isEnabled()) {
700
+		if ($config->getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true' && $expiration->isEnabled()) {
701 701
 
702 702
 			if (!Filesystem::file_exists($filename)) {
703 703
 				return false;
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 			$user = \OC::$server->getUserManager()->get($uid);
715 715
 			$softQuota = true;
716 716
 			$quota = $user->getQuota();
717
-			if ( $quota === null || $quota === 'none' ) {
717
+			if ($quota === null || $quota === 'none') {
718 718
 				$quota = Filesystem::free_space('/');
719 719
 				$softQuota = false;
720 720
 			} else {
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 			// subtract size of files and current versions size from quota
729 729
 			if ($quota >= 0) {
730 730
 				if ($softQuota) {
731
-					$files_view = new View('/' . $uid . '/files');
731
+					$files_view = new View('/'.$uid.'/files');
732 732
 					$rootInfo = $files_view->getFileInfo('/', false);
733 733
 					$free = $quota - $rootInfo['size']; // remaining free space for user
734 734
 					if ($free > 0) {
@@ -765,18 +765,18 @@  discard block
 block discarded – undo
765 765
 				$versionsSize = $versionsSize - $sizeOfDeletedVersions;
766 766
 			}
767 767
 
768
-			foreach($toDelete as $key => $path) {
768
+			foreach ($toDelete as $key => $path) {
769 769
 				\OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $path, 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED));
770 770
 				self::deleteVersion($versionsFileview, $path);
771 771
 				\OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path, 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED));
772 772
 				unset($allVersions[$key]); // update array with the versions we keep
773
-				\OCP\Util::writeLog('files_versions', "Expire: " . $path, \OCP\Util::INFO);
773
+				\OCP\Util::writeLog('files_versions', "Expire: ".$path, \OCP\Util::INFO);
774 774
 			}
775 775
 
776 776
 			// Check if enough space is available after versions are rearranged.
777 777
 			// If not we delete the oldest versions until we meet the size limit for versions,
778 778
 			// but always keep the two latest versions
779
-			$numOfVersions = count($allVersions) -2 ;
779
+			$numOfVersions = count($allVersions) - 2;
780 780
 			$i = 0;
781 781
 			// sort oldest first and make sure that we start at the first element
782 782
 			ksort($allVersions);
@@ -784,9 +784,9 @@  discard block
 block discarded – undo
784 784
 			while ($availableSpace < 0 && $i < $numOfVersions) {
785 785
 				$version = current($allVersions);
786 786
 				\OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED));
787
-				self::deleteVersion($versionsFileview, $version['path'] . '.v' . $version['version']);
787
+				self::deleteVersion($versionsFileview, $version['path'].'.v'.$version['version']);
788 788
 				\OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED));
789
-				\OCP\Util::writeLog('files_versions', 'running out of space! Delete oldest version: ' . $version['path'].'.v'.$version['version'] , \OCP\Util::INFO);
789
+				\OCP\Util::writeLog('files_versions', 'running out of space! Delete oldest version: '.$version['path'].'.v'.$version['version'], \OCP\Util::INFO);
790 790
 				$versionsSize -= $version['size'];
791 791
 				$availableSpace += $version['size'];
792 792
 				next($allVersions);
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
 		$dirParts = explode('/', $dirname);
813 813
 		$dir = "/files_versions";
814 814
 		foreach ($dirParts as $part) {
815
-			$dir = $dir . '/' . $part;
815
+			$dir = $dir.'/'.$part;
816 816
 			if (!$view->file_exists($dir)) {
817 817
 				$view->mkdir($dir);
818 818
 			}
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 	 * Static workaround
824 824
 	 * @return Expiration
825 825
 	 */
826
-	protected static function getExpiration(){
826
+	protected static function getExpiration() {
827 827
 		if (is_null(self::$application)) {
828 828
 			self::$application = new Application();
829 829
 		}
Please login to merge, or discard this patch.
apps/files_versions/lib/Controller/PreviewController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@
 block discarded – undo
78 78
 		$y = 44,
79 79
 		$version = ''
80 80
 	) {
81
-		if($file === '' || $version === '' || $x === 0 || $y === 0) {
81
+		if ($file === '' || $version === '' || $x === 0 || $y === 0) {
82 82
 			return new DataResponse([], Http::STATUS_BAD_REQUEST);
83 83
 		}
84 84
 
Please login to merge, or discard this patch.
apps/files_versions/lib/Command/ExpireVersions.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@
 block discarded – undo
115 115
 		\OC_Util::setupFS($user);
116 116
 
117 117
 		// Check if this user has a version directory
118
-		$view = new \OC\Files\View('/' . $user);
118
+		$view = new \OC\Files\View('/'.$user);
119 119
 		if (!$view->is_dir('/files_versions')) {
120 120
 			return false;
121 121
 		}
Please login to merge, or discard this patch.
apps/files_versions/lib/Command/CleanUp.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -107,8 +107,8 @@
 block discarded – undo
107 107
 	protected function deleteVersions($user) {
108 108
 		\OC_Util::tearDownFS();
109 109
 		\OC_Util::setupFS($user);
110
-		if ($this->rootFolder->nodeExists('/' . $user . '/files_versions')) {
111
-			$this->rootFolder->get('/' . $user . '/files_versions')->delete();
110
+		if ($this->rootFolder->nodeExists('/'.$user.'/files_versions')) {
111
+			$this->rootFolder->get('/'.$user.'/files_versions')->delete();
112 112
 		}
113 113
 	}
114 114
 
Please login to merge, or discard this patch.
apps/files_versions/lib/BackgroundJob/ExpireVersions.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@
 block discarded – undo
86 86
 		\OC_Util::setupFS($user);
87 87
 
88 88
 		// Check if this user has a versions directory
89
-		$view = new \OC\Files\View('/' . $user);
89
+		$view = new \OC\Files\View('/'.$user);
90 90
 		if (!$view->is_dir('/files_versions')) {
91 91
 			return false;
92 92
 		}
Please login to merge, or discard this patch.