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

if you have some menus displayed only to admins, some to power users, some to users and some to guests you can create the corresponding roles assign them to the users and then use

Yii::app()->user->checkAccess(‘power user’) to decide if the menu item must be visible or not

Thanks 4 the reply. I’m also not able to get the auto create function to work properly. I get a list of my controllers, but then when I try to scan for auth items nothing happens. Do you know why this might be?

I’m using srbac_1_02r13 with yii_version 1.0.10, I’ve also tried yii_1.1.0 but still nothing

If your application uses Yii 1.1.x try the latest srbac release from the SVN

http://srbac.googlecode.com/svn/trunk/

if your are using yii 1.0.x better use srbac 1.0.3

http://code.google.com/p/srbac/downloads/list

It’s recomended to use the svn code because it’s better tested and with more abilities

Hi Spyros, I’m running php 5.3 and found I had to replace ereg_replace with preg_replace and spilt() with explode() in order to install srbac 1.1.x with Yii 1.1.x

My problem is when I click auto create items nothing happens. Also, i tried to use ‘Edit always allowed list’ and all my actions are there, however, when I go to save them they are not saved.

Any ideas?

Thanks for the 5.3 fix, i’ll apply it for 5.3 compatibility

The always allowed list is saved in srbac/components/allowed.php Check if the file is writable

About the auto creation is there an error in firebug?

– Edit—

preg_replace uses different pattern syntax so just replacing the function name won’t work.

I fixed it and commited the changes.

Hi Spyros,

Great tool from what I’ve seen but I’m running into an installation issue. I don’t know if this is a PHP 5.3 issue or a PostgreSQL issue although I’ve managed to install it in PostgreSQL in the past.

When I click the "Install" button, I receive the following error:

[b]PHP Error

Description

Trying to get property of non-object

Source File

C:\Program Files\Zend\Apache2\htdocs\yii\framework\db\ar\CActiveRecord.php(901)

00889: * @return CActiveRelation the named relation declared for this AR class. Null if the relation does not exist.

00890: */

00891: public function getActiveRelation($name)

00892: {

00893: return isset($this->getMetaData()->relations[$name]) ? $this->getMetaData()->relations[$name] : null;

00894: }

00895:

00896: /**

00897: * @return CDbTableSchema the metadata of the table that this AR belongs to

00898: */

00899: public function getTableSchema()

00900: {

00901: return $this->getMetaData()->tableSchema;

00902: }

00903:

00904: /**

00905: * @return CDbCommandBuilder the command builder used by this AR

00906: */

00907: public function getCommandBuilder()

00908: {

00909: return $this->getDbConnection()->getSchema()->getCommandBuilder();

00910: }

00911:

00912: /**

00913: * @param string attribute name[/b]

Do you have any thoughts about why I would be receiving this error?

Thanks much in advance.

Hi Spyros,

Great tool from what I’ve seen but I’m running into an installation issue. I don’t know if this is a PHP 5.3 issue or a PostgreSQL issue although I’ve managed to install it in PostgreSQL in the past.

When I click the "Install" button, I receive the following error:

[b]PHP Error

Description

Trying to get property of non-object

Source File

C:\Program Files\Zend\Apache2\htdocs\yii\framework\db\ar\CActiveRecord.php(901)

00889: * @return CActiveRelation the named relation declared for this AR class. Null if the relation does not exist.

00890: */

00891: public function getActiveRelation($name)

00892: {

00893: return isset($this->getMetaData()->relations[$name]) ? $this->getMetaData()->relations[$name] : null;

00894: }

00895:

00896: /**

00897: * @return CDbTableSchema the metadata of the table that this AR belongs to

00898: */

00899: public function getTableSchema()

00900: {

00901: return $this->getMetaData()->tableSchema;

00902: }

00903:

00904: /**

00905: * @return CDbCommandBuilder the command builder used by this AR

00906: */

00907: public function getCommandBuilder()

00908: {

00909: return $this->getDbConnection()->getSchema()->getCommandBuilder();

00910: }

00911:

00912: /**

00913: * @param string attribute name[/b]

Do you have any thoughts about why I would be receiving this error? I do know that the auth tables did not get created and I’m assuming that AR is complaining that it can’t find them.

Thanks much in advance.

Which versions of srbac and Yii are you using?

I’m using Yii 1.0.10 and SRBAC 1.0.3 sitting on top of PostgreSQL 8.4.1.

Thanks for the quick response. :slight_smile:

I have exactly the same error as above. I use mysql. Downloaded srbac this week. :(

It is not a PHP 2.3.0 issue as i tested the installation in the 2.2.9-2 version with the same result.

It is not a PostgrSQL issue as i am using mysql and have the same result.

What ive done is:

  • I have changed the default table names for CDbAuthManager.

Thats it… the rest is like instructed in the manual. Whats going wrong here?

thanks for Spyros first!~

tow ticket~ :rolleyes:

Issue 32: isInstalled() compatible with table prefix setting

http://code.google.com/p/srbac/issues/detail?id=32

Issue 31: r142 Managing auth items link has a bit error

http://code.google.com/p/srbac/issues/detail?id=31

line 235? there is no such line :)

Issues in the tracker are fixed. Thanks

As for 1.0.3 version replace the isInstalled function in srbacModule.php with this one




<?php

 public function isInstalled() {

    try {

      $tables = Yii::app()->authManager->db->schema->tableNames;

      $tableName = AuthItem::model()->tableName();

      if(in_array($tableName, $tables)) {

        return true;

      }

      

      return false;

    } catch (CDbException  $exc ) {

      return false;

    }

  }

?>



And see if it helps.

Very efficient ;)

i submit the new ticket just now~

a bit advise for autocreate auth item~

http://code.google.com/p/srbac/issues/detail?id=34

Thanks,

I didn’t understand the ticket.

Do you mean that if the controller is deleted then the relative of auth items should be deleted too?

yes~ afford a clean overdue AuthItems function, it will be helpful~

OK, but it will be added in 1.1 version.

Sweet, Spyros! This did the trick! Thanks for the awesome turnaround time. :slight_smile:

Hey Spyros, thanks 4 the php 5.3 update it worked great!

I was wondering if you would be able to add support for nested modules in the next update?

I would like to nest srbac within an admin module. So it would be able to scan controllers and actions from modules within modules within modules, etc…

Let me know your thoughts :D

Version 1.1 supports nested modules and nested controllers