Shared database among Yii sites

Hi all,

I’ve made a CMS system for multiple sites using Yii. All Sites share the same database, but several tables has a “siteId” field, which relates them to one specific site. The problem is the RBAC system. At one site, the forum is visible to guests, but it’s protected on another site. The perfect setup, in my opinion, would be, that all AuthItems are shared (bundled to the system), but AuthItemChild and AuthAssignment would be specific to each site. I just don’t know how to achieve this, without some hack in the Yii framework.

What is your point of view? Can i do this in any way?

I would also like to know if anyone has tackled this problem.

You might want to take a look at potentially applying a "bizrule" on the auth assignment:

http://www.yiiframew…ignment#bizRule

Something like:


//Assign an auth item to a user within the context of a specific site identifier

$auth = Yii::app()->authManager; 

$bizRule='return (isset($params["siteId"]) && $params["siteId"] ==  X);';  

$auth->assign('someAuthItem','someUserId', $bizRule);   


//check whether or not an assignment holds true within the context of a specific site identifier

$params=array('siteId'=>X);  

$auth->checkAccess('someAuthItem','someUserId',$params);

Not entirely sure if such an approach would address exactly what you are trying to achieve. But might be worth exploring.