[EXTENSION] Rights

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!

In rights\views\authItem\permissions.php, ‘authIem’ should be replaced with ‘authItem’ in r129.

I’m enjoying exploring the codes, but I’m really lost now. Please help :(

I assigned the user ‘demo’ to the role ‘Authenticated’ and given him the permissions ‘Menu.Create’ and ‘Menu.Index’, which were generated from the controllers using this amazing extension. Then I extended my class ‘Controller’ to ‘RightsBaseController’, then edited the function




public function filters()

	{

		return array(

			'rights', // perform access control for CRUD operations

		);

	}



in class ‘MenuController’ (which extends to ‘Controller’). My problem is, I cannot access a Menu action (even index and create) unless I add them to allowedActions():




public function allowedActions() 

	{ 

		return 'index'; 

	}



which actually defeats the purpose of this extension. I’m sure I did something wrong, I just don’t know where to look at :(

When I changed the filters from ‘accessControl’ to ‘rights’, my MenuController do not use the accessRules anymore,right?

Agree :) The demo worked fine right after correcting the table names though. (AuthItemWeight to Rights and correcting the table name cAsEs)

I created a new web application and tested Rights, along with Yii-User and both works fine. But Rights still won’t work with my current web app for some reason, so I guess I’ll just rewrite my application on top of my newly created web app.

HAPPY NEW YEAR TO ALL!

Happy New Year everyone!

I’ve update the blog demo to reflect on the recent changes and I also took some time to review some logic for updating own posts.

@mjkulet: Thanks for pointing out the typos in the permissions view! It’s now fixed. About your problem with checking access, did you assign those operations to the user or the role?

Most likely you don’t want to use two different filters to check access so I wouldn’t recommend using ‘rights’ and ‘accessControl’ in the same controller. Keep in mind that it’s not necessary to use Rights for all of your controllers. Sometimes it may be more convenient to use the built-in access control instead (e.g. backend).

Fixed the assignment view paging issue and uploaded a new version (revision 132). Page size is set to 50 to improve usability.

Sorry for the inconvenience.

Hi Chris, thank you for your amazing extension.

Sorry if it has been asked before…

If I check remember me to allow auto-login when I re-open the browser I have this error:

Fatal error: Call to undefined method stdClass::checkAccess() in /var/www/mysite/protected/views/layouts/main.php

The line is a CMenu that contains this piece of code in visible property




!Yii::app()->user->isGuest && Yii::app()->user->checkAccess('admin')



if I press F5 to refresh the page error disappears

Any helps?

Thanks in advance,

Marco