简体   繁体   English

Joomla:使用PHP从页面访问级别获取用户组

[英]Joomla: get the user group from the page access level using PHP

In Joomla 2.5.16: 在Joomla 2.5.16中:

  1. Suppose user 100 belongs to user groups 14 and 16. 假设用户100属于用户组14和16。
  2. Suppose that the page he's currently viewing has an access level id of 6. 假设他当前正在浏览的页面的访问级别ID为6。
  3. According to the table 'viewlevels' in the MySQL database, access level 6 is available for groups 8, 16 and 17 根据MySQL数据库中的表“ viewlevels”,访问级别6可用于组8、16和17

My goal is to find the "right" user group for this page. 我的目标是为此页面找到“正确的”用户组。 Since the user belongs to 2 user groups and one of them (16) is contained in the array of groups allowed to see this page, how can I query the database to find that group? 由于该用户属于2个用户组,并且其中一个(16)包含在允许查看此页面的组数组中,我如何查询数据库以找到该组?

I tried: 我试过了:

$usr_id=100;
$access=6;

$query(SELECT rules from 'viewlevels' WHERE ???);

Table viewlevels has a structure like: 表视图级别具有以下结构:

ID   | rules
6   |[8,16,17]

Table user_usergroup_map has a structure like: 表user_usergroup_map具有以下结构:

User_id   |Group_id
100   |14
100   |16

Any help, please? 有什么帮助吗?

SELECT * FROM `#__viewlevels` AS `a` 
INNER JOIN `#__usergroups` AS `b` 
ON `a`.`rules` LIKE CONCAT('%',b.id,'%') 
INNER JOIN `#__user_usergroup_map` AS `m` 
ON m.group_id=b.id 
WHERE m.user_id = 100

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

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