i also like the rights module. Thank you for that. But I still have a problem.
I want to give users the right to access the rights admin interface. Can I create a role to give them access? I dont want to give them the role "Administrator" and of course they should not give the "Administrator" role to somebody.
If the user has access to Rights, it is as good as being an administrator because he has an access to everything, and grant everything to himself if not everything has been given yet. And restricting him to other tasks will be useless because he can just re-assign that particular rights to himself.
Maybe you can create a different interface and include your desired roles and tasks and operations that should be only seen there, and then grant it to your users of choice. I have actually done the same: copied the rights module and created right_2, and configured it according to my requirements. I did it because I don’t want my client’s admin to be able to generate,create and edit operations and tasks, 'cause it should only be done by me.
I actually thought of this but when I implemented it caused a lot of problems so I removed it. However I think this is something to conciser so please submit an issue on GoogleCode for this and I’ll do it when I can find the time. In the meanwhile you need to create operations/tasks for Rights and implement the checking of them manually. Sorry for the inconvenience.
I’m dropping in a bit late on the conversation but you’re scenario is indeed a bit different and also complicated. You could do this with a business rule and I think that’s the cleanest way to do it, however that might give you a problem with performance. It would also leave you with the problem of managing the huge amount of permissions if you have one permission for each location.
I would probably try the business rule solution first because it should be by far the easiest to implement. You could just call a function that returns the location and check that it’s the desired location, e.g.
Yes, I think this is the way to go, and I’m sure there is a way to do this efficiently. I’m thinking that what I’ll do is store a link to the role type in the user-location bridge file for the MANY::MANY relationship. Then I can grab this and enter it into the user’s state at the time they choose the location they are working on. The roles will be defined the same for all locations. So this could be pretty efficient.
Let me know if you have any other ideas, and thanks for taking the time to get back to me.
I got the Rigths-modul to work (installed the tables manually, because I use MS SQl Server), and the permissionchecking works as it should. Except for one thing. I cant allow members of a role (e.g. the Admin role) to get access to the rights module.
I checked it logged in as superuser:
config:
'rights'=>array(
'superuserName'=>'Admin',
)
In the authitemcontroller->init() method I did some debugging:
print_r($this->_authorizer->getSuperusers()); --> array('myUserName'), as expected
Yii::app()->user->getIsSuperuser(); --> true, as expected
But then: CAccessControlFilter->accessDenied(Object(RWebUser), ‘You are not aut…’)
On the other hand, it "works" when I change the settings:
First off, fantastic extension. It took me a while to get it going but most of it was my bad. There was one thing that was not mentioned in documentation. I don’t see anywhere in the documentation what version of MySQL must be used, but I noticed that Rinstaller.php uses type=InnoDB instead of Engine = InnoDB. I needed to update Rinstaller.php in order for the tables to be created. The schema.sql also uses type instead of engine.
I have some usage questions but I’ll save it for another post. Good job and thank you.
I’d like to create some functions for hiding and displaying menu options for users with different roles. I was using the below code to hide and show different menu options, but Yii::app()->user->isGuest no longer works. What can I use as an alternative now? I know I can return an array of roles assigned to the logged in user and parse that, but is there an easier way? The below snippet was acceptable code to drop in the menu view, but if I’m doing something more complicated, I want to make it reusable and put it somewhere easy to get. Maybe I could add a function right into Rights but that could make upgrading more difficult. Any suggestions?
I get the following error when using Yii::app()->user->userName to get the username of the currently logged in user.
Property "RWebUser.userName" is not defined
If I change userName to name, it does not error out but it always returns guest as the user no matter what I login as. I’m happy to furnish more info as necessary. Thanks
@Wiktor: The authorization items associated to controller actions should be named {ControllerId}.{ActionId}. However, if you have some custom authorization items and check for those in your code the code will not work after changing the name, obviously.
I’m actually thinking of writing an ACL module for Yii but right now I have too many projects going on so I’m not going to do it right now at least.
Glad to hear that your team liked my module.
@truck0321: With the core web user (CWebUser) you can get the username by calling Yii::app()->user->name (or getName()). It is set when you log in by CWebUser::changeIdentity(). The same applies for the RWebUser which extends CWebUser.
After installing yii rights am getting following issue…
include(C:\xampp\htdocs\myapp\protected\modules\rights\components\RightsWebUser.php) [<a href=‘function.include’>function.include</a>]: failed to open stream: No such file or directory