Home » Authentication » LiveUser » Bug #6417
Incorrect getRight result with field param `right_level`
Details
| Submitted | 2006-01-05 11:40 UTC |
|---|---|
| From | michiel at dinnersite dot nl |
| Assigned | lsmith |
| Status | No Feedback |
| Package | LiveUser |
| PHP Version | 4.4.0 |
| OS | Linux mandrake 9.0 |
| Roadmaps | (Not assigned) |
Comments
[2006-01-05 11:40 UTC] michiel at dinnersite dot nl
Description:
------------
SELECT liveuser_rights.right_id AS right_id, liveuser_userrights.right_level AS right_level, liveuser_rights.area_id AS area_id, liveuser_rights.right_define_name AS right_define_name, liveuser_rights.has_implied AS has_implied FROM liveuser_rights, liveuser_userrights WHERE liveuser_rights.right_id IN ('11') AND liveuser_rights.right_id = liveuser_userrights.right_id
Array
(
[filters] => Array
(
[perm_user_id] => 8
)
[inherited] => 1
[implied] => 1
[rekey] => 1
[fields] => Array
(
[0] => right_id
[1] => right_level
[2] => area_id
[3] => right_define_name
[4] => has_implied
)
[select] => all
)
The situation:
We have a group and a user. The user is part of the group.
The group has the Right `WRITE` assigned. The `READ` right is implied by the `WRITE` right.
The user inherits the right because of it's membership to this group. The user has the READ right because it's implied by the WRITE right.
The problem:
I want to retrieve all the rights of this user. This works fine, except for one problem. If I retrieve the right through the getRights function with the following params:
Array
(
[filters] => Array
(
[perm_user_id] => 8
)
[inherited] => 1
[implied] => 1
[rekey] => 1
)
I get a proper result. All the rights are there. However, I need the right_level included in the result, so I defined the
fields list. Now my params array looks like this:
Array
(
[filters] => Array
(
[perm_user_id] => 8
)
[inherited] => 1
[implied] => 1
[rekey] => 1
[fields] => Array
(
[0] => right_id
[1] => area_id
[2] => right_level
[3] => right_define_name
[4] => has_implied
)
)
Just to clarify: I get NO errors from the LUA->getErrors() with these params.
The result I get is as follow:
Array
(
[1] => Array
(
[area_id] => 1
[right_define_name] => WRITE
[has_implied] => 1
[_type] => inherited
)
)
while I expected:
Array
(
[1] => Array
(
[area_id] => 1
[right_define_name] => WRITE
[has_implied] => 1
[_type] => inherited
)
[2] => Array
(
[area_id] => 1
[right_define_name] => READ
[has_implied] =>
[_type] => implied
)
)
The problem: All the granted and inherited rights are correctly fetched. The implied rights are not fetched.
The problem is with the custom field `right_level` I included. If I remove this right everything works fine. I do need this field though for granting and revoking rights.
The query generated for the getImpliedRights getRight call is as follows:
SELECT liveuser_rights.right_id AS right_id, liveuser_userrights.right_level AS right_level, liveuser_rights.area_id AS area_id, liveuser_rights.right_define_name AS right_define_name, liveuser_rights.has_implied AS has_implied FROM liveuser_rights, liveuser_userrights WHERE liveuser_rights.right_id IN ('11') AND liveuser_rights.right_id = liveuser_userrights.right_id
The problem here is the last where restriction `liveuser_rights.right_id = liveuser_userrights.right_id`, this relation doesn't exist because the right is inherited instead of granted (ie: the right_id doesn't exist in the userrights table but in the grouprights table).
With the right_level field removed the query is as follows:
SELECT right_id AS right_id, area_id AS area_id, right_define_name AS right_define_name, has_implied AS has_implied FROM liveuser_rights WHERE right_id IN ('11')
This query does give a proper result. The query problem is that it only checks on the userrights table but not on the grouprights table.
A small note:
The rights mentioned above are fictional. My right/user structure is identical though.
[2006-01-05 11:47 UTC] michiel at dinnersite dot nl
The first query is an accidental copy-paste, sorry about that.
[2006-01-05 18:31 UTC] michiel at dinnersite dot nl
I emailed the dump to you.