@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | /** |
4 | 4 | * @copyright Copyright (c) 2016, ownCloud, Inc. |
5 | 5 | * |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | // Admin? Or SubAdmin? |
141 | 141 | $uid = $user->getUID(); |
142 | 142 | $subAdminManager = $this->groupManager->getSubAdmin(); |
143 | - if($this->groupManager->isAdmin($uid)){ |
|
143 | + if ($this->groupManager->isAdmin($uid)) { |
|
144 | 144 | $users = $this->userManager->search($search, $limit, $offset); |
145 | 145 | } else if ($subAdminManager->isSubAdmin($user)) { |
146 | 146 | $subAdminOfGroups = $subAdminManager->getSubAdminsGroups($user); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | // Admin? Or SubAdmin? |
174 | 174 | $uid = $user->getUID(); |
175 | 175 | $subAdminManager = $this->groupManager->getSubAdmin(); |
176 | - if($this->groupManager->isAdmin($uid)){ |
|
176 | + if ($this->groupManager->isAdmin($uid)) { |
|
177 | 177 | $users = $this->userManager->search($search, $limit, $offset); |
178 | 178 | } else if ($subAdminManager->isSubAdmin($user)) { |
179 | 179 | $subAdminOfGroups = $subAdminManager->getSubAdminsGroups($user); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | foreach ($users as $key => $userId) { |
193 | 193 | $userData = $this->getUserData($userId); |
194 | 194 | // Do not insert empty entry |
195 | - if(!empty($userData)) { |
|
195 | + if (!empty($userData)) { |
|
196 | 196 | $usersDetails[$userId] = $userData; |
197 | 197 | } |
198 | 198 | } |
@@ -213,27 +213,27 @@ discard block |
||
213 | 213 | * @return DataResponse |
214 | 214 | * @throws OCSException |
215 | 215 | */ |
216 | - public function addUser(string $userid, string $password = '', string $email='', array $groups = []): DataResponse { |
|
216 | + public function addUser(string $userid, string $password = '', string $email = '', array $groups = []): DataResponse { |
|
217 | 217 | $user = $this->userSession->getUser(); |
218 | 218 | $isAdmin = $this->groupManager->isAdmin($user->getUID()); |
219 | 219 | $subAdminManager = $this->groupManager->getSubAdmin(); |
220 | 220 | |
221 | - if($this->userManager->userExists($userid)) { |
|
221 | + if ($this->userManager->userExists($userid)) { |
|
222 | 222 | $this->logger->error('Failed addUser attempt: User already exists.', ['app' => 'ocs_api']); |
223 | 223 | throw new OCSException('User already exists', 102); |
224 | 224 | } |
225 | 225 | |
226 | - if($groups !== []) { |
|
226 | + if ($groups !== []) { |
|
227 | 227 | foreach ($groups as $group) { |
228 | - if(!$this->groupManager->groupExists($group)) { |
|
228 | + if (!$this->groupManager->groupExists($group)) { |
|
229 | 229 | throw new OCSException('group '.$group.' does not exist', 104); |
230 | 230 | } |
231 | - if(!$isAdmin && !$subAdminManager->isSubAdminOfGroup($user, $this->groupManager->get($group))) { |
|
232 | - throw new OCSException('insufficient privileges for group '. $group, 105); |
|
231 | + if (!$isAdmin && !$subAdminManager->isSubAdminOfGroup($user, $this->groupManager->get($group))) { |
|
232 | + throw new OCSException('insufficient privileges for group '.$group, 105); |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | } else { |
236 | - if(!$isAdmin) { |
|
236 | + if (!$isAdmin) { |
|
237 | 237 | throw new OCSException('no group specified (required for subadmins)', 106); |
238 | 238 | } |
239 | 239 | } |
@@ -252,11 +252,11 @@ discard block |
||
252 | 252 | |
253 | 253 | try { |
254 | 254 | $newUser = $this->userManager->createUser($userid, $password); |
255 | - $this->logger->info('Successful addUser call with userid: ' . $userid, ['app' => 'ocs_api']); |
|
255 | + $this->logger->info('Successful addUser call with userid: '.$userid, ['app' => 'ocs_api']); |
|
256 | 256 | |
257 | 257 | foreach ($groups as $group) { |
258 | 258 | $this->groupManager->get($group)->addUser($newUser); |
259 | - $this->logger->info('Added userid ' . $userid . ' to group ' . $group, ['app' => 'ocs_api']); |
|
259 | + $this->logger->info('Added userid '.$userid.' to group '.$group, ['app' => 'ocs_api']); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | // Send new user mail only if a mail is set |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | |
278 | 278 | return new DataResponse(); |
279 | 279 | |
280 | - } catch (HintException $e ) { |
|
280 | + } catch (HintException $e) { |
|
281 | 281 | $this->logger->logException($e, [ |
282 | 282 | 'message' => 'Failed addUser attempt with hint exception.', |
283 | 283 | 'level' => \OCP\Util::WARN, |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | public function getUser(string $userId): DataResponse { |
308 | 308 | $data = $this->getUserData($userId); |
309 | 309 | // getUserData returns empty array if not enough permissions |
310 | - if(empty($data)) { |
|
310 | + if (empty($data)) { |
|
311 | 311 | throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); |
312 | 312 | } |
313 | 313 | return new DataResponse($data); |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | public function getCurrentUser(): DataResponse { |
326 | 326 | $user = $this->userSession->getUser(); |
327 | 327 | if ($user) { |
328 | - $data = $this->getUserData($user->getUID()); |
|
328 | + $data = $this->getUserData($user->getUID()); |
|
329 | 329 | // rename "displayname" to "display-name" only for this call to keep |
330 | 330 | // the API stable. |
331 | 331 | $data['display-name'] = $data['displayname']; |
@@ -381,12 +381,12 @@ discard block |
||
381 | 381 | $currentLoggedInUser = $this->userSession->getUser(); |
382 | 382 | |
383 | 383 | $targetUser = $this->userManager->get($userId); |
384 | - if($targetUser === null) { |
|
384 | + if ($targetUser === null) { |
|
385 | 385 | throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); |
386 | 386 | } |
387 | 387 | |
388 | 388 | $permittedFields = []; |
389 | - if($targetUser->getUID() === $currentLoggedInUser->getUID()) { |
|
389 | + if ($targetUser->getUID() === $currentLoggedInUser->getUID()) { |
|
390 | 390 | // Editing self (display, email) |
391 | 391 | if ($this->config->getSystemValue('allow_user_to_change_display_name', true) !== false) { |
392 | 392 | $permittedFields[] = 'display'; |
@@ -412,13 +412,13 @@ discard block |
||
412 | 412 | } |
413 | 413 | |
414 | 414 | // If admin they can edit their own quota |
415 | - if($this->groupManager->isAdmin($currentLoggedInUser->getUID())) { |
|
415 | + if ($this->groupManager->isAdmin($currentLoggedInUser->getUID())) { |
|
416 | 416 | $permittedFields[] = 'quota'; |
417 | 417 | } |
418 | 418 | } else { |
419 | 419 | // Check if admin / subadmin |
420 | 420 | $subAdminManager = $this->groupManager->getSubAdmin(); |
421 | - if($subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser) |
|
421 | + if ($subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser) |
|
422 | 422 | || $this->groupManager->isAdmin($currentLoggedInUser->getUID())) { |
423 | 423 | // They have permissions over the user |
424 | 424 | $permittedFields[] = 'display'; |
@@ -437,18 +437,18 @@ discard block |
||
437 | 437 | } |
438 | 438 | } |
439 | 439 | // Check if permitted to edit this field |
440 | - if(!in_array($key, $permittedFields)) { |
|
440 | + if (!in_array($key, $permittedFields)) { |
|
441 | 441 | throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); |
442 | 442 | } |
443 | 443 | // Process the edit |
444 | - switch($key) { |
|
444 | + switch ($key) { |
|
445 | 445 | case 'display': |
446 | 446 | case AccountManager::PROPERTY_DISPLAYNAME: |
447 | 447 | $targetUser->setDisplayName($value); |
448 | 448 | break; |
449 | 449 | case 'quota': |
450 | 450 | $quota = $value; |
451 | - if($quota !== 'none' && $quota !== 'default') { |
|
451 | + if ($quota !== 'none' && $quota !== 'default') { |
|
452 | 452 | if (is_numeric($quota)) { |
453 | 453 | $quota = (float) $quota; |
454 | 454 | } else { |
@@ -457,9 +457,9 @@ discard block |
||
457 | 457 | if ($quota === false) { |
458 | 458 | throw new OCSException('Invalid quota value '.$value, 103); |
459 | 459 | } |
460 | - if($quota === 0) { |
|
460 | + if ($quota === 0) { |
|
461 | 461 | $quota = 'default'; |
462 | - }else if($quota === -1) { |
|
462 | + } else if ($quota === -1) { |
|
463 | 463 | $quota = 'none'; |
464 | 464 | } else { |
465 | 465 | $quota = \OCP\Util::humanFileSize($quota); |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | $this->config->setUserValue($targetUser->getUID(), 'core', 'lang', $value); |
479 | 479 | break; |
480 | 480 | case AccountManager::PROPERTY_EMAIL: |
481 | - if(filter_var($value, FILTER_VALIDATE_EMAIL) || $value === '') { |
|
481 | + if (filter_var($value, FILTER_VALIDATE_EMAIL) || $value === '') { |
|
482 | 482 | $targetUser->setEMailAddress($value); |
483 | 483 | } else { |
484 | 484 | throw new OCSException('', 102); |
@@ -513,18 +513,18 @@ discard block |
||
513 | 513 | |
514 | 514 | $targetUser = $this->userManager->get($userId); |
515 | 515 | |
516 | - if($targetUser === null || $targetUser->getUID() === $currentLoggedInUser->getUID()) { |
|
516 | + if ($targetUser === null || $targetUser->getUID() === $currentLoggedInUser->getUID()) { |
|
517 | 517 | throw new OCSException('', 101); |
518 | 518 | } |
519 | 519 | |
520 | 520 | // If not permitted |
521 | 521 | $subAdminManager = $this->groupManager->getSubAdmin(); |
522 | - if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) { |
|
522 | + if (!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) { |
|
523 | 523 | throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); |
524 | 524 | } |
525 | 525 | |
526 | 526 | // Go ahead with the delete |
527 | - if($targetUser->delete()) { |
|
527 | + if ($targetUser->delete()) { |
|
528 | 528 | return new DataResponse(); |
529 | 529 | } else { |
530 | 530 | throw new OCSException('', 101); |
@@ -567,13 +567,13 @@ discard block |
||
567 | 567 | $currentLoggedInUser = $this->userSession->getUser(); |
568 | 568 | |
569 | 569 | $targetUser = $this->userManager->get($userId); |
570 | - if($targetUser === null || $targetUser->getUID() === $currentLoggedInUser->getUID()) { |
|
570 | + if ($targetUser === null || $targetUser->getUID() === $currentLoggedInUser->getUID()) { |
|
571 | 571 | throw new OCSException('', 101); |
572 | 572 | } |
573 | 573 | |
574 | 574 | // If not permitted |
575 | 575 | $subAdminManager = $this->groupManager->getSubAdmin(); |
576 | - if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) { |
|
576 | + if (!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) { |
|
577 | 577 | throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); |
578 | 578 | } |
579 | 579 | |
@@ -594,11 +594,11 @@ discard block |
||
594 | 594 | $loggedInUser = $this->userSession->getUser(); |
595 | 595 | |
596 | 596 | $targetUser = $this->userManager->get($userId); |
597 | - if($targetUser === null) { |
|
597 | + if ($targetUser === null) { |
|
598 | 598 | throw new OCSException('', \OCP\API::RESPOND_NOT_FOUND); |
599 | 599 | } |
600 | 600 | |
601 | - if($targetUser->getUID() === $loggedInUser->getUID() || $this->groupManager->isAdmin($loggedInUser->getUID())) { |
|
601 | + if ($targetUser->getUID() === $loggedInUser->getUID() || $this->groupManager->isAdmin($loggedInUser->getUID())) { |
|
602 | 602 | // Self lookup or admin lookup |
603 | 603 | return new DataResponse([ |
604 | 604 | 'groups' => $this->groupManager->getUserGroupIds($targetUser) |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | $subAdminManager = $this->groupManager->getSubAdmin(); |
608 | 608 | |
609 | 609 | // Looking up someone else |
610 | - if($subAdminManager->isUserAccessible($loggedInUser, $targetUser)) { |
|
610 | + if ($subAdminManager->isUserAccessible($loggedInUser, $targetUser)) { |
|
611 | 611 | // Return the group that the method caller is subadmin of for the user in question |
612 | 612 | /** @var IGroup[] $getSubAdminsGroups */ |
613 | 613 | $getSubAdminsGroups = $subAdminManager->getSubAdminsGroups($loggedInUser); |
@@ -637,16 +637,16 @@ discard block |
||
637 | 637 | * @throws OCSException |
638 | 638 | */ |
639 | 639 | public function addToGroup(string $userId, string $groupid = ''): DataResponse { |
640 | - if($groupid === '') { |
|
640 | + if ($groupid === '') { |
|
641 | 641 | throw new OCSException('', 101); |
642 | 642 | } |
643 | 643 | |
644 | 644 | $group = $this->groupManager->get($groupid); |
645 | 645 | $targetUser = $this->userManager->get($userId); |
646 | - if($group === null) { |
|
646 | + if ($group === null) { |
|
647 | 647 | throw new OCSException('', 102); |
648 | 648 | } |
649 | - if($targetUser === null) { |
|
649 | + if ($targetUser === null) { |
|
650 | 650 | throw new OCSException('', 103); |
651 | 651 | } |
652 | 652 | |
@@ -674,17 +674,17 @@ discard block |
||
674 | 674 | public function removeFromGroup(string $userId, string $groupid): DataResponse { |
675 | 675 | $loggedInUser = $this->userSession->getUser(); |
676 | 676 | |
677 | - if($groupid === null || trim($groupid) === '') { |
|
677 | + if ($groupid === null || trim($groupid) === '') { |
|
678 | 678 | throw new OCSException('', 101); |
679 | 679 | } |
680 | 680 | |
681 | 681 | $group = $this->groupManager->get($groupid); |
682 | - if($group === null) { |
|
682 | + if ($group === null) { |
|
683 | 683 | throw new OCSException('', 102); |
684 | 684 | } |
685 | 685 | |
686 | 686 | $targetUser = $this->userManager->get($userId); |
687 | - if($targetUser === null) { |
|
687 | + if ($targetUser === null) { |
|
688 | 688 | throw new OCSException('', 103); |
689 | 689 | } |
690 | 690 | |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | } else if (!$this->groupManager->isAdmin($loggedInUser->getUID())) { |
709 | 709 | /** @var IGroup[] $subAdminGroups */ |
710 | 710 | $subAdminGroups = $subAdminManager->getSubAdminsGroups($loggedInUser); |
711 | - $subAdminGroups = array_map(function (IGroup $subAdminGroup) { |
|
711 | + $subAdminGroups = array_map(function(IGroup $subAdminGroup) { |
|
712 | 712 | return $subAdminGroup->getGID(); |
713 | 713 | }, $subAdminGroups); |
714 | 714 | $userGroups = $this->groupManager->getUserGroupIds($targetUser); |
@@ -740,15 +740,15 @@ discard block |
||
740 | 740 | $user = $this->userManager->get($userId); |
741 | 741 | |
742 | 742 | // Check if the user exists |
743 | - if($user === null) { |
|
743 | + if ($user === null) { |
|
744 | 744 | throw new OCSException('User does not exist', 101); |
745 | 745 | } |
746 | 746 | // Check if group exists |
747 | - if($group === null) { |
|
748 | - throw new OCSException('Group does not exist', 102); |
|
747 | + if ($group === null) { |
|
748 | + throw new OCSException('Group does not exist', 102); |
|
749 | 749 | } |
750 | 750 | // Check if trying to make subadmin of admin group |
751 | - if($group->getGID() === 'admin') { |
|
751 | + if ($group->getGID() === 'admin') { |
|
752 | 752 | throw new OCSException('Cannot create subadmins for admin group', 103); |
753 | 753 | } |
754 | 754 | |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | return new DataResponse(); |
760 | 760 | } |
761 | 761 | // Go |
762 | - if($subAdminManager->createSubAdmin($user, $group)) { |
|
762 | + if ($subAdminManager->createSubAdmin($user, $group)) { |
|
763 | 763 | return new DataResponse(); |
764 | 764 | } else { |
765 | 765 | throw new OCSException('Unknown error occurred', 103); |
@@ -782,20 +782,20 @@ discard block |
||
782 | 782 | $subAdminManager = $this->groupManager->getSubAdmin(); |
783 | 783 | |
784 | 784 | // Check if the user exists |
785 | - if($user === null) { |
|
785 | + if ($user === null) { |
|
786 | 786 | throw new OCSException('User does not exist', 101); |
787 | 787 | } |
788 | 788 | // Check if the group exists |
789 | - if($group === null) { |
|
789 | + if ($group === null) { |
|
790 | 790 | throw new OCSException('Group does not exist', 101); |
791 | 791 | } |
792 | 792 | // Check if they are a subadmin of this said group |
793 | - if(!$subAdminManager->isSubAdminOfGroup($user, $group)) { |
|
793 | + if (!$subAdminManager->isSubAdminOfGroup($user, $group)) { |
|
794 | 794 | throw new OCSException('User is not a subadmin of this group', 102); |
795 | 795 | } |
796 | 796 | |
797 | 797 | // Go |
798 | - if($subAdminManager->deleteSubAdmin($user, $group)) { |
|
798 | + if ($subAdminManager->deleteSubAdmin($user, $group)) { |
|
799 | 799 | return new DataResponse(); |
800 | 800 | } else { |
801 | 801 | throw new OCSException('Unknown error occurred', 103); |
@@ -828,13 +828,13 @@ discard block |
||
828 | 828 | $currentLoggedInUser = $this->userSession->getUser(); |
829 | 829 | |
830 | 830 | $targetUser = $this->userManager->get($userId); |
831 | - if($targetUser === null) { |
|
831 | + if ($targetUser === null) { |
|
832 | 832 | throw new OCSException('', \OCP\API::RESPOND_NOT_FOUND); |
833 | 833 | } |
834 | 834 | |
835 | 835 | // Check if admin / subadmin |
836 | 836 | $subAdminManager = $this->groupManager->getSubAdmin(); |
837 | - if(!$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser) |
|
837 | + if (!$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser) |
|
838 | 838 | && !$this->groupManager->isAdmin($currentLoggedInUser->getUID())) { |
839 | 839 | // No rights |
840 | 840 | throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | $this->newUserMailHelper->setL10N($l10n); |
857 | 857 | $emailTemplate = $this->newUserMailHelper->generateTemplate($targetUser, false); |
858 | 858 | $this->newUserMailHelper->sendMail($targetUser, $emailTemplate); |
859 | - } catch(\Exception $e) { |
|
859 | + } catch (\Exception $e) { |
|
860 | 860 | $this->logger->logException($e, [ |
861 | 861 | 'message' => "Can't send new user mail to $email", |
862 | 862 | 'level' => \OCP\Util::ERROR, |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | /** |
4 | 4 | * @copyright Copyright (c) 2016, ownCloud, Inc. |
5 | 5 | * |
@@ -164,16 +164,16 @@ discard block |
||
164 | 164 | // Check the group exists |
165 | 165 | $group = $this->groupManager->get($groupId); |
166 | 166 | if ($group !== null) { |
167 | - $isSubadminOfGroup =$this->groupManager->getSubAdmin()->isSubAdminOfGroup($user, $group); |
|
167 | + $isSubadminOfGroup = $this->groupManager->getSubAdmin()->isSubAdminOfGroup($user, $group); |
|
168 | 168 | } else { |
169 | 169 | throw new OCSNotFoundException('The requested group could not be found'); |
170 | 170 | } |
171 | 171 | |
172 | 172 | // Check subadmin has access to this group |
173 | - if($this->groupManager->isAdmin($user->getUID()) |
|
173 | + if ($this->groupManager->isAdmin($user->getUID()) |
|
174 | 174 | || $isSubadminOfGroup) { |
175 | 175 | $users = $this->groupManager->get($groupId)->getUsers(); |
176 | - $users = array_map(function($user) { |
|
176 | + $users = array_map(function($user) { |
|
177 | 177 | /** @var IUser $user */ |
178 | 178 | return $user->getUID(); |
179 | 179 | }, $users); |
@@ -202,13 +202,13 @@ discard block |
||
202 | 202 | // Check the group exists |
203 | 203 | $group = $this->groupManager->get($groupId); |
204 | 204 | if ($group !== null) { |
205 | - $isSubadminOfGroup =$this->groupManager->getSubAdmin()->isSubAdminOfGroup($user, $group); |
|
205 | + $isSubadminOfGroup = $this->groupManager->getSubAdmin()->isSubAdminOfGroup($user, $group); |
|
206 | 206 | } else { |
207 | 207 | throw new OCSException('The requested group could not be found', \OCP\API::RESPOND_NOT_FOUND); |
208 | 208 | } |
209 | 209 | |
210 | 210 | // Check subadmin has access to this group |
211 | - if($this->groupManager->isAdmin($user->getUID()) |
|
211 | + if ($this->groupManager->isAdmin($user->getUID()) |
|
212 | 212 | || $isSubadminOfGroup) { |
213 | 213 | $users = $this->groupManager->get($groupId)->getUsers(); |
214 | 214 | // Extract required number |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | foreach ($users as $userId) { |
219 | 219 | $userData = $this->getUserData($userId); |
220 | 220 | // Do not insert empty entry |
221 | - if(!empty($userData)) { |
|
221 | + if (!empty($userData)) { |
|
222 | 222 | $usersDetails[$userId] = $userData; |
223 | 223 | } |
224 | 224 | } |
@@ -239,12 +239,12 @@ discard block |
||
239 | 239 | */ |
240 | 240 | public function addGroup(string $groupid): DataResponse { |
241 | 241 | // Validate name |
242 | - if(empty($groupid)) { |
|
242 | + if (empty($groupid)) { |
|
243 | 243 | $this->logger->error('Group name not supplied', ['app' => 'provisioning_api']); |
244 | 244 | throw new OCSException('Invalid group name', 101); |
245 | 245 | } |
246 | 246 | // Check if it exists |
247 | - if($this->groupManager->groupExists($groupid)){ |
|
247 | + if ($this->groupManager->groupExists($groupid)) { |
|
248 | 248 | throw new OCSException('', 102); |
249 | 249 | } |
250 | 250 | $this->groupManager->createGroup($groupid); |
@@ -260,9 +260,9 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public function deleteGroup(string $groupId): DataResponse { |
262 | 262 | // Check it exists |
263 | - if(!$this->groupManager->groupExists($groupId)){ |
|
263 | + if (!$this->groupManager->groupExists($groupId)) { |
|
264 | 264 | throw new OCSException('', 101); |
265 | - } else if($groupId === 'admin' || !$this->groupManager->get($groupId)->delete()){ |
|
265 | + } else if ($groupId === 'admin' || !$this->groupManager->get($groupId)->delete()) { |
|
266 | 266 | // Cannot delete admin group |
267 | 267 | throw new OCSException('', 102); |
268 | 268 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | public function getSubAdminsOfGroup(string $groupId): DataResponse { |
279 | 279 | // Check group exists |
280 | 280 | $targetGroup = $this->groupManager->get($groupId); |
281 | - if($targetGroup === null) { |
|
281 | + if ($targetGroup === null) { |
|
282 | 282 | throw new OCSException('Group does not exist', 101); |
283 | 283 | } |
284 | 284 |
@@ -6,35 +6,35 @@ |
||
6 | 6 | |
7 | 7 | class ComposerStaticInitProvisioning_API |
8 | 8 | { |
9 | - public static $prefixLengthsPsr4 = array ( |
|
9 | + public static $prefixLengthsPsr4 = array( |
|
10 | 10 | 'O' => |
11 | - array ( |
|
11 | + array( |
|
12 | 12 | 'OCA\\Provisioning_API\\' => 21, |
13 | 13 | ), |
14 | 14 | ); |
15 | 15 | |
16 | - public static $prefixDirsPsr4 = array ( |
|
16 | + public static $prefixDirsPsr4 = array( |
|
17 | 17 | 'OCA\\Provisioning_API\\' => |
18 | - array ( |
|
19 | - 0 => __DIR__ . '/..' . '/../lib', |
|
18 | + array( |
|
19 | + 0 => __DIR__.'/..'.'/../lib', |
|
20 | 20 | ), |
21 | 21 | ); |
22 | 22 | |
23 | - public static $classMap = array ( |
|
24 | - 'OCA\\Provisioning_API\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', |
|
25 | - 'OCA\\Provisioning_API\\Controller\\AUserData' => __DIR__ . '/..' . '/../lib/Controller/AUserData.php', |
|
26 | - 'OCA\\Provisioning_API\\Controller\\AppConfigController' => __DIR__ . '/..' . '/../lib/Controller/AppConfigController.php', |
|
27 | - 'OCA\\Provisioning_API\\Controller\\AppsController' => __DIR__ . '/..' . '/../lib/Controller/AppsController.php', |
|
28 | - 'OCA\\Provisioning_API\\Controller\\GroupsController' => __DIR__ . '/..' . '/../lib/Controller/GroupsController.php', |
|
29 | - 'OCA\\Provisioning_API\\Controller\\UsersController' => __DIR__ . '/..' . '/../lib/Controller/UsersController.php', |
|
30 | - 'OCA\\Provisioning_API\\FederatedFileSharingFactory' => __DIR__ . '/..' . '/../lib/FederatedFileSharingFactory.php', |
|
31 | - 'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => __DIR__ . '/..' . '/../lib/Middleware/Exceptions/NotSubAdminException.php', |
|
32 | - 'OCA\\Provisioning_API\\Middleware\\ProvisioningApiMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/ProvisioningApiMiddleware.php', |
|
23 | + public static $classMap = array( |
|
24 | + 'OCA\\Provisioning_API\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php', |
|
25 | + 'OCA\\Provisioning_API\\Controller\\AUserData' => __DIR__.'/..'.'/../lib/Controller/AUserData.php', |
|
26 | + 'OCA\\Provisioning_API\\Controller\\AppConfigController' => __DIR__.'/..'.'/../lib/Controller/AppConfigController.php', |
|
27 | + 'OCA\\Provisioning_API\\Controller\\AppsController' => __DIR__.'/..'.'/../lib/Controller/AppsController.php', |
|
28 | + 'OCA\\Provisioning_API\\Controller\\GroupsController' => __DIR__.'/..'.'/../lib/Controller/GroupsController.php', |
|
29 | + 'OCA\\Provisioning_API\\Controller\\UsersController' => __DIR__.'/..'.'/../lib/Controller/UsersController.php', |
|
30 | + 'OCA\\Provisioning_API\\FederatedFileSharingFactory' => __DIR__.'/..'.'/../lib/FederatedFileSharingFactory.php', |
|
31 | + 'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => __DIR__.'/..'.'/../lib/Middleware/Exceptions/NotSubAdminException.php', |
|
32 | + 'OCA\\Provisioning_API\\Middleware\\ProvisioningApiMiddleware' => __DIR__.'/..'.'/../lib/Middleware/ProvisioningApiMiddleware.php', |
|
33 | 33 | ); |
34 | 34 | |
35 | 35 | public static function getInitializer(ClassLoader $loader) |
36 | 36 | { |
37 | - return \Closure::bind(function () use ($loader) { |
|
37 | + return \Closure::bind(function() use ($loader) { |
|
38 | 38 | $loader->prefixLengthsPsr4 = ComposerStaticInitProvisioning_API::$prefixLengthsPsr4; |
39 | 39 | $loader->prefixDirsPsr4 = ComposerStaticInitProvisioning_API::$prefixDirsPsr4; |
40 | 40 | $loader->classMap = ComposerStaticInitProvisioning_API::$classMap; |
@@ -6,13 +6,13 @@ |
||
6 | 6 | $baseDir = $vendorDir; |
7 | 7 | |
8 | 8 | return array( |
9 | - 'OCA\\Provisioning_API\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', |
|
10 | - 'OCA\\Provisioning_API\\Controller\\AUserData' => $baseDir . '/../lib/Controller/AUserData.php', |
|
11 | - 'OCA\\Provisioning_API\\Controller\\AppConfigController' => $baseDir . '/../lib/Controller/AppConfigController.php', |
|
12 | - 'OCA\\Provisioning_API\\Controller\\AppsController' => $baseDir . '/../lib/Controller/AppsController.php', |
|
13 | - 'OCA\\Provisioning_API\\Controller\\GroupsController' => $baseDir . '/../lib/Controller/GroupsController.php', |
|
14 | - 'OCA\\Provisioning_API\\Controller\\UsersController' => $baseDir . '/../lib/Controller/UsersController.php', |
|
15 | - 'OCA\\Provisioning_API\\FederatedFileSharingFactory' => $baseDir . '/../lib/FederatedFileSharingFactory.php', |
|
16 | - 'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => $baseDir . '/../lib/Middleware/Exceptions/NotSubAdminException.php', |
|
17 | - 'OCA\\Provisioning_API\\Middleware\\ProvisioningApiMiddleware' => $baseDir . '/../lib/Middleware/ProvisioningApiMiddleware.php', |
|
9 | + 'OCA\\Provisioning_API\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php', |
|
10 | + 'OCA\\Provisioning_API\\Controller\\AUserData' => $baseDir.'/../lib/Controller/AUserData.php', |
|
11 | + 'OCA\\Provisioning_API\\Controller\\AppConfigController' => $baseDir.'/../lib/Controller/AppConfigController.php', |
|
12 | + 'OCA\\Provisioning_API\\Controller\\AppsController' => $baseDir.'/../lib/Controller/AppsController.php', |
|
13 | + 'OCA\\Provisioning_API\\Controller\\GroupsController' => $baseDir.'/../lib/Controller/GroupsController.php', |
|
14 | + 'OCA\\Provisioning_API\\Controller\\UsersController' => $baseDir.'/../lib/Controller/UsersController.php', |
|
15 | + 'OCA\\Provisioning_API\\FederatedFileSharingFactory' => $baseDir.'/../lib/FederatedFileSharingFactory.php', |
|
16 | + 'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => $baseDir.'/../lib/Middleware/Exceptions/NotSubAdminException.php', |
|
17 | + 'OCA\\Provisioning_API\\Middleware\\ProvisioningApiMiddleware' => $baseDir.'/../lib/Middleware/ProvisioningApiMiddleware.php', |
|
18 | 18 | ); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | /** |
4 | 4 | * @copyright Copyright (c) 2018 John Molakvoæ (skjnldsv) <[email protected]> |
5 | 5 | * |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | |
46 | 46 | // Check if the target user exists |
47 | 47 | $targetUserObject = $this->userManager->get($userId); |
48 | - if($targetUserObject === null) { |
|
48 | + if ($targetUserObject === null) { |
|
49 | 49 | throw new OCSNotFoundException('User does not exist'); |
50 | 50 | } |
51 | 51 | |
52 | 52 | // Should be at least Admin Or SubAdmin! |
53 | - if( $this->groupManager->isAdmin($currentLoggedInUser->getUID()) |
|
53 | + if ($this->groupManager->isAdmin($currentLoggedInUser->getUID()) |
|
54 | 54 | || $this->groupManager->getSubAdmin()->isUserAccessible($currentLoggedInUser, $targetUserObject)) { |
55 | 55 | $data['enabled'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'enabled', 'true'); |
56 | 56 | } else { |
57 | 57 | // Check they are looking up themselves |
58 | - if($currentLoggedInUser->getUID() !== $targetUserObject->getUID()) { |
|
58 | + if ($currentLoggedInUser->getUID() !== $targetUserObject->getUID()) { |
|
59 | 59 | return $data; |
60 | 60 | } |
61 | 61 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | protected function getUserSubAdminGroupsData(string $userId): array { |
98 | 98 | $user = $this->userManager->get($userId); |
99 | 99 | // Check if the user exists |
100 | - if($user === null) { |
|
100 | + if ($user === null) { |
|
101 | 101 | throw new OCSNotFoundException('User does not exist'); |
102 | 102 | } |
103 | 103 |