[EXTENSION] srbac : Web interface for the administration of rbac

I noticed that the srbac.css file was not loading and Firebug showed that the URL was being computed incorrectly. I have srbac.css under the web root css so the file should be linked with http://mysite.com/css/srbac.css but instead it was being linked to with /var/www/mysite/css/srbac.css. Obviously this is the file path and not the URL so the file will never load in a browser. I traced the issue down to line 473 of Helper.php which calls registerCssFile() with a file path. But the Yii API says that registerCssFile() should be called with a URL. So I changed that line to read:


Yii::app()->clientScript->registerCssFile("/css/$css");

This fixed my problem and srbac.css now loads correctly.

There may be 3 feature in my option.

  1. we can’t simple identify module base on ‘_’ character

in controller variable in _getControllerInfo, wo should enhance this,

this is my code:




$c = explode("_", $controller);

$modulesArray = array_keys(Yii::app()->modules);

    if (in_array($c[0], $modulesArray)) {

    	$module = $c[0]."_";

    	$controller = substr($controller, strlen($module));

    	$contPath = Yii::app()->getModule($c[0])->getControllerPath();

    	$control = $contPath.DIRECTORY_SEPARATOR.str_replace(".", DIRECTORY_SEPARATOR, $controller).".php";

}

so, wo can fill ‘_’ character in controller name, but in module name.

  1. sometimes, we don’t want to scan all file in controller path(mean to not want all contrller to be task), we can define a property liek $notScanControllerList in Srbacmodule.

my code in SrbacModule:


public $notAllowedControllerList = array('srbac_DefaultController', 'VxmlController'...);

function _scanDir()




// @janne modify

$controller = (($module) ? $module."_" : "").

              (($subdir) ? $subdir."." : "").

              str_replace(".php","",$file);

          // @janne added

          if (!in_array($controller, Yii::app()->getModule('srbac')->notAllowedControllerList)) {

              $controllers[] = $controller;  

          }

in fact, my project need this feature, it can give our max freedom;

  1. if our action with default argument, authitem looks ugly. eg: model_ConterllerAction arg=null.

so my code in function _getControllerInfo():


$patterns[0] = '/\s*/m';

        $patterns[1] = '/\(/m';

        //$patterns[2] = '/\)/m';

        //$patterns[3] = '/\{/m';

       // @janne modify

       $patterns[1] = '/\(.*\)/m';

       $patterns[2] = '/\{/m';

What do you think of it?

don’t mind my pool english and jmmq( stupid options)!

pool english.

When i open install page, it says , that i have an error, (with no "red lines")

I use srbac from your SVN .

i’m trying to create permitions for controllers generated by - yiic shell -> crud

Thanks,

The code that worked for me was




<?php

Yii::app()->request->baseUrl."/css/".$css;

?>



It’s fixed along with some other css problems in SVN

pangjanne and geralt,

I will be away for Christmas holiday so I will check your issues when I get back.

SOLVED!

I’ve found the problem - i’ve used an “underscore” in the name of my tables, so i had symbol “_” in the names of my controllers.

And this part didn’t work for me (AuthItemController)




 if(substr_count($controller, "_")) {

      $c = explode("_", $controller);



so i had to add an exception for "srbac" and my modules.

Thanks for your help !

Happy holidays :)

hey spyros,

i have a problem ,that is I use srbac to create admin,and role is "admin,administrator,user"

and task like user_management for example, and there is "usercreate userdelete " in the task.

i realy can use admin to do the user_management task.

and i can user authmanager->getTask(); return "user_management" task.

however, i use authmanager->getTask(‘admin’) ,and return nothing?

what’s the problem with api?

thank you

I made a Portuguese translation to srbac.

Thanks for this great extension.

Sérgio Villela

I found a typo on the file. Here is the correction.

Sérgio

I have a fresh install of Yii 1.1 and a fresh install of RBAC. When I go to install RBAC I got error messages about missing layout files.

When I commented out the default layout setup as follows:


//The layout to use

//"layout"=>"application.views.layouts.admin",

I get:

Application.log reports:

I was under the impression that RBAC should install these tables during initialization?


//The layout to use

//"layout"=>"application.views.layouts.admin",

This is an example for how to use a different layout for srbac. Probably protected/views/layouts/admin.php does not exist so there’s an error.If you comment the line the default layout is used that has the new Yii 1.1 breadcrumbs attribute.

I will fix the problem for Yii 1.1 version.

The tables are created during the install of srbac

Thanks! Looking forward to the fix.

Thanks! Looking forward to the fix.

Version 1.1.0

Downloads:

http://www.yiiframework.com/extension/srbac/files/srbac_1.1.0_r162.zip

http://srbac.googlecode.com/files/srbac_1.1.0_r162.zip

Documentation:

http://srbac.googlecode.com/files/srbac_guide_1.1.0.pdf

May be due to me being n00b in Yii, but I couldn’t understand this->

I followed the documentation and added all the required configuration options. Now I am able to do all the changes using the srbac interface and all the changes are being saved into the db also. But the biggest issues is the changes are not being reflected in views. Should I add some function/code to the controllers to make the access rules work. Currently, no srbac access rules are ina ction and its behaving according tot he default accessrules function in the controllers. Please help :)

PS:I registered in the forum all just due to SRBAC.

If you are using the auto creation access rules tool, your controllers should extend SBaseController.

Else you have to checkAccess in every action manually.

Undefined variable: sort

Source File

E:\servers\wamp\www\LA17\protected\modules\srbac\views\authitem\admin.php(28)

00016: * @obsolete

00017: */

00018: ?>

00019: <h2><?php echo Helper::translate(‘srbac’,‘Managing AuthItem’)?></h2>

00020:

00021: <div class="actionBar">

00022: [<?php echo CHtml::link(Helper::translate(‘srbac’,‘AuthItem List’),array(‘list’)); ?>]

00023: [<?php echo CHtml::link(Helper::translate(‘srbac’,‘New AuthItem’),array(‘create’)); ?>]

00024: </div>

00025:

00026: <table class="srbacDataGrid">

00027: <tr>

00028: <th><?php echo $sort->link(‘name’); ?></th>

I get trouble. Who can help me??? Thanks!!!

What version of srbac do you use?

Which is the url that rendered that view? This view is obsolete and not accessible anymore.

Is there a guide to install for idiots like me? i am thoroughly confused.

I don’t know where to add all the config like:

‘srbac’ => array(

‘userclass’=>'User

I put that in my main.php, but I get this:

Property "CWebApplication.srbac" is not defined.

I am completely lost,

Thanks