yiisoft/yii — Issue #341: Params for accessControl
Author: claudejanz
Created: 2012-02-16 16:35:56+00:00
State: open

It would be nice to pass params to accessControl so that bizRules works.

I would like to do this in conroller:

```php
public function accessRules() {

return array(

array('allow',
'actions'=>array('update'),
'roles'=>array('updateActivity'=>array('activity'=>$this->activity)),
),

array('deny',
'users'=>array('*'),
),
);
}
```

for this to work i have slightly modified the CAccessRule in web/auth/CAccessControlFilter.php by changing the flowing function:

```php
protected function isRoleMatched($user)
{
if(empty($this->roles))
return true;
foreach($this->roles as $role)
{
if($user->checkAccess($role))
return true;
}
return false;
}
```

to

```php
protected function isRoleMatched($user)
{
if(empty($this->roles))
return true;
foreach($this->roles as $key => $role)
{
if(is_numeric($key)){
if($user->checkAccess($role))
return true;
}else{
if($user->checkAccess($key,$role))
return true;
}
}
return false;
}
```

Can this feature be implemented in next version ? Or is there an issue I haven't noticed about this solution?