@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * Checks whether the user is member of a group or not. |
| 152 | 152 | */ |
| 153 | - public function inGroup( $uid, $gid ) { |
|
| 153 | + public function inGroup($uid, $gid) { |
|
| 154 | 154 | $this->fixDI(); |
| 155 | 155 | |
| 156 | 156 | // check |
@@ -179,14 +179,14 @@ discard block |
||
| 179 | 179 | $this->fixDI(); |
| 180 | 180 | |
| 181 | 181 | // No duplicate entries! |
| 182 | - if( !$this->inGroup( $uid, $gid )) { |
|
| 182 | + if (!$this->inGroup($uid, $gid)) { |
|
| 183 | 183 | $qb = $this->dbConn->getQueryBuilder(); |
| 184 | 184 | $qb->insert('group_user') |
| 185 | 185 | ->setValue('uid', $qb->createNamedParameter($uid)) |
| 186 | 186 | ->setValue('gid', $qb->createNamedParameter($gid)) |
| 187 | 187 | ->execute(); |
| 188 | 188 | return true; |
| 189 | - }else{ |
|
| 189 | + } else { |
|
| 190 | 190 | return false; |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * This function fetches all groups a user belongs to. It does not check |
| 220 | 220 | * if the user exists at all. |
| 221 | 221 | */ |
| 222 | - public function getUserGroups( $uid ) { |
|
| 222 | + public function getUserGroups($uid) { |
|
| 223 | 223 | //guests has empty or null $uid |
| 224 | 224 | if ($uid === null || $uid === '') { |
| 225 | 225 | return []; |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | ->execute(); |
| 236 | 236 | |
| 237 | 237 | $groups = []; |
| 238 | - while( $row = $cursor->fetch()) { |
|
| 238 | + while ($row = $cursor->fetch()) { |
|
| 239 | 239 | $groups[] = $row['gid']; |
| 240 | 240 | $this->groupCache[$row['gid']] = $row['gid']; |
| 241 | 241 | } |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | if ($search !== '') { |
| 265 | 265 | $query->where($query->expr()->iLike('gid', $query->createNamedParameter( |
| 266 | - '%' . $this->dbConn->escapeLikeParameter($search) . '%' |
|
| 266 | + '%'.$this->dbConn->escapeLikeParameter($search).'%' |
|
| 267 | 267 | ))); |
| 268 | 268 | } |
| 269 | 269 | |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | |
| 328 | 328 | if ($search !== '') { |
| 329 | 329 | $query->andWhere($query->expr()->like('uid', $query->createNamedParameter( |
| 330 | - '%' . $this->dbConn->escapeLikeParameter($search) . '%' |
|
| 330 | + '%'.$this->dbConn->escapeLikeParameter($search).'%' |
|
| 331 | 331 | ))); |
| 332 | 332 | } |
| 333 | 333 | |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | |
| 361 | 361 | if ($search !== '') { |
| 362 | 362 | $query->andWhere($query->expr()->like('uid', $query->createNamedParameter( |
| 363 | - '%' . $this->dbConn->escapeLikeParameter($search) . '%' |
|
| 363 | + '%'.$this->dbConn->escapeLikeParameter($search).'%' |
|
| 364 | 364 | ))); |
| 365 | 365 | } |
| 366 | 366 | |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | $result->closeCursor(); |
| 370 | 370 | |
| 371 | 371 | if ($count !== false) { |
| 372 | - $count = (int)$count; |
|
| 372 | + $count = (int) $count; |
|
| 373 | 373 | } else { |
| 374 | 374 | $count = 0; |
| 375 | 375 | } |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | $result->closeCursor(); |
| 401 | 401 | |
| 402 | 402 | if ($count !== false) { |
| 403 | - $count = (int)$count; |
|
| 403 | + $count = (int) $count; |
|
| 404 | 404 | } else { |
| 405 | 405 | $count = 0; |
| 406 | 406 | } |
@@ -226,8 +226,8 @@ discard block |
||
| 226 | 226 | public function count($search = '') { |
| 227 | 227 | $users = false; |
| 228 | 228 | foreach ($this->backends as $backend) { |
| 229 | - if($backend->implementsActions(\OC\Group\Backend::COUNT_USERS)) { |
|
| 230 | - if($users === false) { |
|
| 229 | + if ($backend->implementsActions(\OC\Group\Backend::COUNT_USERS)) { |
|
| 230 | + if ($users === false) { |
|
| 231 | 231 | //we could directly add to a bool variable, but this would |
| 232 | 232 | //be ugly |
| 233 | 233 | $users = 0; |
@@ -246,8 +246,8 @@ discard block |
||
| 246 | 246 | public function countDisabled() { |
| 247 | 247 | $users = false; |
| 248 | 248 | foreach ($this->backends as $backend) { |
| 249 | - if($backend instanceOf ICountDisabledInGroup) { |
|
| 250 | - if($users === false) { |
|
| 249 | + if ($backend instanceOf ICountDisabledInGroup) { |
|
| 250 | + if ($users === false) { |
|
| 251 | 251 | //we could directly add to a bool variable, but this would |
| 252 | 252 | //be ugly |
| 253 | 253 | $users = 0; |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | // Check if the target user exists |
| 87 | 87 | $targetUserObject = $this->userManager->get($userId); |
| 88 | - if($targetUserObject === null) { |
|
| 88 | + if ($targetUserObject === null) { |
|
| 89 | 89 | throw new OCSNotFoundException('User does not exist'); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | protected function getUserSubAdminGroupsData(string $userId): array { |
| 138 | 138 | $user = $this->userManager->get($userId); |
| 139 | 139 | // Check if the user exists |
| 140 | - if($user === null) { |
|
| 140 | + if ($user === null) { |
|
| 141 | 141 | throw new OCSNotFoundException('User does not exist'); |
| 142 | 142 | } |
| 143 | 143 | |
@@ -151,16 +151,16 @@ discard block |
||
| 151 | 151 | // Check the group exists |
| 152 | 152 | $group = $this->groupManager->get($groupId); |
| 153 | 153 | if ($group !== null) { |
| 154 | - $isSubadminOfGroup =$this->groupManager->getSubAdmin()->isSubAdminOfGroup($user, $group); |
|
| 154 | + $isSubadminOfGroup = $this->groupManager->getSubAdmin()->isSubAdminOfGroup($user, $group); |
|
| 155 | 155 | } else { |
| 156 | 156 | throw new OCSNotFoundException('The requested group could not be found'); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | // Check subadmin has access to this group |
| 160 | - if($this->groupManager->isAdmin($user->getUID()) |
|
| 160 | + if ($this->groupManager->isAdmin($user->getUID()) |
|
| 161 | 161 | || $isSubadminOfGroup) { |
| 162 | 162 | $users = $this->groupManager->get($groupId)->getUsers(); |
| 163 | - $users = array_map(function($user) { |
|
| 163 | + $users = array_map(function($user) { |
|
| 164 | 164 | /** @var IUser $user */ |
| 165 | 165 | return $user->getUID(); |
| 166 | 166 | }, $users); |
@@ -189,13 +189,13 @@ discard block |
||
| 189 | 189 | // Check the group exists |
| 190 | 190 | $group = $this->groupManager->get($groupId); |
| 191 | 191 | if ($group !== null) { |
| 192 | - $isSubadminOfGroup =$this->groupManager->getSubAdmin()->isSubAdminOfGroup($user, $group); |
|
| 192 | + $isSubadminOfGroup = $this->groupManager->getSubAdmin()->isSubAdminOfGroup($user, $group); |
|
| 193 | 193 | } else { |
| 194 | 194 | throw new OCSException('The requested group could not be found', \OCP\API::RESPOND_NOT_FOUND); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | // Check subadmin has access to this group |
| 198 | - if($this->groupManager->isAdmin($user->getUID()) |
|
| 198 | + if ($this->groupManager->isAdmin($user->getUID()) |
|
| 199 | 199 | || $isSubadminOfGroup) { |
| 200 | 200 | $users = $this->groupManager->get($groupId)->getUsers(); |
| 201 | 201 | // Extract required number |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | foreach ($users as $userId) { |
| 206 | 206 | $userData = $this->getUserData($userId); |
| 207 | 207 | // Do not insert empty entry |
| 208 | - if(!empty($userData)) { |
|
| 208 | + if (!empty($userData)) { |
|
| 209 | 209 | $usersDetails[$userId] = $userData; |
| 210 | 210 | } else { |
| 211 | 211 | // Logged user does not have permissions to see this user |
@@ -230,12 +230,12 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | public function addGroup(string $groupid): DataResponse { |
| 232 | 232 | // Validate name |
| 233 | - if(empty($groupid)) { |
|
| 233 | + if (empty($groupid)) { |
|
| 234 | 234 | $this->logger->error('Group name not supplied', ['app' => 'provisioning_api']); |
| 235 | 235 | throw new OCSException('Invalid group name', 101); |
| 236 | 236 | } |
| 237 | 237 | // Check if it exists |
| 238 | - if($this->groupManager->groupExists($groupid)){ |
|
| 238 | + if ($this->groupManager->groupExists($groupid)) { |
|
| 239 | 239 | throw new OCSException('', 102); |
| 240 | 240 | } |
| 241 | 241 | $this->groupManager->createGroup($groupid); |
@@ -251,9 +251,9 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | public function deleteGroup(string $groupId): DataResponse { |
| 253 | 253 | // Check it exists |
| 254 | - if(!$this->groupManager->groupExists($groupId)){ |
|
| 254 | + if (!$this->groupManager->groupExists($groupId)) { |
|
| 255 | 255 | throw new OCSException('', 101); |
| 256 | - } else if($groupId === 'admin' || !$this->groupManager->get($groupId)->delete()){ |
|
| 256 | + } else if ($groupId === 'admin' || !$this->groupManager->get($groupId)->delete()) { |
|
| 257 | 257 | // Cannot delete admin group |
| 258 | 258 | throw new OCSException('', 102); |
| 259 | 259 | } |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | public function getSubAdminsOfGroup(string $groupId): DataResponse { |
| 270 | 270 | // Check group exists |
| 271 | 271 | $targetGroup = $this->groupManager->get($groupId); |
| 272 | - if($targetGroup === null) { |
|
| 272 | + if ($targetGroup === null) { |
|
| 273 | 273 | throw new OCSException('Group does not exist', 101); |
| 274 | 274 | } |
| 275 | 275 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | if ($this->isAdmin) { |
| 190 | 190 | $disabledUsers = $isLDAPUsed ? 0 : $this->userManager->countDisabledUsers(); |
| 191 | 191 | $userCount = array_reduce($this->userManager->countUsers(), function($v, $w) { |
| 192 | - return $v + (int)$w; |
|
| 192 | + return $v + (int) $w; |
|
| 193 | 193 | }, 0); |
| 194 | 194 | } else { |
| 195 | 195 | // User is subadmin ! |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | $groupsNames = []; |
| 199 | 199 | $userCount = 0; |
| 200 | 200 | |
| 201 | - foreach($groups as $key => $group) { |
|
| 201 | + foreach ($groups as $key => $group) { |
|
| 202 | 202 | // $userCount += (int)$group['usercount']; |
| 203 | 203 | array_push($groupsNames, $group['name']); |
| 204 | 204 | // we prevent subadmins from looking up themselves |
@@ -397,11 +397,11 @@ discard block |
||
| 397 | 397 | |
| 398 | 398 | $accountData = $this->accountManager->getUser($user); |
| 399 | 399 | $cloudId = $user->getCloudId(); |
| 400 | - $message = 'Use my Federated Cloud ID to share with me: ' . $cloudId; |
|
| 400 | + $message = 'Use my Federated Cloud ID to share with me: '.$cloudId; |
|
| 401 | 401 | $signature = $this->signMessage($user, $message); |
| 402 | 402 | |
| 403 | - $code = $message . ' ' . $signature; |
|
| 404 | - $codeMd5 = $message . ' ' . md5($signature); |
|
| 403 | + $code = $message.' '.$signature; |
|
| 404 | + $codeMd5 = $message.' '.md5($signature); |
|
| 405 | 405 | |
| 406 | 406 | switch ($account) { |
| 407 | 407 | case 'verify-twitter': |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | IUserSession $userSession |
| 64 | 64 | ) { |
| 65 | 65 | $this->user = $user; |
| 66 | - $this->isAdmin = (bool)$isAdmin; |
|
| 66 | + $this->isAdmin = (bool) $isAdmin; |
|
| 67 | 67 | $this->groupManager = $groupManager; |
| 68 | 68 | $this->userSession = $userSession; |
| 69 | 69 | } |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | * @return array |
| 80 | 80 | */ |
| 81 | 81 | public function get($groupSearch = '', $userSearch = '') { |
| 82 | - $key = $groupSearch . '::' . $userSearch; |
|
| 83 | - if(isset($this->metaData[$key])) { |
|
| 82 | + $key = $groupSearch.'::'.$userSearch; |
|
| 83 | + if (isset($this->metaData[$key])) { |
|
| 84 | 84 | return $this->metaData[$key]; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $sortAdminGroupsIndex = 0; |
| 92 | 92 | $sortAdminGroupsKeys = array(); |
| 93 | 93 | |
| 94 | - foreach($this->getGroups($groupSearch) as $group) { |
|
| 94 | + foreach ($this->getGroups($groupSearch) as $group) { |
|
| 95 | 95 | $groupMetaData = $this->generateGroupMetaData($group, $userSearch); |
| 96 | 96 | if (strtolower($group->getGID()) !== 'admin') { |
| 97 | 97 | $this->addEntry( |
@@ -189,11 +189,11 @@ discard block |
||
| 189 | 189 | * @return \OCP\IGroup[] |
| 190 | 190 | */ |
| 191 | 191 | public function getGroups($search = '') { |
| 192 | - if($this->isAdmin) { |
|
| 192 | + if ($this->isAdmin) { |
|
| 193 | 193 | return $this->groupManager->search($search); |
| 194 | 194 | } else { |
| 195 | 195 | $userObject = $this->userSession->getUser(); |
| 196 | - if($userObject !== null) { |
|
| 196 | + if ($userObject !== null) { |
|
| 197 | 197 | $groups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($userObject); |
| 198 | 198 | } else { |
| 199 | 199 | $groups = []; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public function __construct(IConfig $config) { |
| 80 | 80 | $this->config = $config; |
| 81 | 81 | $cachedUsers = &$this->cachedUsers; |
| 82 | - $this->listen('\OC\User', 'postDelete', function ($user) use (&$cachedUsers) { |
|
| 82 | + $this->listen('\OC\User', 'postDelete', function($user) use (&$cachedUsers) { |
|
| 83 | 83 | /** @var \OC\User\User $user */ |
| 84 | 84 | unset($cachedUsers[$user->getUID()]); |
| 85 | 85 | }); |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | $result = $this->checkPasswordNoLogging($loginName, $password); |
| 186 | 186 | |
| 187 | 187 | if ($result === false) { |
| 188 | - \OC::$server->getLogger()->warning('Login failed: \''. $loginName .'\' (Remote IP: \''. \OC::$server->getRequest()->getRemoteAddress(). '\')', ['app' => 'core']); |
|
| 188 | + \OC::$server->getLogger()->warning('Login failed: \''.$loginName.'\' (Remote IP: \''.\OC::$server->getRequest()->getRemoteAddress().'\')', ['app' => 'core']); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | return $result; |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - uasort($users, function ($a, $b) { |
|
| 237 | + uasort($users, function($a, $b) { |
|
| 238 | 238 | /** |
| 239 | 239 | * @var \OC\User\User $a |
| 240 | 240 | * @var \OC\User\User $b |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - usort($users, function ($a, $b) { |
|
| 266 | + usort($users, function($a, $b) { |
|
| 267 | 267 | /** |
| 268 | 268 | * @var \OC\User\User $a |
| 269 | 269 | * @var \OC\User\User $b |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | |
| 343 | 343 | $this->emit('\OC\User', 'preCreateUser', [$uid, $password]); |
| 344 | 344 | $state = $backend->createUser($uid, $password); |
| 345 | - if($state === false) { |
|
| 345 | + if ($state === false) { |
|
| 346 | 346 | throw new \InvalidArgumentException($l->t('Could not create user')); |
| 347 | 347 | } |
| 348 | 348 | $user = $this->getUserObject($uid, $backend); |
@@ -368,13 +368,13 @@ discard block |
||
| 368 | 368 | foreach ($this->backends as $backend) { |
| 369 | 369 | if ($backend->implementsActions(Backend::COUNT_USERS)) { |
| 370 | 370 | $backendUsers = $backend->countUsers(); |
| 371 | - if($backendUsers !== false) { |
|
| 372 | - if($backend instanceof IUserBackend) { |
|
| 371 | + if ($backendUsers !== false) { |
|
| 372 | + if ($backend instanceof IUserBackend) { |
|
| 373 | 373 | $name = $backend->getBackendName(); |
| 374 | 374 | } else { |
| 375 | 375 | $name = get_class($backend); |
| 376 | 376 | } |
| 377 | - if(isset($userCountStatistics[$name])) { |
|
| 377 | + if (isset($userCountStatistics[$name])) { |
|
| 378 | 378 | $userCountStatistics[$name] += $backendUsers; |
| 379 | 379 | } else { |
| 380 | 380 | $userCountStatistics[$name] = $backendUsers; |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | */ |
| 395 | 395 | public function countUsersOfGroups(array $groups) { |
| 396 | 396 | $users = []; |
| 397 | - foreach($groups as $group) { |
|
| 397 | + foreach ($groups as $group) { |
|
| 398 | 398 | $usersIds = array_map(function($user) { |
| 399 | 399 | return $user->getUID(); |
| 400 | 400 | }, $group->getUsers()); |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | $result->closeCursor(); |
| 459 | 459 | |
| 460 | 460 | if ($count !== false) { |
| 461 | - $count = (int)$count; |
|
| 461 | + $count = (int) $count; |
|
| 462 | 462 | } else { |
| 463 | 463 | $count = 0; |
| 464 | 464 | } |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | $result->closeCursor(); |
| 489 | 489 | |
| 490 | 490 | if ($count !== false) { |
| 491 | - $count = (int)$count; |
|
| 491 | + $count = (int) $count; |
|
| 492 | 492 | } else { |
| 493 | 493 | $count = 0; |
| 494 | 494 | } |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | |
| 513 | 513 | $query = $queryBuilder->execute(); |
| 514 | 514 | |
| 515 | - $result = (int)$query->fetchColumn(); |
|
| 515 | + $result = (int) $query->fetchColumn(); |
|
| 516 | 516 | $query->closeCursor(); |
| 517 | 517 | |
| 518 | 518 | return $result; |