Passed
Push — master ( 07dffb...bd5189 )
by John
11:02 queued 10s
created
lib/private/Encryption/Util.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		$this->config = $config;
97 97
 
98 98
 		$this->excludedPaths[] = 'files_encryption';
99
-		$this->excludedPaths[] = 'appdata_' . $config->getSystemValue('instanceid', null);
99
+		$this->excludedPaths[] = 'appdata_'.$config->getSystemValue('instanceid', null);
100 100
 		$this->excludedPaths[] = 'files_external';
101 101
 	}
102 102
 
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
 	 * @throws EncryptionHeaderKeyExistsException if header key is already in use
137 137
 	 */
138 138
 	public function createHeader(array $headerData, IEncryptionModule $encryptionModule) {
139
-		$header = self::HEADER_START . ':' . self::HEADER_ENCRYPTION_MODULE_KEY . ':' . $encryptionModule->getId() . ':';
139
+		$header = self::HEADER_START.':'.self::HEADER_ENCRYPTION_MODULE_KEY.':'.$encryptionModule->getId().':';
140 140
 		foreach ($headerData as $key => $value) {
141 141
 			if (in_array($key, $this->ocHeaderKeys)) {
142 142
 				throw new EncryptionHeaderKeyExistsException($key);
143 143
 			}
144
-			$header .= $key . ':' . $value . ':';
144
+			$header .= $key.':'.$value.':';
145 145
 		}
146 146
 		$header .= self::HEADER_END;
147 147
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 				if ($c->getType() === 'dir') {
173 173
 					$dirList[] = $c->getPath();
174 174
 				} else {
175
-					$result[] =  $c->getPath();
175
+					$result[] = $c->getPath();
176 176
 				}
177 177
 			}
178 178
 
@@ -249,15 +249,15 @@  discard block
 block discarded – undo
249 249
 	public function stripPartialFileExtension($path) {
250 250
 		$extension = pathinfo($path, PATHINFO_EXTENSION);
251 251
 
252
-		if ( $extension === 'part') {
252
+		if ($extension === 'part') {
253 253
 
254 254
 			$newLength = strlen($path) - 5; // 5 = strlen(".part")
255 255
 			$fPath = substr($path, 0, $newLength);
256 256
 
257 257
 			// if path also contains a transaction id, we remove it too
258 258
 			$extension = pathinfo($fPath, PATHINFO_EXTENSION);
259
-			if(substr($extension, 0, 12) === 'ocTransferId') { // 12 = strlen("ocTransferId")
260
-				$newLength = strlen($fPath) - strlen($extension) -1;
259
+			if (substr($extension, 0, 12) === 'ocTransferId') { // 12 = strlen("ocTransferId")
260
+				$newLength = strlen($fPath) - strlen($extension) - 1;
261 261
 				$fPath = substr($fPath, 0, $newLength);
262 262
 			}
263 263
 			return $fPath;
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 		if (\OCP\App::isEnabled("files_external")) {
302 302
 			$mounts = \OC_Mount_Config::getSystemMountPoints();
303 303
 			foreach ($mounts as $mount) {
304
-				if (strpos($path, '/files/' . $mount['mountpoint']) === 0) {
304
+				if (strpos($path, '/files/'.$mount['mountpoint']) === 0) {
305 305
 					if ($this->isMountPointApplicableToUser($mount, $uid)) {
306 306
 						return true;
307 307
 					}
Please login to merge, or discard this patch.
Indentation   +369 added lines, -369 removed lines patch added patch discarded remove patch
@@ -39,374 +39,374 @@
 block discarded – undo
39 39
 
40 40
 class Util {
41 41
 
42
-	const HEADER_START = 'HBEGIN';
43
-	const HEADER_END = 'HEND';
44
-	const HEADER_PADDING_CHAR = '-';
45
-
46
-	const HEADER_ENCRYPTION_MODULE_KEY = 'oc_encryption_module';
47
-
48
-	/**
49
-	 * block size will always be 8192 for a PHP stream
50
-	 * @see https://bugs.php.net/bug.php?id=21641
51
-	 * @var integer
52
-	 */
53
-	protected $headerSize = 8192;
54
-
55
-	/**
56
-	 * block size will always be 8192 for a PHP stream
57
-	 * @see https://bugs.php.net/bug.php?id=21641
58
-	 * @var integer
59
-	 */
60
-	protected $blockSize = 8192;
61
-
62
-	/** @var View */
63
-	protected $rootView;
64
-
65
-	/** @var array */
66
-	protected $ocHeaderKeys;
67
-
68
-	/** @var \OC\User\Manager */
69
-	protected $userManager;
70
-
71
-	/** @var IConfig */
72
-	protected $config;
73
-
74
-	/** @var array paths excluded from encryption */
75
-	protected $excludedPaths;
76
-
77
-	/** @var \OC\Group\Manager $manager */
78
-	protected $groupManager;
79
-
80
-	/**
81
-	 *
82
-	 * @param View $rootView
83
-	 * @param \OC\User\Manager $userManager
84
-	 * @param \OC\Group\Manager $groupManager
85
-	 * @param IConfig $config
86
-	 */
87
-	public function __construct(
88
-		View $rootView,
89
-		\OC\User\Manager $userManager,
90
-		\OC\Group\Manager $groupManager,
91
-		IConfig $config) {
92
-
93
-		$this->ocHeaderKeys = [
94
-			self::HEADER_ENCRYPTION_MODULE_KEY
95
-		];
96
-
97
-		$this->rootView = $rootView;
98
-		$this->userManager = $userManager;
99
-		$this->groupManager = $groupManager;
100
-		$this->config = $config;
101
-
102
-		$this->excludedPaths[] = 'files_encryption';
103
-		$this->excludedPaths[] = 'appdata_' . $config->getSystemValue('instanceid', null);
104
-		$this->excludedPaths[] = 'files_external';
105
-	}
106
-
107
-	/**
108
-	 * read encryption module ID from header
109
-	 *
110
-	 * @param array $header
111
-	 * @return string
112
-	 * @throws ModuleDoesNotExistsException
113
-	 */
114
-	public function getEncryptionModuleId(array $header = null) {
115
-		$id = '';
116
-		$encryptionModuleKey = self::HEADER_ENCRYPTION_MODULE_KEY;
117
-
118
-		if (isset($header[$encryptionModuleKey])) {
119
-			$id = $header[$encryptionModuleKey];
120
-		} elseif (isset($header['cipher'])) {
121
-			if (class_exists('\OCA\Encryption\Crypto\Encryption')) {
122
-				// fall back to default encryption if the user migrated from
123
-				// ownCloud <= 8.0 with the old encryption
124
-				$id = \OCA\Encryption\Crypto\Encryption::ID;
125
-			} else {
126
-				throw new ModuleDoesNotExistsException('Default encryption module missing');
127
-			}
128
-		}
129
-
130
-		return $id;
131
-	}
132
-
133
-	/**
134
-	 * create header for encrypted file
135
-	 *
136
-	 * @param array $headerData
137
-	 * @param IEncryptionModule $encryptionModule
138
-	 * @return string
139
-	 * @throws EncryptionHeaderToLargeException if header has to many arguments
140
-	 * @throws EncryptionHeaderKeyExistsException if header key is already in use
141
-	 */
142
-	public function createHeader(array $headerData, IEncryptionModule $encryptionModule) {
143
-		$header = self::HEADER_START . ':' . self::HEADER_ENCRYPTION_MODULE_KEY . ':' . $encryptionModule->getId() . ':';
144
-		foreach ($headerData as $key => $value) {
145
-			if (in_array($key, $this->ocHeaderKeys)) {
146
-				throw new EncryptionHeaderKeyExistsException($key);
147
-			}
148
-			$header .= $key . ':' . $value . ':';
149
-		}
150
-		$header .= self::HEADER_END;
151
-
152
-		if (strlen($header) > $this->getHeaderSize()) {
153
-			throw new EncryptionHeaderToLargeException();
154
-		}
155
-
156
-		$paddedHeader = str_pad($header, $this->headerSize, self::HEADER_PADDING_CHAR, STR_PAD_RIGHT);
157
-
158
-		return $paddedHeader;
159
-	}
160
-
161
-	/**
162
-	 * go recursively through a dir and collect all files and sub files.
163
-	 *
164
-	 * @param string $dir relative to the users files folder
165
-	 * @return array with list of files relative to the users files folder
166
-	 */
167
-	public function getAllFiles($dir) {
168
-		$result = array();
169
-		$dirList = array($dir);
170
-
171
-		while ($dirList) {
172
-			$dir = array_pop($dirList);
173
-			$content = $this->rootView->getDirectoryContent($dir);
174
-
175
-			foreach ($content as $c) {
176
-				if ($c->getType() === 'dir') {
177
-					$dirList[] = $c->getPath();
178
-				} else {
179
-					$result[] =  $c->getPath();
180
-				}
181
-			}
182
-
183
-		}
184
-
185
-		return $result;
186
-	}
187
-
188
-	/**
189
-	 * check if it is a file uploaded by the user stored in data/user/files
190
-	 * or a metadata file
191
-	 *
192
-	 * @param string $path relative to the data/ folder
193
-	 * @return boolean
194
-	 */
195
-	public function isFile($path) {
196
-		$parts = explode('/', Filesystem::normalizePath($path), 4);
197
-		if (isset($parts[2]) && $parts[2] === 'files') {
198
-			return true;
199
-		}
200
-		return false;
201
-	}
202
-
203
-	/**
204
-	 * return size of encryption header
205
-	 *
206
-	 * @return integer
207
-	 */
208
-	public function getHeaderSize() {
209
-		return $this->headerSize;
210
-	}
211
-
212
-	/**
213
-	 * return size of block read by a PHP stream
214
-	 *
215
-	 * @return integer
216
-	 */
217
-	public function getBlockSize() {
218
-		return $this->blockSize;
219
-	}
220
-
221
-	/**
222
-	 * get the owner and the path for the file relative to the owners files folder
223
-	 *
224
-	 * @param string $path
225
-	 * @return array
226
-	 * @throws \BadMethodCallException
227
-	 */
228
-	public function getUidAndFilename($path) {
229
-
230
-		$parts = explode('/', $path);
231
-		$uid = '';
232
-		if (count($parts) > 2) {
233
-			$uid = $parts[1];
234
-		}
235
-		if (!$this->userManager->userExists($uid)) {
236
-			throw new \BadMethodCallException(
237
-				'path needs to be relative to the system wide data folder and point to a user specific file'
238
-			);
239
-		}
240
-
241
-		$ownerPath = implode('/', array_slice($parts, 2));
242
-
243
-		return array($uid, Filesystem::normalizePath($ownerPath));
244
-
245
-	}
246
-
247
-	/**
248
-	 * Remove .path extension from a file path
249
-	 * @param string $path Path that may identify a .part file
250
-	 * @return string File path without .part extension
251
-	 * @note this is needed for reusing keys
252
-	 */
253
-	public function stripPartialFileExtension($path) {
254
-		$extension = pathinfo($path, PATHINFO_EXTENSION);
255
-
256
-		if ( $extension === 'part') {
257
-
258
-			$newLength = strlen($path) - 5; // 5 = strlen(".part")
259
-			$fPath = substr($path, 0, $newLength);
260
-
261
-			// if path also contains a transaction id, we remove it too
262
-			$extension = pathinfo($fPath, PATHINFO_EXTENSION);
263
-			if(substr($extension, 0, 12) === 'ocTransferId') { // 12 = strlen("ocTransferId")
264
-				$newLength = strlen($fPath) - strlen($extension) -1;
265
-				$fPath = substr($fPath, 0, $newLength);
266
-			}
267
-			return $fPath;
268
-
269
-		} else {
270
-			return $path;
271
-		}
272
-	}
273
-
274
-	public function getUserWithAccessToMountPoint($users, $groups) {
275
-		$result = [];
276
-		if (in_array('all', $users)) {
277
-			$users = $this->userManager->search('', null, null);
278
-			$result = array_map(function(IUser $user) {
279
-				return $user->getUID();
280
-			}, $users);
281
-		} else {
282
-			$result = array_merge($result, $users);
283
-
284
-			$groupManager = \OC::$server->getGroupManager();
285
-			foreach ($groups as $group) {
286
-				$groupObject = $groupManager->get($group);
287
-				if ($groupObject) {
288
-					$foundUsers = $groupObject->searchUsers('', -1, 0);
289
-					$userIds = [];
290
-					foreach ($foundUsers as $user) {
291
-						$userIds[] = $user->getUID();
292
-					}
293
-					$result = array_merge($result, $userIds);
294
-				}
295
-			}
296
-		}
297
-
298
-		return $result;
299
-	}
300
-
301
-	/**
302
-	 * check if the file is stored on a system wide mount point
303
-	 * @param string $path relative to /data/user with leading '/'
304
-	 * @param string $uid
305
-	 * @return boolean
306
-	 */
307
-	public function isSystemWideMountPoint($path, $uid) {
308
-		if (\OCP\App::isEnabled("files_external")) {
309
-			$mounts = \OC_Mount_Config::getSystemMountPoints();
310
-			foreach ($mounts as $mount) {
311
-				if (strpos($path, '/files/' . $mount['mountpoint']) === 0) {
312
-					if ($this->isMountPointApplicableToUser($mount, $uid)) {
313
-						return true;
314
-					}
315
-				}
316
-			}
317
-		}
318
-		return false;
319
-	}
320
-
321
-	/**
322
-	 * check if mount point is applicable to user
323
-	 *
324
-	 * @param array $mount contains $mount['applicable']['users'], $mount['applicable']['groups']
325
-	 * @param string $uid
326
-	 * @return boolean
327
-	 */
328
-	private function isMountPointApplicableToUser($mount, $uid) {
329
-		$acceptedUids = array('all', $uid);
330
-		// check if mount point is applicable for the user
331
-		$intersection = array_intersect($acceptedUids, $mount['applicable']['users']);
332
-		if (!empty($intersection)) {
333
-			return true;
334
-		}
335
-		// check if mount point is applicable for group where the user is a member
336
-		foreach ($mount['applicable']['groups'] as $gid) {
337
-			if ($this->groupManager->isInGroup($uid, $gid)) {
338
-				return true;
339
-			}
340
-		}
341
-		return false;
342
-	}
343
-
344
-	/**
345
-	 * check if it is a path which is excluded by ownCloud from encryption
346
-	 *
347
-	 * @param string $path
348
-	 * @return boolean
349
-	 */
350
-	public function isExcluded($path) {
351
-		$normalizedPath = Filesystem::normalizePath($path);
352
-		$root = explode('/', $normalizedPath, 4);
353
-		if (count($root) > 1) {
354
-
355
-			// detect alternative key storage root
356
-			$rootDir = $this->getKeyStorageRoot();
357
-			if ($rootDir !== '' &&
358
-				0 === strpos(
359
-					Filesystem::normalizePath($path),
360
-					Filesystem::normalizePath($rootDir)
361
-				)
362
-			) {
363
-				return true;
364
-			}
365
-
366
-
367
-			//detect system wide folders
368
-			if (in_array($root[1], $this->excludedPaths)) {
369
-				return true;
370
-			}
371
-
372
-			// detect user specific folders
373
-			if ($this->userManager->userExists($root[1])
374
-				&& in_array($root[2], $this->excludedPaths)) {
375
-
376
-				return true;
377
-			}
378
-		}
379
-		return false;
380
-	}
381
-
382
-	/**
383
-	 * check if recovery key is enabled for user
384
-	 *
385
-	 * @param string $uid
386
-	 * @return boolean
387
-	 */
388
-	public function recoveryEnabled($uid) {
389
-		$enabled = $this->config->getUserValue($uid, 'encryption', 'recovery_enabled', '0');
390
-
391
-		return $enabled === '1';
392
-	}
393
-
394
-	/**
395
-	 * set new key storage root
396
-	 *
397
-	 * @param string $root new key store root relative to the data folder
398
-	 */
399
-	public function setKeyStorageRoot($root) {
400
-		$this->config->setAppValue('core', 'encryption_key_storage_root', $root);
401
-	}
402
-
403
-	/**
404
-	 * get key storage root
405
-	 *
406
-	 * @return string key storage root
407
-	 */
408
-	public function getKeyStorageRoot() {
409
-		return $this->config->getAppValue('core', 'encryption_key_storage_root', '');
410
-	}
42
+    const HEADER_START = 'HBEGIN';
43
+    const HEADER_END = 'HEND';
44
+    const HEADER_PADDING_CHAR = '-';
45
+
46
+    const HEADER_ENCRYPTION_MODULE_KEY = 'oc_encryption_module';
47
+
48
+    /**
49
+     * block size will always be 8192 for a PHP stream
50
+     * @see https://bugs.php.net/bug.php?id=21641
51
+     * @var integer
52
+     */
53
+    protected $headerSize = 8192;
54
+
55
+    /**
56
+     * block size will always be 8192 for a PHP stream
57
+     * @see https://bugs.php.net/bug.php?id=21641
58
+     * @var integer
59
+     */
60
+    protected $blockSize = 8192;
61
+
62
+    /** @var View */
63
+    protected $rootView;
64
+
65
+    /** @var array */
66
+    protected $ocHeaderKeys;
67
+
68
+    /** @var \OC\User\Manager */
69
+    protected $userManager;
70
+
71
+    /** @var IConfig */
72
+    protected $config;
73
+
74
+    /** @var array paths excluded from encryption */
75
+    protected $excludedPaths;
76
+
77
+    /** @var \OC\Group\Manager $manager */
78
+    protected $groupManager;
79
+
80
+    /**
81
+     *
82
+     * @param View $rootView
83
+     * @param \OC\User\Manager $userManager
84
+     * @param \OC\Group\Manager $groupManager
85
+     * @param IConfig $config
86
+     */
87
+    public function __construct(
88
+        View $rootView,
89
+        \OC\User\Manager $userManager,
90
+        \OC\Group\Manager $groupManager,
91
+        IConfig $config) {
92
+
93
+        $this->ocHeaderKeys = [
94
+            self::HEADER_ENCRYPTION_MODULE_KEY
95
+        ];
96
+
97
+        $this->rootView = $rootView;
98
+        $this->userManager = $userManager;
99
+        $this->groupManager = $groupManager;
100
+        $this->config = $config;
101
+
102
+        $this->excludedPaths[] = 'files_encryption';
103
+        $this->excludedPaths[] = 'appdata_' . $config->getSystemValue('instanceid', null);
104
+        $this->excludedPaths[] = 'files_external';
105
+    }
106
+
107
+    /**
108
+     * read encryption module ID from header
109
+     *
110
+     * @param array $header
111
+     * @return string
112
+     * @throws ModuleDoesNotExistsException
113
+     */
114
+    public function getEncryptionModuleId(array $header = null) {
115
+        $id = '';
116
+        $encryptionModuleKey = self::HEADER_ENCRYPTION_MODULE_KEY;
117
+
118
+        if (isset($header[$encryptionModuleKey])) {
119
+            $id = $header[$encryptionModuleKey];
120
+        } elseif (isset($header['cipher'])) {
121
+            if (class_exists('\OCA\Encryption\Crypto\Encryption')) {
122
+                // fall back to default encryption if the user migrated from
123
+                // ownCloud <= 8.0 with the old encryption
124
+                $id = \OCA\Encryption\Crypto\Encryption::ID;
125
+            } else {
126
+                throw new ModuleDoesNotExistsException('Default encryption module missing');
127
+            }
128
+        }
129
+
130
+        return $id;
131
+    }
132
+
133
+    /**
134
+     * create header for encrypted file
135
+     *
136
+     * @param array $headerData
137
+     * @param IEncryptionModule $encryptionModule
138
+     * @return string
139
+     * @throws EncryptionHeaderToLargeException if header has to many arguments
140
+     * @throws EncryptionHeaderKeyExistsException if header key is already in use
141
+     */
142
+    public function createHeader(array $headerData, IEncryptionModule $encryptionModule) {
143
+        $header = self::HEADER_START . ':' . self::HEADER_ENCRYPTION_MODULE_KEY . ':' . $encryptionModule->getId() . ':';
144
+        foreach ($headerData as $key => $value) {
145
+            if (in_array($key, $this->ocHeaderKeys)) {
146
+                throw new EncryptionHeaderKeyExistsException($key);
147
+            }
148
+            $header .= $key . ':' . $value . ':';
149
+        }
150
+        $header .= self::HEADER_END;
151
+
152
+        if (strlen($header) > $this->getHeaderSize()) {
153
+            throw new EncryptionHeaderToLargeException();
154
+        }
155
+
156
+        $paddedHeader = str_pad($header, $this->headerSize, self::HEADER_PADDING_CHAR, STR_PAD_RIGHT);
157
+
158
+        return $paddedHeader;
159
+    }
160
+
161
+    /**
162
+     * go recursively through a dir and collect all files and sub files.
163
+     *
164
+     * @param string $dir relative to the users files folder
165
+     * @return array with list of files relative to the users files folder
166
+     */
167
+    public function getAllFiles($dir) {
168
+        $result = array();
169
+        $dirList = array($dir);
170
+
171
+        while ($dirList) {
172
+            $dir = array_pop($dirList);
173
+            $content = $this->rootView->getDirectoryContent($dir);
174
+
175
+            foreach ($content as $c) {
176
+                if ($c->getType() === 'dir') {
177
+                    $dirList[] = $c->getPath();
178
+                } else {
179
+                    $result[] =  $c->getPath();
180
+                }
181
+            }
182
+
183
+        }
184
+
185
+        return $result;
186
+    }
187
+
188
+    /**
189
+     * check if it is a file uploaded by the user stored in data/user/files
190
+     * or a metadata file
191
+     *
192
+     * @param string $path relative to the data/ folder
193
+     * @return boolean
194
+     */
195
+    public function isFile($path) {
196
+        $parts = explode('/', Filesystem::normalizePath($path), 4);
197
+        if (isset($parts[2]) && $parts[2] === 'files') {
198
+            return true;
199
+        }
200
+        return false;
201
+    }
202
+
203
+    /**
204
+     * return size of encryption header
205
+     *
206
+     * @return integer
207
+     */
208
+    public function getHeaderSize() {
209
+        return $this->headerSize;
210
+    }
211
+
212
+    /**
213
+     * return size of block read by a PHP stream
214
+     *
215
+     * @return integer
216
+     */
217
+    public function getBlockSize() {
218
+        return $this->blockSize;
219
+    }
220
+
221
+    /**
222
+     * get the owner and the path for the file relative to the owners files folder
223
+     *
224
+     * @param string $path
225
+     * @return array
226
+     * @throws \BadMethodCallException
227
+     */
228
+    public function getUidAndFilename($path) {
229
+
230
+        $parts = explode('/', $path);
231
+        $uid = '';
232
+        if (count($parts) > 2) {
233
+            $uid = $parts[1];
234
+        }
235
+        if (!$this->userManager->userExists($uid)) {
236
+            throw new \BadMethodCallException(
237
+                'path needs to be relative to the system wide data folder and point to a user specific file'
238
+            );
239
+        }
240
+
241
+        $ownerPath = implode('/', array_slice($parts, 2));
242
+
243
+        return array($uid, Filesystem::normalizePath($ownerPath));
244
+
245
+    }
246
+
247
+    /**
248
+     * Remove .path extension from a file path
249
+     * @param string $path Path that may identify a .part file
250
+     * @return string File path without .part extension
251
+     * @note this is needed for reusing keys
252
+     */
253
+    public function stripPartialFileExtension($path) {
254
+        $extension = pathinfo($path, PATHINFO_EXTENSION);
255
+
256
+        if ( $extension === 'part') {
257
+
258
+            $newLength = strlen($path) - 5; // 5 = strlen(".part")
259
+            $fPath = substr($path, 0, $newLength);
260
+
261
+            // if path also contains a transaction id, we remove it too
262
+            $extension = pathinfo($fPath, PATHINFO_EXTENSION);
263
+            if(substr($extension, 0, 12) === 'ocTransferId') { // 12 = strlen("ocTransferId")
264
+                $newLength = strlen($fPath) - strlen($extension) -1;
265
+                $fPath = substr($fPath, 0, $newLength);
266
+            }
267
+            return $fPath;
268
+
269
+        } else {
270
+            return $path;
271
+        }
272
+    }
273
+
274
+    public function getUserWithAccessToMountPoint($users, $groups) {
275
+        $result = [];
276
+        if (in_array('all', $users)) {
277
+            $users = $this->userManager->search('', null, null);
278
+            $result = array_map(function(IUser $user) {
279
+                return $user->getUID();
280
+            }, $users);
281
+        } else {
282
+            $result = array_merge($result, $users);
283
+
284
+            $groupManager = \OC::$server->getGroupManager();
285
+            foreach ($groups as $group) {
286
+                $groupObject = $groupManager->get($group);
287
+                if ($groupObject) {
288
+                    $foundUsers = $groupObject->searchUsers('', -1, 0);
289
+                    $userIds = [];
290
+                    foreach ($foundUsers as $user) {
291
+                        $userIds[] = $user->getUID();
292
+                    }
293
+                    $result = array_merge($result, $userIds);
294
+                }
295
+            }
296
+        }
297
+
298
+        return $result;
299
+    }
300
+
301
+    /**
302
+     * check if the file is stored on a system wide mount point
303
+     * @param string $path relative to /data/user with leading '/'
304
+     * @param string $uid
305
+     * @return boolean
306
+     */
307
+    public function isSystemWideMountPoint($path, $uid) {
308
+        if (\OCP\App::isEnabled("files_external")) {
309
+            $mounts = \OC_Mount_Config::getSystemMountPoints();
310
+            foreach ($mounts as $mount) {
311
+                if (strpos($path, '/files/' . $mount['mountpoint']) === 0) {
312
+                    if ($this->isMountPointApplicableToUser($mount, $uid)) {
313
+                        return true;
314
+                    }
315
+                }
316
+            }
317
+        }
318
+        return false;
319
+    }
320
+
321
+    /**
322
+     * check if mount point is applicable to user
323
+     *
324
+     * @param array $mount contains $mount['applicable']['users'], $mount['applicable']['groups']
325
+     * @param string $uid
326
+     * @return boolean
327
+     */
328
+    private function isMountPointApplicableToUser($mount, $uid) {
329
+        $acceptedUids = array('all', $uid);
330
+        // check if mount point is applicable for the user
331
+        $intersection = array_intersect($acceptedUids, $mount['applicable']['users']);
332
+        if (!empty($intersection)) {
333
+            return true;
334
+        }
335
+        // check if mount point is applicable for group where the user is a member
336
+        foreach ($mount['applicable']['groups'] as $gid) {
337
+            if ($this->groupManager->isInGroup($uid, $gid)) {
338
+                return true;
339
+            }
340
+        }
341
+        return false;
342
+    }
343
+
344
+    /**
345
+     * check if it is a path which is excluded by ownCloud from encryption
346
+     *
347
+     * @param string $path
348
+     * @return boolean
349
+     */
350
+    public function isExcluded($path) {
351
+        $normalizedPath = Filesystem::normalizePath($path);
352
+        $root = explode('/', $normalizedPath, 4);
353
+        if (count($root) > 1) {
354
+
355
+            // detect alternative key storage root
356
+            $rootDir = $this->getKeyStorageRoot();
357
+            if ($rootDir !== '' &&
358
+                0 === strpos(
359
+                    Filesystem::normalizePath($path),
360
+                    Filesystem::normalizePath($rootDir)
361
+                )
362
+            ) {
363
+                return true;
364
+            }
365
+
366
+
367
+            //detect system wide folders
368
+            if (in_array($root[1], $this->excludedPaths)) {
369
+                return true;
370
+            }
371
+
372
+            // detect user specific folders
373
+            if ($this->userManager->userExists($root[1])
374
+                && in_array($root[2], $this->excludedPaths)) {
375
+
376
+                return true;
377
+            }
378
+        }
379
+        return false;
380
+    }
381
+
382
+    /**
383
+     * check if recovery key is enabled for user
384
+     *
385
+     * @param string $uid
386
+     * @return boolean
387
+     */
388
+    public function recoveryEnabled($uid) {
389
+        $enabled = $this->config->getUserValue($uid, 'encryption', 'recovery_enabled', '0');
390
+
391
+        return $enabled === '1';
392
+    }
393
+
394
+    /**
395
+     * set new key storage root
396
+     *
397
+     * @param string $root new key store root relative to the data folder
398
+     */
399
+    public function setKeyStorageRoot($root) {
400
+        $this->config->setAppValue('core', 'encryption_key_storage_root', $root);
401
+    }
402
+
403
+    /**
404
+     * get key storage root
405
+     *
406
+     * @return string key storage root
407
+     */
408
+    public function getKeyStorageRoot() {
409
+        return $this->config->getAppValue('core', 'encryption_key_storage_root', '');
410
+    }
411 411
 
412 412
 }
Please login to merge, or discard this patch.
lib/private/Comments/ManagerFactory.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -30,33 +30,33 @@
 block discarded – undo
30 30
 
31 31
 class ManagerFactory implements ICommentsManagerFactory {
32 32
 
33
-	/**
34
-	 * Server container
35
-	 *
36
-	 * @var IServerContainer
37
-	 */
38
-	private $serverContainer;
33
+    /**
34
+     * Server container
35
+     *
36
+     * @var IServerContainer
37
+     */
38
+    private $serverContainer;
39 39
 
40
-	/**
41
-	 * Constructor for the comments manager factory
42
-	 *
43
-	 * @param IServerContainer $serverContainer server container
44
-	 */
45
-	public function __construct(IServerContainer $serverContainer) {
46
-		$this->serverContainer = $serverContainer;
47
-	}
40
+    /**
41
+     * Constructor for the comments manager factory
42
+     *
43
+     * @param IServerContainer $serverContainer server container
44
+     */
45
+    public function __construct(IServerContainer $serverContainer) {
46
+        $this->serverContainer = $serverContainer;
47
+    }
48 48
 
49
-	/**
50
-	 * creates and returns an instance of the ICommentsManager
51
-	 *
52
-	 * @return ICommentsManager
53
-	 * @since 9.0.0
54
-	 */
55
-	public function getManager() {
56
-		return new Manager(
57
-			$this->serverContainer->getDatabaseConnection(),
58
-			$this->serverContainer->getLogger(),
59
-			$this->serverContainer->getConfig()
60
-		);
61
-	}
49
+    /**
50
+     * creates and returns an instance of the ICommentsManager
51
+     *
52
+     * @return ICommentsManager
53
+     * @since 9.0.0
54
+     */
55
+    public function getManager() {
56
+        return new Manager(
57
+            $this->serverContainer->getDatabaseConnection(),
58
+            $this->serverContainer->getLogger(),
59
+            $this->serverContainer->getConfig()
60
+        );
61
+    }
62 62
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/CachingTree.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -24,16 +24,16 @@
 block discarded – undo
24 24
 use Sabre\DAV\Tree;
25 25
 
26 26
 class CachingTree extends Tree {
27
-	/**
28
-	 * Store a node in the cache
29
-	 *
30
-	 * @param Node $node
31
-	 * @param null|string $path
32
-	 */
33
-	public function cacheNode(Node $node, $path = null) {
34
-		if (is_null($path)) {
35
-			$path = $node->getPath();
36
-		}
37
-		$this->cache[trim($path, '/')] = $node;
38
-	}
27
+    /**
28
+     * Store a node in the cache
29
+     *
30
+     * @param Node $node
31
+     * @param null|string $path
32
+     */
33
+    public function cacheNode(Node $node, $path = null) {
34
+        if (is_null($path)) {
35
+            $path = $node->getPath();
36
+        }
37
+        $this->cache[trim($path, '/')] = $node;
38
+    }
39 39
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/Server.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -33,14 +33,14 @@
 block discarded – undo
33 33
  * @see \Sabre\DAV\Server
34 34
  */
35 35
 class Server extends \Sabre\DAV\Server {
36
-	/** @var CachingTree $tree */
36
+    /** @var CachingTree $tree */
37 37
 
38
-	/**
39
-	 * @see \Sabre\DAV\Server
40
-	 */
41
-	public function __construct($treeOrNode = null) {
42
-		parent::__construct($treeOrNode);
43
-		self::$exposeVersion = false;
44
-		$this->enablePropfindDepthInfinity = true;
45
-	}
38
+    /**
39
+     * @see \Sabre\DAV\Server
40
+     */
41
+    public function __construct($treeOrNode = null) {
42
+        parent::__construct($treeOrNode);
43
+        self::$exposeVersion = false;
44
+        $this->enablePropfindDepthInfinity = true;
45
+    }
46 46
 }
Please login to merge, or discard this patch.
core/templates/error.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <div class="error">
2 2
 	<h2><?php p($l->t('Error')) ?></h2>
3 3
 	<ul>
4
-	<?php foreach($_["errors"] as $error):?>
4
+	<?php foreach ($_["errors"] as $error):?>
5 5
 		<li>
6 6
 			<p><?php p($error['error']) ?></p>
7
-			<?php if(isset($error['hint']) && $error['hint']): ?>
7
+			<?php if (isset($error['hint']) && $error['hint']): ?>
8 8
 				<p class='hint'><?php p($error['hint']) ?></p>
9
-			<?php endif;?>
9
+			<?php endif; ?>
10 10
 		</li>
11 11
 	<?php endforeach ?>
12 12
 	</ul>
Please login to merge, or discard this patch.
apps/twofactor_backupcodes/lib/Activity/Provider.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -31,47 +31,47 @@
 block discarded – undo
31 31
 
32 32
 class Provider implements IProvider {
33 33
 
34
-	/** @var L10nFactory */
35
-	private $l10n;
34
+    /** @var L10nFactory */
35
+    private $l10n;
36 36
 
37
-	/** @var IURLGenerator */
38
-	private $urlGenerator;
37
+    /** @var IURLGenerator */
38
+    private $urlGenerator;
39 39
 
40
-	/** @var IManager */
41
-	private $activityManager;
40
+    /** @var IManager */
41
+    private $activityManager;
42 42
 
43
-	/**
44
-	 * @param L10nFactory $l10n
45
-	 * @param IURLGenerator $urlGenerator
46
-	 * @param IManager $activityManager
47
-	 */
48
-	public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator, IManager $activityManager) {
49
-		$this->urlGenerator = $urlGenerator;
50
-		$this->activityManager = $activityManager;
51
-		$this->l10n = $l10n;
52
-	}
43
+    /**
44
+     * @param L10nFactory $l10n
45
+     * @param IURLGenerator $urlGenerator
46
+     * @param IManager $activityManager
47
+     */
48
+    public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator, IManager $activityManager) {
49
+        $this->urlGenerator = $urlGenerator;
50
+        $this->activityManager = $activityManager;
51
+        $this->l10n = $l10n;
52
+    }
53 53
 
54
-	public function parse($language, IEvent $event, IEvent $previousEvent = null) {
55
-		if ($event->getApp() !== 'twofactor_backupcodes') {
56
-			throw new InvalidArgumentException();
57
-		}
54
+    public function parse($language, IEvent $event, IEvent $previousEvent = null) {
55
+        if ($event->getApp() !== 'twofactor_backupcodes') {
56
+            throw new InvalidArgumentException();
57
+        }
58 58
 
59
-		$l = $this->l10n->get('twofactor_backupcodes', $language);
59
+        $l = $this->l10n->get('twofactor_backupcodes', $language);
60 60
 
61
-		switch ($event->getSubject()) {
62
-			case 'codes_generated':
63
-				$event->setParsedSubject($l->t('You created two-factor backup codes for your account'));
61
+        switch ($event->getSubject()) {
62
+            case 'codes_generated':
63
+                $event->setParsedSubject($l->t('You created two-factor backup codes for your account'));
64 64
 
65
-				if ($this->activityManager->getRequirePNG()) {
66
-					$event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.png')));
67
-				} else {
68
-					$event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')));
69
-				}
70
-				break;
71
-			default:
72
-				throw new InvalidArgumentException();
73
-		}
74
-		return $event;
75
-	}
65
+                if ($this->activityManager->getRequirePNG()) {
66
+                    $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.png')));
67
+                } else {
68
+                    $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')));
69
+                }
70
+                break;
71
+            default:
72
+                throw new InvalidArgumentException();
73
+        }
74
+        return $event;
75
+    }
76 76
 
77 77
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/Activity/Providers/PublicLinks.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -25,105 +25,105 @@
 block discarded – undo
25 25
 
26 26
 class PublicLinks extends Base {
27 27
 
28
-	const SUBJECT_SHARED_LINK_SELF = 'shared_link_self';
29
-	const SUBJECT_RESHARED_LINK_BY = 'reshared_link_by';
30
-	const SUBJECT_UNSHARED_LINK_SELF = 'unshared_link_self';
31
-	const SUBJECT_UNSHARED_LINK_BY = 'unshared_link_by';
32
-	const SUBJECT_LINK_EXPIRED = 'link_expired';
33
-	const SUBJECT_LINK_BY_EXPIRED = 'link_by_expired';
34
-
35
-	/**
36
-	 * @param IEvent $event
37
-	 * @return IEvent
38
-	 * @throws \InvalidArgumentException
39
-	 * @since 11.0.0
40
-	 */
41
-	public function parseShortVersion(IEvent $event) {
42
-		$parsedParameters = $this->getParsedParameters($event);
43
-
44
-		if ($event->getSubject() === self::SUBJECT_SHARED_LINK_SELF) {
45
-			$subject = $this->l->t('Shared as public link');
46
-		} else if ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_SELF) {
47
-			$subject = $this->l->t('Removed public link');
48
-		} else if ($event->getSubject() === self::SUBJECT_LINK_EXPIRED) {
49
-			$subject = $this->l->t('Public link expired');
50
-		} else if ($event->getSubject() === self::SUBJECT_RESHARED_LINK_BY) {
51
-			$subject = $this->l->t('{actor} shared as public link');
52
-		} else if ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_BY) {
53
-			$subject = $this->l->t('{actor} removed public link');
54
-		} else if ($event->getSubject() === self::SUBJECT_LINK_BY_EXPIRED) {
55
-			$subject = $this->l->t('Public link of {actor} expired');
56
-
57
-		} else {
58
-			throw new \InvalidArgumentException();
59
-		}
60
-
61
-		if ($this->activityManager->getRequirePNG()) {
62
-			$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
63
-		} else {
64
-			$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
65
-		}
66
-		$this->setSubjects($event, $subject, $parsedParameters);
67
-
68
-		return $event;
69
-	}
70
-
71
-	/**
72
-	 * @param IEvent $event
73
-	 * @return IEvent
74
-	 * @throws \InvalidArgumentException
75
-	 * @since 11.0.0
76
-	 */
77
-	public function parseLongVersion(IEvent $event) {
78
-		$parsedParameters = $this->getParsedParameters($event);
79
-
80
-		if ($event->getSubject() === self::SUBJECT_SHARED_LINK_SELF) {
81
-			$subject = $this->l->t('You shared {file} as public link');
82
-		} else if ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_SELF) {
83
-			$subject = $this->l->t('You removed public link for {file}');
84
-		} else if ($event->getSubject() === self::SUBJECT_LINK_EXPIRED) {
85
-			$subject = $this->l->t('Public link expired for {file}');
86
-		} else if ($event->getSubject() === self::SUBJECT_RESHARED_LINK_BY) {
87
-			$subject = $this->l->t('{actor} shared {file} as public link');
88
-		} else if ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_BY) {
89
-			$subject = $this->l->t('{actor} removed public link for {file}');
90
-		} else if ($event->getSubject() === self::SUBJECT_LINK_BY_EXPIRED) {
91
-			$subject = $this->l->t('Public link of {actor} for {file} expired');
92
-
93
-		} else {
94
-			throw new \InvalidArgumentException();
95
-		}
96
-
97
-		if ($this->activityManager->getRequirePNG()) {
98
-			$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
99
-		} else {
100
-			$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
101
-		}
102
-		$this->setSubjects($event, $subject, $parsedParameters);
103
-
104
-		return $event;
105
-	}
106
-
107
-	protected function getParsedParameters(IEvent $event) {
108
-		$subject = $event->getSubject();
109
-		$parameters = $event->getSubjectParameters();
110
-
111
-		switch ($subject) {
112
-			case self::SUBJECT_SHARED_LINK_SELF:
113
-			case self::SUBJECT_UNSHARED_LINK_SELF:
114
-			case self::SUBJECT_LINK_EXPIRED:
115
-				return [
116
-					'file' => $this->getFile($parameters[0], $event),
117
-				];
118
-			case self::SUBJECT_RESHARED_LINK_BY:
119
-			case self::SUBJECT_UNSHARED_LINK_BY:
120
-			case self::SUBJECT_LINK_BY_EXPIRED:
121
-				return [
122
-					'file' => $this->getFile($parameters[0], $event),
123
-					'actor' => $this->getUser($parameters[1]),
124
-				];
125
-		}
126
-		return [];
127
-	}
28
+    const SUBJECT_SHARED_LINK_SELF = 'shared_link_self';
29
+    const SUBJECT_RESHARED_LINK_BY = 'reshared_link_by';
30
+    const SUBJECT_UNSHARED_LINK_SELF = 'unshared_link_self';
31
+    const SUBJECT_UNSHARED_LINK_BY = 'unshared_link_by';
32
+    const SUBJECT_LINK_EXPIRED = 'link_expired';
33
+    const SUBJECT_LINK_BY_EXPIRED = 'link_by_expired';
34
+
35
+    /**
36
+     * @param IEvent $event
37
+     * @return IEvent
38
+     * @throws \InvalidArgumentException
39
+     * @since 11.0.0
40
+     */
41
+    public function parseShortVersion(IEvent $event) {
42
+        $parsedParameters = $this->getParsedParameters($event);
43
+
44
+        if ($event->getSubject() === self::SUBJECT_SHARED_LINK_SELF) {
45
+            $subject = $this->l->t('Shared as public link');
46
+        } else if ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_SELF) {
47
+            $subject = $this->l->t('Removed public link');
48
+        } else if ($event->getSubject() === self::SUBJECT_LINK_EXPIRED) {
49
+            $subject = $this->l->t('Public link expired');
50
+        } else if ($event->getSubject() === self::SUBJECT_RESHARED_LINK_BY) {
51
+            $subject = $this->l->t('{actor} shared as public link');
52
+        } else if ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_BY) {
53
+            $subject = $this->l->t('{actor} removed public link');
54
+        } else if ($event->getSubject() === self::SUBJECT_LINK_BY_EXPIRED) {
55
+            $subject = $this->l->t('Public link of {actor} expired');
56
+
57
+        } else {
58
+            throw new \InvalidArgumentException();
59
+        }
60
+
61
+        if ($this->activityManager->getRequirePNG()) {
62
+            $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
63
+        } else {
64
+            $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
65
+        }
66
+        $this->setSubjects($event, $subject, $parsedParameters);
67
+
68
+        return $event;
69
+    }
70
+
71
+    /**
72
+     * @param IEvent $event
73
+     * @return IEvent
74
+     * @throws \InvalidArgumentException
75
+     * @since 11.0.0
76
+     */
77
+    public function parseLongVersion(IEvent $event) {
78
+        $parsedParameters = $this->getParsedParameters($event);
79
+
80
+        if ($event->getSubject() === self::SUBJECT_SHARED_LINK_SELF) {
81
+            $subject = $this->l->t('You shared {file} as public link');
82
+        } else if ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_SELF) {
83
+            $subject = $this->l->t('You removed public link for {file}');
84
+        } else if ($event->getSubject() === self::SUBJECT_LINK_EXPIRED) {
85
+            $subject = $this->l->t('Public link expired for {file}');
86
+        } else if ($event->getSubject() === self::SUBJECT_RESHARED_LINK_BY) {
87
+            $subject = $this->l->t('{actor} shared {file} as public link');
88
+        } else if ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_BY) {
89
+            $subject = $this->l->t('{actor} removed public link for {file}');
90
+        } else if ($event->getSubject() === self::SUBJECT_LINK_BY_EXPIRED) {
91
+            $subject = $this->l->t('Public link of {actor} for {file} expired');
92
+
93
+        } else {
94
+            throw new \InvalidArgumentException();
95
+        }
96
+
97
+        if ($this->activityManager->getRequirePNG()) {
98
+            $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
99
+        } else {
100
+            $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
101
+        }
102
+        $this->setSubjects($event, $subject, $parsedParameters);
103
+
104
+        return $event;
105
+    }
106
+
107
+    protected function getParsedParameters(IEvent $event) {
108
+        $subject = $event->getSubject();
109
+        $parameters = $event->getSubjectParameters();
110
+
111
+        switch ($subject) {
112
+            case self::SUBJECT_SHARED_LINK_SELF:
113
+            case self::SUBJECT_UNSHARED_LINK_SELF:
114
+            case self::SUBJECT_LINK_EXPIRED:
115
+                return [
116
+                    'file' => $this->getFile($parameters[0], $event),
117
+                ];
118
+            case self::SUBJECT_RESHARED_LINK_BY:
119
+            case self::SUBJECT_UNSHARED_LINK_BY:
120
+            case self::SUBJECT_LINK_BY_EXPIRED:
121
+                return [
122
+                    'file' => $this->getFile($parameters[0], $event),
123
+                    'actor' => $this->getUser($parameters[1]),
124
+                ];
125
+        }
126
+        return [];
127
+    }
128 128
 
129 129
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/Activity/Providers/Downloads.php 1 patch
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -26,97 +26,97 @@
 block discarded – undo
26 26
 class Downloads extends Base {
27 27
 
28 28
 
29
-	const SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED = 'public_shared_file_downloaded';
30
-	const SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED = 'public_shared_folder_downloaded';
31
-
32
-	const SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED = 'file_shared_with_email_downloaded';
33
-	const SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED = 'folder_shared_with_email_downloaded';
34
-
35
-	/**
36
-	 * @param IEvent $event
37
-	 * @return IEvent
38
-	 * @throws \InvalidArgumentException
39
-	 * @since 11.0.0
40
-	 */
41
-	public function parseShortVersion(IEvent $event) {
42
-		$parsedParameters = $this->getParsedParameters($event);
43
-
44
-		if ($event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED ||
45
-			$event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED) {
46
-			$subject = $this->l->t('Downloaded via public link');
47
-		} else if ($event->getSubject() === self::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED ||
48
-			$event->getSubject() === self::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED) {
49
-			$subject = $this->l->t('Downloaded by {email}');
50
-		} else {
51
-			throw new \InvalidArgumentException();
52
-		}
53
-
54
-		if ($this->activityManager->getRequirePNG()) {
55
-			$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.png')));
56
-		} else {
57
-			$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.svg')));
58
-		}
59
-		$this->setSubjects($event, $subject, $parsedParameters);
60
-
61
-		return $event;
62
-	}
63
-
64
-	/**
65
-	 * @param IEvent $event
66
-	 * @return IEvent
67
-	 * @throws \InvalidArgumentException
68
-	 * @since 11.0.0
69
-	 */
70
-	public function parseLongVersion(IEvent $event) {
71
-		$parsedParameters = $this->getParsedParameters($event);
72
-
73
-		if ($event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED ||
74
-			$event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED) {
75
-			$subject = $this->l->t('{file} downloaded via public link');
76
-		} else if ($event->getSubject() === self::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED ||
77
-			$event->getSubject() === self::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED) {
78
-			$subject = $this->l->t('{email} downloaded {file}');
79
-		} else {
80
-			throw new \InvalidArgumentException();
81
-		}
82
-
83
-		if ($this->activityManager->getRequirePNG()) {
84
-			$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.png')));
85
-		} else {
86
-			$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.svg')));
87
-		}
88
-		$this->setSubjects($event, $subject, $parsedParameters);
89
-
90
-		return $event;
91
-	}
92
-
93
-	/**
94
-	 * @param IEvent $event
95
-	 * @return array
96
-	 * @throws \InvalidArgumentException
97
-	 */
98
-	protected function getParsedParameters(IEvent $event) {
99
-		$subject = $event->getSubject();
100
-		$parameters = $event->getSubjectParameters();
101
-
102
-		switch ($subject) {
103
-			case self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED:
104
-			case self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED:
105
-				return [
106
-					'file' => $this->getFile($parameters[0], $event),
107
-				];
108
-			case self::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED:
109
-			case self::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED:
110
-				return [
111
-					'file' => $this->getFile($parameters[0], $event),
112
-					'email' => [
113
-						'type' => 'email',
114
-						'id' => $parameters[1],
115
-						'name' => $parameters[1],
116
-					],
117
-				];
118
-		}
119
-
120
-		throw new \InvalidArgumentException();
121
-	}
29
+    const SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED = 'public_shared_file_downloaded';
30
+    const SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED = 'public_shared_folder_downloaded';
31
+
32
+    const SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED = 'file_shared_with_email_downloaded';
33
+    const SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED = 'folder_shared_with_email_downloaded';
34
+
35
+    /**
36
+     * @param IEvent $event
37
+     * @return IEvent
38
+     * @throws \InvalidArgumentException
39
+     * @since 11.0.0
40
+     */
41
+    public function parseShortVersion(IEvent $event) {
42
+        $parsedParameters = $this->getParsedParameters($event);
43
+
44
+        if ($event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED ||
45
+            $event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED) {
46
+            $subject = $this->l->t('Downloaded via public link');
47
+        } else if ($event->getSubject() === self::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED ||
48
+            $event->getSubject() === self::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED) {
49
+            $subject = $this->l->t('Downloaded by {email}');
50
+        } else {
51
+            throw new \InvalidArgumentException();
52
+        }
53
+
54
+        if ($this->activityManager->getRequirePNG()) {
55
+            $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.png')));
56
+        } else {
57
+            $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.svg')));
58
+        }
59
+        $this->setSubjects($event, $subject, $parsedParameters);
60
+
61
+        return $event;
62
+    }
63
+
64
+    /**
65
+     * @param IEvent $event
66
+     * @return IEvent
67
+     * @throws \InvalidArgumentException
68
+     * @since 11.0.0
69
+     */
70
+    public function parseLongVersion(IEvent $event) {
71
+        $parsedParameters = $this->getParsedParameters($event);
72
+
73
+        if ($event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED ||
74
+            $event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED) {
75
+            $subject = $this->l->t('{file} downloaded via public link');
76
+        } else if ($event->getSubject() === self::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED ||
77
+            $event->getSubject() === self::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED) {
78
+            $subject = $this->l->t('{email} downloaded {file}');
79
+        } else {
80
+            throw new \InvalidArgumentException();
81
+        }
82
+
83
+        if ($this->activityManager->getRequirePNG()) {
84
+            $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.png')));
85
+        } else {
86
+            $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.svg')));
87
+        }
88
+        $this->setSubjects($event, $subject, $parsedParameters);
89
+
90
+        return $event;
91
+    }
92
+
93
+    /**
94
+     * @param IEvent $event
95
+     * @return array
96
+     * @throws \InvalidArgumentException
97
+     */
98
+    protected function getParsedParameters(IEvent $event) {
99
+        $subject = $event->getSubject();
100
+        $parameters = $event->getSubjectParameters();
101
+
102
+        switch ($subject) {
103
+            case self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED:
104
+            case self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED:
105
+                return [
106
+                    'file' => $this->getFile($parameters[0], $event),
107
+                ];
108
+            case self::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED:
109
+            case self::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED:
110
+                return [
111
+                    'file' => $this->getFile($parameters[0], $event),
112
+                    'email' => [
113
+                        'type' => 'email',
114
+                        'id' => $parameters[1],
115
+                        'name' => $parameters[1],
116
+                    ],
117
+                ];
118
+        }
119
+
120
+        throw new \InvalidArgumentException();
121
+    }
122 122
 }
Please login to merge, or discard this patch.
apps/federatedfilesharing/lib/Settings/PersonalSection.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -29,58 +29,58 @@
 block discarded – undo
29 29
 use OCP\Settings\IIconSection;
30 30
 
31 31
 class PersonalSection implements IIconSection {
32
-	/** @var IURLGenerator */
33
-	private $urlGenerator;
34
-	/** @var IL10N */
35
-	private $l;
32
+    /** @var IURLGenerator */
33
+    private $urlGenerator;
34
+    /** @var IL10N */
35
+    private $l;
36 36
 
37
-	public function __construct(IURLGenerator $urlGenerator, IL10N $l) {
38
-		$this->urlGenerator = $urlGenerator;
39
-		$this->l = $l;
40
-	}
37
+    public function __construct(IURLGenerator $urlGenerator, IL10N $l) {
38
+        $this->urlGenerator = $urlGenerator;
39
+        $this->l = $l;
40
+    }
41 41
 
42
-	/**
43
-	 * returns the relative path to an 16*16 icon describing the section.
44
-	 * e.g. '/core/img/places/files.svg'
45
-	 *
46
-	 * @returns string
47
-	 * @since 13.0.0
48
-	 */
49
-	public function getIcon() {
50
-		return $this->urlGenerator->imagePath('core', 'actions/share.svg');
51
-	}
42
+    /**
43
+     * returns the relative path to an 16*16 icon describing the section.
44
+     * e.g. '/core/img/places/files.svg'
45
+     *
46
+     * @returns string
47
+     * @since 13.0.0
48
+     */
49
+    public function getIcon() {
50
+        return $this->urlGenerator->imagePath('core', 'actions/share.svg');
51
+    }
52 52
 
53
-	/**
54
-	 * returns the ID of the section. It is supposed to be a lower case string,
55
-	 * e.g. 'ldap'
56
-	 *
57
-	 * @returns string
58
-	 * @since 9.1
59
-	 */
60
-	public function getID() {
61
-		return 'sharing';
62
-	}
53
+    /**
54
+     * returns the ID of the section. It is supposed to be a lower case string,
55
+     * e.g. 'ldap'
56
+     *
57
+     * @returns string
58
+     * @since 9.1
59
+     */
60
+    public function getID() {
61
+        return 'sharing';
62
+    }
63 63
 
64
-	/**
65
-	 * returns the translated name as it should be displayed, e.g. 'LDAP / AD
66
-	 * integration'. Use the L10N service to translate it.
67
-	 *
68
-	 * @return string
69
-	 * @since 9.1
70
-	 */
71
-	public function getName() {
72
-		return $this->l->t('Sharing');
73
-	}
64
+    /**
65
+     * returns the translated name as it should be displayed, e.g. 'LDAP / AD
66
+     * integration'. Use the L10N service to translate it.
67
+     *
68
+     * @return string
69
+     * @since 9.1
70
+     */
71
+    public function getName() {
72
+        return $this->l->t('Sharing');
73
+    }
74 74
 
75
-	/**
76
-	 * @return int whether the form should be rather on the top or bottom of
77
-	 * the settings navigation. The sections are arranged in ascending order of
78
-	 * the priority values. It is required to return a value between 0 and 99.
79
-	 *
80
-	 * E.g.: 70
81
-	 * @since 9.1
82
-	 */
83
-	public function getPriority() {
84
-		return 15;
85
-	}
75
+    /**
76
+     * @return int whether the form should be rather on the top or bottom of
77
+     * the settings navigation. The sections are arranged in ascending order of
78
+     * the priority values. It is required to return a value between 0 and 99.
79
+     *
80
+     * E.g.: 70
81
+     * @since 9.1
82
+     */
83
+    public function getPriority() {
84
+        return 15;
85
+    }
86 86
 }
Please login to merge, or discard this patch.