Source for file AdminUserController.class.php

Documentation is available at AdminUserController.class.php

  1. <?php
  2. lmb_require('limb/web_app/src/controller/lmbController.class.php');
  3. lmb_require('limb/validation/src/rule/lmbMatchRule.class.php');
  4. lmb_require('limb/cms/src/model/lmbCmsUser.class.php');
  5.  
  6. {
  7.   protected $_form_id = 'user_form';
  8.  
  9.   function doCreate()
  10.   {
  11.     $item new lmbCmsUser();
  12.     $this->useForm($this->_form_id);
  13.     $this->setFormDatasource($item);
  14.  
  15.     if($this->request->hasPost())
  16.     {
  17.       $this->_import($item);
  18.  
  19.       $this->_validatePasswordField();
  20.  
  21.       $this->_validateAndSave($item);
  22.     }
  23.   }
  24.  
  25.   function doEdit()
  26.   {
  27.     $item new lmbCmsUser((int)$this->request->get('id'));
  28.     $this->useForm($this->_form_id);
  29.     $this->setFormDatasource($item);
  30.  
  31.     if($this->request->hasPost())
  32.     {
  33.       $this->_import($item);
  34.       $this->_validateAndSave($item);
  35.     }
  36.   }
  37.  
  38.   function doDetail()
  39.   {
  40.     if($id=$this->request->get('id'))
  41.     {
  42.       $this->view->set('user'new lmbCmsUser((int)$id));
  43.     }
  44.   }
  45.  
  46.   protected function _import($item)
  47.   {
  48.     $item->import($this->request->export());
  49.   }
  50.  
  51.   protected function _validateAndSave($item)
  52.   {
  53.     $item->validate($this->error_list);
  54.  
  55.     if($this->error_list->isValid())
  56.     {
  57.       $item->saveSkipValidation();
  58.       $this->closePopup();
  59.     }
  60.   }
  61.  
  62.   function doDelete()
  63.   {
  64.     if(($this->request->hasPost())&&($this->request->get('delete')))
  65.     {
  66.       foreach($this->request->getArray('ids'as $id)
  67.       {
  68.         $item new lmbCmsUser((int)$id);
  69.         $item->destroy();
  70.       }
  71.       $this->closePopup();
  72.     }
  73.  
  74.   }
  75.  
  76.   function doChangePassword()
  77.   {
  78.     if(!$this->request->hasPost())
  79.       return;
  80.  
  81.     $this->useForm('user_form');
  82.     $this->setFormDatasource($this->request);
  83.  
  84.     $this->_validatePasswordField();
  85.  
  86.     if(!$this->error_list->isValid())
  87.       return;
  88.  
  89.     $user new lmbCmsUser($this->request->getInteger('id'));
  90.     $user->setPassword($this->request->get('password'));
  91.  
  92.     if($user->trySave($this->error_list))
  93.       $this->closePopup();
  94.   }
  95.  
  96.   function _validatePasswordField()
  97.   {
  98.     $validator new lmbValidator();
  99.     $validator->addRequiredRule('repeat_password');
  100.     $validator->addRule(new lmbMatchRule('password''repeat_password'));
  101.     $validator->setErrorList($this->error_list);
  102.     $validator->validate($this->request);
  103.   }
  104. }

Documentation generated on Tue, 06 Jan 2009 03:46:53 +0300 by phpDocumentor 1.3.2