Skip to Content Skip to Menu

UserList to include child usergroups

  • joomally
  • joomally
  • OFFLINE
  • Posts: 104
  • Thanks: 8
  • Karma: 1
4 years 7 months ago #318036 by joomally
UserList to include child usergroups was created by joomally
I have created a User List with Usergroups set to 'Group A'.
When I access the list, I see all members who are in the Usergroup 'Group A', as is expected.

I would like to create a User List which includes all users in Usergroup 'Group A' and also all users in any groups which are children of 'Group A'. I realise that I can select more than one usergroup to include in the list, but our usergroups are constantly changing and I dont want to have to keep updating the list.

I saw the advanced filter option, but couldn't figure out how to use it to achieve what I want.
Since all my users are in the 'Registered' usergroup, I could use this as the usergroup of the list, and then use advanced filter options to limit it to users who are in 'Group A' or a child of Group A, but I'm not sure what the SQL would be for this filter.

Is it possible to have a user list which lists users who are either in a particular usergroup, or in a group which is a child of that usergroup ?

Thank

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48551
  • Thanks: 8291
  • Karma: 1445
4 years 7 months ago #318048 by krileon
Replied by krileon on topic UserList to include child usergroups
The usergroup parameter does not use inheritance. It only includes uses that actually have the usergroups you've selected. Why are you needing to constantly add new usergroups? I really do not recommend doing that. It's possible what you're doing can be done in another way that doesn't require negatively impacting ACL so heavily as the more usergroups you have the slower every page will be as ACL is accessed constantly.

Since all my users are in the 'Registered' usergroup, I could use this as the usergroup of the list, and then use advanced filter options to limit it to users who are in 'Group A' or a child of Group A, but I'm not sure what the SQL would be for this filter.

Yes, that's doable. Normally we do not perform a JOIN of the usergroup table. This is because it causes too many row scans and slows the query down significantly on large sites. Instead usergroups are filtered by an IN subquery. To be able to add your own custom filtering on the usergroup query your filter must utilize the table alias "g" and it will perform a JOIN of the usergroup table. The table aliases are as follows.

_comprofiler = ue
_users = u
_user_usergroup_map = g

So using an Advanced query with the "g" table alias will let you filter against the _user_usergroup_map table. Example as follows.

Code:
g.`group_id` >= 2

The above would show any user with the usergroup id of 2 or greater than 2. This will be in addition to whatever is selected in the usergroup parameter, which in your case is fine since everyone still has Registered usergroup.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • joomally
  • joomally
  • OFFLINE
  • Posts: 104
  • Thanks: 8
  • Karma: 1
4 years 7 months ago #318062 by joomally
Replied by joomally on topic UserList to include child usergroups
Thank you.

I can see other ways to do what I'm trying to do, I just thought that usergroups would be the simplest, and I didn't know that too many usergroups would negatively impact site performance.

I just tried to do some research but couldn't see any stats on how the number of usergroups affects performance. I dont know if you have any experience with this ? The site will have less than 100 usergroups, and less than 50 viewing access levels. Each user is only a member of a few groups, and most pages of the site are just an article with a few modules. The site only has about 100 users online at any one time (and obviously they're not all doing page loads at the same moment)

Do you think this will be ok ?

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48551
  • Thanks: 8291
  • Karma: 1445
4 years 6 months ago #318087 by krileon
Replied by krileon on topic UserList to include child usergroups

I dont know if you have any experience with this ? The site will have less than 100 usergroups, and less than 50 viewing access levels.

Basically the less the better. I recommend only using as many as absolutely necessary beyond the defaults (do not delete defaults; Joomla doesn't like that). Anyone using that many usergroups always makes me question why they need so many and how can we do this without impacting ACL. ACL is used constantly on every page and often multiple times. It is also often joined into other queries or used as subqueries. So the more usergroups you have the slower all of that becomes.

Do you think this will be ok ?

Yes, you'll be fine (as in your site will work) but it's just a heads up warning that you should consider an alternative approach. On top of potential performance problems you have management issues to deal with as well. That's a lot of ACL to manage across your site. For example permission pages (e.g. System > Global Configuration > Permissions) become unusable. This isn't a CB specific thing though this is a Joomla in general thing.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • joomally
  • joomally
  • OFFLINE
  • Posts: 104
  • Thanks: 8
  • Karma: 1
4 years 6 months ago #318116 by joomally
Replied by joomally on topic UserList to include child usergroups
Thanks for the expert tips !

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum