Advertisement
fernandezekiel

Untitled

Jan 1st, 2013
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. public function actionAdmin()
  2.     {
  3.         $model=new Customer('search');
  4.         $model->unsetAttributes();  // clear any default values
  5.        
  6.         //this should display customers that are accessible
  7.         $viewConfig = array();
  8.        
  9.         $viewConfig['showOwner'] = true;
  10.        
  11.         //this is the code that i would like to reuse
  12.         if(!Yii::app()->user->checkAccess('Admin'))
  13.         {
  14.             //if it is not an admin
  15.             $model->owner_id = Yii::app()->user->id; //display results that he only owns
  16.             $viewConfig['showOwner'] = false;
  17.            
  18.         }
  19.        
  20.          // for filtering only owned records
  21.         if(isset($_GET['Customer']))
  22.             $model->attributes=$_GET['Customer'];
  23.  
  24.         $this->render('admin',array(
  25.             'model'=>$model,
  26.             'viewConfig'=>$viewConfig,
  27.         ));
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement