简体   繁体   English

joomla 3:获取“最高”级别的用户组ID

[英]joomla 3: get the user group id with the 'highest' level

I'm writing a Joomla 3.x component and I search now the possibility to get from a user (which is assigned to multiple user groups) the 'ID' from the user group with the 'highest level'. 我正在编写一个Joomla 3.x组件,现在我搜索是否有可能从用户(已分配给多个用户组)中从具有“最高级别”的用户组中获取“ ID”。

Example: - user is a member from registered and manager and some other groups. 示例:-用户是注册用户,管理员和其他一些组的成员。

I can get in a first step the ID from 'all' assigned user groups: 第一步,我可以从“所有”分配的用户组中获取ID:

jimport( 'joomla.access.access' );
$groups = JAccess::getGroupsByUser($user->id);

But how can i get now the 'id' from the user group with the 'highest' level? 但是,现在如何从具有最高级别的用户组中获取“ ID”? I can not found a method for this in the core files. 我在核心文件中找不到用于此的方法。

Edit: I have in my component added a backend part where it is possible to define many special settings for every user group. 编辑:我在我的组件中添加了一个后端部分,可以为每个用户组定义许多特殊设置。 But i have not an idea how i can get then in the frontend the correct settings, when a user is a member in multiple groups. 但是当用户是多个组的成员时,我不知道如何在前端获得正确的设置。 I need in this case not any 'permissions' from the Joomla assets table. 在这种情况下,我不需要Joomla资产表中的任何“权限”。 Only the 'ID' from the 'most important' group. 仅来自“最重要”组中的“ ID”。 It is useful to check then the 'parent' ID from every group? 然后检查每个组的“父母” ID是否有用? Or use getGroupPath($groupId)? 还是使用getGroupPath($ groupId)?

Since $groups is an array: $highestLevel = max($groups); 由于$ groups是一个数组:$ highestLevel = max($ groups); should do the trick! 应该做的把戏!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM