[EXTENSION] Rights

Hi,

This problem has been described early

Andrejs.

Andrejs: I read that, I was just curious if that is how it is supposed to be. The way I understand it ‘Guest’ role should be automatically assigned only to users that are not logged on and using defaultRoles assigns the ‘Guest’ role to everybody.

Hello Jan,

Thanks for the feedback, it’s much appreciated. About the default roles. In the current development version I have removed the support for configuring default roles for Rights (because it didn’t work as I thought it would). The correct way to configure your default roles is to set them for the authorization manager. I apologize for the confusion I’ve caused with the default roles.

As a side note I might add that Rights version 1.1 should be ready in a few days. I just need to do some final testing before I pack it. However, I can promise that it will be released before Christmas.

Version 1.1.0 is now available.

New features are:

  • Optimization by runtime caching authorization items and their children

  • Improved the authorization manager and authorizer

  • Minor user interface improvements

  • Proper support for CSRF validation in authorization item sorting

  • Renamed the AuthItemWeight table to Rights

The documentation has also been updated and can be found at:

http://yii-rights.googlecode.com/files/yii-rights-doc-1.1.0.pdf

Merry Christmas to everyone!

Awesome! Merry Christmas. :)

I have download the demo but i think there is a problem with database creation.

I got this error


CDbCommand failed to execute the SQL statement: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘blog.Rights’ doesn’t exist


I have created mySQl database by using blog-with-rights.sql.

Any idea ?

Thanks,

@amdawi: That’s my fault. I forgot to change the “AuthItemWeight” table name (should be “Rights”) in the blog schema I will correct this immediately. Sorry for the inconvenience.

Thanks Chris83 , it’s working.

But if the user don’t have access for example to post , I got this error :


Fatal error: Wrong parameters for Exception([string $exception [, long $code ]]) in /opt/lampp/htdocs/yii/framework/base/CHttpException.php on line 38


:mellow:

I think Chris83 , you have to check the example again and give us a new copy.

:rolleyes:

Thanks,

@amdawi: Sorry for the delay, the problem was not a the sample data but a bug in the release. I’ve fixed this bug now and uploaded new packages.

Everyone else who has downloaded the revision 128 should download the revision 129 where this bug has been fixed. Sorry for the inconvenience.

Hi,

Is it possible to give rights to individual id in the model…

for example:

Branch is one model…in that branch having

id 1.bangalore

id 2.chennai.

i have to give rights for each n every branch in the application for view ,create ,update and delete…

thanks in advance

Sounds like a nice extension

altho i have 2 questions :

  1. I use postgresql (because i need it for my aplication) and i looked in the schema.sql but it’s seems to be Mysql only. Is it me or is this not gonna work on postgre (altho the documentation says it’s cross-database) ?

  2. Before i used rights (only had a ‘User’ model), i extended the login function because it needs to check username and pasword in a different database (yeh complicated appilication). This worked fine without rights installed. Can you tell me which function i need to edit, or to extend to change this?

Kind Regard,

Ruben

@Mukke: Rights uses Yii’s built-in database authorization manager (CDbAuthManager) and I understand that it work with PostgreSQL. Please try it and report back. What comes to your second question you only need to configure the user model name if it’s not ‘User’, an id column if it isn’t ‘id’ and a name column if it isn’t ‘username’. For further information please refer to the documentation.

Hi,

Is it possible to give rights to individual id in the model…

for example:

Branch is one model…in that branch having

id 1.bangalore

id 2.chennai.

i have to give rights for each n every branch in the application for view ,create ,update and delete…

thanks in advance

anyone can help me…

[TIPS]

On /index.php/rights/authItem/update

if you want to see parents, childs and add childs list with their names and not with description (if description is not empty), you’ve 2 solutions:

  1. change on protected/modules/rights/views/authItem/update.php $data->getNameLink() with $data->getNameLink(false) and on controller getNameText() to getNameText(false)

  2. change on protected/modules/rights/components/RightsAuthItemBehavior.php getNameText and getNameLink argument $humanReadable to false

Hi, I’m fairly new to Yii, so bear with me. I installed Yii-user and Yii-rights and everything looks good. I’m creating a subscription based site. If a user does not belong to role-subscriber, I’d like to redirect them to a subscription signup page.

My thoughts on doing this are to create a new class that extends RightsWebUser (../modules/rights/components/RightsWebUser.php) and overrides the afterLogin() method. I’d call parent::afterLogin() to execute the old functionality and guard against updates to Rights, then execute any new functionality. In the ../config/main.php file, I’d replace

‘class’=>‘RightsWebUser’ with ‘class’=>‘MyRightsWebUser’.

Does this sound like the correct approach? If so, where is the best place to put the MyRightsWebUser.php file?

Thanks for any assistance.

I put some proof of concept code in MyRightsWebUser.php and put it in the app level directory, ../protected/components. It worked like a charm, at least for a simple redirect. I have to lookup the syntax for checking if a user is a member of a role, but it looks promising.

What if I want to change the name of the table,say ‘AuthAssignment’, to ‘tbl_authassignment’, for table name consistency? I scanned this thread and found no concern regarding this…or maybe I just missed it,please correct me.

I did this:


    	'authManager' => array(

        	// The authorization manager (default: CDbAuthManager)

        	'class' => 'RightsAuthManager',

        	// The database component used

        	'connectionID' => 'db',

        	// The itemTable name (default: AuthItem)

        	'itemTable' => 'tbl_auth_item',

        	// The assignmentTable name (default: AuthAssignment)

        	'assignmentTable' => 'tbl_auth_assignment',

        	// The itemChildTable name (default: AuthItemChild)

        	'itemChildTable' => 'tbl_auth_item_child',

        	// The itemWeightTable (default: AuthItemWeight)

        	'itemWeightTable' => 'tbl_auth_item_weight',

    	),



Thanks!