@@ -153,16 +153,16 @@ discard block |
||
| 153 | 153 | // Check the group exists |
| 154 | 154 | $group = $this->groupManager->get($groupId); |
| 155 | 155 | if ($group !== null) { |
| 156 | - $isSubadminOfGroup =$this->groupManager->getSubAdmin()->isSubAdminOfGroup($user, $group); |
|
| 156 | + $isSubadminOfGroup = $this->groupManager->getSubAdmin()->isSubAdminOfGroup($user, $group); |
|
| 157 | 157 | } else { |
| 158 | 158 | throw new OCSNotFoundException('The requested group could not be found'); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | // Check subadmin has access to this group |
| 162 | - if($this->groupManager->isAdmin($user->getUID()) |
|
| 162 | + if ($this->groupManager->isAdmin($user->getUID()) |
|
| 163 | 163 | || $isSubadminOfGroup) { |
| 164 | 164 | $users = $this->groupManager->get($groupId)->getUsers(); |
| 165 | - $users = array_map(function($user) { |
|
| 165 | + $users = array_map(function($user) { |
|
| 166 | 166 | /** @var IUser $user */ |
| 167 | 167 | return $user->getUID(); |
| 168 | 168 | }, $users); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // Check subadmin has access to this group |
| 200 | - if($this->groupManager->isAdmin($currentUser->getUID()) || $isSubadminOfGroup) { |
|
| 200 | + if ($this->groupManager->isAdmin($currentUser->getUID()) || $isSubadminOfGroup) { |
|
| 201 | 201 | $users = $group->searchUsers($search, $limit, $offset); |
| 202 | 202 | |
| 203 | 203 | // Extract required number |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | $userId = (string) $user->getUID(); |
| 208 | 208 | $userData = $this->getUserData($userId); |
| 209 | 209 | // Do not insert empty entry |
| 210 | - if(!empty($userData)) { |
|
| 210 | + if (!empty($userData)) { |
|
| 211 | 211 | $usersDetails[$userId] = $userData; |
| 212 | 212 | } else { |
| 213 | 213 | // Logged user does not have permissions to see this user |
@@ -232,12 +232,12 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public function addGroup(string $groupid): DataResponse { |
| 234 | 234 | // Validate name |
| 235 | - if(empty($groupid)) { |
|
| 235 | + if (empty($groupid)) { |
|
| 236 | 236 | $this->logger->error('Group name not supplied', ['app' => 'provisioning_api']); |
| 237 | 237 | throw new OCSException('Invalid group name', 101); |
| 238 | 238 | } |
| 239 | 239 | // Check if it exists |
| 240 | - if($this->groupManager->groupExists($groupid)){ |
|
| 240 | + if ($this->groupManager->groupExists($groupid)) { |
|
| 241 | 241 | throw new OCSException('group exists', 102); |
| 242 | 242 | } |
| 243 | 243 | $this->groupManager->createGroup($groupid); |
@@ -253,9 +253,9 @@ discard block |
||
| 253 | 253 | */ |
| 254 | 254 | public function deleteGroup(string $groupId): DataResponse { |
| 255 | 255 | // Check it exists |
| 256 | - if(!$this->groupManager->groupExists($groupId)){ |
|
| 256 | + if (!$this->groupManager->groupExists($groupId)) { |
|
| 257 | 257 | throw new OCSException('', 101); |
| 258 | - } else if($groupId === 'admin' || !$this->groupManager->get($groupId)->delete()){ |
|
| 258 | + } else if ($groupId === 'admin' || !$this->groupManager->get($groupId)->delete()) { |
|
| 259 | 259 | // Cannot delete admin group |
| 260 | 260 | throw new OCSException('', 102); |
| 261 | 261 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | public function getSubAdminsOfGroup(string $groupId): DataResponse { |
| 272 | 272 | // Check group exists |
| 273 | 273 | $targetGroup = $this->groupManager->get($groupId); |
| 274 | - if($targetGroup === null) { |
|
| 274 | + if ($targetGroup === null) { |
|
| 275 | 275 | throw new OCSException('Group does not exist', 101); |
| 276 | 276 | } |
| 277 | 277 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | // Admin? Or SubAdmin? |
| 129 | 129 | $uid = $user->getUID(); |
| 130 | 130 | $subAdminManager = $this->groupManager->getSubAdmin(); |
| 131 | - if ($this->groupManager->isAdmin($uid)){ |
|
| 131 | + if ($this->groupManager->isAdmin($uid)) { |
|
| 132 | 132 | $users = $this->userManager->search($search, $limit, $offset); |
| 133 | 133 | } else if ($subAdminManager->isSubAdmin($user)) { |
| 134 | 134 | $subAdminOfGroups = $subAdminManager->getSubAdminsGroups($user); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | // Admin? Or SubAdmin? |
| 162 | 162 | $uid = $currentUser->getUID(); |
| 163 | 163 | $subAdminManager = $this->groupManager->getSubAdmin(); |
| 164 | - if ($this->groupManager->isAdmin($uid)){ |
|
| 164 | + if ($this->groupManager->isAdmin($uid)) { |
|
| 165 | 165 | $users = $this->userManager->search($search, $limit, $offset); |
| 166 | 166 | $users = array_keys($users); |
| 167 | 167 | } else if ($subAdminManager->isSubAdmin($currentUser)) { |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | throw new OCSException('group '.$group.' does not exist', 104); |
| 235 | 235 | } |
| 236 | 236 | if (!$isAdmin && !$subAdminManager->isSubAdminOfGroup($user, $this->groupManager->get($group))) { |
| 237 | - throw new OCSException('insufficient privileges for group '. $group, 105); |
|
| 237 | + throw new OCSException('insufficient privileges for group '.$group, 105); |
|
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | 240 | } else { |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | $group = $this->groupManager->get($groupid); |
| 250 | 250 | // Check if group exists |
| 251 | 251 | if ($group === null) { |
| 252 | - throw new OCSException('Subadmin group does not exist', 102); |
|
| 252 | + throw new OCSException('Subadmin group does not exist', 102); |
|
| 253 | 253 | } |
| 254 | 254 | // Check if trying to make subadmin of admin group |
| 255 | 255 | if ($group->getGID() === 'admin') { |
@@ -277,11 +277,11 @@ discard block |
||
| 277 | 277 | |
| 278 | 278 | try { |
| 279 | 279 | $newUser = $this->userManager->createUser($userid, $password); |
| 280 | - $this->logger->info('Successful addUser call with userid: ' . $userid, ['app' => 'ocs_api']); |
|
| 280 | + $this->logger->info('Successful addUser call with userid: '.$userid, ['app' => 'ocs_api']); |
|
| 281 | 281 | |
| 282 | 282 | foreach ($groups as $group) { |
| 283 | 283 | $this->groupManager->get($group)->addUser($newUser); |
| 284 | - $this->logger->info('Added userid ' . $userid . ' to group ' . $group, ['app' => 'ocs_api']); |
|
| 284 | + $this->logger->info('Added userid '.$userid.' to group '.$group, ['app' => 'ocs_api']); |
|
| 285 | 285 | } |
| 286 | 286 | foreach ($subadminGroups as $group) { |
| 287 | 287 | $subAdminManager->createSubAdmin($newUser, $group); |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | |
| 318 | 318 | return new DataResponse(); |
| 319 | 319 | |
| 320 | - } catch (HintException $e ) { |
|
| 320 | + } catch (HintException $e) { |
|
| 321 | 321 | $this->logger->logException($e, [ |
| 322 | 322 | 'message' => 'Failed addUser attempt with hint exception.', |
| 323 | 323 | 'level' => ILogger::WARN, |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | public function getCurrentUser(): DataResponse { |
| 366 | 366 | $user = $this->userSession->getUser(); |
| 367 | 367 | if ($user) { |
| 368 | - $data = $this->getUserData($user->getUID()); |
|
| 368 | + $data = $this->getUserData($user->getUID()); |
|
| 369 | 369 | // rename "displayname" to "display-name" only for this call to keep |
| 370 | 370 | // the API stable. |
| 371 | 371 | $data['display-name'] = $data['displayname']; |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); |
| 488 | 488 | } |
| 489 | 489 | // Process the edit |
| 490 | - switch($key) { |
|
| 490 | + switch ($key) { |
|
| 491 | 491 | case 'display': |
| 492 | 492 | case AccountManager::PROPERTY_DISPLAYNAME: |
| 493 | 493 | $targetUser->setDisplayName($value); |
@@ -758,7 +758,7 @@ discard block |
||
| 758 | 758 | } else if (!$this->groupManager->isAdmin($loggedInUser->getUID())) { |
| 759 | 759 | /** @var IGroup[] $subAdminGroups */ |
| 760 | 760 | $subAdminGroups = $subAdminManager->getSubAdminsGroups($loggedInUser); |
| 761 | - $subAdminGroups = array_map(function (IGroup $subAdminGroup) { |
|
| 761 | + $subAdminGroups = array_map(function(IGroup $subAdminGroup) { |
|
| 762 | 762 | return $subAdminGroup->getGID(); |
| 763 | 763 | }, $subAdminGroups); |
| 764 | 764 | $userGroups = $this->groupManager->getUserGroupIds($targetUser); |
@@ -795,7 +795,7 @@ discard block |
||
| 795 | 795 | } |
| 796 | 796 | // Check if group exists |
| 797 | 797 | if ($group === null) { |
| 798 | - throw new OCSException('Group does not exist', 102); |
|
| 798 | + throw new OCSException('Group does not exist', 102); |
|
| 799 | 799 | } |
| 800 | 800 | // Check if trying to make subadmin of admin group |
| 801 | 801 | if ($group->getGID() === 'admin') { |
@@ -906,7 +906,7 @@ discard block |
||
| 906 | 906 | $this->newUserMailHelper->setL10N($l10n); |
| 907 | 907 | $emailTemplate = $this->newUserMailHelper->generateTemplate($targetUser, false); |
| 908 | 908 | $this->newUserMailHelper->sendMail($targetUser, $emailTemplate); |
| 909 | - } catch(\Exception $e) { |
|
| 909 | + } catch (\Exception $e) { |
|
| 910 | 910 | $this->logger->logException($e, [ |
| 911 | 911 | 'message' => "Can't send new user mail to $email", |
| 912 | 912 | 'level' => ILogger::ERROR, |