Filter DataProvider based on user access


I have a CActiveRecord class called Article,and I use CListView fed with a CDataProvider instance to display the articles in a view.

I have a column in Article called access where I store the least powerful role that can read the article.I can’t figure out,when buliding the CdataProvider innstance, how to fetch only the articles whose access column returns true for this test:


The above condition should return true for the article but obviously I cannot use it like a condition in CDbCriteria since it is not an SQL condition but uses php code.

I will appreciate your help,thanks in advance.

Obviously you cannot use the Yii access control checking in your SQL criteria, so either you will have to use your knowledge of the available access codes and however a user’s access level is stored in tables to do some joining/filtering according to access level, or you’ll have to change data provider.