Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

How To Search Models Based On Function-Result?

$
0
0
I have a File-model, for which I restrict access. The access is provided through a membership of groups having access - rather complex. Anyway, I have a function in my model called checkAccess() which checks the access of the current user (Yii::app()->user) for the File and returns true or false.

My question: I want to search models and display only the models which are available/accessable for the current user, thus returning true on checkAccess(). Whether the user has access, is no direct (in-database) model property, so I don't know how to search on it. I've tried things with CDbCriteria and model Scopes, but I can't find a solution.

Thanks in advance for helping!


public function checkAccess() 
{
	if( < --- check the permission here --- > ) {
		return true;
	}

	return false;
}	

Viewing all articles
Browse latest Browse all 18717

Trending Articles