Advertisement
fernandezekiel

Untitled

Feb 8th, 2013
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.58 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.  * To change this template, choose Tools | Templates
  5.  * and open the template in the editor.
  6.  */
  7.  
  8. /**
  9.  * Description of Admin
  10.  *
  11.  * @author Web Developer
  12.  */
  13. class Admin extends CAction{
  14.     //put your code here
  15.     public $showSoftDeleted = false;
  16.     public $defaultViewConfig = array(
  17.         'showOwner'=>false,
  18.         'showSoftDeleted'=>false,
  19.         );
  20.     public $modelClass = "Customer";
  21.     //public $
  22.    
  23.     public function run($showSoftDeleted = false) {
  24.         $controller = $this->getController();
  25.         $modelClass = $this->modelClass;
  26.         $viewConfig = $this->defaultViewConfig;
  27.         $model = new $this->modelClass('search');
  28.         $model->unsetAttributes();  // clear any default values
  29.         //
  30.         //$model->enableFiltering = false;
  31.         if($showSoftDeleted == true){
  32.             $model->hideSoftDeleted = !$showSoftDeleted;
  33.             $viewConfig['showSoftDeleted'] = true;
  34.            
  35.         }
  36.         //$model->owner_id = Yii::app()->user->id;
  37.         //this should display customers that are accessible
  38.  
  39.         //var_dump($viewConfig['showSoftDeleted']);
  40.         if (RestrictedActiveRecord::mayGenerally($model, $model->accessTerms['readAccessTerm']))
  41.             $viewConfig['showOwner'] = true;
  42.  
  43.      
  44.        
  45.         // for filtering only owned records
  46.         if (isset($_GET[$modelClass]))
  47.             $model->attributes = $_GET[$modelClass];
  48.        
  49.         $controller->render('admin', array(
  50.             'model' => $model,
  51.             'viewConfig' => $viewConfig,
  52.         ));
  53.     }
  54. }
  55.  
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement