[EXTENSION] Rights

Thanks for the props! I’m glad to hear that you like it.

I have no plans of extending this module to do anything that is not directly associated with access control.

I might make a separate module for user management later if I can find the time.

If you don’t want to do that yourself you could always use yii-user. I have the impression that it’s pretty good.

http://code.google.com/p/yii-user/

I want it to be as good as it can be. I’m almost satisfied now and that’s quite a lot coming from a perfectionist. :)

Let me know how it went.

Hi Chris,

I’ve installed the latest release and everything works fine ‘out of the box’ …except (of course ;)) I’m getting the following JS error :


$tbody.sortable is not a function

http://localhost/project/yii-1.1.3/assets/346a9ce9/js/rights.js

Line 133

This occurs on following grid view :

  • rights/authItem/roles

  • rights/authItem/tasks

  • rights/authItem/operations

For ‘assignations’ and ‘Permissions’ no error. This is not really a problem to use the extension, but as the perfectionist you are, I thought you would like to know ;)

(by the way, I will send you updated french message files as soon as possible)

ciao

B)

@raoul: Are you running the latest version with zii checked out from the yii repository (after zii was merged into the yii repository)? It would seem like your application doesn’t find the jquery-ui script file. I’ve tested that it works as it should. If everything is working as it should, it should be possible to register jquery-ui as a core script. Please check the yii change log for further information.

You’re right … it works fine now !

8)

hello

i just installed version 9.11

the install script went ok, but there is not menu in the interface - i don’t see any of the buttons i see in the screen shots - Permissions, assignments, etc. the ?r=rights page loads with a table of users with no navigation items.

also, i see you created a table called AuthItemWeight. i need to use a custom name for the table, specifically have a prefix of tbl_, (this is already in my db config).

in my config i put the following and it seems to be using my table names ok:

‘authManager’=>array(

        //'class'=>'CDbAuthManager',


'class'=>'RightsAuthManager',


        // The database component used


        'connectionID'=>'db',


        // The itemTable name (default:authitem)


        'itemTable'=>'auth_item',


        // The assignmentTable name (default:authassignment)


        'assignmentTable'=>'auth_assignment',


        // The itemChildTable name (default:authitemchild)


        'itemChildTable'=>'auth_item_child',


	),

thanks

@unbelievable luck: You could configure your authorization manager as following before you run the installer (the installer uses the authorization manager table names when inserting the tables):




'authManager'=>array(

	// The authorization manager (default: CDbAuthManager)

	'class'=>'RightsAuthManager',

	// The database component used

	'connectionID'=>'db',

	// The itemTable name (default: AuthItem)

	'itemTable'=>'auth_item',

	// The assignmentTable name (default: AuthAssignment)

	'assignmentTable'=>'auth_assignment',

	// The itemChildTable name (default: AuthItemChild)

	'itemChildTable'=>'auth_item_child',

	// The itemWeightTable (default: AuthItemWeight)

	'itemWeightTable'=>'auth_item_weight',

),



About the problem with the menu, could you check if the CMenu-widget is rendered at all and that the user you’re logged in as is a superuser. You can check this with:


Yii::app()->user->checkAccess(Rights::module()->superuserName)

(In the next version you can simply do Yii::app()->user->isSuperuser but not in 0.9.11.)

I see the menu fine in all my test installations but maybe you’ve found a bug.

i am logged in as superuser.

i’m not quite sure how to check if the menu is rendered, but when i look at the html source code, i have div with id “menu” that is empty. also an empty “flashes” div.

<div id="menu">

</div>

<div class="flashes">

</div>

Anyone else who can’t see the menu?

I have to look into this.

Hi,

I’m having troubles to make rights extension installed as a nested module. Here’s my main.php config file:


    'import'=>array(

        'application.models.*',

        'application.components.*',

                'application.extensions.nestedset.*',

                'application.modules.membres.rights.components.*',

        'application.modules.membres.rights.models.*',

                'application.modules.membres.components.*',

                'application.modules.membres.models.*',

        //'application.modules.rights.components.*',

        //'application.modules.rights.models.*',

    ),


    'modules'=>array(

        // uncomment the following to enable the Gii tool

        

        'gii'=>array(

            'class'=>'system.gii.GiiModule',

            'password'=>'XXXX',

        ),

               /* 'membres' => array(

            'modules'=>array('rights'),

            ),*/

        'membres'=>array(

            'modules'=>array('rights'=>array('install'=>true),),

            )

         ), 


    // application components

    'components'=>array(

        'user'=>array(

            // enable cookie-based authentication            

                     // 'class' => 'application.modules.user.components.YumWebUser',

                      'allowAutoLogin'=>true,

                      'loginUrl' => array('/membres/login'),

            'class' => 'RightsWebUser',

                ),

        'authmanager' => array(

            // The authorization manager (default: CDbAuthManager)

            'class'=>'RightsAuthManager',

            // The database component used

            'connectionID'=>'db',

            // The itemTable name (default: AuthItem)

            'itemTable'=>'auth_item',

            // The assignmentTable name (default: AuthAssignment)

            'assignmentTable'=>'auth_assignment',

            // The itemChildTable name (default: AuthItemChild)

            'itemChildTable'=>'auth_item_child',

            // The itemWeightTable (default: AuthItemWeight)

            'itemWeightTable'=>'auth_item_weight',


        ),

RightsModule.php is modified with:


public $baseUrl = '/membres/rights';

And here’s the error I’ve got:


Alias "rights.RightsModule" is invalid. Make sure it points to an existing PHP file.

@luc: You could try to change your import path to:


'application.modules.membres.modules.rights'

Also, don’t change anything in the RightsModule.php, you can configure it’s properties.

In other words, configure rights like so:




'modules'=>array(

	'membres'=>array(

		'modules'=>array(

			'rights'=>array(

				'install'=>true, // Remove after install of course...

				'baseUrl'=>'/membres/rights',

			),

		),

	),

),



Let me know if this solved your problem.

Hi, thank you for your support.

Now, I’ve got:


Property "CPhpAuthManager.db" is not defined.

EDIT

Ok,it was just a mistyped declaration of authManager in main.php.

It works well now.

Many thanks for your help and this nice extension.

Luc

After operation preservation, we receive an error in line 00451.

Though all data remains.


PHP Error

Описание


preg_match() [<a href='function.preg-match'>function.preg-match</a>]: Compilation failed: missing terminating ] for character class at offset 30

Исходный код


I:\home\league.ru\www\protected\modules\rights\components\RightsAuthorizer.php(451)


00439:         // Loop through the language constructs

00440:         foreach( $languageConstructs as $lc )

00441:             if( preg_match('/'.$lc.'\ *\(?\ *[\"\']+/', $code)>0 )

00442:                 return null; // Language construct found, not safe for eval

00443: 

00444:         // Get a list of all defined functions

00445:         $definedFunctions = get_defined_functions();

00446:         $functions = array_merge($definedFunctions['internal'], $definedFunctions['user']);

00447: 

00448:         // Loop through the functions and check the code for function calls

00449:         // Append a '(' to the functions to avoid confusion between e.g. array() and array_merge()

00450:         foreach( $functions as $f )

00451: if( preg_match('/'.$f.'\ *\({1}/', $code)>0 )

00452:                 return null; // Function call found, not safe for eval

00453: 

00454:         // Evaluate the safer code

00455:         $result = @eval($code);

00456: 

00457:         // Return the evaluated code or null if the result was false

00458:         return $result!==false ? $result : null;

00459:     }

00460: 

00461:     /**

00462:     * @return RightsAuthManager the authorization manager

00463:     */


Содержимое стека


#0 I:\home\www\protected\modules\rights\components\RightsAuthorizer.php(451): preg_match()

#1 I:\home\www\protected\modules\rights\components\RightsAuthorizer.php(76): RightsAuthorizer->sanitizeExpression()

#2 I:\home\www\protected\modules\rights\controllers\AuthItemController.php(303): RightsAuthorizer->updateAuthItem()

#3 I:\home\www\core\web\actions\CInlineAction.php(50): AuthItemController->actionUpdate()

#4 I:\home\www\core\web\CController.php(300): CInlineAction->run()

#5 I:\home\www\core\web\filters\CFilterChain.php(133): AuthItemController->runAction()

#6 I:\home\www\core\web\filters\CFilter.php(41): CFilterChain->run()

#7 I:\home\www\core\web\CController.php(1049): CAccessControlFilter->filter()

#8 I:\home\www\core\web\filters\CInlineFilter.php(59): AuthItemController->filterAccessControl()

#9 I:\home\www\core\web\filters\CFilterChain.php(130): CInlineFilter->filter()

#10 I:\home\www\core\web\CController.php(283): CFilterChain->run()

#11 I:\home\www\core\web\CController.php(257): AuthItemController->runActionWithFilters()

#12 I:\home\www\core\web\CWebApplication.php(324): AuthItemController->run()

#13 I:\home\www\core\web\CWebApplication.php(121): CWebApplication->runController()

#14 I:\home\www\core\base\CApplication.php(135): CWebApplication->processRequest()

#15 I:\home\www\index.php(13): CWebApplication->run()



@s@nya: I’m not exactly sure I understand what the problem is. Could you tell me the necessary steps I need to take to reproduce this exception?

Has found out that the given problem occurs on PHP 5.2.12 (Denwer). On PHP 5.3.3 such problems aren’t present.

Operations procedure:

  1. Click Task (Operations)

  2. Enter the Description

  3. Click Save

and we receive the given error. All data thus saves.

PS. Sorry for my bad English

Hello again S@nya,

May I ask what data you had in your data field at the time you got this error?

There seems to be a syntax error in the string given entered into the data field…

I entered description of task. Click Save. Recive error.

Was the data field even visible in the form? Have you enabled in the module configuration?

It’s only data that uses the RightsAuthorizer::sanitizeExpression method in which your exception was thrown.

I’m having a hard time to reproduce this…

What kind of description did you enter? Could you post the text so that I can reproduce this problem?

I’m running with php 5.2.11. I guess I have to try with php 5.2.12.

go back

@S@nya: Thanks for the detailed screenshots.

The data field does not currently support function calls for security reasons. I will check if it would be possible to allow some function calls when I can find the time to do so.

Could you make sure that this is the problem by checking the same without calling a function.