-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show users without groups #14614
Show users without groups #14614
Changes from 6 commits
0e2f5c2
3f9b559
7f83e85
43f3174
5bd2d3d
e45ca80
e47a8f1
999837f
5fff2f8
daa5eba
f2ab515
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -495,6 +495,37 @@ public function countDisabledUsersOfGroups(array $groups): int { | |
return $count; | ||
} | ||
|
||
/** | ||
* returns how many enabled users have no groups | ||
* | ||
* @return int | ||
* @since 1?.0.0 | ||
*/ | ||
public function countNotGroupedUsers(): int { | ||
$queryBuilder = \OC::$server->getDatabaseConnection()->getQueryBuilder(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the wrong place to gather the information for the database, as the UserManager forwards all requests to the registered Backends. This implementation would go to |
||
$queryBuilder->select($queryBuilder->func()->count('*')) | ||
->from('accounts', 'a') | ||
->leftJoin('a', 'group_user', 'g', $queryBuilder->expr()->eq('a.uid', 'g.uid')) | ||
->innerJoin('a', 'preferences', 'p', $queryBuilder->expr()->eq('a.uid', 'p.userid')) | ||
->where($queryBuilder->expr()->isNull('g.uid')) | ||
->andWhere($queryBuilder->expr()->eq('appid', $queryBuilder->createNamedParameter('core'))) | ||
->andWhere($queryBuilder->expr()->eq('configkey', $queryBuilder->createNamedParameter('enabled'))) | ||
->andWhere($queryBuilder->expr()->eq('configvalue', $queryBuilder->createNamedParameter('true'), IQueryBuilder::PARAM_STR)); | ||
|
||
|
||
$result = $queryBuilder->execute(); | ||
$count = $result->fetchColumn(); | ||
$result->closeCursor(); | ||
|
||
if ($count !== false) { | ||
$count = (int)$count; | ||
} else { | ||
$count = 0; | ||
} | ||
|
||
return $count; | ||
} | ||
|
||
/** | ||
* returns how many users have logged in once | ||
* | ||
|
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,7 +169,7 @@ const getters = { | |
}, | ||
getSubadminGroups(state) { | ||
// Can't be subadmin of admin or disabled | ||
return state.groups.filter(group => group.id !== 'admin' && group.id !== 'disabled'); | ||
return state.groups.filter(group => group.id !== 'admin' && group.id !== 'disabled' && group.id !== 'notGrouped'); | ||
}, | ||
getPasswordPolicyMinLength(state) { | ||
return state.minPasswordLength; | ||
|
@@ -201,7 +201,18 @@ const actions = { | |
getUsers(context, { offset, limit, search, group }) { | ||
search = typeof search === 'string' ? search : ''; | ||
group = typeof group === 'string' ? group : ''; | ||
if (group !== '') { | ||
if (group === 'notGrouped') { | ||
return api.get(OC.linkToOCS(`cloud/users/details?offset=${offset}&limit=${limit}&search=${search}`, 2)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be identical to the following section… why? |
||
.then((response) => { | ||
if (Object.keys(response.data.ocs.data.users).length > 0) { | ||
context.commit('appendUsers', response.data.ocs.data.users); | ||
return true; | ||
} | ||
return false; | ||
}) | ||
.catch((error) => context.commit('API_FAILURE', error)); | ||
} | ||
else if (group !== '') { | ||
return api.get(OC.linkToOCS(`cloud/groups/${group}/users/details?offset=${offset}&limit=${limit}&search=${search}`, 2)) | ||
.then((response) => { | ||
if (Object.keys(response.data.ocs.data.users).length > 0) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -313,6 +313,8 @@ export default { | |
menu() { | ||
// Data provided php side | ||
let self = this; | ||
|
||
// Entry: add "groups" | ||
let groups = this.$store.getters.getGroups; | ||
groups = Array.isArray(groups) ? groups : []; | ||
|
||
|
@@ -338,7 +340,7 @@ export default { | |
item.utils.counter = group.usercount - group.disabled; | ||
} | ||
|
||
if (item.id !== 'admin' && item.id !== 'disabled' && this.settings.isAdmin) { | ||
if (item.id !== 'admin' && item.id !== 'disabled' && this.settings.isAdmin && item.id !== 'notGrouped') { | ||
// add delete button on real groups | ||
item.utils.actions = [{ | ||
icon: 'icon-delete', | ||
|
@@ -352,7 +354,7 @@ export default { | |
}); | ||
|
||
// Every item is added on top of the array, so we're going backward | ||
// Groups, separator, disabled, admin, everyone | ||
// Groups, separator, no groups, separator, admin, disabled, everyone | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the right-most seperator is unnecessary as it is a special group like the others imho |
||
|
||
// Add separator | ||
let realGroups = groups.find((group) => {return group.id !== 'disabled' && group.id !== 'admin'}); | ||
|
@@ -366,7 +368,18 @@ export default { | |
groups.unshift(separator); | ||
} | ||
|
||
// Adjust admin and disabled groups | ||
// Entry: adjust "no groups" | ||
let notGroupedGroup = groups.find(group => group.id == 'notGrouped'); | ||
|
||
if (notGroupedGroup && notGroupedGroup.text) { | ||
// filter out to re-add later to correct position | ||
groups = groups.filter(group => notGroupedGroup != group); | ||
|
||
notGroupedGroup.text = t('settings', 'Users w/o groups'); // rename notGrouped group | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's write out "w/o", for many, especially non-native speaks it might not be clear, and it means different things in different fields (e.g. banking), not making sense, necessarily, but perhaps enough to irritate. |
||
groups.unshift(notGroupedGroup); // re-add notGrouped group | ||
} | ||
|
||
// Entry: adjust "admin and disabled groups" | ||
let adminGroup = groups.find(group => group.id == 'admin'); | ||
let disabledGroup = groups.find(group => group.id == 'disabled'); | ||
|
||
|
@@ -390,14 +403,15 @@ export default { | |
} | ||
|
||
|
||
// Add everyone group | ||
// Entry: add "everyone group" | ||
let everyoneGroup = { | ||
id: 'everyone', | ||
key: 'everyone', | ||
icon: 'icon-contacts-dark', | ||
router: {name:'users'}, | ||
text: t('settings', 'Everyone'), | ||
}; | ||
|
||
// users count | ||
if (this.userCount > 0) { | ||
Vue.set(everyoneGroup, 'utils', { | ||
|
@@ -406,6 +420,7 @@ export default { | |
} | ||
groups.unshift(everyoneGroup); | ||
|
||
// Entry: add "add group" | ||
let addGroup = { | ||
id: 'addgroup', | ||
key: 'addgroup', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
17 (as we're in feature freeze for 16) – but the annotation should go into the Interface
\OCP\IUserManager