public function actionAdmin() { $model=new Customer('search'); $model->unsetAttributes(); // clear any default values //this should display customers that are accessible $viewConfig = array(); $viewConfig['showOwner'] = true; //this is the code that i would like to reuse if(!Yii::app()->user->checkAccess('Admin')) { //if it is not an admin $model->owner_id = Yii::app()->user->id; //display results that he only owns $viewConfig['showOwner'] = false; } // for filtering only owned records if(isset($_GET['Customer'])) $model->attributes=$_GET['Customer']; $this->render('admin',array( 'model'=>$model, 'viewConfig'=>$viewConfig, )); }