Passed
Push — master ( 970f39...e4f050 )
by Joas
15:13 queued 12s
created
apps/encryption/lib/Hooks/UserHooks.php 1 patch
Indentation   +300 added lines, -300 removed lines patch added patch discarded remove patch
@@ -44,304 +44,304 @@
 block discarded – undo
44 44
 
45 45
 class UserHooks implements IHook {
46 46
 
47
-	/**
48
-	 * list of user for which we perform a password reset
49
-	 * @var array
50
-	 */
51
-	protected static $passwordResetUsers = [];
52
-
53
-	/**
54
-	 * @var KeyManager
55
-	 */
56
-	private $keyManager;
57
-	/**
58
-	 * @var IUserManager
59
-	 */
60
-	private $userManager;
61
-	/**
62
-	 * @var ILogger
63
-	 */
64
-	private $logger;
65
-	/**
66
-	 * @var Setup
67
-	 */
68
-	private $userSetup;
69
-	/**
70
-	 * @var IUserSession
71
-	 */
72
-	private $userSession;
73
-	/**
74
-	 * @var Util
75
-	 */
76
-	private $util;
77
-	/**
78
-	 * @var Session
79
-	 */
80
-	private $session;
81
-	/**
82
-	 * @var Recovery
83
-	 */
84
-	private $recovery;
85
-	/**
86
-	 * @var Crypt
87
-	 */
88
-	private $crypt;
89
-
90
-	/**
91
-	 * UserHooks constructor.
92
-	 *
93
-	 * @param KeyManager $keyManager
94
-	 * @param IUserManager $userManager
95
-	 * @param ILogger $logger
96
-	 * @param Setup $userSetup
97
-	 * @param IUserSession $userSession
98
-	 * @param Util $util
99
-	 * @param Session $session
100
-	 * @param Crypt $crypt
101
-	 * @param Recovery $recovery
102
-	 */
103
-	public function __construct(KeyManager $keyManager,
104
-								IUserManager $userManager,
105
-								ILogger $logger,
106
-								Setup $userSetup,
107
-								IUserSession $userSession,
108
-								Util $util,
109
-								Session $session,
110
-								Crypt $crypt,
111
-								Recovery $recovery) {
112
-		$this->keyManager = $keyManager;
113
-		$this->userManager = $userManager;
114
-		$this->logger = $logger;
115
-		$this->userSetup = $userSetup;
116
-		$this->userSession = $userSession;
117
-		$this->util = $util;
118
-		$this->session = $session;
119
-		$this->recovery = $recovery;
120
-		$this->crypt = $crypt;
121
-	}
122
-
123
-	/**
124
-	 * Connects Hooks
125
-	 *
126
-	 * @return null
127
-	 */
128
-	public function addHooks() {
129
-		OCUtil::connectHook('OC_User', 'post_login', $this, 'login');
130
-		OCUtil::connectHook('OC_User', 'logout', $this, 'logout');
131
-
132
-		// this hooks only make sense if no master key is used
133
-		if ($this->util->isMasterKeyEnabled() === false) {
134
-			OCUtil::connectHook('OC_User',
135
-				'post_setPassword',
136
-				$this,
137
-				'setPassphrase');
138
-
139
-			OCUtil::connectHook('OC_User',
140
-				'pre_setPassword',
141
-				$this,
142
-				'preSetPassphrase');
143
-
144
-			OCUtil::connectHook('\OC\Core\LostPassword\Controller\LostController',
145
-				'post_passwordReset',
146
-				$this,
147
-				'postPasswordReset');
148
-
149
-			OCUtil::connectHook('\OC\Core\LostPassword\Controller\LostController',
150
-				'pre_passwordReset',
151
-				$this,
152
-				'prePasswordReset');
153
-
154
-			OCUtil::connectHook('OC_User',
155
-				'post_createUser',
156
-				$this,
157
-				'postCreateUser');
158
-
159
-			OCUtil::connectHook('OC_User',
160
-				'post_deleteUser',
161
-				$this,
162
-				'postDeleteUser');
163
-		}
164
-	}
165
-
166
-
167
-	/**
168
-	 * Startup encryption backend upon user login
169
-	 *
170
-	 * @note This method should never be called for users using client side encryption
171
-	 * @param array $params
172
-	 * @return boolean|null
173
-	 */
174
-	public function login($params) {
175
-		// ensure filesystem is loaded
176
-		if (!\OC\Files\Filesystem::$loaded) {
177
-			$this->setupFS($params['uid']);
178
-		}
179
-		if ($this->util->isMasterKeyEnabled() === false) {
180
-			$this->userSetup->setupUser($params['uid'], $params['password']);
181
-		}
182
-
183
-		$this->keyManager->init($params['uid'], $params['password']);
184
-	}
185
-
186
-	/**
187
-	 * remove keys from session during logout
188
-	 */
189
-	public function logout() {
190
-		$this->session->clear();
191
-	}
192
-
193
-	/**
194
-	 * setup encryption backend upon user created
195
-	 *
196
-	 * @note This method should never be called for users using client side encryption
197
-	 * @param array $params
198
-	 */
199
-	public function postCreateUser($params) {
200
-		$this->userSetup->setupUser($params['uid'], $params['password']);
201
-	}
202
-
203
-	/**
204
-	 * cleanup encryption backend upon user deleted
205
-	 *
206
-	 * @param array $params : uid, password
207
-	 * @note This method should never be called for users using client side encryption
208
-	 */
209
-	public function postDeleteUser($params) {
210
-		$this->keyManager->deletePublicKey($params['uid']);
211
-	}
212
-
213
-	public function prePasswordReset($params) {
214
-		$user = $params['uid'];
215
-		self::$passwordResetUsers[$user] = true;
216
-	}
217
-
218
-	public function postPasswordReset($params) {
219
-		$uid = $params['uid'];
220
-		$password = $params['password'];
221
-		$this->keyManager->backupUserKeys('passwordReset', $uid);
222
-		$this->keyManager->deleteUserKeys($uid);
223
-		$this->userSetup->setupUser($uid, $password);
224
-		unset(self::$passwordResetUsers[$uid]);
225
-	}
226
-
227
-	/**
228
-	 * If the password can't be changed within Nextcloud, than update the key password in advance.
229
-	 *
230
-	 * @param array $params : uid, password
231
-	 * @return boolean|null
232
-	 */
233
-	public function preSetPassphrase($params) {
234
-		$user = $this->userManager->get($params['uid']);
235
-
236
-		if ($user && !$user->canChangePassword()) {
237
-			$this->setPassphrase($params);
238
-		}
239
-	}
240
-
241
-	/**
242
-	 * Change a user's encryption passphrase
243
-	 *
244
-	 * @param array $params keys: uid, password
245
-	 * @return boolean|null
246
-	 */
247
-	public function setPassphrase($params) {
248
-
249
-		// if we are in the process to resetting a user password, we have nothing
250
-		// to do here
251
-		if (isset(self::$passwordResetUsers[$params['uid']])) {
252
-			return true;
253
-		}
254
-
255
-		// Get existing decrypted private key
256
-		$user = $this->userSession->getUser();
257
-
258
-		// current logged in user changes his own password
259
-		if ($user && $params['uid'] === $user->getUID()) {
260
-			$privateKey = $this->session->getPrivateKey();
261
-
262
-			// Encrypt private key with new user pwd as passphrase
263
-			$encryptedPrivateKey = $this->crypt->encryptPrivateKey($privateKey, $params['password'], $params['uid']);
264
-
265
-			// Save private key
266
-			if ($encryptedPrivateKey) {
267
-				$this->keyManager->setPrivateKey($user->getUID(),
268
-					$this->crypt->generateHeader() . $encryptedPrivateKey);
269
-			} else {
270
-				$this->logger->error('Encryption could not update users encryption password');
271
-			}
272
-
273
-			// NOTE: Session does not need to be updated as the
274
-			// private key has not changed, only the passphrase
275
-			// used to decrypt it has changed
276
-		} else { // admin changed the password for a different user, create new keys and re-encrypt file keys
277
-			$userId = $params['uid'];
278
-			$this->initMountPoints($userId);
279
-			$recoveryPassword = isset($params['recoveryPassword']) ? $params['recoveryPassword'] : null;
280
-
281
-			$recoveryKeyId = $this->keyManager->getRecoveryKeyId();
282
-			$recoveryKey = $this->keyManager->getSystemPrivateKey($recoveryKeyId);
283
-			try {
284
-				$decryptedRecoveryKey = $this->crypt->decryptPrivateKey($recoveryKey, $recoveryPassword);
285
-			} catch (\Exception $e) {
286
-				$decryptedRecoveryKey = false;
287
-			}
288
-			if ($decryptedRecoveryKey === false) {
289
-				$message = 'Can not decrypt the recovery key. Maybe you provided the wrong password. Try again.';
290
-				throw new GenericEncryptionException($message, $message);
291
-			}
292
-
293
-			// we generate new keys if...
294
-			// ...we have a recovery password and the user enabled the recovery key
295
-			// ...encryption was activated for the first time (no keys exists)
296
-			// ...the user doesn't have any files
297
-			if (
298
-				($this->recovery->isRecoveryEnabledForUser($userId) && $recoveryPassword)
299
-				|| !$this->keyManager->userHasKeys($userId)
300
-				|| !$this->util->userHasFiles($userId)
301
-			) {
302
-
303
-				// backup old keys
304
-				//$this->backupAllKeys('recovery');
305
-
306
-				$newUserPassword = $params['password'];
307
-
308
-				$keyPair = $this->crypt->createKeyPair();
309
-
310
-				// Save public key
311
-				$this->keyManager->setPublicKey($userId, $keyPair['publicKey']);
312
-
313
-				// Encrypt private key with new password
314
-				$encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], $newUserPassword, $userId);
315
-
316
-				if ($encryptedKey) {
317
-					$this->keyManager->setPrivateKey($userId, $this->crypt->generateHeader() . $encryptedKey);
318
-
319
-					if ($recoveryPassword) { // if recovery key is set we can re-encrypt the key files
320
-						$this->recovery->recoverUsersFiles($recoveryPassword, $userId);
321
-					}
322
-				} else {
323
-					$this->logger->error('Encryption Could not update users encryption password');
324
-				}
325
-			}
326
-		}
327
-	}
328
-
329
-	/**
330
-	 * init mount points for given user
331
-	 *
332
-	 * @param string $user
333
-	 * @throws \OC\User\NoUserException
334
-	 */
335
-	protected function initMountPoints($user) {
336
-		Filesystem::initMountPoints($user);
337
-	}
338
-
339
-	/**
340
-	 * setup file system for user
341
-	 *
342
-	 * @param string $uid user id
343
-	 */
344
-	protected function setupFS($uid) {
345
-		\OC_Util::setupFS($uid);
346
-	}
47
+    /**
48
+     * list of user for which we perform a password reset
49
+     * @var array
50
+     */
51
+    protected static $passwordResetUsers = [];
52
+
53
+    /**
54
+     * @var KeyManager
55
+     */
56
+    private $keyManager;
57
+    /**
58
+     * @var IUserManager
59
+     */
60
+    private $userManager;
61
+    /**
62
+     * @var ILogger
63
+     */
64
+    private $logger;
65
+    /**
66
+     * @var Setup
67
+     */
68
+    private $userSetup;
69
+    /**
70
+     * @var IUserSession
71
+     */
72
+    private $userSession;
73
+    /**
74
+     * @var Util
75
+     */
76
+    private $util;
77
+    /**
78
+     * @var Session
79
+     */
80
+    private $session;
81
+    /**
82
+     * @var Recovery
83
+     */
84
+    private $recovery;
85
+    /**
86
+     * @var Crypt
87
+     */
88
+    private $crypt;
89
+
90
+    /**
91
+     * UserHooks constructor.
92
+     *
93
+     * @param KeyManager $keyManager
94
+     * @param IUserManager $userManager
95
+     * @param ILogger $logger
96
+     * @param Setup $userSetup
97
+     * @param IUserSession $userSession
98
+     * @param Util $util
99
+     * @param Session $session
100
+     * @param Crypt $crypt
101
+     * @param Recovery $recovery
102
+     */
103
+    public function __construct(KeyManager $keyManager,
104
+                                IUserManager $userManager,
105
+                                ILogger $logger,
106
+                                Setup $userSetup,
107
+                                IUserSession $userSession,
108
+                                Util $util,
109
+                                Session $session,
110
+                                Crypt $crypt,
111
+                                Recovery $recovery) {
112
+        $this->keyManager = $keyManager;
113
+        $this->userManager = $userManager;
114
+        $this->logger = $logger;
115
+        $this->userSetup = $userSetup;
116
+        $this->userSession = $userSession;
117
+        $this->util = $util;
118
+        $this->session = $session;
119
+        $this->recovery = $recovery;
120
+        $this->crypt = $crypt;
121
+    }
122
+
123
+    /**
124
+     * Connects Hooks
125
+     *
126
+     * @return null
127
+     */
128
+    public function addHooks() {
129
+        OCUtil::connectHook('OC_User', 'post_login', $this, 'login');
130
+        OCUtil::connectHook('OC_User', 'logout', $this, 'logout');
131
+
132
+        // this hooks only make sense if no master key is used
133
+        if ($this->util->isMasterKeyEnabled() === false) {
134
+            OCUtil::connectHook('OC_User',
135
+                'post_setPassword',
136
+                $this,
137
+                'setPassphrase');
138
+
139
+            OCUtil::connectHook('OC_User',
140
+                'pre_setPassword',
141
+                $this,
142
+                'preSetPassphrase');
143
+
144
+            OCUtil::connectHook('\OC\Core\LostPassword\Controller\LostController',
145
+                'post_passwordReset',
146
+                $this,
147
+                'postPasswordReset');
148
+
149
+            OCUtil::connectHook('\OC\Core\LostPassword\Controller\LostController',
150
+                'pre_passwordReset',
151
+                $this,
152
+                'prePasswordReset');
153
+
154
+            OCUtil::connectHook('OC_User',
155
+                'post_createUser',
156
+                $this,
157
+                'postCreateUser');
158
+
159
+            OCUtil::connectHook('OC_User',
160
+                'post_deleteUser',
161
+                $this,
162
+                'postDeleteUser');
163
+        }
164
+    }
165
+
166
+
167
+    /**
168
+     * Startup encryption backend upon user login
169
+     *
170
+     * @note This method should never be called for users using client side encryption
171
+     * @param array $params
172
+     * @return boolean|null
173
+     */
174
+    public function login($params) {
175
+        // ensure filesystem is loaded
176
+        if (!\OC\Files\Filesystem::$loaded) {
177
+            $this->setupFS($params['uid']);
178
+        }
179
+        if ($this->util->isMasterKeyEnabled() === false) {
180
+            $this->userSetup->setupUser($params['uid'], $params['password']);
181
+        }
182
+
183
+        $this->keyManager->init($params['uid'], $params['password']);
184
+    }
185
+
186
+    /**
187
+     * remove keys from session during logout
188
+     */
189
+    public function logout() {
190
+        $this->session->clear();
191
+    }
192
+
193
+    /**
194
+     * setup encryption backend upon user created
195
+     *
196
+     * @note This method should never be called for users using client side encryption
197
+     * @param array $params
198
+     */
199
+    public function postCreateUser($params) {
200
+        $this->userSetup->setupUser($params['uid'], $params['password']);
201
+    }
202
+
203
+    /**
204
+     * cleanup encryption backend upon user deleted
205
+     *
206
+     * @param array $params : uid, password
207
+     * @note This method should never be called for users using client side encryption
208
+     */
209
+    public function postDeleteUser($params) {
210
+        $this->keyManager->deletePublicKey($params['uid']);
211
+    }
212
+
213
+    public function prePasswordReset($params) {
214
+        $user = $params['uid'];
215
+        self::$passwordResetUsers[$user] = true;
216
+    }
217
+
218
+    public function postPasswordReset($params) {
219
+        $uid = $params['uid'];
220
+        $password = $params['password'];
221
+        $this->keyManager->backupUserKeys('passwordReset', $uid);
222
+        $this->keyManager->deleteUserKeys($uid);
223
+        $this->userSetup->setupUser($uid, $password);
224
+        unset(self::$passwordResetUsers[$uid]);
225
+    }
226
+
227
+    /**
228
+     * If the password can't be changed within Nextcloud, than update the key password in advance.
229
+     *
230
+     * @param array $params : uid, password
231
+     * @return boolean|null
232
+     */
233
+    public function preSetPassphrase($params) {
234
+        $user = $this->userManager->get($params['uid']);
235
+
236
+        if ($user && !$user->canChangePassword()) {
237
+            $this->setPassphrase($params);
238
+        }
239
+    }
240
+
241
+    /**
242
+     * Change a user's encryption passphrase
243
+     *
244
+     * @param array $params keys: uid, password
245
+     * @return boolean|null
246
+     */
247
+    public function setPassphrase($params) {
248
+
249
+        // if we are in the process to resetting a user password, we have nothing
250
+        // to do here
251
+        if (isset(self::$passwordResetUsers[$params['uid']])) {
252
+            return true;
253
+        }
254
+
255
+        // Get existing decrypted private key
256
+        $user = $this->userSession->getUser();
257
+
258
+        // current logged in user changes his own password
259
+        if ($user && $params['uid'] === $user->getUID()) {
260
+            $privateKey = $this->session->getPrivateKey();
261
+
262
+            // Encrypt private key with new user pwd as passphrase
263
+            $encryptedPrivateKey = $this->crypt->encryptPrivateKey($privateKey, $params['password'], $params['uid']);
264
+
265
+            // Save private key
266
+            if ($encryptedPrivateKey) {
267
+                $this->keyManager->setPrivateKey($user->getUID(),
268
+                    $this->crypt->generateHeader() . $encryptedPrivateKey);
269
+            } else {
270
+                $this->logger->error('Encryption could not update users encryption password');
271
+            }
272
+
273
+            // NOTE: Session does not need to be updated as the
274
+            // private key has not changed, only the passphrase
275
+            // used to decrypt it has changed
276
+        } else { // admin changed the password for a different user, create new keys and re-encrypt file keys
277
+            $userId = $params['uid'];
278
+            $this->initMountPoints($userId);
279
+            $recoveryPassword = isset($params['recoveryPassword']) ? $params['recoveryPassword'] : null;
280
+
281
+            $recoveryKeyId = $this->keyManager->getRecoveryKeyId();
282
+            $recoveryKey = $this->keyManager->getSystemPrivateKey($recoveryKeyId);
283
+            try {
284
+                $decryptedRecoveryKey = $this->crypt->decryptPrivateKey($recoveryKey, $recoveryPassword);
285
+            } catch (\Exception $e) {
286
+                $decryptedRecoveryKey = false;
287
+            }
288
+            if ($decryptedRecoveryKey === false) {
289
+                $message = 'Can not decrypt the recovery key. Maybe you provided the wrong password. Try again.';
290
+                throw new GenericEncryptionException($message, $message);
291
+            }
292
+
293
+            // we generate new keys if...
294
+            // ...we have a recovery password and the user enabled the recovery key
295
+            // ...encryption was activated for the first time (no keys exists)
296
+            // ...the user doesn't have any files
297
+            if (
298
+                ($this->recovery->isRecoveryEnabledForUser($userId) && $recoveryPassword)
299
+                || !$this->keyManager->userHasKeys($userId)
300
+                || !$this->util->userHasFiles($userId)
301
+            ) {
302
+
303
+                // backup old keys
304
+                //$this->backupAllKeys('recovery');
305
+
306
+                $newUserPassword = $params['password'];
307
+
308
+                $keyPair = $this->crypt->createKeyPair();
309
+
310
+                // Save public key
311
+                $this->keyManager->setPublicKey($userId, $keyPair['publicKey']);
312
+
313
+                // Encrypt private key with new password
314
+                $encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], $newUserPassword, $userId);
315
+
316
+                if ($encryptedKey) {
317
+                    $this->keyManager->setPrivateKey($userId, $this->crypt->generateHeader() . $encryptedKey);
318
+
319
+                    if ($recoveryPassword) { // if recovery key is set we can re-encrypt the key files
320
+                        $this->recovery->recoverUsersFiles($recoveryPassword, $userId);
321
+                    }
322
+                } else {
323
+                    $this->logger->error('Encryption Could not update users encryption password');
324
+                }
325
+            }
326
+        }
327
+    }
328
+
329
+    /**
330
+     * init mount points for given user
331
+     *
332
+     * @param string $user
333
+     * @throws \OC\User\NoUserException
334
+     */
335
+    protected function initMountPoints($user) {
336
+        Filesystem::initMountPoints($user);
337
+    }
338
+
339
+    /**
340
+     * setup file system for user
341
+     *
342
+     * @param string $uid user id
343
+     */
344
+    protected function setupFS($uid) {
345
+        \OC_Util::setupFS($uid);
346
+    }
347 347
 }
Please login to merge, or discard this patch.
apps/settings/lib/Controller/LogSettingsController.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -35,28 +35,28 @@
 block discarded – undo
35 35
 
36 36
 class LogSettingsController extends Controller {
37 37
 
38
-	/** @var Log */
39
-	private $log;
38
+    /** @var Log */
39
+    private $log;
40 40
 
41
-	public function __construct(string $appName, IRequest $request, Log $logger) {
42
-		parent::__construct($appName, $request);
43
-		$this->log = $logger;
44
-	}
41
+    public function __construct(string $appName, IRequest $request, Log $logger) {
42
+        parent::__construct($appName, $request);
43
+        $this->log = $logger;
44
+    }
45 45
 
46
-	/**
47
-	 * download logfile
48
-	 *
49
-	 * @NoCSRFRequired
50
-	 *
51
-	 * @return StreamResponse
52
-	 */
53
-	public function download() {
54
-		if (!$this->log instanceof Log) {
55
-			throw new \UnexpectedValueException('Log file not available');
56
-		}
57
-		$resp = new StreamResponse($this->log->getLogPath());
58
-		$resp->addHeader('Content-Type', 'application/octet-stream');
59
-		$resp->addHeader('Content-Disposition', 'attachment; filename="nextcloud.log"');
60
-		return $resp;
61
-	}
46
+    /**
47
+     * download logfile
48
+     *
49
+     * @NoCSRFRequired
50
+     *
51
+     * @return StreamResponse
52
+     */
53
+    public function download() {
54
+        if (!$this->log instanceof Log) {
55
+            throw new \UnexpectedValueException('Log file not available');
56
+        }
57
+        $resp = new StreamResponse($this->log->getLogPath());
58
+        $resp->addHeader('Content-Type', 'application/octet-stream');
59
+        $resp->addHeader('Content-Disposition', 'attachment; filename="nextcloud.log"');
60
+        return $resp;
61
+    }
62 62
 }
Please login to merge, or discard this patch.
apps/settings/templates/settings/admin/overview.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,9 +46,9 @@
 block discarded – undo
46 46
 	</div>
47 47
 
48 48
 	<div id="postsetupchecks" data-check-wellknown="<?php if ($_['checkForWorkingWellKnownSetup']) {
49
-	p('true');
49
+    p('true');
50 50
 } else {
51
-	p('false');
51
+    p('false');
52 52
 } ?>">
53 53
 		<ul class="errors hidden"></ul>
54 54
 		<ul class="warnings hidden"></ul>
Please login to merge, or discard this patch.
apps/settings/templates/settings/additional.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 ?>
28 28
 
29 29
 <?php foreach ($_['forms'] as $form) {
30
-	if (isset($form['form'])) {?>
30
+    if (isset($form['form'])) {?>
31 31
 		<div id="<?php isset($form['anchor']) ? p($form['anchor']) : p('');?>"><?php print_unescaped($form['form']);?></div>
32 32
 	<?php }
33 33
 } ?>
Please login to merge, or discard this patch.
apps/settings/templates/settings-vue.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 
27 27
 // Do we have some data to inject ?
28 28
 if (is_array($_['serverData'])) {
29
-	?>
29
+    ?>
30 30
 <span id="serverData" data-server="<?php p(json_encode($_['serverData'])); ?>"></span>
31 31
 <?php
32 32
 } ?>
Please login to merge, or discard this patch.
apps/files/lib/Settings/PersonalSettings.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -31,15 +31,15 @@
 block discarded – undo
31 31
 use OCP\Settings\ISettings;
32 32
 
33 33
 class PersonalSettings implements ISettings {
34
-	public function getForm(): TemplateResponse {
35
-		return new TemplateResponse(Application::APP_ID, 'settings-personal');
36
-	}
34
+    public function getForm(): TemplateResponse {
35
+        return new TemplateResponse(Application::APP_ID, 'settings-personal');
36
+    }
37 37
 
38
-	public function getSection(): string {
39
-		return 'sharing';
40
-	}
38
+    public function getSection(): string {
39
+        return 'sharing';
40
+    }
41 41
 
42
-	public function getPriority(): int {
43
-		return 90;
44
-	}
42
+    public function getPriority(): int {
43
+        return 90;
44
+    }
45 45
 }
Please login to merge, or discard this patch.
apps/files/lib/Collaboration/Resources/ResourceProvider.php 1 patch
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -37,100 +37,100 @@
 block discarded – undo
37 37
 use OCP\IUser;
38 38
 
39 39
 class ResourceProvider implements IProvider {
40
-	public const RESOURCE_TYPE = 'file';
41
-
42
-	/** @var IRootFolder */
43
-	protected $rootFolder;
44
-	/** @var IPreview */
45
-	private $preview;
46
-	/** @var IURLGenerator */
47
-	private $urlGenerator;
48
-
49
-	/** @var array */
50
-	protected $nodes = [];
51
-
52
-	public function __construct(IRootFolder $rootFolder,
53
-								IPreview $preview,
54
-								IURLGenerator $urlGenerator) {
55
-		$this->rootFolder = $rootFolder;
56
-		$this->preview = $preview;
57
-		$this->urlGenerator = $urlGenerator;
58
-	}
59
-
60
-	private function getNode(IResource $resource): ?Node {
61
-		if (isset($this->nodes[(int) $resource->getId()])) {
62
-			return $this->nodes[(int) $resource->getId()];
63
-		}
64
-		$nodes = $this->rootFolder->getById((int) $resource->getId());
65
-		if (!empty($nodes)) {
66
-			$this->nodes[(int) $resource->getId()] = array_shift($nodes);
67
-			return $this->nodes[(int) $resource->getId()];
68
-		}
69
-		return null;
70
-	}
71
-
72
-	/**
73
-	 * @param IResource $resource
74
-	 * @return array
75
-	 * @since 16.0.0
76
-	 */
77
-	public function getResourceRichObject(IResource $resource): array {
78
-		if (isset($this->nodes[(int) $resource->getId()])) {
79
-			$node = $this->nodes[(int) $resource->getId()]->getPath();
80
-		} else {
81
-			$node = $this->getNode($resource);
82
-		}
83
-
84
-		if ($node instanceof Node) {
85
-			$link = $this->urlGenerator->linkToRouteAbsolute(
86
-				'files.viewcontroller.showFile',
87
-				['fileid' => $resource->getId()]
88
-			);
89
-			return [
90
-				'type' => 'file',
91
-				'id' => $resource->getId(),
92
-				'name' => $node->getName(),
93
-				'path' => $node->getInternalPath(),
94
-				'link' => $link,
95
-				'mimetype' => $node->getMimetype(),
96
-				'preview-available' => $this->preview->isAvailable($node),
97
-			];
98
-		}
99
-
100
-		throw new ResourceException('File not found');
101
-	}
102
-
103
-	/**
104
-	 * Can a user/guest access the collection
105
-	 *
106
-	 * @param IResource $resource
107
-	 * @param IUser $user
108
-	 * @return bool
109
-	 * @since 16.0.0
110
-	 */
111
-	public function canAccessResource(IResource $resource, IUser $user = null): bool {
112
-		if (!$user instanceof IUser) {
113
-			return false;
114
-		}
115
-
116
-		$userFolder = $this->rootFolder->getUserFolder($user->getUID());
117
-		$nodes = $userFolder->getById((int) $resource->getId());
118
-
119
-		if (!empty($nodes)) {
120
-			$this->nodes[(int) $resource->getId()] = array_shift($nodes);
121
-			return true;
122
-		}
123
-
124
-		return false;
125
-	}
126
-
127
-	/**
128
-	 * Get the resource type of the provider
129
-	 *
130
-	 * @return string
131
-	 * @since 16.0.0
132
-	 */
133
-	public function getType(): string {
134
-		return self::RESOURCE_TYPE;
135
-	}
40
+    public const RESOURCE_TYPE = 'file';
41
+
42
+    /** @var IRootFolder */
43
+    protected $rootFolder;
44
+    /** @var IPreview */
45
+    private $preview;
46
+    /** @var IURLGenerator */
47
+    private $urlGenerator;
48
+
49
+    /** @var array */
50
+    protected $nodes = [];
51
+
52
+    public function __construct(IRootFolder $rootFolder,
53
+                                IPreview $preview,
54
+                                IURLGenerator $urlGenerator) {
55
+        $this->rootFolder = $rootFolder;
56
+        $this->preview = $preview;
57
+        $this->urlGenerator = $urlGenerator;
58
+    }
59
+
60
+    private function getNode(IResource $resource): ?Node {
61
+        if (isset($this->nodes[(int) $resource->getId()])) {
62
+            return $this->nodes[(int) $resource->getId()];
63
+        }
64
+        $nodes = $this->rootFolder->getById((int) $resource->getId());
65
+        if (!empty($nodes)) {
66
+            $this->nodes[(int) $resource->getId()] = array_shift($nodes);
67
+            return $this->nodes[(int) $resource->getId()];
68
+        }
69
+        return null;
70
+    }
71
+
72
+    /**
73
+     * @param IResource $resource
74
+     * @return array
75
+     * @since 16.0.0
76
+     */
77
+    public function getResourceRichObject(IResource $resource): array {
78
+        if (isset($this->nodes[(int) $resource->getId()])) {
79
+            $node = $this->nodes[(int) $resource->getId()]->getPath();
80
+        } else {
81
+            $node = $this->getNode($resource);
82
+        }
83
+
84
+        if ($node instanceof Node) {
85
+            $link = $this->urlGenerator->linkToRouteAbsolute(
86
+                'files.viewcontroller.showFile',
87
+                ['fileid' => $resource->getId()]
88
+            );
89
+            return [
90
+                'type' => 'file',
91
+                'id' => $resource->getId(),
92
+                'name' => $node->getName(),
93
+                'path' => $node->getInternalPath(),
94
+                'link' => $link,
95
+                'mimetype' => $node->getMimetype(),
96
+                'preview-available' => $this->preview->isAvailable($node),
97
+            ];
98
+        }
99
+
100
+        throw new ResourceException('File not found');
101
+    }
102
+
103
+    /**
104
+     * Can a user/guest access the collection
105
+     *
106
+     * @param IResource $resource
107
+     * @param IUser $user
108
+     * @return bool
109
+     * @since 16.0.0
110
+     */
111
+    public function canAccessResource(IResource $resource, IUser $user = null): bool {
112
+        if (!$user instanceof IUser) {
113
+            return false;
114
+        }
115
+
116
+        $userFolder = $this->rootFolder->getUserFolder($user->getUID());
117
+        $nodes = $userFolder->getById((int) $resource->getId());
118
+
119
+        if (!empty($nodes)) {
120
+            $this->nodes[(int) $resource->getId()] = array_shift($nodes);
121
+            return true;
122
+        }
123
+
124
+        return false;
125
+    }
126
+
127
+    /**
128
+     * Get the resource type of the provider
129
+     *
130
+     * @return string
131
+     * @since 16.0.0
132
+     */
133
+    public function getType(): string {
134
+        return self::RESOURCE_TYPE;
135
+    }
136 136
 }
Please login to merge, or discard this patch.
apps/files/lib/BackgroundJob/TransferOwnership.php 1 patch
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -42,141 +42,141 @@
 block discarded – undo
42 42
 
43 43
 class TransferOwnership extends QueuedJob {
44 44
 
45
-	/** @var IUserManager $userManager */
46
-	private $userManager;
47
-
48
-	/** @var OwnershipTransferService */
49
-	private $transferService;
50
-
51
-	/** @var ILogger */
52
-	private $logger;
53
-
54
-	/** @var NotificationManager */
55
-	private $notificationManager;
56
-
57
-	/** @var TransferOwnershipMapper */
58
-	private $mapper;
59
-	/** @var IRootFolder */
60
-	private $rootFolder;
61
-
62
-	public function __construct(ITimeFactory $timeFactory,
63
-								IUserManager $userManager,
64
-								OwnershipTransferService $transferService,
65
-								ILogger $logger,
66
-								NotificationManager $notificationManager,
67
-								TransferOwnershipMapper $mapper,
68
-								IRootFolder $rootFolder) {
69
-		parent::__construct($timeFactory);
70
-
71
-		$this->userManager = $userManager;
72
-		$this->transferService = $transferService;
73
-		$this->logger = $logger;
74
-		$this->notificationManager = $notificationManager;
75
-		$this->mapper = $mapper;
76
-		$this->rootFolder = $rootFolder;
77
-	}
78
-
79
-	protected function run($argument) {
80
-		$id = $argument['id'];
81
-
82
-		$transfer = $this->mapper->getById($id);
83
-		$sourceUser = $transfer->getSourceUser();
84
-		$destinationUser = $transfer->getTargetUser();
85
-		$fileId = $transfer->getFileId();
86
-
87
-		$userFolder = $this->rootFolder->getUserFolder($sourceUser);
88
-		$nodes = $userFolder->getById($fileId);
89
-
90
-		if (empty($nodes)) {
91
-			$this->logger->alert('Could not transfer ownership: Node not found');
92
-			$this->failedNotication($transfer);
93
-			return;
94
-		}
95
-		$path = $userFolder->getRelativePath($nodes[0]->getPath());
96
-
97
-		$sourceUserObject = $this->userManager->get($sourceUser);
98
-		$destinationUserObject = $this->userManager->get($destinationUser);
99
-
100
-		if (!$sourceUserObject instanceof IUser) {
101
-			$this->logger->alert('Could not transfer ownership: Unknown source user ' . $sourceUser);
102
-			$this->failedNotication($transfer);
103
-			return;
104
-		}
105
-
106
-		if (!$destinationUserObject instanceof IUser) {
107
-			$this->logger->alert("Unknown destination user $destinationUser");
108
-			$this->failedNotication($transfer);
109
-			return;
110
-		}
111
-
112
-		try {
113
-			$this->transferService->transfer(
114
-				$sourceUserObject,
115
-				$destinationUserObject,
116
-				ltrim($path, '/')
117
-			);
118
-			$this->successNotification($transfer);
119
-		} catch (TransferOwnershipException $e) {
120
-			$this->logger->logException($e);
121
-			$this->failedNotication($transfer);
122
-		}
123
-
124
-		$this->mapper->delete($transfer);
125
-	}
126
-
127
-	private function failedNotication(Transfer $transfer): void {
128
-		// Send notification to source user
129
-		$notification = $this->notificationManager->createNotification();
130
-		$notification->setUser($transfer->getSourceUser())
131
-			->setApp(Application::APP_ID)
132
-			->setDateTime($this->time->getDateTime())
133
-			->setSubject('transferOwnershipFailedSource', [
134
-				'sourceUser' => $transfer->getSourceUser(),
135
-				'targetUser' => $transfer->getTargetUser(),
136
-				'nodeName' => $transfer->getNodeName(),
137
-			])
138
-			->setObject('transfer', (string)$transfer->getId());
139
-		$this->notificationManager->notify($notification);
140
-
141
-		// Send notification to source user
142
-		$notification = $this->notificationManager->createNotification();
143
-		$notification->setUser($transfer->getTargetUser())
144
-			->setApp(Application::APP_ID)
145
-			->setDateTime($this->time->getDateTime())
146
-			->setSubject('transferOwnershipFailedTarget', [
147
-				'sourceUser' => $transfer->getSourceUser(),
148
-				'targetUser' => $transfer->getTargetUser(),
149
-				'nodeName' => $transfer->getNodeName(),
150
-			])
151
-			->setObject('transfer', (string)$transfer->getId());
152
-		$this->notificationManager->notify($notification);
153
-	}
154
-
155
-	private function successNotification(Transfer $transfer): void {
156
-		// Send notification to source user
157
-		$notification = $this->notificationManager->createNotification();
158
-		$notification->setUser($transfer->getSourceUser())
159
-			->setApp(Application::APP_ID)
160
-			->setDateTime($this->time->getDateTime())
161
-			->setSubject('transferOwnershipDoneSource', [
162
-				'sourceUser' => $transfer->getSourceUser(),
163
-				'targetUser' => $transfer->getTargetUser(),
164
-				'nodeName' => $transfer->getNodeName(),
165
-			])
166
-			->setObject('transfer', (string)$transfer->getId());
167
-		$this->notificationManager->notify($notification);
168
-
169
-		// Send notification to source user
170
-		$notification = $this->notificationManager->createNotification();
171
-		$notification->setUser($transfer->getTargetUser())
172
-			->setApp(Application::APP_ID)
173
-			->setDateTime($this->time->getDateTime())
174
-			->setSubject('transferOwnershipDoneTarget', [
175
-				'sourceUser' => $transfer->getSourceUser(),
176
-				'targetUser' => $transfer->getTargetUser(),
177
-				'nodeName' => $transfer->getNodeName(),
178
-			])
179
-			->setObject('transfer', (string)$transfer->getId());
180
-		$this->notificationManager->notify($notification);
181
-	}
45
+    /** @var IUserManager $userManager */
46
+    private $userManager;
47
+
48
+    /** @var OwnershipTransferService */
49
+    private $transferService;
50
+
51
+    /** @var ILogger */
52
+    private $logger;
53
+
54
+    /** @var NotificationManager */
55
+    private $notificationManager;
56
+
57
+    /** @var TransferOwnershipMapper */
58
+    private $mapper;
59
+    /** @var IRootFolder */
60
+    private $rootFolder;
61
+
62
+    public function __construct(ITimeFactory $timeFactory,
63
+                                IUserManager $userManager,
64
+                                OwnershipTransferService $transferService,
65
+                                ILogger $logger,
66
+                                NotificationManager $notificationManager,
67
+                                TransferOwnershipMapper $mapper,
68
+                                IRootFolder $rootFolder) {
69
+        parent::__construct($timeFactory);
70
+
71
+        $this->userManager = $userManager;
72
+        $this->transferService = $transferService;
73
+        $this->logger = $logger;
74
+        $this->notificationManager = $notificationManager;
75
+        $this->mapper = $mapper;
76
+        $this->rootFolder = $rootFolder;
77
+    }
78
+
79
+    protected function run($argument) {
80
+        $id = $argument['id'];
81
+
82
+        $transfer = $this->mapper->getById($id);
83
+        $sourceUser = $transfer->getSourceUser();
84
+        $destinationUser = $transfer->getTargetUser();
85
+        $fileId = $transfer->getFileId();
86
+
87
+        $userFolder = $this->rootFolder->getUserFolder($sourceUser);
88
+        $nodes = $userFolder->getById($fileId);
89
+
90
+        if (empty($nodes)) {
91
+            $this->logger->alert('Could not transfer ownership: Node not found');
92
+            $this->failedNotication($transfer);
93
+            return;
94
+        }
95
+        $path = $userFolder->getRelativePath($nodes[0]->getPath());
96
+
97
+        $sourceUserObject = $this->userManager->get($sourceUser);
98
+        $destinationUserObject = $this->userManager->get($destinationUser);
99
+
100
+        if (!$sourceUserObject instanceof IUser) {
101
+            $this->logger->alert('Could not transfer ownership: Unknown source user ' . $sourceUser);
102
+            $this->failedNotication($transfer);
103
+            return;
104
+        }
105
+
106
+        if (!$destinationUserObject instanceof IUser) {
107
+            $this->logger->alert("Unknown destination user $destinationUser");
108
+            $this->failedNotication($transfer);
109
+            return;
110
+        }
111
+
112
+        try {
113
+            $this->transferService->transfer(
114
+                $sourceUserObject,
115
+                $destinationUserObject,
116
+                ltrim($path, '/')
117
+            );
118
+            $this->successNotification($transfer);
119
+        } catch (TransferOwnershipException $e) {
120
+            $this->logger->logException($e);
121
+            $this->failedNotication($transfer);
122
+        }
123
+
124
+        $this->mapper->delete($transfer);
125
+    }
126
+
127
+    private function failedNotication(Transfer $transfer): void {
128
+        // Send notification to source user
129
+        $notification = $this->notificationManager->createNotification();
130
+        $notification->setUser($transfer->getSourceUser())
131
+            ->setApp(Application::APP_ID)
132
+            ->setDateTime($this->time->getDateTime())
133
+            ->setSubject('transferOwnershipFailedSource', [
134
+                'sourceUser' => $transfer->getSourceUser(),
135
+                'targetUser' => $transfer->getTargetUser(),
136
+                'nodeName' => $transfer->getNodeName(),
137
+            ])
138
+            ->setObject('transfer', (string)$transfer->getId());
139
+        $this->notificationManager->notify($notification);
140
+
141
+        // Send notification to source user
142
+        $notification = $this->notificationManager->createNotification();
143
+        $notification->setUser($transfer->getTargetUser())
144
+            ->setApp(Application::APP_ID)
145
+            ->setDateTime($this->time->getDateTime())
146
+            ->setSubject('transferOwnershipFailedTarget', [
147
+                'sourceUser' => $transfer->getSourceUser(),
148
+                'targetUser' => $transfer->getTargetUser(),
149
+                'nodeName' => $transfer->getNodeName(),
150
+            ])
151
+            ->setObject('transfer', (string)$transfer->getId());
152
+        $this->notificationManager->notify($notification);
153
+    }
154
+
155
+    private function successNotification(Transfer $transfer): void {
156
+        // Send notification to source user
157
+        $notification = $this->notificationManager->createNotification();
158
+        $notification->setUser($transfer->getSourceUser())
159
+            ->setApp(Application::APP_ID)
160
+            ->setDateTime($this->time->getDateTime())
161
+            ->setSubject('transferOwnershipDoneSource', [
162
+                'sourceUser' => $transfer->getSourceUser(),
163
+                'targetUser' => $transfer->getTargetUser(),
164
+                'nodeName' => $transfer->getNodeName(),
165
+            ])
166
+            ->setObject('transfer', (string)$transfer->getId());
167
+        $this->notificationManager->notify($notification);
168
+
169
+        // Send notification to source user
170
+        $notification = $this->notificationManager->createNotification();
171
+        $notification->setUser($transfer->getTargetUser())
172
+            ->setApp(Application::APP_ID)
173
+            ->setDateTime($this->time->getDateTime())
174
+            ->setSubject('transferOwnershipDoneTarget', [
175
+                'sourceUser' => $transfer->getSourceUser(),
176
+                'targetUser' => $transfer->getTargetUser(),
177
+                'nodeName' => $transfer->getNodeName(),
178
+            ])
179
+            ->setObject('transfer', (string)$transfer->getId());
180
+        $this->notificationManager->notify($notification);
181
+    }
182 182
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Integration/ExternalCalendar.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -33,99 +33,99 @@
 block discarded – undo
33 33
  */
34 34
 abstract class ExternalCalendar implements CalDAV\ICalendar, DAV\IProperties {
35 35
 
36
-	/** @var string */
37
-	private const PREFIX = 'app-generated';
36
+    /** @var string */
37
+    private const PREFIX = 'app-generated';
38 38
 
39
-	/**
40
-	 * @var string
41
-	 *
42
-	 * Double dash is a valid delimiter,
43
-	 * because it will always split the calendarURIs correctly:
44
-	 * - our prefix contains only one dash and won't be split
45
-	 * - appIds are not allowed to contain dashes as per spec:
46
-	 * > must contain only lowercase ASCII characters and underscore
47
-	 * - explode has a limit of three, so even if the app-generated
48
-	 *   calendar uri has double dashes, it won't be split
49
-	 */
50
-	private const DELIMITER = '--';
39
+    /**
40
+     * @var string
41
+     *
42
+     * Double dash is a valid delimiter,
43
+     * because it will always split the calendarURIs correctly:
44
+     * - our prefix contains only one dash and won't be split
45
+     * - appIds are not allowed to contain dashes as per spec:
46
+     * > must contain only lowercase ASCII characters and underscore
47
+     * - explode has a limit of three, so even if the app-generated
48
+     *   calendar uri has double dashes, it won't be split
49
+     */
50
+    private const DELIMITER = '--';
51 51
 
52
-	/** @var string */
53
-	private $appId;
52
+    /** @var string */
53
+    private $appId;
54 54
 
55
-	/** @var string */
56
-	private $calendarUri;
55
+    /** @var string */
56
+    private $calendarUri;
57 57
 
58
-	/**
59
-	 * ExternalCalendar constructor.
60
-	 *
61
-	 * @param string $appId
62
-	 * @param string $calendarUri
63
-	 */
64
-	public function __construct(string $appId, string $calendarUri) {
65
-		$this->appId = $appId;
66
-		$this->calendarUri = $calendarUri;
67
-	}
58
+    /**
59
+     * ExternalCalendar constructor.
60
+     *
61
+     * @param string $appId
62
+     * @param string $calendarUri
63
+     */
64
+    public function __construct(string $appId, string $calendarUri) {
65
+        $this->appId = $appId;
66
+        $this->calendarUri = $calendarUri;
67
+    }
68 68
 
69
-	/**
70
-	 * @inheritDoc
71
-	 */
72
-	final public function getName() {
73
-		return implode(self::DELIMITER, [
74
-			self::PREFIX,
75
-			$this->appId,
76
-			$this->calendarUri,
77
-		]);
78
-	}
69
+    /**
70
+     * @inheritDoc
71
+     */
72
+    final public function getName() {
73
+        return implode(self::DELIMITER, [
74
+            self::PREFIX,
75
+            $this->appId,
76
+            $this->calendarUri,
77
+        ]);
78
+    }
79 79
 
80
-	/**
81
-	 * @inheritDoc
82
-	 */
83
-	final public function setName($name) {
84
-		throw new DAV\Exception\MethodNotAllowed('Renaming calendars is not yet supported');
85
-	}
80
+    /**
81
+     * @inheritDoc
82
+     */
83
+    final public function setName($name) {
84
+        throw new DAV\Exception\MethodNotAllowed('Renaming calendars is not yet supported');
85
+    }
86 86
 
87
-	/**
88
-	 * @inheritDoc
89
-	 */
90
-	final public function createDirectory($name) {
91
-		throw new DAV\Exception\MethodNotAllowed('Creating collections in calendar objects is not allowed');
92
-	}
87
+    /**
88
+     * @inheritDoc
89
+     */
90
+    final public function createDirectory($name) {
91
+        throw new DAV\Exception\MethodNotAllowed('Creating collections in calendar objects is not allowed');
92
+    }
93 93
 
94
-	/**
95
-	 * Checks whether the calendar uri is app-generated
96
-	 *
97
-	 * @param string $calendarUri
98
-	 * @return bool
99
-	 */
100
-	public static function isAppGeneratedCalendar(string $calendarUri):bool {
101
-		return strpos($calendarUri, self::PREFIX) === 0 && substr_count($calendarUri, self::DELIMITER) >= 2;
102
-	}
94
+    /**
95
+     * Checks whether the calendar uri is app-generated
96
+     *
97
+     * @param string $calendarUri
98
+     * @return bool
99
+     */
100
+    public static function isAppGeneratedCalendar(string $calendarUri):bool {
101
+        return strpos($calendarUri, self::PREFIX) === 0 && substr_count($calendarUri, self::DELIMITER) >= 2;
102
+    }
103 103
 
104
-	/**
105
-	 * Splits an app-generated calendar-uri into appId and calendarUri
106
-	 *
107
-	 * @param string $calendarUri
108
-	 * @return array
109
-	 */
110
-	public static function splitAppGeneratedCalendarUri(string $calendarUri):array {
111
-		$array = array_slice(explode(self::DELIMITER, $calendarUri, 3), 1);
112
-		// Check the array has expected amount of elements
113
-		// and none of them is an empty string
114
-		if (\count($array) !== 2 || \in_array('', $array, true)) {
115
-			throw new \InvalidArgumentException('Provided calendar uri was not app-generated');
116
-		}
104
+    /**
105
+     * Splits an app-generated calendar-uri into appId and calendarUri
106
+     *
107
+     * @param string $calendarUri
108
+     * @return array
109
+     */
110
+    public static function splitAppGeneratedCalendarUri(string $calendarUri):array {
111
+        $array = array_slice(explode(self::DELIMITER, $calendarUri, 3), 1);
112
+        // Check the array has expected amount of elements
113
+        // and none of them is an empty string
114
+        if (\count($array) !== 2 || \in_array('', $array, true)) {
115
+            throw new \InvalidArgumentException('Provided calendar uri was not app-generated');
116
+        }
117 117
 
118
-		return $array;
119
-	}
118
+        return $array;
119
+    }
120 120
 
121
-	/**
122
-	 * Checks whether a calendar-name, the user wants to create, violates
123
-	 * the reserved name for calendar uris
124
-	 *
125
-	 * @param string $calendarUri
126
-	 * @return bool
127
-	 */
128
-	public static function doesViolateReservedName(string $calendarUri):bool {
129
-		return strpos($calendarUri, self::PREFIX) === 0;
130
-	}
121
+    /**
122
+     * Checks whether a calendar-name, the user wants to create, violates
123
+     * the reserved name for calendar uris
124
+     *
125
+     * @param string $calendarUri
126
+     * @return bool
127
+     */
128
+    public static function doesViolateReservedName(string $calendarUri):bool {
129
+        return strpos($calendarUri, self::PREFIX) === 0;
130
+    }
131 131
 }
Please login to merge, or discard this patch.