diff options
Diffstat (limited to 'apps/provisioning_api/lib')
5 files changed, 20 insertions, 29 deletions
diff --git a/apps/provisioning_api/lib/Controller/AUserData.php b/apps/provisioning_api/lib/Controller/AUserData.php index 3579202b36f..31a8322e4a7 100644 --- a/apps/provisioning_api/lib/Controller/AUserData.php +++ b/apps/provisioning_api/lib/Controller/AUserData.php @@ -100,14 +100,14 @@ abstract class AUserData extends OCSController { // Check if the target user exists $targetUserObject = $this->userManager->get($userId); - if($targetUserObject === null) { + if ($targetUserObject === null) { throw new OCSNotFoundException('User does not exist'); } // Should be at least Admin Or SubAdmin! if ($this->groupManager->isAdmin($currentLoggedInUser->getUID()) || $this->groupManager->getSubAdmin()->isUserAccessible($currentLoggedInUser, $targetUserObject)) { - $data['enabled'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'enabled', 'true') === 'true'; + $data['enabled'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'enabled', 'true') === 'true'; } else { // Check they are looking up themselves if ($currentLoggedInUser->getUID() !== $targetUserObject->getUID()) { @@ -167,7 +167,7 @@ abstract class AUserData extends OCSController { protected function getUserSubAdminGroupsData(string $userId): array { $user = $this->userManager->get($userId); // Check if the user exists - if($user === null) { + if ($user === null) { throw new OCSNotFoundException('User does not exist'); } @@ -215,5 +215,4 @@ abstract class AUserData extends OCSController { } return $data; } - } diff --git a/apps/provisioning_api/lib/Controller/AppsController.php b/apps/provisioning_api/lib/Controller/AppsController.php index d5a8de91772..e59440e5e8c 100644 --- a/apps/provisioning_api/lib/Controller/AppsController.php +++ b/apps/provisioning_api/lib/Controller/AppsController.php @@ -64,11 +64,11 @@ class AppsController extends OCSController { public function getApps(string $filter = null): DataResponse { $apps = (new OC_App())->listAllApps(); $list = []; - foreach($apps as $app) { + foreach ($apps as $app) { $list[] = $app['id']; } - if($filter){ - switch($filter){ + if ($filter) { + switch ($filter) { case 'enabled': return new DataResponse(['apps' => \OC_App::getEnabledApps()]); break; @@ -80,7 +80,6 @@ class AppsController extends OCSController { // Invalid filter variable throw new OCSException('', 101); } - } else { return new DataResponse(['apps' => $list]); } @@ -93,7 +92,7 @@ class AppsController extends OCSController { */ public function getAppInfo(string $app): DataResponse { $info = \OCP\App::getAppInfo($app); - if(!is_null($info)) { + if (!is_null($info)) { return new DataResponse(OC_App::getAppInfo($app)); } @@ -124,5 +123,4 @@ class AppsController extends OCSController { $this->appManager->disableApp($app); return new DataResponse(); } - } diff --git a/apps/provisioning_api/lib/Controller/GroupsController.php b/apps/provisioning_api/lib/Controller/GroupsController.php index 435f0410217..7f2da88a097 100644 --- a/apps/provisioning_api/lib/Controller/GroupsController.php +++ b/apps/provisioning_api/lib/Controller/GroupsController.php @@ -163,7 +163,7 @@ class GroupsController extends AUserData { } // Check subadmin has access to this group - if($this->groupManager->isAdmin($user->getUID()) + if ($this->groupManager->isAdmin($user->getUID()) || $isSubadminOfGroup) { $users = $this->groupManager->get($groupId)->getUsers(); $users = array_map(function ($user) { @@ -201,7 +201,7 @@ class GroupsController extends AUserData { } // Check subadmin has access to this group - if($this->groupManager->isAdmin($currentUser->getUID()) || $isSubadminOfGroup) { + if ($this->groupManager->isAdmin($currentUser->getUID()) || $isSubadminOfGroup) { $users = $group->searchUsers($search, $limit, $offset); // Extract required number @@ -219,7 +219,7 @@ class GroupsController extends AUserData { // only showing its id $usersDetails[$userId] = ['id' => $userId]; } - } catch(OCSNotFoundException $e) { + } catch (OCSNotFoundException $e) { // continue if a users ceased to exist. } } @@ -240,12 +240,12 @@ class GroupsController extends AUserData { */ public function addGroup(string $groupid): DataResponse { // Validate name - if(empty($groupid)) { + if (empty($groupid)) { $this->logger->error('Group name not supplied', ['app' => 'provisioning_api']); throw new OCSException('Invalid group name', 101); } // Check if it exists - if($this->groupManager->groupExists($groupid)){ + if ($this->groupManager->groupExists($groupid)) { throw new OCSException('group exists', 102); } $this->groupManager->createGroup($groupid); @@ -283,9 +283,9 @@ class GroupsController extends AUserData { */ public function deleteGroup(string $groupId): DataResponse { // Check it exists - if(!$this->groupManager->groupExists($groupId)){ + if (!$this->groupManager->groupExists($groupId)) { throw new OCSException('', 101); - } elseif($groupId === 'admin' || !$this->groupManager->get($groupId)->delete()){ + } elseif ($groupId === 'admin' || !$this->groupManager->get($groupId)->delete()) { // Cannot delete admin group throw new OCSException('', 102); } @@ -301,7 +301,7 @@ class GroupsController extends AUserData { public function getSubAdminsOfGroup(string $groupId): DataResponse { // Check group exists $targetGroup = $this->groupManager->get($groupId); - if($targetGroup === null) { + if ($targetGroup === null) { throw new OCSException('Group does not exist', 101); } @@ -315,5 +315,4 @@ class GroupsController extends AUserData { return new DataResponse($uids); } - } diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index ff67a880c13..bd327ffe441 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -140,7 +140,7 @@ class UsersController extends AUserData { // Admin? Or SubAdmin? $uid = $user->getUID(); $subAdminManager = $this->groupManager->getSubAdmin(); - if ($this->groupManager->isAdmin($uid)){ + if ($this->groupManager->isAdmin($uid)) { $users = $this->userManager->search($search, $limit, $offset); } elseif ($subAdminManager->isSubAdmin($user)) { $subAdminOfGroups = $subAdminManager->getSubAdminsGroups($user); @@ -173,7 +173,7 @@ class UsersController extends AUserData { // Admin? Or SubAdmin? $uid = $currentUser->getUID(); $subAdminManager = $this->groupManager->getSubAdmin(); - if ($this->groupManager->isAdmin($uid)){ + if ($this->groupManager->isAdmin($uid)) { $users = $this->userManager->search($search, $limit, $offset); $users = array_keys($users); } elseif ($subAdminManager->isSubAdmin($currentUser)) { @@ -250,7 +250,7 @@ class UsersController extends AUserData { $isAdmin = $this->groupManager->isAdmin($user->getUID()); $subAdminManager = $this->groupManager->getSubAdmin(); - if(empty($userid) && $this->config->getAppValue('core', 'newUser.generateUserID', 'no') === 'yes') { + if (empty($userid) && $this->config->getAppValue('core', 'newUser.generateUserID', 'no') === 'yes') { $userid = $this->createNewUserId(); } @@ -352,7 +352,6 @@ class UsersController extends AUserData { } return new DataResponse(['id' => $userid]); - } catch (HintException $e) { $this->logger->logException($e, [ 'message' => 'Failed addUser attempt with hint exception.', @@ -414,7 +413,6 @@ class UsersController extends AUserData { $data['display-name'] = $data['displayname']; unset($data['displayname']); return new DataResponse($data); - } throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); @@ -530,7 +528,7 @@ class UsersController extends AUserData { throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); } // Process the edit - switch($key) { + switch ($key) { case 'display': case AccountManager::PROPERTY_DISPLAYNAME: $targetUser->setDisplayName($value); @@ -755,7 +753,6 @@ class UsersController extends AUserData { throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); } } - } /** @@ -835,7 +832,6 @@ class UsersController extends AUserData { // Not an admin, so the user must be a subadmin of this group, but that is not allowed. throw new OCSException('Cannot remove yourself from this group as you are a SubAdmin', 105); } - } elseif (!$this->groupManager->isAdmin($loggedInUser->getUID())) { /** @var IGroup[] $subAdminGroups */ $subAdminGroups = $subAdminManager->getSubAdminsGroups($loggedInUser); @@ -973,7 +969,7 @@ class UsersController extends AUserData { try { $emailTemplate = $this->newUserMailHelper->generateTemplate($targetUser, false); $this->newUserMailHelper->sendMail($targetUser, $emailTemplate); - } catch(\Exception $e) { + } catch (\Exception $e) { $this->logger->logException($e, [ 'message' => "Can't send new user mail to $email", 'level' => ILogger::ERROR, diff --git a/apps/provisioning_api/lib/FederatedFileSharingFactory.php b/apps/provisioning_api/lib/FederatedFileSharingFactory.php index 63a0f0ff200..6a630542af5 100644 --- a/apps/provisioning_api/lib/FederatedFileSharingFactory.php +++ b/apps/provisioning_api/lib/FederatedFileSharingFactory.php @@ -40,5 +40,4 @@ class FederatedFileSharingFactory { public function get(): Application { return $this->serverContainer->query(Application::class); } - } |