[rtl]سلام. تو کد زیر در صورتی که من گروهی داشته به اسمهای ادمین و پادلیشر چطوری میتونم این گروه های خاص رو تعریف و دسترسی بدم؟[/rtl]
public function accessRules()
{
return array(
array('allow', // allow all users to access 'index' and 'view' actions.
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow', // allow authenticated users to access all actions
'users'=>array('@'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
البته یک راه حل خیلی ساده تر و سبک تر از Role-Based Access Control هم هست که برای بیشتر موارد جواب میده.
به صورت زیر
[/rtl]
Two things about this expression. First, you still need to use the users element,
and you’ll probably want to still restrict this to logged-in users (most likely).
Second, the expression itself should be some PHP code, quoted,
that when evaluated gives a Boolean result.
If the code in the expression will be true, then permission will be allowed; false, denied.
Say you wanted to restrict the publish action to only those with the role of editor:
array('allow',
'actions'=>array('publish'),
'users'=>array('@'),
'expression'=>'isset($user->role) && ($user->role==="editor")'
),
[rtl]
مراجعه شود به Framework Access Control Lists- Larry Ullman