Is there a variable available in the CMSMS admin that reveals the Group that a logged in User belongs to? I've examined the $user object which contains several pieces of information about the logged in user, but not the group it seems.
In my custom admin theme I'd like to include a CSS file based on whether or not the user is in the "Editor" group, so I need to test for the user's group.
[solved] Variable in admin that reveals user group?
[solved] Variable in admin that reveals user group?
Last edited by Cerulean on Thu Oct 02, 2014 1:35 am, edited 1 time in total.
- paulbaker
- Dev Team Member
- Posts: 1465
- Joined: Sat Apr 18, 2009 10:09 pm
- Location: Maidenhead, UK
- Contact:
Re: Variable in admin that reveals user group?
memberof? I have this in the template of a working site:
Code: Select all
{if $ccuser->loggedin() AND !$ccuser->memberof('members') AND !$ccuser->memberof('members-hr') AND $position >= 2}
Re: Variable in admin that reveals user group?
Thanks, but your code is for frontend users and I'm talking about backend (admin) users.
I'm looking for a way to test what Group an admin User belongs to, as per the "Users & Groups" section of the CMSMS admin. The test will occur in the template for my custom admin theme.
I'm looking for a way to test what Group an admin User belongs to, as per the "Users & Groups" section of the CMSMS admin. The test will occur in the template for my custom admin theme.
- paulbaker
- Dev Team Member
- Posts: 1465
- Joined: Sat Apr 18, 2009 10:09 pm
- Location: Maidenhead, UK
- Contact:
Re: Variable in admin that reveals user group?
Ah, sorry I misunderstood. I don't know how to show back end group.
Re: Variable in admin that reveals user group?
Not that I know of, as admin templates check for specific permissions that should be common to all admin templates. That is a different mechanism than the one you are looking for. You will probably be able to compute the group the current logged in user belongs by using CMSMS API, eventually by using UserOperations.Cerulean wrote:Is there a variable available in the CMSMS admin that reveals the Group that a logged in User belongs to?
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Re: Variable in admin that reveals user group?
using @print_r on $theme reveals:
Am I able to access any of these permissions settings in my admin template? (I could use one of the permission settings to derive the user's group by making sure the setting was unique to the group.)
Code: Select all
[_perms:CmsAdminThemeBase:private] => Array
(
[htmlPerms] => 0
[pagePerms] => 1
[contentPerms] => 1
[templatePerms] => 0
[cssPerms] => 0
[cssAssocPerms] => 0
[layoutPerms] => 0
[filePerms] => 1
[userPerms] => 0
[groupPerms] => 0
[groupPermPerms] =>
[groupMemberPerms] =>
[usersGroupsPerms] => 0
[sitePrefPerms] => 0
[adminPerms] => 0
[siteAdminPerms] => 0
[codeBlockPerms] =>
[modulePerms] =>
[eventPerms] =>
[taghelpPerms] =>
[extensionsPerms] => 0
)
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: Variable in admin that reveals user group?
You are NOT able to access any of the private members of the theme object.
You CAN however use the CMSMS API functions to determine what groupS (multiple) the currently logged in user is a member of.
Take a look at the UserOperations class in the API docs.
Keep in mind that the 'Editor' group is merely a group created on install. That group can be deleted or renamed, and re-created
Therefore, in anything but a special purpose admin theme for a special site you really cannot rely on a group id or its name.
Therefore, doing special things for special groups (considering you cannot guarantee that there is an 'Editor' group, or that the group with editor privilege is group 2, and because any admin user can belong to one or more groups) is generally a bad idea.
You CAN however use the CMSMS API functions to determine what groupS (multiple) the currently logged in user is a member of.
Take a look at the UserOperations class in the API docs.
Keep in mind that the 'Editor' group is merely a group created on install. That group can be deleted or renamed, and re-created
Therefore, in anything but a special purpose admin theme for a special site you really cannot rely on a group id or its name.
Therefore, doing special things for special groups (considering you cannot guarantee that there is an 'Editor' group, or that the group with editor privilege is group 2, and because any admin user can belong to one or more groups) is generally a bad idea.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Re: Variable in admin that reveals user group?
Thanks Calguy, I was just on the verge of figuring that out by myself...
I understand what you're saying about it not being a very robust solution because the group ID can change and multiple group assignments are possible, but on all my sites I am the only admin with permissions to create users or assign groups, and I always assign my users to the Editor group.
My solution:
In my custom admin theme PHP...
...and in pagetemplate.tpl...
In my case, I am using jQuery to hide links to the (godawful) Image Manager from editors while still allowing them the Modify Files permission so they can create folders, etc, via TinyMCE.
I understand what you're saying about it not being a very robust solution because the group ID can change and multiple group assignments are possible, but on all my sites I am the only admin with permissions to create users or assign groups, and I always assign my users to the Editor group.
My solution:
In my custom admin theme PHP...
Code: Select all
$smarty->assign('is_editor', $userops->UserInGroup(get_userid(), 2)); // "2" is the default group id for the Editor group
Code: Select all
{if !empty($is_editor)}
...stuff that is just for users in the Editor group...
{/if}