Joomla:使用PHP从页面访问级别获取用户组 [英] Joomla: get the user group from the page access level using PHP
本文介绍了Joomla:使用PHP从页面访问级别获取用户组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Joomla 2.5.16中:
In Joomla 2.5.16:
- 假设用户100属于用户组14和16.
- 假设他当前正在浏览的页面的访问级别ID为6.
- 根据MySQL数据库中的表"viewlevels",访问级别6可用于组8、16和17
我的目标是为该页面找到正确的"用户组.由于该用户属于2个用户组,并且其中一个(16)包含在允许查看此页面的组数组中,因此如何查询数据库以找到该组?
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?
我尝试过:
$usr_id=100;
$access=6;
$query(SELECT rules from 'viewlevels' WHERE ???);
表视图级别具有以下结构:
Table viewlevels has a structure like:
ID | rules
6 |[8,16,17]
表user_usergroup_map具有如下结构:
Table user_usergroup_map has a structure like:
User_id |Group_id
100 |14
100 |16
有什么帮助吗?
推荐答案
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
这篇关于Joomla:使用PHP从页面访问级别获取用户组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文