Passed
Push — master ( 61a02b...010b07 )
by Roeland
19:08 queued 08:59
created
apps/files/lib/Helper.php 1 patch
Indentation   +208 added lines, -208 removed lines patch added patch discarded remove patch
@@ -39,232 +39,232 @@
 block discarded – undo
39 39
  * Helper class for manipulating file information
40 40
  */
41 41
 class Helper {
42
-	/**
43
-	 * @param string $dir
44
-	 * @return array
45
-	 * @throws \OCP\Files\NotFoundException
46
-	 */
47
-	public static function buildFileStorageStatistics($dir) {
48
-		// information about storage capacities
49
-		$storageInfo = \OC_Helper::getStorageInfo($dir);
50
-		$l = \OC::$server->getL10N('files');
51
-		$maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']);
52
-		$maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize);
53
-		$maxHumanFileSize = $l->t('Upload (max. %s)', array($maxHumanFileSize));
42
+    /**
43
+     * @param string $dir
44
+     * @return array
45
+     * @throws \OCP\Files\NotFoundException
46
+     */
47
+    public static function buildFileStorageStatistics($dir) {
48
+        // information about storage capacities
49
+        $storageInfo = \OC_Helper::getStorageInfo($dir);
50
+        $l = \OC::$server->getL10N('files');
51
+        $maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']);
52
+        $maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize);
53
+        $maxHumanFileSize = $l->t('Upload (max. %s)', array($maxHumanFileSize));
54 54
 
55
-		return [
56
-			'uploadMaxFilesize' => $maxUploadFileSize,
57
-			'maxHumanFilesize'  => $maxHumanFileSize,
58
-			'freeSpace' => $storageInfo['free'],
59
-			'quota' => $storageInfo['quota'],
60
-			'used' => $storageInfo['used'],
61
-			'usedSpacePercent'  => (int)$storageInfo['relative'],
62
-			'owner' => $storageInfo['owner'],
63
-			'ownerDisplayName' => $storageInfo['ownerDisplayName'],
64
-		];
65
-	}
55
+        return [
56
+            'uploadMaxFilesize' => $maxUploadFileSize,
57
+            'maxHumanFilesize'  => $maxHumanFileSize,
58
+            'freeSpace' => $storageInfo['free'],
59
+            'quota' => $storageInfo['quota'],
60
+            'used' => $storageInfo['used'],
61
+            'usedSpacePercent'  => (int)$storageInfo['relative'],
62
+            'owner' => $storageInfo['owner'],
63
+            'ownerDisplayName' => $storageInfo['ownerDisplayName'],
64
+        ];
65
+    }
66 66
 
67
-	/**
68
-	 * Determine icon for a given file
69
-	 *
70
-	 * @param \OCP\Files\FileInfo $file file info
71
-	 * @return string icon URL
72
-	 */
73
-	public static function determineIcon($file) {
74
-		if($file['type'] === 'dir') {
75
-			$icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon('dir');
76
-			// TODO: move this part to the client side, using mountType
77
-			if ($file->isShared()) {
78
-				$icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon('dir-shared');
79
-			} elseif ($file->isMounted()) {
80
-				$icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon('dir-external');
81
-			}
82
-		}else{
83
-			$icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon($file->getMimetype());
84
-		}
67
+    /**
68
+     * Determine icon for a given file
69
+     *
70
+     * @param \OCP\Files\FileInfo $file file info
71
+     * @return string icon URL
72
+     */
73
+    public static function determineIcon($file) {
74
+        if($file['type'] === 'dir') {
75
+            $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon('dir');
76
+            // TODO: move this part to the client side, using mountType
77
+            if ($file->isShared()) {
78
+                $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon('dir-shared');
79
+            } elseif ($file->isMounted()) {
80
+                $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon('dir-external');
81
+            }
82
+        }else{
83
+            $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon($file->getMimetype());
84
+        }
85 85
 
86
-		return substr($icon, 0, -3) . 'svg';
87
-	}
86
+        return substr($icon, 0, -3) . 'svg';
87
+    }
88 88
 
89
-	/**
90
-	 * Comparator function to sort files alphabetically and have
91
-	 * the directories appear first
92
-	 *
93
-	 * @param \OCP\Files\FileInfo $a file
94
-	 * @param \OCP\Files\FileInfo $b file
95
-	 * @return int -1 if $a must come before $b, 1 otherwise
96
-	 */
97
-	public static function compareFileNames(FileInfo $a, FileInfo $b) {
98
-		$aType = $a->getType();
99
-		$bType = $b->getType();
100
-		if ($aType === 'dir' and $bType !== 'dir') {
101
-			return -1;
102
-		} elseif ($aType !== 'dir' and $bType === 'dir') {
103
-			return 1;
104
-		} else {
105
-			return \OCP\Util::naturalSortCompare($a->getName(), $b->getName());
106
-		}
107
-	}
89
+    /**
90
+     * Comparator function to sort files alphabetically and have
91
+     * the directories appear first
92
+     *
93
+     * @param \OCP\Files\FileInfo $a file
94
+     * @param \OCP\Files\FileInfo $b file
95
+     * @return int -1 if $a must come before $b, 1 otherwise
96
+     */
97
+    public static function compareFileNames(FileInfo $a, FileInfo $b) {
98
+        $aType = $a->getType();
99
+        $bType = $b->getType();
100
+        if ($aType === 'dir' and $bType !== 'dir') {
101
+            return -1;
102
+        } elseif ($aType !== 'dir' and $bType === 'dir') {
103
+            return 1;
104
+        } else {
105
+            return \OCP\Util::naturalSortCompare($a->getName(), $b->getName());
106
+        }
107
+    }
108 108
 
109
-	/**
110
-	 * Comparator function to sort files by date
111
-	 *
112
-	 * @param \OCP\Files\FileInfo $a file
113
-	 * @param \OCP\Files\FileInfo $b file
114
-	 * @return int -1 if $a must come before $b, 1 otherwise
115
-	 */
116
-	public static function compareTimestamp(FileInfo $a, FileInfo $b) {
117
-		$aTime = $a->getMTime();
118
-		$bTime = $b->getMTime();
119
-		return ($aTime < $bTime) ? -1 : 1;
120
-	}
109
+    /**
110
+     * Comparator function to sort files by date
111
+     *
112
+     * @param \OCP\Files\FileInfo $a file
113
+     * @param \OCP\Files\FileInfo $b file
114
+     * @return int -1 if $a must come before $b, 1 otherwise
115
+     */
116
+    public static function compareTimestamp(FileInfo $a, FileInfo $b) {
117
+        $aTime = $a->getMTime();
118
+        $bTime = $b->getMTime();
119
+        return ($aTime < $bTime) ? -1 : 1;
120
+    }
121 121
 
122
-	/**
123
-	 * Comparator function to sort files by size
124
-	 *
125
-	 * @param \OCP\Files\FileInfo $a file
126
-	 * @param \OCP\Files\FileInfo $b file
127
-	 * @return int -1 if $a must come before $b, 1 otherwise
128
-	 */
129
-	public static function compareSize(FileInfo $a, FileInfo $b) {
130
-		$aSize = $a->getSize();
131
-		$bSize = $b->getSize();
132
-		return ($aSize < $bSize) ? -1 : 1;
133
-	}
122
+    /**
123
+     * Comparator function to sort files by size
124
+     *
125
+     * @param \OCP\Files\FileInfo $a file
126
+     * @param \OCP\Files\FileInfo $b file
127
+     * @return int -1 if $a must come before $b, 1 otherwise
128
+     */
129
+    public static function compareSize(FileInfo $a, FileInfo $b) {
130
+        $aSize = $a->getSize();
131
+        $bSize = $b->getSize();
132
+        return ($aSize < $bSize) ? -1 : 1;
133
+    }
134 134
 
135
-	/**
136
-	 * Formats the file info to be returned as JSON to the client.
137
-	 *
138
-	 * @param \OCP\Files\FileInfo $i
139
-	 * @return array formatted file info
140
-	 */
141
-	public static function formatFileInfo(FileInfo $i) {
142
-		$entry = array();
135
+    /**
136
+     * Formats the file info to be returned as JSON to the client.
137
+     *
138
+     * @param \OCP\Files\FileInfo $i
139
+     * @return array formatted file info
140
+     */
141
+    public static function formatFileInfo(FileInfo $i) {
142
+        $entry = array();
143 143
 
144
-		$entry['id'] = $i['fileid'];
145
-		$entry['parentId'] = $i['parent'];
146
-		$entry['mtime'] = $i['mtime'] * 1000;
147
-		// only pick out the needed attributes
148
-		$entry['name'] = $i->getName();
149
-		$entry['permissions'] = $i['permissions'];
150
-		$entry['mimetype'] = $i['mimetype'];
151
-		$entry['size'] = $i['size'];
152
-		$entry['type'] = $i['type'];
153
-		$entry['etag'] = $i['etag'];
154
-		if (isset($i['tags'])) {
155
-			$entry['tags'] = $i['tags'];
156
-		}
157
-		if (isset($i['displayname_owner'])) {
158
-			$entry['shareOwner'] = $i['displayname_owner'];
159
-		}
160
-		if (isset($i['is_share_mount_point'])) {
161
-			$entry['isShareMountPoint'] = $i['is_share_mount_point'];
162
-		}
163
-		$mountType = null;
164
-		$mount = $i->getMountPoint();
165
-		$mountType = $mount->getMountType();
166
-		if ($mountType !== '') {
167
-			if ($i->getInternalPath() === '') {
168
-				$mountType .= '-root';
169
-			}
170
-			$entry['mountType'] = $mountType;
171
-		}
172
-		if (isset($i['extraData'])) {
173
-			$entry['extraData'] = $i['extraData'];
174
-		}
175
-		return $entry;
176
-	}
144
+        $entry['id'] = $i['fileid'];
145
+        $entry['parentId'] = $i['parent'];
146
+        $entry['mtime'] = $i['mtime'] * 1000;
147
+        // only pick out the needed attributes
148
+        $entry['name'] = $i->getName();
149
+        $entry['permissions'] = $i['permissions'];
150
+        $entry['mimetype'] = $i['mimetype'];
151
+        $entry['size'] = $i['size'];
152
+        $entry['type'] = $i['type'];
153
+        $entry['etag'] = $i['etag'];
154
+        if (isset($i['tags'])) {
155
+            $entry['tags'] = $i['tags'];
156
+        }
157
+        if (isset($i['displayname_owner'])) {
158
+            $entry['shareOwner'] = $i['displayname_owner'];
159
+        }
160
+        if (isset($i['is_share_mount_point'])) {
161
+            $entry['isShareMountPoint'] = $i['is_share_mount_point'];
162
+        }
163
+        $mountType = null;
164
+        $mount = $i->getMountPoint();
165
+        $mountType = $mount->getMountType();
166
+        if ($mountType !== '') {
167
+            if ($i->getInternalPath() === '') {
168
+                $mountType .= '-root';
169
+            }
170
+            $entry['mountType'] = $mountType;
171
+        }
172
+        if (isset($i['extraData'])) {
173
+            $entry['extraData'] = $i['extraData'];
174
+        }
175
+        return $entry;
176
+    }
177 177
 
178
-	/**
179
-	 * Format file info for JSON
180
-	 * @param \OCP\Files\FileInfo[] $fileInfos file infos
181
-	 * @return array
182
-	 */
183
-	public static function formatFileInfos($fileInfos) {
184
-		$files = array();
185
-		foreach ($fileInfos as $i) {
186
-			$files[] = self::formatFileInfo($i);
187
-		}
178
+    /**
179
+     * Format file info for JSON
180
+     * @param \OCP\Files\FileInfo[] $fileInfos file infos
181
+     * @return array
182
+     */
183
+    public static function formatFileInfos($fileInfos) {
184
+        $files = array();
185
+        foreach ($fileInfos as $i) {
186
+            $files[] = self::formatFileInfo($i);
187
+        }
188 188
 
189
-		return $files;
190
-	}
189
+        return $files;
190
+    }
191 191
 
192
-	/**
193
-	 * Retrieves the contents of the given directory and
194
-	 * returns it as a sorted array of FileInfo.
195
-	 *
196
-	 * @param string $dir path to the directory
197
-	 * @param string $sortAttribute attribute to sort on
198
-	 * @param bool $sortDescending true for descending sort, false otherwise
199
-	 * @param string $mimetypeFilter limit returned content to this mimetype or mimepart
200
-	 * @return \OCP\Files\FileInfo[] files
201
-	 */
202
-	public static function getFiles($dir, $sortAttribute = 'name', $sortDescending = false, $mimetypeFilter = '') {
203
-		$content = \OC\Files\Filesystem::getDirectoryContent($dir, $mimetypeFilter);
192
+    /**
193
+     * Retrieves the contents of the given directory and
194
+     * returns it as a sorted array of FileInfo.
195
+     *
196
+     * @param string $dir path to the directory
197
+     * @param string $sortAttribute attribute to sort on
198
+     * @param bool $sortDescending true for descending sort, false otherwise
199
+     * @param string $mimetypeFilter limit returned content to this mimetype or mimepart
200
+     * @return \OCP\Files\FileInfo[] files
201
+     */
202
+    public static function getFiles($dir, $sortAttribute = 'name', $sortDescending = false, $mimetypeFilter = '') {
203
+        $content = \OC\Files\Filesystem::getDirectoryContent($dir, $mimetypeFilter);
204 204
 
205
-		return self::sortFiles($content, $sortAttribute, $sortDescending);
206
-	}
205
+        return self::sortFiles($content, $sortAttribute, $sortDescending);
206
+    }
207 207
 
208
-	/**
209
-	 * Populate the result set with file tags
210
-	 *
211
-	 * @param array $fileList
212
-	 * @param string $fileIdentifier identifier attribute name for values in $fileList
213
-	 * @param ITagManager $tagManager
214
-	 * @return array file list populated with tags
215
-	 */
216
-	public static function populateTags(array $fileList, $fileIdentifier = 'fileid', ITagManager $tagManager) {
217
-		$ids = [];
218
-		foreach ($fileList as $fileData) {
219
-			$ids[] = $fileData[$fileIdentifier];
220
-		}
221
-		$tagger = $tagManager->load('files');
222
-		$tags = $tagger->getTagsForObjects($ids);
208
+    /**
209
+     * Populate the result set with file tags
210
+     *
211
+     * @param array $fileList
212
+     * @param string $fileIdentifier identifier attribute name for values in $fileList
213
+     * @param ITagManager $tagManager
214
+     * @return array file list populated with tags
215
+     */
216
+    public static function populateTags(array $fileList, $fileIdentifier = 'fileid', ITagManager $tagManager) {
217
+        $ids = [];
218
+        foreach ($fileList as $fileData) {
219
+            $ids[] = $fileData[$fileIdentifier];
220
+        }
221
+        $tagger = $tagManager->load('files');
222
+        $tags = $tagger->getTagsForObjects($ids);
223 223
 
224
-		if (!is_array($tags)) {
225
-			throw new \UnexpectedValueException('$tags must be an array');
226
-		}
224
+        if (!is_array($tags)) {
225
+            throw new \UnexpectedValueException('$tags must be an array');
226
+        }
227 227
 
228
-		// Set empty tag array
229
-		foreach ($fileList as $key => $fileData) {
230
-			$fileList[$key]['tags'] = [];
231
-		}
228
+        // Set empty tag array
229
+        foreach ($fileList as $key => $fileData) {
230
+            $fileList[$key]['tags'] = [];
231
+        }
232 232
 
233
-		if (!empty($tags)) {
234
-			foreach ($tags as $fileId => $fileTags) {
233
+        if (!empty($tags)) {
234
+            foreach ($tags as $fileId => $fileTags) {
235 235
 
236
-				foreach ($fileList as $key => $fileData) {
237
-					if ($fileId !== $fileData[$fileIdentifier]) {
238
-						continue;
239
-					}
236
+                foreach ($fileList as $key => $fileData) {
237
+                    if ($fileId !== $fileData[$fileIdentifier]) {
238
+                        continue;
239
+                    }
240 240
 
241
-					$fileList[$key]['tags'] = $fileTags;
242
-				}
243
-			}
244
-		}
241
+                    $fileList[$key]['tags'] = $fileTags;
242
+                }
243
+            }
244
+        }
245 245
 
246
-		return $fileList;
247
-	}
246
+        return $fileList;
247
+    }
248 248
 
249
-	/**
250
-	 * Sort the given file info array
251
-	 *
252
-	 * @param \OCP\Files\FileInfo[] $files files to sort
253
-	 * @param string $sortAttribute attribute to sort on
254
-	 * @param bool $sortDescending true for descending sort, false otherwise
255
-	 * @return \OCP\Files\FileInfo[] sorted files
256
-	 */
257
-	public static function sortFiles($files, $sortAttribute = 'name', $sortDescending = false) {
258
-		$sortFunc = 'compareFileNames';
259
-		if ($sortAttribute === 'mtime') {
260
-			$sortFunc = 'compareTimestamp';
261
-		} else if ($sortAttribute === 'size') {
262
-			$sortFunc = 'compareSize';
263
-		}
264
-		usort($files, array(Helper::class, $sortFunc));
265
-		if ($sortDescending) {
266
-			$files = array_reverse($files);
267
-		}
268
-		return $files;
269
-	}
249
+    /**
250
+     * Sort the given file info array
251
+     *
252
+     * @param \OCP\Files\FileInfo[] $files files to sort
253
+     * @param string $sortAttribute attribute to sort on
254
+     * @param bool $sortDescending true for descending sort, false otherwise
255
+     * @return \OCP\Files\FileInfo[] sorted files
256
+     */
257
+    public static function sortFiles($files, $sortAttribute = 'name', $sortDescending = false) {
258
+        $sortFunc = 'compareFileNames';
259
+        if ($sortAttribute === 'mtime') {
260
+            $sortFunc = 'compareTimestamp';
261
+        } else if ($sortAttribute === 'size') {
262
+            $sortFunc = 'compareSize';
263
+        }
264
+        usort($files, array(Helper::class, $sortFunc));
265
+        if ($sortDescending) {
266
+            $files = array_reverse($files);
267
+        }
268
+        return $files;
269
+    }
270 270
 }
Please login to merge, or discard this patch.
apps/files_external/appinfo/app.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,14 +37,14 @@
 block discarded – undo
37 37
 $appContainer = \OC_Mount_Config::$app->getContainer();
38 38
 
39 39
 \OCA\Files\App::getNavigationManager()->add(function () {
40
-	$l = \OC::$server->getL10N('files_external');
41
-	return [
42
-		'id' => 'extstoragemounts',
43
-		'appname' => 'files_external',
44
-		'script' => 'list.php',
45
-		'order' => 30,
46
-		'name' => $l->t('External storages'),
47
-	];
40
+    $l = \OC::$server->getL10N('files_external');
41
+    return [
42
+        'id' => 'extstoragemounts',
43
+        'appname' => 'files_external',
44
+        'script' => 'list.php',
45
+        'order' => 30,
46
+        'name' => $l->t('External storages'),
47
+    ];
48 48
 });
49 49
 
50 50
 $mountProvider = $appContainer->query(ConfigAdapter::class);
Please login to merge, or discard this patch.
apps/federation/lib/AppInfo/Application.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -36,48 +36,48 @@
 block discarded – undo
36 36
 
37 37
 class Application extends App {
38 38
 
39
-	/**
40
-	 * @param array $urlParams
41
-	 */
42
-	public function __construct($urlParams = []) {
43
-		parent::__construct('federation', $urlParams);
44
-		$this->registerMiddleware();
45
-	}
39
+    /**
40
+     * @param array $urlParams
41
+     */
42
+    public function __construct($urlParams = []) {
43
+        parent::__construct('federation', $urlParams);
44
+        $this->registerMiddleware();
45
+    }
46 46
 
47
-	private function registerMiddleware() {
48
-		$container = $this->getContainer();
49
-		$container->registerAlias('AddServerMiddleware', AddServerMiddleware::class);
50
-		$container->registerMiddleWare('AddServerMiddleware');
51
-	}
47
+    private function registerMiddleware() {
48
+        $container = $this->getContainer();
49
+        $container->registerAlias('AddServerMiddleware', AddServerMiddleware::class);
50
+        $container->registerMiddleWare('AddServerMiddleware');
51
+    }
52 52
 
53
-	/**
54
-	 * listen to federated_share_added hooks to auto-add new servers to the
55
-	 * list of trusted servers.
56
-	 */
57
-	public function registerHooks() {
53
+    /**
54
+     * listen to federated_share_added hooks to auto-add new servers to the
55
+     * list of trusted servers.
56
+     */
57
+    public function registerHooks() {
58 58
 
59
-		$container = $this->getContainer();
60
-		$hooksManager = $container->query(Hooks::class);
59
+        $container = $this->getContainer();
60
+        $hooksManager = $container->query(Hooks::class);
61 61
 
62
-		Util::connectHook(
63
-				Share::class,
64
-				'federated_share_added',
65
-				$hooksManager,
66
-				'addServerHook'
67
-		);
62
+        Util::connectHook(
63
+                Share::class,
64
+                'federated_share_added',
65
+                $hooksManager,
66
+                'addServerHook'
67
+        );
68 68
 
69
-		$dispatcher = $container->getServer()->getEventDispatcher();
70
-		$dispatcher->addListener('OCA\DAV\Connector\Sabre::authInit', function($event) use($container) {
71
-			if ($event instanceof SabrePluginEvent) {
72
-				$server = $event->getServer();
73
-				if ($server instanceof Server) {
74
-					$authPlugin = $server->getPlugin('auth');
75
-					if ($authPlugin instanceof Plugin) {
76
-						$authPlugin->addBackend($container->query(FedAuth::class));
77
-					}
78
-				}
79
-			}
80
-		});
81
-	}
69
+        $dispatcher = $container->getServer()->getEventDispatcher();
70
+        $dispatcher->addListener('OCA\DAV\Connector\Sabre::authInit', function($event) use($container) {
71
+            if ($event instanceof SabrePluginEvent) {
72
+                $server = $event->getServer();
73
+                if ($server instanceof Server) {
74
+                    $authPlugin = $server->getPlugin('auth');
75
+                    if ($authPlugin instanceof Plugin) {
76
+                        $authPlugin->addBackend($container->query(FedAuth::class));
77
+                    }
78
+                }
79
+            }
80
+        });
81
+    }
82 82
 
83 83
 }
Please login to merge, or discard this patch.
lib/private/Authentication/Token/DefaultTokenCleanupJob.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@
 block discarded – undo
27 27
 
28 28
 class DefaultTokenCleanupJob extends Job {
29 29
 
30
-	protected function run($argument) {
31
-		/* @var $provider IProvider */
32
-		$provider = OC::$server->query(IProvider::class);
33
-		$provider->invalidateOldTokens();
34
-	}
30
+    protected function run($argument) {
31
+        /* @var $provider IProvider */
32
+        $provider = OC::$server->query(IProvider::class);
33
+        $provider->invalidateOldTokens();
34
+    }
35 35
 
36 36
 }
Please login to merge, or discard this patch.
lib/private/Tagging/TagMapper.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -33,47 +33,47 @@
 block discarded – undo
33 33
  */
34 34
 class TagMapper extends Mapper {
35 35
 
36
-	/**
37
-	* Constructor.
38
-	*
39
-	* @param IDBConnection $db Instance of the Db abstraction layer.
40
-	*/
41
-	public function __construct(IDBConnection $db) {
42
-		parent::__construct($db, 'vcategory', Tag::class);
43
-	}
36
+    /**
37
+     * Constructor.
38
+     *
39
+     * @param IDBConnection $db Instance of the Db abstraction layer.
40
+     */
41
+    public function __construct(IDBConnection $db) {
42
+        parent::__construct($db, 'vcategory', Tag::class);
43
+    }
44 44
 
45
-	/**
46
-	* Load tags from the database.
47
-	*
48
-	* @param array|string $owners The user(s) whose tags we are going to load.
49
-	* @param string $type The type of item for which we are loading tags.
50
-	* @return array An array of Tag objects.
51
-	*/
52
-	public function loadTags($owners, $type) {
53
-		if(!is_array($owners)) {
54
-			$owners = array($owners);
55
-		}
45
+    /**
46
+     * Load tags from the database.
47
+     *
48
+     * @param array|string $owners The user(s) whose tags we are going to load.
49
+     * @param string $type The type of item for which we are loading tags.
50
+     * @return array An array of Tag objects.
51
+     */
52
+    public function loadTags($owners, $type) {
53
+        if(!is_array($owners)) {
54
+            $owners = array($owners);
55
+        }
56 56
 
57
-		$sql = 'SELECT `id`, `uid`, `type`, `category` FROM `' . $this->getTableName() . '` '
58
-			. 'WHERE `uid` IN (' . str_repeat('?,', count($owners)-1) . '?) AND `type` = ? ORDER BY `category`';
59
-		return $this->findEntities($sql, array_merge($owners, array($type)));
60
-	}
57
+        $sql = 'SELECT `id`, `uid`, `type`, `category` FROM `' . $this->getTableName() . '` '
58
+            . 'WHERE `uid` IN (' . str_repeat('?,', count($owners)-1) . '?) AND `type` = ? ORDER BY `category`';
59
+        return $this->findEntities($sql, array_merge($owners, array($type)));
60
+    }
61 61
 
62
-	/**
63
-	* Check if a given Tag object already exists in the database.
64
-	*
65
-	* @param Tag $tag The tag to look for in the database.
66
-	* @return bool
67
-	*/
68
-	public function tagExists($tag) {
69
-		$sql = 'SELECT `id`, `uid`, `type`, `category` FROM `' . $this->getTableName() . '` '
70
-			. 'WHERE `uid` = ? AND `type` = ? AND `category` = ?';
71
-		try {
72
-			$this->findEntity($sql, array($tag->getOwner(), $tag->getType(), $tag->getName()));
73
-		} catch (DoesNotExistException $e) {
74
-			return false;
75
-		}
76
-		return true;
77
-	}
62
+    /**
63
+     * Check if a given Tag object already exists in the database.
64
+     *
65
+     * @param Tag $tag The tag to look for in the database.
66
+     * @return bool
67
+     */
68
+    public function tagExists($tag) {
69
+        $sql = 'SELECT `id`, `uid`, `type`, `category` FROM `' . $this->getTableName() . '` '
70
+            . 'WHERE `uid` = ? AND `type` = ? AND `category` = ?';
71
+        try {
72
+            $this->findEntity($sql, array($tag->getOwner(), $tag->getType(), $tag->getName()));
73
+        } catch (DoesNotExistException $e) {
74
+            return false;
75
+        }
76
+        return true;
77
+    }
78 78
 }
79 79
 
Please login to merge, or discard this patch.
lib/private/Command/CronBus.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -28,51 +28,51 @@
 block discarded – undo
28 28
 use SuperClosure\Serializer;
29 29
 
30 30
 class CronBus extends AsyncBus {
31
-	/**
32
-	 * @var \OCP\BackgroundJob\IJobList
33
-	 */
34
-	private $jobList;
31
+    /**
32
+     * @var \OCP\BackgroundJob\IJobList
33
+     */
34
+    private $jobList;
35 35
 
36 36
 
37
-	/**
38
-	 * @param \OCP\BackgroundJob\IJobList $jobList
39
-	 */
40
-	public function __construct($jobList) {
41
-		$this->jobList = $jobList;
42
-	}
37
+    /**
38
+     * @param \OCP\BackgroundJob\IJobList $jobList
39
+     */
40
+    public function __construct($jobList) {
41
+        $this->jobList = $jobList;
42
+    }
43 43
 
44
-	protected function queueCommand($command) {
45
-		$this->jobList->add($this->getJobClass($command), $this->serializeCommand($command));
46
-	}
44
+    protected function queueCommand($command) {
45
+        $this->jobList->add($this->getJobClass($command), $this->serializeCommand($command));
46
+    }
47 47
 
48
-	/**
49
-	 * @param \OCP\Command\ICommand | callable $command
50
-	 * @return string
51
-	 */
52
-	private function getJobClass($command) {
53
-		if ($command instanceof \Closure) {
54
-			return ClosureJob::class;
55
-		} else if (is_callable($command)) {
56
-			return CallableJob::class;
57
-		} else if ($command instanceof ICommand) {
58
-			return CommandJob::class;
59
-		} else {
60
-			throw new \InvalidArgumentException('Invalid command');
61
-		}
62
-	}
48
+    /**
49
+     * @param \OCP\Command\ICommand | callable $command
50
+     * @return string
51
+     */
52
+    private function getJobClass($command) {
53
+        if ($command instanceof \Closure) {
54
+            return ClosureJob::class;
55
+        } else if (is_callable($command)) {
56
+            return CallableJob::class;
57
+        } else if ($command instanceof ICommand) {
58
+            return CommandJob::class;
59
+        } else {
60
+            throw new \InvalidArgumentException('Invalid command');
61
+        }
62
+    }
63 63
 
64
-	/**
65
-	 * @param \OCP\Command\ICommand | callable $command
66
-	 * @return string
67
-	 */
68
-	private function serializeCommand($command) {
69
-		if ($command instanceof \Closure) {
70
-			$serializer = new Serializer();
71
-			return $serializer->serialize($command);
72
-		} else if (is_callable($command) or $command instanceof ICommand) {
73
-			return serialize($command);
74
-		} else {
75
-			throw new \InvalidArgumentException('Invalid command');
76
-		}
77
-	}
64
+    /**
65
+     * @param \OCP\Command\ICommand | callable $command
66
+     * @return string
67
+     */
68
+    private function serializeCommand($command) {
69
+        if ($command instanceof \Closure) {
70
+            $serializer = new Serializer();
71
+            return $serializer->serialize($command);
72
+        } else if (is_callable($command) or $command instanceof ICommand) {
73
+            return serialize($command);
74
+        } else {
75
+            throw new \InvalidArgumentException('Invalid command');
76
+        }
77
+    }
78 78
 }
Please login to merge, or discard this patch.
apps/dav/lib/CardDAV/Converter.php 1 patch
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -31,122 +31,122 @@
 block discarded – undo
31 31
 
32 32
 class Converter {
33 33
 
34
-	/** @var AccountManager */
35
-	private $accountManager;
36
-
37
-	/**
38
-	 * Converter constructor.
39
-	 *
40
-	 * @param AccountManager $accountManager
41
-	 */
42
-	public function __construct(AccountManager $accountManager) {
43
-		$this->accountManager = $accountManager;
44
-	}
45
-
46
-	/**
47
-	 * @param IUser $user
48
-	 * @return VCard|null
49
-	 */
50
-	public function createCardFromUser(IUser $user) {
51
-
52
-		$userData = $this->accountManager->getUser($user);
53
-
54
-		$uid = $user->getUID();
55
-		$cloudId = $user->getCloudId();
56
-		$image = $this->getAvatarImage($user);
57
-
58
-		$vCard = new VCard();
59
-		$vCard->VERSION = '3.0';
60
-		$vCard->UID = $uid;
61
-
62
-		$publish = false;
63
-
64
-		if ($image !== null && isset($userData[AccountManager::PROPERTY_AVATAR])) {
65
-			$userData[AccountManager::PROPERTY_AVATAR]['value'] = true;
66
-		}
67
-
68
-		foreach ($userData as $property => $value) {
69
-
70
-			$shareWithTrustedServers =
71
-				$value['scope'] === AccountManager::VISIBILITY_CONTACTS_ONLY ||
72
-				$value['scope'] === AccountManager::VISIBILITY_PUBLIC;
73
-
74
-			$emptyValue = !isset($value['value']) || $value['value'] === '';
75
-
76
-			if ($shareWithTrustedServers && !$emptyValue) {
77
-				$publish = true;
78
-				switch ($property) {
79
-					case AccountManager::PROPERTY_DISPLAYNAME:
80
-						$vCard->add(new Text($vCard, 'FN', $value['value']));
81
-						$vCard->add(new Text($vCard, 'N', $this->splitFullName($value['value'])));
82
-						break;
83
-					case AccountManager::PROPERTY_AVATAR:
84
-						if ($image !== null) {
85
-							$vCard->add('PHOTO', $image->data(), ['ENCODING' => 'b', 'TYPE' => $image->mimeType()]);
86
-						}
87
-						break;
88
-					case AccountManager::PROPERTY_EMAIL:
89
-						$vCard->add(new Text($vCard, 'EMAIL', $value['value'], ['TYPE' => 'OTHER']));
90
-						break;
91
-					case AccountManager::PROPERTY_WEBSITE:
92
-						$vCard->add(new Text($vCard, 'URL', $value['value']));
93
-						break;
94
-					case AccountManager::PROPERTY_PHONE:
95
-						$vCard->add(new Text($vCard, 'TEL', $value['value'], ['TYPE' => 'OTHER']));
96
-						break;
97
-					case AccountManager::PROPERTY_ADDRESS:
98
-						$vCard->add(new Text($vCard, 'ADR', $value['value'], ['TYPE' => 'OTHER']));
99
-						break;
100
-					case AccountManager::PROPERTY_TWITTER:
101
-						$vCard->add(new Text($vCard, 'X-SOCIALPROFILE', $value['value'], ['TYPE' => 'TWITTER']));
102
-						break;
103
-				}
104
-			}
105
-		}
106
-
107
-		if ($publish && !empty($cloudId)) {
108
-			$vCard->add(new Text($vCard, 'CLOUD', $cloudId));
109
-			$vCard->validate();
110
-			return $vCard;
111
-		}
112
-
113
-		return null;
114
-	}
115
-
116
-	/**
117
-	 * @param string $fullName
118
-	 * @return string[]
119
-	 */
120
-	public function splitFullName($fullName) {
121
-		// Very basic western style parsing. I'm not gonna implement
122
-		// https://github.com/android/platform_packages_providers_contactsprovider/blob/master/src/com/android/providers/contacts/NameSplitter.java ;)
123
-
124
-		$elements = explode(' ', $fullName);
125
-		$result = ['', '', '', '', ''];
126
-		if (count($elements) > 2) {
127
-			$result[0] = implode(' ', array_slice($elements, count($elements)-1));
128
-			$result[1] = $elements[0];
129
-			$result[2] = implode(' ', array_slice($elements, 1, count($elements)-2));
130
-		} elseif (count($elements) === 2) {
131
-			$result[0] = $elements[1];
132
-			$result[1] = $elements[0];
133
-		} else {
134
-			$result[0] = $elements[0];
135
-		}
136
-
137
-		return $result;
138
-	}
139
-
140
-	/**
141
-	 * @param IUser $user
142
-	 * @return null|IImage
143
-	 */
144
-	private function getAvatarImage(IUser $user) {
145
-		try {
146
-			return $user->getAvatarImage(-1);
147
-		} catch (\Exception $ex) {
148
-			return null;
149
-		}
150
-	}
34
+    /** @var AccountManager */
35
+    private $accountManager;
36
+
37
+    /**
38
+     * Converter constructor.
39
+     *
40
+     * @param AccountManager $accountManager
41
+     */
42
+    public function __construct(AccountManager $accountManager) {
43
+        $this->accountManager = $accountManager;
44
+    }
45
+
46
+    /**
47
+     * @param IUser $user
48
+     * @return VCard|null
49
+     */
50
+    public function createCardFromUser(IUser $user) {
51
+
52
+        $userData = $this->accountManager->getUser($user);
53
+
54
+        $uid = $user->getUID();
55
+        $cloudId = $user->getCloudId();
56
+        $image = $this->getAvatarImage($user);
57
+
58
+        $vCard = new VCard();
59
+        $vCard->VERSION = '3.0';
60
+        $vCard->UID = $uid;
61
+
62
+        $publish = false;
63
+
64
+        if ($image !== null && isset($userData[AccountManager::PROPERTY_AVATAR])) {
65
+            $userData[AccountManager::PROPERTY_AVATAR]['value'] = true;
66
+        }
67
+
68
+        foreach ($userData as $property => $value) {
69
+
70
+            $shareWithTrustedServers =
71
+                $value['scope'] === AccountManager::VISIBILITY_CONTACTS_ONLY ||
72
+                $value['scope'] === AccountManager::VISIBILITY_PUBLIC;
73
+
74
+            $emptyValue = !isset($value['value']) || $value['value'] === '';
75
+
76
+            if ($shareWithTrustedServers && !$emptyValue) {
77
+                $publish = true;
78
+                switch ($property) {
79
+                    case AccountManager::PROPERTY_DISPLAYNAME:
80
+                        $vCard->add(new Text($vCard, 'FN', $value['value']));
81
+                        $vCard->add(new Text($vCard, 'N', $this->splitFullName($value['value'])));
82
+                        break;
83
+                    case AccountManager::PROPERTY_AVATAR:
84
+                        if ($image !== null) {
85
+                            $vCard->add('PHOTO', $image->data(), ['ENCODING' => 'b', 'TYPE' => $image->mimeType()]);
86
+                        }
87
+                        break;
88
+                    case AccountManager::PROPERTY_EMAIL:
89
+                        $vCard->add(new Text($vCard, 'EMAIL', $value['value'], ['TYPE' => 'OTHER']));
90
+                        break;
91
+                    case AccountManager::PROPERTY_WEBSITE:
92
+                        $vCard->add(new Text($vCard, 'URL', $value['value']));
93
+                        break;
94
+                    case AccountManager::PROPERTY_PHONE:
95
+                        $vCard->add(new Text($vCard, 'TEL', $value['value'], ['TYPE' => 'OTHER']));
96
+                        break;
97
+                    case AccountManager::PROPERTY_ADDRESS:
98
+                        $vCard->add(new Text($vCard, 'ADR', $value['value'], ['TYPE' => 'OTHER']));
99
+                        break;
100
+                    case AccountManager::PROPERTY_TWITTER:
101
+                        $vCard->add(new Text($vCard, 'X-SOCIALPROFILE', $value['value'], ['TYPE' => 'TWITTER']));
102
+                        break;
103
+                }
104
+            }
105
+        }
106
+
107
+        if ($publish && !empty($cloudId)) {
108
+            $vCard->add(new Text($vCard, 'CLOUD', $cloudId));
109
+            $vCard->validate();
110
+            return $vCard;
111
+        }
112
+
113
+        return null;
114
+    }
115
+
116
+    /**
117
+     * @param string $fullName
118
+     * @return string[]
119
+     */
120
+    public function splitFullName($fullName) {
121
+        // Very basic western style parsing. I'm not gonna implement
122
+        // https://github.com/android/platform_packages_providers_contactsprovider/blob/master/src/com/android/providers/contacts/NameSplitter.java ;)
123
+
124
+        $elements = explode(' ', $fullName);
125
+        $result = ['', '', '', '', ''];
126
+        if (count($elements) > 2) {
127
+            $result[0] = implode(' ', array_slice($elements, count($elements)-1));
128
+            $result[1] = $elements[0];
129
+            $result[2] = implode(' ', array_slice($elements, 1, count($elements)-2));
130
+        } elseif (count($elements) === 2) {
131
+            $result[0] = $elements[1];
132
+            $result[1] = $elements[0];
133
+        } else {
134
+            $result[0] = $elements[0];
135
+        }
136
+
137
+        return $result;
138
+    }
139
+
140
+    /**
141
+     * @param IUser $user
142
+     * @return null|IImage
143
+     */
144
+    private function getAvatarImage(IUser $user) {
145
+        try {
146
+            return $user->getAvatarImage(-1);
147
+        } catch (\Exception $ex) {
148
+            return null;
149
+        }
150
+    }
151 151
 
152 152
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Service/UserStoragesService.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -40,104 +40,104 @@
 block discarded – undo
40 40
  * (aka personal storages)
41 41
  */
42 42
 class UserStoragesService extends StoragesService {
43
-	use UserTrait;
43
+    use UserTrait;
44 44
 
45
-	/**
46
-	 * Create a user storages service
47
-	 *
48
-	 * @param BackendService $backendService
49
-	 * @param DBConfigService $dbConfig
50
-	 * @param IUserSession $userSession user session
51
-	 * @param IUserMountCache $userMountCache
52
-	 */
53
-	public function __construct(
54
-		BackendService $backendService,
55
-		DBConfigService $dbConfig,
56
-		IUserSession $userSession,
57
-		IUserMountCache $userMountCache
58
-	) {
59
-		$this->userSession = $userSession;
60
-		parent::__construct($backendService, $dbConfig, $userMountCache);
61
-	}
45
+    /**
46
+     * Create a user storages service
47
+     *
48
+     * @param BackendService $backendService
49
+     * @param DBConfigService $dbConfig
50
+     * @param IUserSession $userSession user session
51
+     * @param IUserMountCache $userMountCache
52
+     */
53
+    public function __construct(
54
+        BackendService $backendService,
55
+        DBConfigService $dbConfig,
56
+        IUserSession $userSession,
57
+        IUserMountCache $userMountCache
58
+    ) {
59
+        $this->userSession = $userSession;
60
+        parent::__construct($backendService, $dbConfig, $userMountCache);
61
+    }
62 62
 
63
-	protected function readDBConfig() {
64
-		return $this->dbConfig->getUserMountsFor(DBConfigService::APPLICABLE_TYPE_USER, $this->getUser()->getUID());
65
-	}
63
+    protected function readDBConfig() {
64
+        return $this->dbConfig->getUserMountsFor(DBConfigService::APPLICABLE_TYPE_USER, $this->getUser()->getUID());
65
+    }
66 66
 
67
-	/**
68
-	 * Triggers $signal for all applicable users of the given
69
-	 * storage
70
-	 *
71
-	 * @param StorageConfig $storage storage data
72
-	 * @param string $signal signal to trigger
73
-	 */
74
-	protected function triggerHooks(StorageConfig $storage, $signal) {
75
-		$user = $this->getUser()->getUID();
67
+    /**
68
+     * Triggers $signal for all applicable users of the given
69
+     * storage
70
+     *
71
+     * @param StorageConfig $storage storage data
72
+     * @param string $signal signal to trigger
73
+     */
74
+    protected function triggerHooks(StorageConfig $storage, $signal) {
75
+        $user = $this->getUser()->getUID();
76 76
 
77
-		// trigger hook for the current user
78
-		$this->triggerApplicableHooks(
79
-			$signal,
80
-			$storage->getMountPoint(),
81
-			\OC_Mount_Config::MOUNT_TYPE_USER,
82
-			[$user]
83
-		);
84
-	}
77
+        // trigger hook for the current user
78
+        $this->triggerApplicableHooks(
79
+            $signal,
80
+            $storage->getMountPoint(),
81
+            \OC_Mount_Config::MOUNT_TYPE_USER,
82
+            [$user]
83
+        );
84
+    }
85 85
 
86
-	/**
87
-	 * Triggers signal_create_mount or signal_delete_mount to
88
-	 * accommodate for additions/deletions in applicableUsers
89
-	 * and applicableGroups fields.
90
-	 *
91
-	 * @param StorageConfig $oldStorage old storage data
92
-	 * @param StorageConfig $newStorage new storage data
93
-	 */
94
-	protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $newStorage) {
95
-		// if mount point changed, it's like a deletion + creation
96
-		if ($oldStorage->getMountPoint() !== $newStorage->getMountPoint()) {
97
-			$this->triggerHooks($oldStorage, Filesystem::signal_delete_mount);
98
-			$this->triggerHooks($newStorage, Filesystem::signal_create_mount);
99
-		}
100
-	}
86
+    /**
87
+     * Triggers signal_create_mount or signal_delete_mount to
88
+     * accommodate for additions/deletions in applicableUsers
89
+     * and applicableGroups fields.
90
+     *
91
+     * @param StorageConfig $oldStorage old storage data
92
+     * @param StorageConfig $newStorage new storage data
93
+     */
94
+    protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $newStorage) {
95
+        // if mount point changed, it's like a deletion + creation
96
+        if ($oldStorage->getMountPoint() !== $newStorage->getMountPoint()) {
97
+            $this->triggerHooks($oldStorage, Filesystem::signal_delete_mount);
98
+            $this->triggerHooks($newStorage, Filesystem::signal_create_mount);
99
+        }
100
+    }
101 101
 
102
-	protected function getType() {
103
-		return DBConfigService::MOUNT_TYPE_PERSONAl;
104
-	}
102
+    protected function getType() {
103
+        return DBConfigService::MOUNT_TYPE_PERSONAl;
104
+    }
105 105
 
106
-	/**
107
-	 * Add new storage to the configuration
108
-	 *
109
-	 * @param StorageConfig $newStorage storage attributes
110
-	 *
111
-	 * @return StorageConfig storage config, with added id
112
-	 */
113
-	public function addStorage(StorageConfig $newStorage) {
114
-		$newStorage->setApplicableUsers([$this->getUser()->getUID()]);
115
-		return parent::addStorage($newStorage);
116
-	}
106
+    /**
107
+     * Add new storage to the configuration
108
+     *
109
+     * @param StorageConfig $newStorage storage attributes
110
+     *
111
+     * @return StorageConfig storage config, with added id
112
+     */
113
+    public function addStorage(StorageConfig $newStorage) {
114
+        $newStorage->setApplicableUsers([$this->getUser()->getUID()]);
115
+        return parent::addStorage($newStorage);
116
+    }
117 117
 
118
-	/**
119
-	 * Update storage to the configuration
120
-	 *
121
-	 * @param StorageConfig $updatedStorage storage attributes
122
-	 *
123
-	 * @return StorageConfig storage config
124
-	 * @throws NotFoundException if the given storage does not exist in the config
125
-	 */
126
-	public function updateStorage(StorageConfig $updatedStorage) {
127
-		$updatedStorage->setApplicableUsers([$this->getUser()->getUID()]);
128
-		return parent::updateStorage($updatedStorage);
129
-	}
118
+    /**
119
+     * Update storage to the configuration
120
+     *
121
+     * @param StorageConfig $updatedStorage storage attributes
122
+     *
123
+     * @return StorageConfig storage config
124
+     * @throws NotFoundException if the given storage does not exist in the config
125
+     */
126
+    public function updateStorage(StorageConfig $updatedStorage) {
127
+        $updatedStorage->setApplicableUsers([$this->getUser()->getUID()]);
128
+        return parent::updateStorage($updatedStorage);
129
+    }
130 130
 
131
-	/**
132
-	 * Get the visibility type for this controller, used in validation
133
-	 *
134
-	 * @return string BackendService::VISIBILITY_* constants
135
-	 */
136
-	public function getVisibilityType() {
137
-		return BackendService::VISIBILITY_PERSONAL;
138
-	}
131
+    /**
132
+     * Get the visibility type for this controller, used in validation
133
+     *
134
+     * @return string BackendService::VISIBILITY_* constants
135
+     */
136
+    public function getVisibilityType() {
137
+        return BackendService::VISIBILITY_PERSONAL;
138
+    }
139 139
 
140
-	protected function isApplicable(StorageConfig $config) {
141
-		return ($config->getApplicableUsers() === [$this->getUser()->getUID()]) && $config->getType() === StorageConfig::MOUNT_TYPE_PERSONAl;
142
-	}
140
+    protected function isApplicable(StorageConfig $config) {
141
+        return ($config->getApplicableUsers() === [$this->getUser()->getUID()]) && $config->getType() === StorageConfig::MOUNT_TYPE_PERSONAl;
142
+    }
143 143
 }
Please login to merge, or discard this patch.
apps/encryption/lib/Util.php 1 patch
Indentation   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -37,166 +37,166 @@
 block discarded – undo
37 37
 use OCP\PreConditionNotMetException;
38 38
 
39 39
 class Util {
40
-	/**
41
-	 * @var View
42
-	 */
43
-	private $files;
44
-	/**
45
-	 * @var Crypt
46
-	 */
47
-	private $crypt;
48
-	/**
49
-	 * @var ILogger
50
-	 */
51
-	private $logger;
52
-	/**
53
-	 * @var bool|IUser
54
-	 */
55
-	private $user;
56
-	/**
57
-	 * @var IConfig
58
-	 */
59
-	private $config;
60
-	/**
61
-	 * @var IUserManager
62
-	 */
63
-	private $userManager;
64
-
65
-	/**
66
-	 * Util constructor.
67
-	 *
68
-	 * @param View $files
69
-	 * @param Crypt $crypt
70
-	 * @param ILogger $logger
71
-	 * @param IUserSession $userSession
72
-	 * @param IConfig $config
73
-	 * @param IUserManager $userManager
74
-	 */
75
-	public function __construct(View $files,
76
-								Crypt $crypt,
77
-								ILogger $logger,
78
-								IUserSession $userSession,
79
-								IConfig $config,
80
-								IUserManager $userManager
81
-	) {
82
-		$this->files = $files;
83
-		$this->crypt = $crypt;
84
-		$this->logger = $logger;
85
-		$this->user = $userSession && $userSession->isLoggedIn() ? $userSession->getUser() : false;
86
-		$this->config = $config;
87
-		$this->userManager = $userManager;
88
-	}
89
-
90
-	/**
91
-	 * check if recovery key is enabled for user
92
-	 *
93
-	 * @param string $uid
94
-	 * @return bool
95
-	 */
96
-	public function isRecoveryEnabledForUser($uid) {
97
-		$recoveryMode = $this->config->getUserValue($uid,
98
-			'encryption',
99
-			'recoveryEnabled',
100
-			'0');
101
-
102
-		return ($recoveryMode === '1');
103
-	}
104
-
105
-	/**
106
-	 * check if the home storage should be encrypted
107
-	 *
108
-	 * @return bool
109
-	 */
110
-	public function shouldEncryptHomeStorage() {
111
-		$encryptHomeStorage = $this->config->getAppValue(
112
-			'encryption',
113
-			'encryptHomeStorage',
114
-			'1'
115
-		);
116
-
117
-		return ($encryptHomeStorage === '1');
118
-	}
119
-
120
-	/**
121
-	 * set the home storage encryption on/off
122
-	 *
123
-	 * @param bool $encryptHomeStorage
124
-	 */
125
-	public function setEncryptHomeStorage($encryptHomeStorage) {
126
-		$value = $encryptHomeStorage ? '1' : '0';
127
-		$this->config->setAppValue(
128
-			'encryption',
129
-			'encryptHomeStorage',
130
-			$value
131
-		);
132
-	}
133
-
134
-	/**
135
-	 * check if master key is enabled
136
-	 *
137
-	 * @return bool
138
-	 */
139
-	public function isMasterKeyEnabled() {
140
-		$userMasterKey = $this->config->getAppValue('encryption', 'useMasterKey', '1');
141
-		return ($userMasterKey === '1');
142
-	}
143
-
144
-	/**
145
-	 * @param $enabled
146
-	 * @return bool
147
-	 */
148
-	public function setRecoveryForUser($enabled) {
149
-		$value = $enabled ? '1' : '0';
150
-
151
-		try {
152
-			$this->config->setUserValue($this->user->getUID(),
153
-				'encryption',
154
-				'recoveryEnabled',
155
-				$value);
156
-			return true;
157
-		} catch (PreConditionNotMetException $e) {
158
-			return false;
159
-		}
160
-	}
161
-
162
-	/**
163
-	 * @param string $uid
164
-	 * @return bool
165
-	 */
166
-	public function userHasFiles($uid) {
167
-		return $this->files->file_exists($uid . '/files');
168
-	}
169
-
170
-	/**
171
-	 * get owner from give path, path relative to data/ expected
172
-	 *
173
-	 * @param string $path relative to data/
174
-	 * @return string
175
-	 * @throws \BadMethodCallException
176
-	 */
177
-	public function getOwner($path) {
178
-		$owner = '';
179
-		$parts = explode('/', $path, 3);
180
-		if (count($parts) > 1) {
181
-			$owner = $parts[1];
182
-			if ($this->userManager->userExists($owner) === false) {
183
-				throw new \BadMethodCallException('Unknown user: ' .
184
-				'method expects path to a user folder relative to the data folder');
185
-			}
186
-
187
-		}
188
-
189
-		return $owner;
190
-	}
191
-
192
-	/**
193
-	 * get storage of path
194
-	 *
195
-	 * @param string $path
196
-	 * @return \OC\Files\Storage\Storage
197
-	 */
198
-	public function getStorage($path) {
199
-		return $this->files->getMount($path)->getStorage();
200
-	}
40
+    /**
41
+     * @var View
42
+     */
43
+    private $files;
44
+    /**
45
+     * @var Crypt
46
+     */
47
+    private $crypt;
48
+    /**
49
+     * @var ILogger
50
+     */
51
+    private $logger;
52
+    /**
53
+     * @var bool|IUser
54
+     */
55
+    private $user;
56
+    /**
57
+     * @var IConfig
58
+     */
59
+    private $config;
60
+    /**
61
+     * @var IUserManager
62
+     */
63
+    private $userManager;
64
+
65
+    /**
66
+     * Util constructor.
67
+     *
68
+     * @param View $files
69
+     * @param Crypt $crypt
70
+     * @param ILogger $logger
71
+     * @param IUserSession $userSession
72
+     * @param IConfig $config
73
+     * @param IUserManager $userManager
74
+     */
75
+    public function __construct(View $files,
76
+                                Crypt $crypt,
77
+                                ILogger $logger,
78
+                                IUserSession $userSession,
79
+                                IConfig $config,
80
+                                IUserManager $userManager
81
+    ) {
82
+        $this->files = $files;
83
+        $this->crypt = $crypt;
84
+        $this->logger = $logger;
85
+        $this->user = $userSession && $userSession->isLoggedIn() ? $userSession->getUser() : false;
86
+        $this->config = $config;
87
+        $this->userManager = $userManager;
88
+    }
89
+
90
+    /**
91
+     * check if recovery key is enabled for user
92
+     *
93
+     * @param string $uid
94
+     * @return bool
95
+     */
96
+    public function isRecoveryEnabledForUser($uid) {
97
+        $recoveryMode = $this->config->getUserValue($uid,
98
+            'encryption',
99
+            'recoveryEnabled',
100
+            '0');
101
+
102
+        return ($recoveryMode === '1');
103
+    }
104
+
105
+    /**
106
+     * check if the home storage should be encrypted
107
+     *
108
+     * @return bool
109
+     */
110
+    public function shouldEncryptHomeStorage() {
111
+        $encryptHomeStorage = $this->config->getAppValue(
112
+            'encryption',
113
+            'encryptHomeStorage',
114
+            '1'
115
+        );
116
+
117
+        return ($encryptHomeStorage === '1');
118
+    }
119
+
120
+    /**
121
+     * set the home storage encryption on/off
122
+     *
123
+     * @param bool $encryptHomeStorage
124
+     */
125
+    public function setEncryptHomeStorage($encryptHomeStorage) {
126
+        $value = $encryptHomeStorage ? '1' : '0';
127
+        $this->config->setAppValue(
128
+            'encryption',
129
+            'encryptHomeStorage',
130
+            $value
131
+        );
132
+    }
133
+
134
+    /**
135
+     * check if master key is enabled
136
+     *
137
+     * @return bool
138
+     */
139
+    public function isMasterKeyEnabled() {
140
+        $userMasterKey = $this->config->getAppValue('encryption', 'useMasterKey', '1');
141
+        return ($userMasterKey === '1');
142
+    }
143
+
144
+    /**
145
+     * @param $enabled
146
+     * @return bool
147
+     */
148
+    public function setRecoveryForUser($enabled) {
149
+        $value = $enabled ? '1' : '0';
150
+
151
+        try {
152
+            $this->config->setUserValue($this->user->getUID(),
153
+                'encryption',
154
+                'recoveryEnabled',
155
+                $value);
156
+            return true;
157
+        } catch (PreConditionNotMetException $e) {
158
+            return false;
159
+        }
160
+    }
161
+
162
+    /**
163
+     * @param string $uid
164
+     * @return bool
165
+     */
166
+    public function userHasFiles($uid) {
167
+        return $this->files->file_exists($uid . '/files');
168
+    }
169
+
170
+    /**
171
+     * get owner from give path, path relative to data/ expected
172
+     *
173
+     * @param string $path relative to data/
174
+     * @return string
175
+     * @throws \BadMethodCallException
176
+     */
177
+    public function getOwner($path) {
178
+        $owner = '';
179
+        $parts = explode('/', $path, 3);
180
+        if (count($parts) > 1) {
181
+            $owner = $parts[1];
182
+            if ($this->userManager->userExists($owner) === false) {
183
+                throw new \BadMethodCallException('Unknown user: ' .
184
+                'method expects path to a user folder relative to the data folder');
185
+            }
186
+
187
+        }
188
+
189
+        return $owner;
190
+    }
191
+
192
+    /**
193
+     * get storage of path
194
+     *
195
+     * @param string $path
196
+     * @return \OC\Files\Storage\Storage
197
+     */
198
+    public function getStorage($path) {
199
+        return $this->files->getMount($path)->getStorage();
200
+    }
201 201
 
202 202
 }
Please login to merge, or discard this patch.