Completed
Pull Request — master (#3856)
by Lukas
14:14
created
lib/private/User/Database.php 2 patches
Indentation   +311 added lines, -311 removed lines patch added patch discarded remove patch
@@ -62,315 +62,315 @@
 block discarded – undo
62 62
  * Class for user management in a SQL Database (e.g. MySQL, SQLite)
63 63
  */
64 64
 class Database extends Backend implements IUserBackend {
65
-	/** @var CappedMemoryCache */
66
-	private $cache;
67
-
68
-	/** @var EventDispatcher */
69
-	private $eventDispatcher;
70
-
71
-	/**
72
-	 * \OC\User\Database constructor.
73
-	 *
74
-	 * @param EventDispatcher $eventDispatcher
75
-	 */
76
-	public function __construct($eventDispatcher = null) {
77
-		$this->cache = new CappedMemoryCache();
78
-		$this->eventDispatcher = $eventDispatcher ? $eventDispatcher : \OC::$server->getEventDispatcher();
79
-	}
80
-
81
-	/**
82
-	 * Create a new user
83
-	 * @param string $uid The username of the user to create
84
-	 * @param string $password The password of the new user
85
-	 * @return bool
86
-	 *
87
-	 * Creates a new user. Basic checking of username is done in OC_User
88
-	 * itself, not in its subclasses.
89
-	 */
90
-	public function createUser($uid, $password) {
91
-		if (!$this->userExists($uid)) {
92
-			$event = new GenericEvent($password);
93
-			$this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event);
94
-			$query = \OC_DB::prepare('INSERT INTO `*PREFIX*users` ( `uid`, `password` ) VALUES( ?, ? )');
95
-			$result = $query->execute(array($uid, \OC::$server->getHasher()->hash($password)));
96
-
97
-			// Clear cache
98
-			unset($this->cache[$uid]);
99
-
100
-			return $result ? true : false;
101
-		}
102
-
103
-		return false;
104
-	}
105
-
106
-	/**
107
-	 * delete a user
108
-	 * @param string $uid The username of the user to delete
109
-	 * @return bool
110
-	 *
111
-	 * Deletes a user
112
-	 */
113
-	public function deleteUser($uid) {
114
-		// Delete user-group-relation
115
-		$query = \OC_DB::prepare('DELETE FROM `*PREFIX*users` WHERE `uid` = ?');
116
-		$result = $query->execute(array($uid));
117
-
118
-		if (isset($this->cache[$uid])) {
119
-			unset($this->cache[$uid]);
120
-		}
121
-
122
-		return $result ? true : false;
123
-	}
124
-
125
-	/**
126
-	 * Set password
127
-	 * @param string $uid The username
128
-	 * @param string $password The new password
129
-	 * @return bool
130
-	 *
131
-	 * Change the password of a user
132
-	 */
133
-	public function setPassword($uid, $password) {
134
-		if ($this->userExists($uid)) {
135
-			$event = new GenericEvent($password);
136
-			$this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event);
137
-			$query = \OC_DB::prepare('UPDATE `*PREFIX*users` SET `password` = ? WHERE `uid` = ?');
138
-			$result = $query->execute(array(\OC::$server->getHasher()->hash($password), $uid));
139
-
140
-			return $result ? true : false;
141
-		}
142
-
143
-		return false;
144
-	}
145
-
146
-	/**
147
-	 * Set display name
148
-	 * @param string $uid The username
149
-	 * @param string $displayName The new display name
150
-	 * @return bool
151
-	 *
152
-	 * Change the display name of a user
153
-	 */
154
-	public function setDisplayName($uid, $displayName) {
155
-		if ($this->userExists($uid)) {
156
-			$query = \OC_DB::prepare('UPDATE `*PREFIX*users` SET `displayname` = ? WHERE LOWER(`uid`) = LOWER(?)');
157
-			$query->execute(array($displayName, $uid));
158
-			$this->cache[$uid]['displayname'] = $displayName;
159
-
160
-			return true;
161
-		}
162
-
163
-		return false;
164
-	}
165
-
166
-	/**
167
-	 * get display name of the user
168
-	 * @param string $uid user ID of the user
169
-	 * @return string display name
170
-	 */
171
-	public function getDisplayName($uid) {
172
-		$this->loadUser($uid);
173
-		return empty($this->cache[$uid]['displayname']) ? $uid : $this->cache[$uid]['displayname'];
174
-	}
175
-
176
-	/**
177
-	 * Get a list of all display names and user ids.
178
-	 *
179
-	 * @param string $search
180
-	 * @param string|null $limit
181
-	 * @param string|null $offset
182
-	 * @return array an array of all displayNames (value) and the corresponding uids (key)
183
-	 */
184
-	public function getDisplayNames($search = '', $limit = null, $offset = null) {
185
-		$parameters = [];
186
-		$searchLike = '';
187
-		if ($search !== '') {
188
-			$parameters[] = '%' . \OC::$server->getDatabaseConnection()->escapeLikeParameter($search) . '%';
189
-			$parameters[] = '%' . \OC::$server->getDatabaseConnection()->escapeLikeParameter($search) . '%';
190
-			$searchLike = ' WHERE LOWER(`displayname`) LIKE LOWER(?) OR '
191
-				. 'LOWER(`uid`) LIKE LOWER(?)';
192
-		}
193
-
194
-		$displayNames = array();
195
-		$query = \OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`'
196
-			. $searchLike .' ORDER BY `uid` ASC', $limit, $offset);
197
-		$result = $query->execute($parameters);
198
-		while ($row = $result->fetchRow()) {
199
-			$displayNames[$row['uid']] = $row['displayname'];
200
-		}
201
-
202
-		return $displayNames;
203
-	}
204
-
205
-	/**
206
-	 * Check if the password is correct
207
-	 * @param string $uid The username
208
-	 * @param string $password The password
209
-	 * @return string
210
-	 *
211
-	 * Check if the password is correct without logging in the user
212
-	 * returns the user id or false
213
-	 */
214
-	public function checkPassword($uid, $password) {
215
-		$query = \OC_DB::prepare('SELECT `uid`, `password` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)');
216
-		$result = $query->execute(array($uid));
217
-
218
-		$row = $result->fetchRow();
219
-		if ($row) {
220
-			$storedHash = $row['password'];
221
-			$newHash = '';
222
-			if(\OC::$server->getHasher()->verify($password, $storedHash, $newHash)) {
223
-				if(!empty($newHash)) {
224
-					$this->setPassword($uid, $password);
225
-				}
226
-				return $row['uid'];
227
-			}
228
-
229
-		}
230
-
231
-		return false;
232
-	}
233
-
234
-	/**
235
-	 * Load an user in the cache
236
-	 * @param string $uid the username
237
-	 * @return boolean
238
-	 */
239
-	private function loadUser($uid) {
240
-		if (!isset($this->cache[$uid])) {
241
-			//guests $uid could be NULL or ''
242
-			if ($uid === null || $uid === '') {
243
-				$this->cache[$uid]=false;
244
-				return true;
245
-			}
246
-
247
-			$query = \OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)');
248
-			$result = $query->execute(array($uid));
249
-
250
-			if ($result === false) {
251
-				Util::writeLog('core', \OC_DB::getErrorMessage(), Util::ERROR);
252
-				return false;
253
-			}
254
-
255
-			$this->cache[$uid] = false;
256
-
257
-			while ($row = $result->fetchRow()) {
258
-				$this->cache[$uid]['uid'] = $row['uid'];
259
-				$this->cache[$uid]['displayname'] = $row['displayname'];
260
-			}
261
-		}
262
-
263
-		return true;
264
-	}
265
-
266
-	/**
267
-	 * Get a list of all users
268
-	 *
269
-	 * @param string $search
270
-	 * @param null|int $limit
271
-	 * @param null|int $offset
272
-	 * @return string[] an array of all uids
273
-	 */
274
-	public function getUsers($search = '', $limit = null, $offset = null) {
275
-		$parameters = [];
276
-		$searchLike = '';
277
-		if ($search !== '') {
278
-			$parameters[] = '%' . \OC::$server->getDatabaseConnection()->escapeLikeParameter($search) . '%';
279
-			$searchLike = ' WHERE LOWER(`uid`) LIKE LOWER(?)';
280
-		}
281
-
282
-		$query = \OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users`' . $searchLike . ' ORDER BY `uid` ASC', $limit, $offset);
283
-		$result = $query->execute($parameters);
284
-		$users = array();
285
-		while ($row = $result->fetchRow()) {
286
-			$users[] = $row['uid'];
287
-		}
288
-		return $users;
289
-	}
290
-
291
-	/**
292
-	 * check if a user exists
293
-	 * @param string $uid the username
294
-	 * @return boolean
295
-	 */
296
-	public function userExists($uid) {
297
-		$this->loadUser($uid);
298
-		return $this->cache[$uid] !== false;
299
-	}
300
-
301
-	/**
302
-	 * get the user's home directory
303
-	 * @param string $uid the username
304
-	 * @return string|false
305
-	 */
306
-	public function getHome($uid) {
307
-		if ($this->userExists($uid)) {
308
-			return \OC::$server->getConfig()->getSystemValue("datadirectory", \OC::$SERVERROOT . "/data") . '/' . $uid;
309
-		}
310
-
311
-		return false;
312
-	}
313
-
314
-	/**
315
-	 * @return bool
316
-	 */
317
-	public function hasUserListings() {
318
-		return true;
319
-	}
320
-
321
-	/**
322
-	 * counts the users in the database
323
-	 *
324
-	 * @return int|bool
325
-	 */
326
-	public function countUsers() {
327
-		$query = \OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users`');
328
-		$result = $query->execute();
329
-		if ($result === false) {
330
-			Util::writeLog('core', \OC_DB::getErrorMessage(), Util::ERROR);
331
-			return false;
332
-		}
333
-		return $result->fetchOne();
334
-	}
335
-
336
-	/**
337
-	 * returns the username for the given login name in the correct casing
338
-	 *
339
-	 * @param string $loginName
340
-	 * @return string|false
341
-	 */
342
-	public function loginName2UserName($loginName) {
343
-		if ($this->userExists($loginName)) {
344
-			return $this->cache[$loginName]['uid'];
345
-		}
346
-
347
-		return false;
348
-	}
349
-
350
-	/**
351
-	 * Backend name to be shown in user management
352
-	 * @return string the name of the backend to be shown
353
-	 */
354
-	public function getBackendName(){
355
-		return 'Database';
356
-	}
357
-
358
-	public static function preLoginNameUsedAsUserName($param) {
359
-		if(!isset($param['uid'])) {
360
-			throw new \Exception('key uid is expected to be set in $param');
361
-		}
362
-
363
-		$backends = \OC::$server->getUserManager()->getBackends();
364
-		foreach ($backends as $backend) {
365
-			if ($backend instanceof Database) {
366
-				/** @var \OC\User\Database $backend */
367
-				$uid = $backend->loginName2UserName($param['uid']);
368
-				if ($uid !== false) {
369
-					$param['uid'] = $uid;
370
-					return;
371
-				}
372
-			}
373
-		}
374
-
375
-	}
65
+    /** @var CappedMemoryCache */
66
+    private $cache;
67
+
68
+    /** @var EventDispatcher */
69
+    private $eventDispatcher;
70
+
71
+    /**
72
+     * \OC\User\Database constructor.
73
+     *
74
+     * @param EventDispatcher $eventDispatcher
75
+     */
76
+    public function __construct($eventDispatcher = null) {
77
+        $this->cache = new CappedMemoryCache();
78
+        $this->eventDispatcher = $eventDispatcher ? $eventDispatcher : \OC::$server->getEventDispatcher();
79
+    }
80
+
81
+    /**
82
+     * Create a new user
83
+     * @param string $uid The username of the user to create
84
+     * @param string $password The password of the new user
85
+     * @return bool
86
+     *
87
+     * Creates a new user. Basic checking of username is done in OC_User
88
+     * itself, not in its subclasses.
89
+     */
90
+    public function createUser($uid, $password) {
91
+        if (!$this->userExists($uid)) {
92
+            $event = new GenericEvent($password);
93
+            $this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event);
94
+            $query = \OC_DB::prepare('INSERT INTO `*PREFIX*users` ( `uid`, `password` ) VALUES( ?, ? )');
95
+            $result = $query->execute(array($uid, \OC::$server->getHasher()->hash($password)));
96
+
97
+            // Clear cache
98
+            unset($this->cache[$uid]);
99
+
100
+            return $result ? true : false;
101
+        }
102
+
103
+        return false;
104
+    }
105
+
106
+    /**
107
+     * delete a user
108
+     * @param string $uid The username of the user to delete
109
+     * @return bool
110
+     *
111
+     * Deletes a user
112
+     */
113
+    public function deleteUser($uid) {
114
+        // Delete user-group-relation
115
+        $query = \OC_DB::prepare('DELETE FROM `*PREFIX*users` WHERE `uid` = ?');
116
+        $result = $query->execute(array($uid));
117
+
118
+        if (isset($this->cache[$uid])) {
119
+            unset($this->cache[$uid]);
120
+        }
121
+
122
+        return $result ? true : false;
123
+    }
124
+
125
+    /**
126
+     * Set password
127
+     * @param string $uid The username
128
+     * @param string $password The new password
129
+     * @return bool
130
+     *
131
+     * Change the password of a user
132
+     */
133
+    public function setPassword($uid, $password) {
134
+        if ($this->userExists($uid)) {
135
+            $event = new GenericEvent($password);
136
+            $this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event);
137
+            $query = \OC_DB::prepare('UPDATE `*PREFIX*users` SET `password` = ? WHERE `uid` = ?');
138
+            $result = $query->execute(array(\OC::$server->getHasher()->hash($password), $uid));
139
+
140
+            return $result ? true : false;
141
+        }
142
+
143
+        return false;
144
+    }
145
+
146
+    /**
147
+     * Set display name
148
+     * @param string $uid The username
149
+     * @param string $displayName The new display name
150
+     * @return bool
151
+     *
152
+     * Change the display name of a user
153
+     */
154
+    public function setDisplayName($uid, $displayName) {
155
+        if ($this->userExists($uid)) {
156
+            $query = \OC_DB::prepare('UPDATE `*PREFIX*users` SET `displayname` = ? WHERE LOWER(`uid`) = LOWER(?)');
157
+            $query->execute(array($displayName, $uid));
158
+            $this->cache[$uid]['displayname'] = $displayName;
159
+
160
+            return true;
161
+        }
162
+
163
+        return false;
164
+    }
165
+
166
+    /**
167
+     * get display name of the user
168
+     * @param string $uid user ID of the user
169
+     * @return string display name
170
+     */
171
+    public function getDisplayName($uid) {
172
+        $this->loadUser($uid);
173
+        return empty($this->cache[$uid]['displayname']) ? $uid : $this->cache[$uid]['displayname'];
174
+    }
175
+
176
+    /**
177
+     * Get a list of all display names and user ids.
178
+     *
179
+     * @param string $search
180
+     * @param string|null $limit
181
+     * @param string|null $offset
182
+     * @return array an array of all displayNames (value) and the corresponding uids (key)
183
+     */
184
+    public function getDisplayNames($search = '', $limit = null, $offset = null) {
185
+        $parameters = [];
186
+        $searchLike = '';
187
+        if ($search !== '') {
188
+            $parameters[] = '%' . \OC::$server->getDatabaseConnection()->escapeLikeParameter($search) . '%';
189
+            $parameters[] = '%' . \OC::$server->getDatabaseConnection()->escapeLikeParameter($search) . '%';
190
+            $searchLike = ' WHERE LOWER(`displayname`) LIKE LOWER(?) OR '
191
+                . 'LOWER(`uid`) LIKE LOWER(?)';
192
+        }
193
+
194
+        $displayNames = array();
195
+        $query = \OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`'
196
+            . $searchLike .' ORDER BY `uid` ASC', $limit, $offset);
197
+        $result = $query->execute($parameters);
198
+        while ($row = $result->fetchRow()) {
199
+            $displayNames[$row['uid']] = $row['displayname'];
200
+        }
201
+
202
+        return $displayNames;
203
+    }
204
+
205
+    /**
206
+     * Check if the password is correct
207
+     * @param string $uid The username
208
+     * @param string $password The password
209
+     * @return string
210
+     *
211
+     * Check if the password is correct without logging in the user
212
+     * returns the user id or false
213
+     */
214
+    public function checkPassword($uid, $password) {
215
+        $query = \OC_DB::prepare('SELECT `uid`, `password` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)');
216
+        $result = $query->execute(array($uid));
217
+
218
+        $row = $result->fetchRow();
219
+        if ($row) {
220
+            $storedHash = $row['password'];
221
+            $newHash = '';
222
+            if(\OC::$server->getHasher()->verify($password, $storedHash, $newHash)) {
223
+                if(!empty($newHash)) {
224
+                    $this->setPassword($uid, $password);
225
+                }
226
+                return $row['uid'];
227
+            }
228
+
229
+        }
230
+
231
+        return false;
232
+    }
233
+
234
+    /**
235
+     * Load an user in the cache
236
+     * @param string $uid the username
237
+     * @return boolean
238
+     */
239
+    private function loadUser($uid) {
240
+        if (!isset($this->cache[$uid])) {
241
+            //guests $uid could be NULL or ''
242
+            if ($uid === null || $uid === '') {
243
+                $this->cache[$uid]=false;
244
+                return true;
245
+            }
246
+
247
+            $query = \OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)');
248
+            $result = $query->execute(array($uid));
249
+
250
+            if ($result === false) {
251
+                Util::writeLog('core', \OC_DB::getErrorMessage(), Util::ERROR);
252
+                return false;
253
+            }
254
+
255
+            $this->cache[$uid] = false;
256
+
257
+            while ($row = $result->fetchRow()) {
258
+                $this->cache[$uid]['uid'] = $row['uid'];
259
+                $this->cache[$uid]['displayname'] = $row['displayname'];
260
+            }
261
+        }
262
+
263
+        return true;
264
+    }
265
+
266
+    /**
267
+     * Get a list of all users
268
+     *
269
+     * @param string $search
270
+     * @param null|int $limit
271
+     * @param null|int $offset
272
+     * @return string[] an array of all uids
273
+     */
274
+    public function getUsers($search = '', $limit = null, $offset = null) {
275
+        $parameters = [];
276
+        $searchLike = '';
277
+        if ($search !== '') {
278
+            $parameters[] = '%' . \OC::$server->getDatabaseConnection()->escapeLikeParameter($search) . '%';
279
+            $searchLike = ' WHERE LOWER(`uid`) LIKE LOWER(?)';
280
+        }
281
+
282
+        $query = \OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users`' . $searchLike . ' ORDER BY `uid` ASC', $limit, $offset);
283
+        $result = $query->execute($parameters);
284
+        $users = array();
285
+        while ($row = $result->fetchRow()) {
286
+            $users[] = $row['uid'];
287
+        }
288
+        return $users;
289
+    }
290
+
291
+    /**
292
+     * check if a user exists
293
+     * @param string $uid the username
294
+     * @return boolean
295
+     */
296
+    public function userExists($uid) {
297
+        $this->loadUser($uid);
298
+        return $this->cache[$uid] !== false;
299
+    }
300
+
301
+    /**
302
+     * get the user's home directory
303
+     * @param string $uid the username
304
+     * @return string|false
305
+     */
306
+    public function getHome($uid) {
307
+        if ($this->userExists($uid)) {
308
+            return \OC::$server->getConfig()->getSystemValue("datadirectory", \OC::$SERVERROOT . "/data") . '/' . $uid;
309
+        }
310
+
311
+        return false;
312
+    }
313
+
314
+    /**
315
+     * @return bool
316
+     */
317
+    public function hasUserListings() {
318
+        return true;
319
+    }
320
+
321
+    /**
322
+     * counts the users in the database
323
+     *
324
+     * @return int|bool
325
+     */
326
+    public function countUsers() {
327
+        $query = \OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users`');
328
+        $result = $query->execute();
329
+        if ($result === false) {
330
+            Util::writeLog('core', \OC_DB::getErrorMessage(), Util::ERROR);
331
+            return false;
332
+        }
333
+        return $result->fetchOne();
334
+    }
335
+
336
+    /**
337
+     * returns the username for the given login name in the correct casing
338
+     *
339
+     * @param string $loginName
340
+     * @return string|false
341
+     */
342
+    public function loginName2UserName($loginName) {
343
+        if ($this->userExists($loginName)) {
344
+            return $this->cache[$loginName]['uid'];
345
+        }
346
+
347
+        return false;
348
+    }
349
+
350
+    /**
351
+     * Backend name to be shown in user management
352
+     * @return string the name of the backend to be shown
353
+     */
354
+    public function getBackendName(){
355
+        return 'Database';
356
+    }
357
+
358
+    public static function preLoginNameUsedAsUserName($param) {
359
+        if(!isset($param['uid'])) {
360
+            throw new \Exception('key uid is expected to be set in $param');
361
+        }
362
+
363
+        $backends = \OC::$server->getUserManager()->getBackends();
364
+        foreach ($backends as $backend) {
365
+            if ($backend instanceof Database) {
366
+                /** @var \OC\User\Database $backend */
367
+                $uid = $backend->loginName2UserName($param['uid']);
368
+                if ($uid !== false) {
369
+                    $param['uid'] = $uid;
370
+                    return;
371
+                }
372
+            }
373
+        }
374
+
375
+    }
376 376
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
 		$parameters = [];
186 186
 		$searchLike = '';
187 187
 		if ($search !== '') {
188
-			$parameters[] = '%' . \OC::$server->getDatabaseConnection()->escapeLikeParameter($search) . '%';
189
-			$parameters[] = '%' . \OC::$server->getDatabaseConnection()->escapeLikeParameter($search) . '%';
188
+			$parameters[] = '%'.\OC::$server->getDatabaseConnection()->escapeLikeParameter($search).'%';
189
+			$parameters[] = '%'.\OC::$server->getDatabaseConnection()->escapeLikeParameter($search).'%';
190 190
 			$searchLike = ' WHERE LOWER(`displayname`) LIKE LOWER(?) OR '
191 191
 				. 'LOWER(`uid`) LIKE LOWER(?)';
192 192
 		}
193 193
 
194 194
 		$displayNames = array();
195 195
 		$query = \OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`'
196
-			. $searchLike .' ORDER BY `uid` ASC', $limit, $offset);
196
+			. $searchLike.' ORDER BY `uid` ASC', $limit, $offset);
197 197
 		$result = $query->execute($parameters);
198 198
 		while ($row = $result->fetchRow()) {
199 199
 			$displayNames[$row['uid']] = $row['displayname'];
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
 		if ($row) {
220 220
 			$storedHash = $row['password'];
221 221
 			$newHash = '';
222
-			if(\OC::$server->getHasher()->verify($password, $storedHash, $newHash)) {
223
-				if(!empty($newHash)) {
222
+			if (\OC::$server->getHasher()->verify($password, $storedHash, $newHash)) {
223
+				if (!empty($newHash)) {
224 224
 					$this->setPassword($uid, $password);
225 225
 				}
226 226
 				return $row['uid'];
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 		if (!isset($this->cache[$uid])) {
241 241
 			//guests $uid could be NULL or ''
242 242
 			if ($uid === null || $uid === '') {
243
-				$this->cache[$uid]=false;
243
+				$this->cache[$uid] = false;
244 244
 				return true;
245 245
 			}
246 246
 
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
 		$parameters = [];
276 276
 		$searchLike = '';
277 277
 		if ($search !== '') {
278
-			$parameters[] = '%' . \OC::$server->getDatabaseConnection()->escapeLikeParameter($search) . '%';
278
+			$parameters[] = '%'.\OC::$server->getDatabaseConnection()->escapeLikeParameter($search).'%';
279 279
 			$searchLike = ' WHERE LOWER(`uid`) LIKE LOWER(?)';
280 280
 		}
281 281
 
282
-		$query = \OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users`' . $searchLike . ' ORDER BY `uid` ASC', $limit, $offset);
282
+		$query = \OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users`'.$searchLike.' ORDER BY `uid` ASC', $limit, $offset);
283 283
 		$result = $query->execute($parameters);
284 284
 		$users = array();
285 285
 		while ($row = $result->fetchRow()) {
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	 */
306 306
 	public function getHome($uid) {
307 307
 		if ($this->userExists($uid)) {
308
-			return \OC::$server->getConfig()->getSystemValue("datadirectory", \OC::$SERVERROOT . "/data") . '/' . $uid;
308
+			return \OC::$server->getConfig()->getSystemValue("datadirectory", \OC::$SERVERROOT."/data").'/'.$uid;
309 309
 		}
310 310
 
311 311
 		return false;
@@ -351,12 +351,12 @@  discard block
 block discarded – undo
351 351
 	 * Backend name to be shown in user management
352 352
 	 * @return string the name of the backend to be shown
353 353
 	 */
354
-	public function getBackendName(){
354
+	public function getBackendName() {
355 355
 		return 'Database';
356 356
 	}
357 357
 
358 358
 	public static function preLoginNameUsedAsUserName($param) {
359
-		if(!isset($param['uid'])) {
359
+		if (!isset($param['uid'])) {
360 360
 			throw new \Exception('key uid is expected to be set in $param');
361 361
 		}
362 362
 
Please login to merge, or discard this patch.