Hi,
i have a problem i wrote behavior to checking user permission to model, and i it works perfect when this code is executed:
SFile::model()->findAll('folder_id = '.$model->id)
but when i use relation i doesn’t work
$model->files;
This behavior simply add relation on fly to active record using metadadata.
To check permissions i used seperate table and onBeforeFind event just simply and criteria:
$criteria->with = array('permission'=>array(
'joinType'=>'INNER JOIN',
'on'=>$this->permissionLevel.' IN '.$this->createInArray($options).' AND '.$this->userFK.'= :userid',
'together'=>true,
'params'=>array(':userid'=>Yii::app()->user->id),
));
$event->sender->getDbCriteria()->mergeWith($criteria);
So my question is why this code works when performing simple findAll and how can i do this in relation?
Simple scenario is when i have to tables and activerecords like folder and files and files have this behavior attached? Please any help?
P.S.
sorry for my language