@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function file_put_contents($filename, $data) { |
61 | 61 | $bytesWritten = @file_put_contents($filename, $data); |
62 | - if ($bytesWritten === false || $bytesWritten !== strlen($data)){ |
|
63 | - throw new \Exception('Failed to write into ' . $filename); |
|
62 | + if ($bytesWritten === false || $bytesWritten !== strlen($data)) { |
|
63 | + throw new \Exception('Failed to write into '.$filename); |
|
64 | 64 | } |
65 | 65 | return $bytesWritten; |
66 | 66 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function assertDirectoryExists($path) { |
81 | 81 | if (!is_dir($path)) { |
82 | - throw new \Exception('Directory ' . $path . ' does not exist.'); |
|
82 | + throw new \Exception('Directory '.$path.' does not exist.'); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | } |
@@ -39,7 +39,7 @@ |
||
39 | 39 | */ |
40 | 40 | public function getAppPath($appId) { |
41 | 41 | $path = \OC_App::getAppPath($appId); |
42 | - if($path === false) { |
|
42 | + if ($path === false) { |
|
43 | 43 | |
44 | 44 | throw new \Exception('App not found'); |
45 | 45 | } |
@@ -61,7 +61,7 @@ |
||
61 | 61 | * @return string |
62 | 62 | */ |
63 | 63 | public function __toString() { |
64 | - return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n"; |
|
64 | + return __CLASS__.": [{$this->code}]: {$this->message} ({$this->hint})\n"; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -58,7 +58,7 @@ |
||
58 | 58 | use Symfony\Component\EventDispatcher\EventDispatcher; |
59 | 59 | use Symfony\Component\EventDispatcher\GenericEvent; |
60 | 60 | |
61 | -class Repair implements IOutput{ |
|
61 | +class Repair implements IOutput { |
|
62 | 62 | /* @var IRepairStep[] */ |
63 | 63 | private $repairSteps; |
64 | 64 | /** @var EventDispatcher */ |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | /** |
81 | 81 | * @inheritdoc |
82 | 82 | */ |
83 | - public function get ($size = 64) { |
|
83 | + public function get($size = 64) { |
|
84 | 84 | try { |
85 | 85 | $file = $this->getFile($size); |
86 | 86 | } catch (NotFoundException $e) { |
@@ -110,9 +110,9 @@ discard block |
||
110 | 110 | * @throws NotSquareException if the image is not square |
111 | 111 | * @return void |
112 | 112 | */ |
113 | - public function set ($data) { |
|
113 | + public function set($data) { |
|
114 | 114 | |
115 | - if($data instanceOf IImage) { |
|
115 | + if ($data instanceOf IImage) { |
|
116 | 116 | $img = $data; |
117 | 117 | $data = $img->data(); |
118 | 118 | } else { |
@@ -143,12 +143,12 @@ discard block |
||
143 | 143 | * remove the users avatar |
144 | 144 | * @return void |
145 | 145 | */ |
146 | - public function remove () { |
|
146 | + public function remove() { |
|
147 | 147 | $regex = '/^avatar\.([0-9]+\.)?(jpg|png)$/'; |
148 | 148 | $avatars = $this->folder->getDirectoryListing(); |
149 | 149 | |
150 | 150 | $this->config->setUserValue($this->user->getUID(), 'avatar', 'version', |
151 | - (int)$this->config->getUserValue($this->user->getUID(), 'avatar', 'version', 0) + 1); |
|
151 | + (int) $this->config->getUserValue($this->user->getUID(), 'avatar', 'version', 0) + 1); |
|
152 | 152 | |
153 | 153 | foreach ($avatars as $avatar) { |
154 | 154 | if (preg_match($regex, $avatar->getName())) { |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | $ext = $this->getExtension(); |
166 | 166 | |
167 | 167 | if ($size === -1) { |
168 | - $path = 'avatar.' . $ext; |
|
168 | + $path = 'avatar.'.$ext; |
|
169 | 169 | } else { |
170 | - $path = 'avatar.' . $size . '.' . $ext; |
|
170 | + $path = 'avatar.'.$size.'.'.$ext; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | try { |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | |
180 | 180 | $avatar = new OC_Image(); |
181 | 181 | /** @var ISimpleFile $file */ |
182 | - $file = $this->folder->getFile('avatar.' . $ext); |
|
182 | + $file = $this->folder->getFile('avatar.'.$ext); |
|
183 | 183 | $avatar->loadFromData($file->getContent()); |
184 | 184 | if ($size !== -1) { |
185 | 185 | $avatar->resize($size); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $file = $this->folder->newFile($path); |
189 | 189 | $file->putContent($avatar->data()); |
190 | 190 | } catch (NotPermittedException $e) { |
191 | - $this->logger->error('Failed to save avatar for ' . $this->user->getUID()); |
|
191 | + $this->logger->error('Failed to save avatar for '.$this->user->getUID()); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $this->uid = $uid; |
84 | 84 | $this->backend = $backend; |
85 | 85 | $this->emitter = $emitter; |
86 | - if(is_null($config)) { |
|
86 | + if (is_null($config)) { |
|
87 | 87 | $config = \OC::$server->getConfig(); |
88 | 88 | } |
89 | 89 | $this->config = $config; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @since 9.0.0 |
159 | 159 | */ |
160 | 160 | public function setEMailAddress($mailAddress) { |
161 | - if($mailAddress === '') { |
|
161 | + if ($mailAddress === '') { |
|
162 | 162 | $this->config->deleteUserValue($this->uid, 'settings', 'email'); |
163 | 163 | } else { |
164 | 164 | $this->config->setUserValue($this->uid, 'settings', 'email', $mailAddress); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | } |
220 | 220 | |
221 | 221 | // Delete the users entry in the storage table |
222 | - Storage::remove('home::' . $this->uid); |
|
222 | + Storage::remove('home::'.$this->uid); |
|
223 | 223 | |
224 | 224 | \OC::$server->getCommentsManager()->deleteReferencesOfActor('users', $this->uid); |
225 | 225 | \OC::$server->getCommentsManager()->deleteReadMarksFromUser($this); |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | if ($this->backend->implementsActions(Backend::GET_HOME) and $home = $this->backend->getHome($this->uid)) { |
268 | 268 | $this->home = $home; |
269 | 269 | } elseif ($this->config) { |
270 | - $this->home = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $this->uid; |
|
270 | + $this->home = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').'/'.$this->uid; |
|
271 | 271 | } else { |
272 | - $this->home = \OC::$SERVERROOT . '/data/' . $this->uid; |
|
272 | + $this->home = \OC::$SERVERROOT.'/data/'.$this->uid; |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | return $this->home; |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * @return string |
282 | 282 | */ |
283 | 283 | public function getBackendClassName() { |
284 | - if($this->backend instanceof IUserBackend) { |
|
284 | + if ($this->backend instanceof IUserBackend) { |
|
285 | 285 | return $this->backend->getBackendName(); |
286 | 286 | } |
287 | 287 | return get_class($this->backend); |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | */ |
359 | 359 | public function getQuota() { |
360 | 360 | $quota = $this->config->getUserValue($this->uid, 'files', 'quota', 'default'); |
361 | - if($quota === 'default') { |
|
361 | + if ($quota === 'default') { |
|
362 | 362 | $quota = $this->config->getAppValue('files', 'default_quota', 'none'); |
363 | 363 | } |
364 | 364 | return $quota; |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * @since 9.0.0 |
373 | 373 | */ |
374 | 374 | public function setQuota($quota) { |
375 | - if($quota !== 'none' and $quota !== 'default') { |
|
375 | + if ($quota !== 'none' and $quota !== 'default') { |
|
376 | 376 | $quota = OC_Helper::computerFileSize($quota); |
377 | 377 | $quota = OC_Helper::humanFileSize($quota); |
378 | 378 | } |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | public function getCloudId() { |
412 | 412 | $uid = $this->getUID(); |
413 | 413 | $server = $this->urlGenerator->getAbsoluteURL('/'); |
414 | - $server = rtrim( $this->removeProtocolFromUrl($server), '/'); |
|
414 | + $server = rtrim($this->removeProtocolFromUrl($server), '/'); |
|
415 | 415 | return \OC::$server->getCloudIdManager()->getCloudId($uid, $server)->getId(); |
416 | 416 | } |
417 | 417 |
@@ -345,14 +345,14 @@ discard block |
||
345 | 345 | if (!$isTokenPassword && $this->isTwoFactorEnforced($user)) { |
346 | 346 | throw new PasswordLoginForbiddenException(); |
347 | 347 | } |
348 | - if (!$this->login($user, $password) ) { |
|
348 | + if (!$this->login($user, $password)) { |
|
349 | 349 | $users = $this->manager->getByEmail($user); |
350 | 350 | if (count($users) === 1) { |
351 | 351 | return $this->login($users[0]->getUID(), $password); |
352 | 352 | } |
353 | 353 | |
354 | 354 | $throttler->registerAttempt('login', $request->getRemoteAddress(), ['uid' => $user]); |
355 | - if($currentDelay === 0) { |
|
355 | + if ($currentDelay === 0) { |
|
356 | 356 | $throttler->sleepDelay($request->getRemoteAddress(), 'login'); |
357 | 357 | } |
358 | 358 | return false; |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | |
361 | 361 | if ($isTokenPassword) { |
362 | 362 | $this->session->set('app_password', $password); |
363 | - } else if($this->supportsCookies($request)) { |
|
363 | + } else if ($this->supportsCookies($request)) { |
|
364 | 364 | // Password login, but cookies supported -> create (browser) session token |
365 | 365 | $this->createSessionToken($request, $this->getUser()->getUID(), $user, $password); |
366 | 366 | } |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | \OC_Util::copySkeleton($user, $userFolder); |
434 | 434 | |
435 | 435 | // trigger any other initialization |
436 | - \OC::$server->getEventDispatcher()->dispatch(IUser::class . '::firstLogin', new GenericEvent($this->getUser())); |
|
436 | + \OC::$server->getEventDispatcher()->dispatch(IUser::class.'::firstLogin', new GenericEvent($this->getUser())); |
|
437 | 437 | } |
438 | 438 | } |
439 | 439 | |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | private function checkTokenCredentials(IToken $dbToken, $token) { |
624 | 624 | // Check whether login credentials are still valid and the user was not disabled |
625 | 625 | // This check is performed each 5 minutes |
626 | - $lastCheck = $dbToken->getLastCheck() ? : 0; |
|
626 | + $lastCheck = $dbToken->getLastCheck() ?: 0; |
|
627 | 627 | $now = $this->timeFacory->getTime(); |
628 | 628 | if ($lastCheck > ($now - 60 * 5)) { |
629 | 629 | // Checked performed recently, nothing to do now |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | if (!$this->loginWithToken($token)) { |
714 | 714 | return false; |
715 | 715 | } |
716 | - if(!$this->validateToken($token)) { |
|
716 | + if (!$this->validateToken($token)) { |
|
717 | 717 | return false; |
718 | 718 | } |
719 | 719 | return true; |
@@ -836,9 +836,9 @@ discard block |
||
836 | 836 | setcookie('nc_session_id', '', $this->timeFacory->getTime() - 3600, OC::$WEBROOT, '', $secureCookie, true); |
837 | 837 | // old cookies might be stored under /webroot/ instead of /webroot |
838 | 838 | // and Firefox doesn't like it! |
839 | - setcookie('nc_username', '', $this->timeFacory->getTime() - 3600, OC::$WEBROOT . '/', '', $secureCookie, true); |
|
840 | - setcookie('nc_token', '', $this->timeFacory->getTime() - 3600, OC::$WEBROOT . '/', '', $secureCookie, true); |
|
841 | - setcookie('nc_session_id', '', $this->timeFacory->getTime() - 3600, OC::$WEBROOT . '/', '', $secureCookie, true); |
|
839 | + setcookie('nc_username', '', $this->timeFacory->getTime() - 3600, OC::$WEBROOT.'/', '', $secureCookie, true); |
|
840 | + setcookie('nc_token', '', $this->timeFacory->getTime() - 3600, OC::$WEBROOT.'/', '', $secureCookie, true); |
|
841 | + setcookie('nc_session_id', '', $this->timeFacory->getTime() - 3600, OC::$WEBROOT.'/', '', $secureCookie, true); |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | /** |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | /** |
38 | 38 | * actions that user backends can define |
39 | 39 | */ |
40 | - const CREATE_USER = 1; // 1 << 0 |
|
41 | - const SET_PASSWORD = 16; // 1 << 4 |
|
42 | - const CHECK_PASSWORD = 256; // 1 << 8 |
|
43 | - const GET_HOME = 4096; // 1 << 12 |
|
44 | - const GET_DISPLAYNAME = 65536; // 1 << 16 |
|
45 | - const SET_DISPLAYNAME = 1048576; // 1 << 20 |
|
46 | - const PROVIDE_AVATAR = 16777216; // 1 << 24 |
|
47 | - const COUNT_USERS = 268435456; // 1 << 28 |
|
40 | + const CREATE_USER = 1; // 1 << 0 |
|
41 | + const SET_PASSWORD = 16; // 1 << 4 |
|
42 | + const CHECK_PASSWORD = 256; // 1 << 8 |
|
43 | + const GET_HOME = 4096; // 1 << 12 |
|
44 | + const GET_DISPLAYNAME = 65536; // 1 << 16 |
|
45 | + const SET_DISPLAYNAME = 1048576; // 1 << 20 |
|
46 | + const PROVIDE_AVATAR = 16777216; // 1 << 24 |
|
47 | + const COUNT_USERS = 268435456; // 1 << 28 |
|
48 | 48 | |
49 | 49 | protected $possibleActions = array( |
50 | 50 | self::CREATE_USER => 'createUser', |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function getSupportedActions() { |
68 | 68 | $actions = 0; |
69 | - foreach($this->possibleActions AS $action => $methodName) { |
|
70 | - if(method_exists($this, $methodName)) { |
|
69 | + foreach ($this->possibleActions AS $action => $methodName) { |
|
70 | + if (method_exists($this, $methodName)) { |
|
71 | 71 | $actions |= $action; |
72 | 72 | } |
73 | 73 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * compared with self::CREATE_USER etc. |
85 | 85 | */ |
86 | 86 | public function implementsActions($actions) { |
87 | - return (bool)($this->getSupportedActions() & $actions); |
|
87 | + return (bool) ($this->getSupportedActions() & $actions); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * |
95 | 95 | * Deletes a user |
96 | 96 | */ |
97 | - public function deleteUser( $uid ) { |
|
97 | + public function deleteUser($uid) { |
|
98 | 98 | return false; |
99 | 99 | } |
100 | 100 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | public function getDisplayNames($search = '', $limit = null, $offset = null) { |
149 | 149 | $displayNames = array(); |
150 | 150 | $users = $this->getUsers($search, $limit, $offset); |
151 | - foreach ( $users as $user) { |
|
151 | + foreach ($users as $user) { |
|
152 | 152 | $displayNames[$user] = $user; |
153 | 153 | } |
154 | 154 | return $displayNames; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | public function __construct(IConfig $config) { |
76 | 76 | $this->config = $config; |
77 | 77 | $cachedUsers = &$this->cachedUsers; |
78 | - $this->listen('\OC\User', 'postDelete', function ($user) use (&$cachedUsers) { |
|
78 | + $this->listen('\OC\User', 'postDelete', function($user) use (&$cachedUsers) { |
|
79 | 79 | /** @var \OC\User\User $user */ |
80 | 80 | unset($cachedUsers[$user->getUID()]); |
81 | 81 | }); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | - \OC::$server->getLogger()->warning('Login failed: \''. $loginName .'\' (Remote IP: \''. \OC::$server->getRequest()->getRemoteAddress(). '\')', ['app' => 'core']); |
|
200 | + \OC::$server->getLogger()->warning('Login failed: \''.$loginName.'\' (Remote IP: \''.\OC::$server->getRequest()->getRemoteAddress().'\')', ['app' => 'core']); |
|
201 | 201 | return false; |
202 | 202 | } |
203 | 203 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | - uasort($users, function ($a, $b) { |
|
223 | + uasort($users, function($a, $b) { |
|
224 | 224 | /** |
225 | 225 | * @var \OC\User\User $a |
226 | 226 | * @var \OC\User\User $b |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
252 | - usort($users, function ($a, $b) { |
|
252 | + usort($users, function($a, $b) { |
|
253 | 253 | /** |
254 | 254 | * @var \OC\User\User $a |
255 | 255 | * @var \OC\User\User $b |
@@ -319,13 +319,13 @@ discard block |
||
319 | 319 | foreach ($this->backends as $backend) { |
320 | 320 | if ($backend->implementsActions(Backend::COUNT_USERS)) { |
321 | 321 | $backendUsers = $backend->countUsers(); |
322 | - if($backendUsers !== false) { |
|
323 | - if($backend instanceof IUserBackend) { |
|
322 | + if ($backendUsers !== false) { |
|
323 | + if ($backend instanceof IUserBackend) { |
|
324 | 324 | $name = $backend->getBackendName(); |
325 | 325 | } else { |
326 | 326 | $name = get_class($backend); |
327 | 327 | } |
328 | - if(isset($userCountStatistics[$name])) { |
|
328 | + if (isset($userCountStatistics[$name])) { |
|
329 | 329 | $userCountStatistics[$name] += $backendUsers; |
330 | 330 | } else { |
331 | 331 | $userCountStatistics[$name] = $backendUsers; |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | |
388 | 388 | $query = $queryBuilder->execute(); |
389 | 389 | |
390 | - $result = (int)$query->fetchColumn(); |
|
390 | + $result = (int) $query->fetchColumn(); |
|
391 | 391 | $query->closeCursor(); |
392 | 392 | |
393 | 393 | return $result; |