diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2018-05-25 15:54:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-25 15:54:47 +0200 |
commit | 760b28ba4c7d4a9b6126aa4063238c2959eb263e (patch) | |
tree | 3671b2c23d7a9316a3b66e0e23d7062a65a30464 /apps | |
parent | d4a0af7e5ec0d0e97dda2d826574779dab82260c (diff) | |
parent | 4644841ba67e1e1f606011b51148303f59be3960 (diff) | |
download | nextcloud-server-760b28ba4c7d4a9b6126aa4063238c2959eb263e.tar.gz nextcloud-server-760b28ba4c7d4a9b6126aa4063238c2959eb263e.zip |
Merge pull request #9488 from nextcloud/disabled-users-fix
Added disabled count per groups & fixed disabled users query
Diffstat (limited to 'apps')
4 files changed, 34 insertions, 5 deletions
diff --git a/apps/provisioning_api/lib/Controller/AUserData.php b/apps/provisioning_api/lib/Controller/AUserData.php index 6c4967a6c3b..7a90e7a0a48 100644 --- a/apps/provisioning_api/lib/Controller/AUserData.php +++ b/apps/provisioning_api/lib/Controller/AUserData.php @@ -90,12 +90,12 @@ abstract class AUserData extends OCSController { } // Should be at least Admin Or SubAdmin! - if( $this->groupManager->isAdmin($currentLoggedInUser->getUID()) + if ($this->groupManager->isAdmin($currentLoggedInUser->getUID()) || $this->groupManager->getSubAdmin()->isUserAccessible($currentLoggedInUser, $targetUserObject)) { $data['enabled'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'enabled', 'true') === 'true'; } else { // Check they are looking up themselves - if($currentLoggedInUser->getUID() !== $targetUserObject->getUID()) { + if ($currentLoggedInUser->getUID() !== $targetUserObject->getUID()) { return $data; } } diff --git a/apps/provisioning_api/lib/Controller/GroupsController.php b/apps/provisioning_api/lib/Controller/GroupsController.php index c2958bc4778..5114c6f01d5 100644 --- a/apps/provisioning_api/lib/Controller/GroupsController.php +++ b/apps/provisioning_api/lib/Controller/GroupsController.php @@ -111,7 +111,12 @@ class GroupsController extends AUserData { $groups = $this->groupManager->search($search, $limit, $offset); $groups = array_map(function($group) { /** @var IGroup $group */ - return ['id' => $group->getGID(), 'displayname' => $group->getDisplayName()]; + return [ + 'id' => $group->getGID(), + 'displayname' => $group->getDisplayName(), + 'usercount' => $group->count(), + 'disabled' => $group->countDisabled() + ]; }, $groups); return new DataResponse(['groups' => $groups]); @@ -202,6 +207,10 @@ class GroupsController extends AUserData { // Do not insert empty entry if(!empty($userData)) { $usersDetails[$userId] = $userData; + } else { + // Logged user does not have permissions to see this user + // only showing its id + $usersDetails[$userId] = ['id' => $userId]; } } return new DataResponse(['users' => $usersDetails]); diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index 21f5382d010..38d0e08ff8b 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -180,6 +180,10 @@ class UsersController extends AUserData { // Do not insert empty entry if (!empty($userData)) { $usersDetails[$userId] = $userData; + } else { + // Logged user does not have permissions to see this user + // only showing its id + $usersDetails[$userId] = ['id' => $userId]; } } diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php index 44b440a40b2..115c9c7ba46 100644 --- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php +++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php @@ -101,6 +101,12 @@ class GroupsControllerTest extends \Test\TestCase { $group ->method('getDisplayName') ->willReturn($gid.'-name'); + $group + ->method('count') + ->willReturn(123); + $group + ->method('countDisabled') + ->willReturn(11); return $group; } @@ -205,8 +211,18 @@ class GroupsControllerTest extends \Test\TestCase { $result = $this->api->getGroupsDetails($search, $limit, $offset); $this->assertEquals(['groups' => [ - Array('id' => 'group1', 'displayname' => 'group1-name'), - Array('id' => 'group2', 'displayname' => 'group2-name') + Array( + 'id' => 'group1', + 'displayname' => 'group1-name', + 'usercount' => 123, + 'disabled' => 11 + ), + Array( + 'id' => 'group2', + 'displayname' => 'group2-name', + 'usercount' => 123, + 'disabled' => 11 + ) ]], $result->getData()); } |