how should i know frontend or backend in one modle?

i have frontend and backend,the backend is a module named ‘admin’.

frontend and backend use one model together.

the modle location at protected\models\

how should i know is frontend or backend in the model?

i have one modle,there has a status field, the value is 1 or 0,on frontend i need to show status = 1,but backend i need to show all data.

so in the model,i define the function relations(),like this:




public function relations()

{

	return array(

		'questions' => array(self::HAS_MANY, 'Question', 'survey_id', 'condition'=>($moduleName == 'admin')?null:'status=1'),

	);

}



i don’t know how to get module name or other ways.

Please help!

Thank you!

Maybe Yii::app()->controller->module->id will work, but I don’t think it’s a good idea. Better use scopes, so in the frontend you can always write: Question::model()->published()->findAll().