backport of #17450
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
63479ba72e
commit
4294347e6a
|
@ -187,31 +187,38 @@ class UsersController extends Controller {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->isAdmin) {
|
$disabledUsers = -1;
|
||||||
$disabledUsers = $isLDAPUsed ? -1 : $this->userManager->countDisabledUsers();
|
$userCount = 0;
|
||||||
$userCount = $isLDAPUsed ? 0 : array_reduce($this->userManager->countUsers(), function($v, $w) {
|
|
||||||
return $v + (int)$w;
|
|
||||||
}, 0);
|
|
||||||
} else {
|
|
||||||
// User is subadmin !
|
|
||||||
// Map group list to names to retrieve the countDisabledUsersOfGroups
|
|
||||||
$userGroups = $this->groupManager->getUserGroups($user);
|
|
||||||
$groupsNames = [];
|
|
||||||
$userCount = 0;
|
|
||||||
|
|
||||||
foreach($groups as $key => $group) {
|
if(!$isLDAPUsed) {
|
||||||
// $userCount += (int)$group['usercount'];
|
if ($this->isAdmin) {
|
||||||
array_push($groupsNames, $group['name']);
|
$disabledUsers = $this->userManager->countDisabledUsers();
|
||||||
// we prevent subadmins from looking up themselves
|
$userCount = array_reduce($this->userManager->countUsers(), function($v, $w) {
|
||||||
// so we lower the count of the groups he belongs to
|
return $v + (int)$w;
|
||||||
if (array_key_exists($group['id'], $userGroups)) {
|
}, 0);
|
||||||
$groups[$key]['usercount']--;
|
} else {
|
||||||
$userCount = -1; // we also lower from one the total count
|
// User is subadmin !
|
||||||
}
|
// Map group list to names to retrieve the countDisabledUsersOfGroups
|
||||||
};
|
$userGroups = $this->groupManager->getUserGroups($user);
|
||||||
$userCount += $isLDAPUsed ? 0 : $this->userManager->countUsersOfGroups($groupsInfo->getGroups());
|
$groupsNames = [];
|
||||||
$disabledUsers = $isLDAPUsed ? -1 : $this->userManager->countDisabledUsersOfGroups($groupsNames);
|
|
||||||
|
foreach($groups as $key => $group) {
|
||||||
|
// $userCount += (int)$group['usercount'];
|
||||||
|
array_push($groupsNames, $group['name']);
|
||||||
|
// we prevent subadmins from looking up themselves
|
||||||
|
// so we lower the count of the groups he belongs to
|
||||||
|
if (array_key_exists($group['id'], $userGroups)) {
|
||||||
|
$groups[$key]['usercount']--;
|
||||||
|
$userCount -= 1; // we also lower from one the total count
|
||||||
|
}
|
||||||
|
};
|
||||||
|
$userCount += $this->userManager->countUsersOfGroups($groupsInfo->getGroups());
|
||||||
|
$disabledUsers = $this->userManager->countDisabledUsersOfGroups($groupsNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
$userCount -= $disabledUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
$disabledUsersGroup = [
|
$disabledUsersGroup = [
|
||||||
'id' => 'disabled',
|
'id' => 'disabled',
|
||||||
'name' => 'Disabled users',
|
'name' => 'Disabled users',
|
||||||
|
@ -240,7 +247,7 @@ class UsersController extends Controller {
|
||||||
$serverData['isAdmin'] = $this->isAdmin;
|
$serverData['isAdmin'] = $this->isAdmin;
|
||||||
$serverData['sortGroups'] = $sortGroupsBy;
|
$serverData['sortGroups'] = $sortGroupsBy;
|
||||||
$serverData['quotaPreset'] = $quotaPreset;
|
$serverData['quotaPreset'] = $quotaPreset;
|
||||||
$serverData['userCount'] = $userCount - $disabledUsers;
|
$serverData['userCount'] = $userCount;
|
||||||
$serverData['languages'] = $languages;
|
$serverData['languages'] = $languages;
|
||||||
$serverData['defaultLanguage'] = $this->config->getSystemValue('default_language', 'en');
|
$serverData['defaultLanguage'] = $this->config->getSystemValue('default_language', 'en');
|
||||||
// Settings
|
// Settings
|
||||||
|
|
|
@ -98,8 +98,8 @@ const mutations = {
|
||||||
let group = state.groups.find(groupSearch => groupSearch.id == gid);
|
let group = state.groups.find(groupSearch => groupSearch.id == gid);
|
||||||
let user = state.users.find(user => user.id == userid);
|
let user = state.users.find(user => user.id == userid);
|
||||||
// increase count if user is enabled
|
// increase count if user is enabled
|
||||||
if (group && user.enabled) {
|
if (group && user.enabled && state.userCount > 0) {
|
||||||
group.usercount++;
|
group.usercount++;
|
||||||
}
|
}
|
||||||
let groups = user.groups;
|
let groups = user.groups;
|
||||||
groups.push(gid);
|
groups.push(gid);
|
||||||
|
@ -109,7 +109,7 @@ const mutations = {
|
||||||
let group = state.groups.find(groupSearch => groupSearch.id == gid);
|
let group = state.groups.find(groupSearch => groupSearch.id == gid);
|
||||||
let user = state.users.find(user => user.id == userid);
|
let user = state.users.find(user => user.id == userid);
|
||||||
// lower count if user is enabled
|
// lower count if user is enabled
|
||||||
if (group && user.enabled) {
|
if (group && user.enabled && state.userCount > 0) {
|
||||||
group.usercount--;
|
group.usercount--;
|
||||||
}
|
}
|
||||||
let groups = user.groups;
|
let groups = user.groups;
|
||||||
|
@ -135,12 +135,14 @@ const mutations = {
|
||||||
let user = state.users.find(user => user.id == userid);
|
let user = state.users.find(user => user.id == userid);
|
||||||
user.enabled = enabled;
|
user.enabled = enabled;
|
||||||
// increment or not
|
// increment or not
|
||||||
state.groups.find(group => group.id == 'disabled').usercount += enabled ? -1 : 1;
|
if (state.userCount > 0) {
|
||||||
state.userCount += enabled ? 1 : -1;
|
state.groups.find(group => group.id === 'disabled').usercount += enabled ? -1 : 1
|
||||||
user.groups.forEach(group => {
|
state.userCount += enabled ? 1 : -1
|
||||||
// Increment disabled count
|
user.groups.forEach(group => {
|
||||||
state.groups.find(groupSearch => groupSearch.id == group).disabled += enabled ? -1 : 1;
|
// Increment disabled count
|
||||||
});
|
state.groups.find(groupSearch => groupSearch.id === group).disabled += enabled ? -1 : 1
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
setUserData(state, { userid, key, value }) {
|
setUserData(state, { userid, key, value }) {
|
||||||
if (key === 'quota') {
|
if (key === 'quota') {
|
||||||
|
|
|
@ -384,6 +384,10 @@ export default {
|
||||||
|| disabledGroup.utils.counter === -1) // add disabled if ldap enabled
|
|| disabledGroup.utils.counter === -1) // add disabled if ldap enabled
|
||||||
) {
|
) {
|
||||||
groups.unshift(disabledGroup);
|
groups.unshift(disabledGroup);
|
||||||
|
if (disabledGroup.utils.counter === -1) {
|
||||||
|
// hides the counter instead of showing -1
|
||||||
|
delete disabledGroup.utils.counter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue