Does the Yii RBAC enable a user to be assigned more than one role?
Assuming roles are set up as follows:
[color="#0000FF"]$auth->createOperation(‘addRecOff’,‘Add Receiving Officer’);
$auth->createOperation(‘enterReceivedItems’,‘Enter Quantites Received’);
$auth->createOperation(‘addReqSup’,‘Add Requisition Supervisor’);
$auth->createOperation(‘submitReq’,‘Submit a requisition’);
$auth->createOperation(‘addReqOff’,‘Add Requisition officer’);
// receivingofficer can only Enter Quantites Received
$role=$auth->createRole(‘receivingofficer’);
$role->addChild(‘enterReceivedItems’);
// reqofficer can only Submit a requisition
$role=$auth->createRole(‘reqofficer’);
$role->addChild(‘submitReq’);
// reqsuper can do all that reqofficer can do, plus can Add Requisition officer
$role=$auth->createRole(‘reqsuper’);
$role->addChild(‘reqofficer’);
$role->addChild(‘addReqOff’);
// manager can do all that receivingofficer and reqsuper can do, plus can Add Requisition Supervisor
$role=$auth->createRole(‘manager’);
$role->addChild(‘receivingofficer’);
$role->addChild(‘reqsuper’);
$role->addChild(‘addRecSup’);
[/color]
If I want userA to be both a receivingofficer AND a reqofficer, can I do the following:
[color="#0000FF"]$auth->assign(‘receivingofficer’,‘userA’);
$auth->assign(‘reqofficer’,‘userA’);[/color]
So that the following both return true when userA is logged in:
[color="#0000FF"]Yii::app()->user->checkAccess(‘enterReceivedItems’)
Yii::app()->user->checkAccess(‘submitReq’)[/color]
Or would I have to create a new role, such as:
[color="#0000FF"]$role=$auth->createRole(‘reqandreceivingofficer’);
$role->addChild(‘receivingofficer’);
$role->addChild(‘reqofficer’);[/color]