1
Codyko
Use of $gperm_handler->checkRight ?
  • 2005/11/4 3:42

  • Codyko

  • Just popping in

  • Posts: 22

  • Since: 2005/8/5 7


Hi!

I asked a question regarding group permission in my clinic module in the post :

https://xoops.org/modules/newbb/viewtopic.php?topic_id=12230&start=20#forumpost187979

I found the answers by self. But now I have another question that I could not find answers in other threads.

Ok, I have implemented an admin page which controls group permissions of my module. I can see that it adds entries to the "group_permission" table smoothly.

My problem is that following code could not grant access rights to "anonymous group" although I have appropriatly granted permissions to this group in the admin page :

$gperm_handler->checkRight($perm_name, $perm_itemid, $groups, $module_id)

However, it can correctly check access rights of other groups , which are granted in the admin page.

Any idea ?

2
Codyko
Re: Use of $gperm_handler->checkRight ?
  • 2005/11/4 4:12

  • Codyko

  • Just popping in

  • Posts: 22

  • Since: 2005/8/5 7


Here is additional information of my question:

A screen shot of the content of xoops_group_permission table

[pre]
mysql> select * from xoops_group_permission where gperm_modid = 9 AND gperm_groupid =3 AND gperm_itemid = 3;
+----------+---------------+--------------+-------------+--------------+
| 
gperm_id | gperm_groupid | gperm_itemid | gperm_modid | gperm_name   |
+----------+---------------+--------------+-------------+--------------+
|      
363 |             3 |            3 |           9 | xclinic_view |
|      
408 |             3 |            3 |           9 | xclinic_add  |
+----------+---------------+--------------+-------------+--------------+
2 rows in set (0.00 sec)

[/
pre]

I suppose the following codes could check access rights of "ANONYMOUS" group correctly, since I have an entry "3" ( groupid of anonymous ) in thegperm_groupid :
[pre]
$perm_name = "xclinic_view";
$perm_itemid = 3; 
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;

$module_id = $xoopsModule->getVar('mid');
$gperm_handler = & xoops_gethandler('groupperm');

if (!
$gperm_handler->checkRight($perm_name, $perm_itemid, $groups, $module_id)) {
    
redirect_header("index.php", 2, _MD_NOACCESSRIGHTS);
    exit();
} else { 
//some actions here }

[/pre]

but it still redirects me to index.php if I visit the page as anonymous user