I want to create a user form and I want to create a rule that a user with the same cmp_id ($user->cmp_id) can edit this user.
I thing I have to use an expression but how can I do this, the id of user is the $_get(‘id’).
The code of edit simiral is as the crud function of Yii is.
$model= users::model()->findbyPk(intval($_GET['id'])); etc
Maybe I do the test at action?
public function accessRules()
{
return array(
array('allow',
'actions'=>array('index','Contact','Login','Logout'),
'users'=>array('*'),
),
array('allow',
'actions'=>array('Users','Company'),
'users'=>array('@'),
),
array('allow',
'actions'=>array('EditCompany', 'User','EditUser'),
'users'=>array('@'),
'expression'=>$user->type==0
),
array('deny',
'users'=>array('*'),
),
);
}