Advertisement
Guest User

Untitled

a guest
Mar 1st, 2012
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1. public function actionChangePassword()
  2.     {
  3.         $model=$this->loadModel();
  4.         $params=array('userid' => $model->id);
  5.        
  6.         if(isset($_POST['User']))
  7.         {
  8.             $model->attributes=$_POST['User'];
  9.             if($model->save())
  10.                 $this->redirect(array('index'));
  11.         }
  12.        
  13.         $model->password=NULL;
  14.         $model->passwordRepeat=NULL;
  15.         /*$params = User::model()->findByPk(Yii::app()->user->id);*/
  16.         if(Yii::app()->user->checkAccess('Profile.ChangePassword',array('userid'=>$params)))
  17.         {
  18.            
  19.         }
  20.        
  21.         $this->render('_form',array('model'=>$model));
  22.     }
  23.    
  24.  
  25.    
  26.  
  27.     /**
  28.      * Returns the data model based on the primary key given in the GET variable.
  29.      * If the data model is not found, an HTTP exception will be raised.
  30.      * @param integer the ID of the model to be loaded
  31.      */
  32.     private function loadModel()
  33.     {
  34.         if(isset($_GET['id']))
  35.             $id = $_GET['id'];
  36.         else
  37.             $id = Yii::app()->user->id;
  38.            
  39.         $model=User::model()->findByPk($id);
  40.         if($model===null)
  41.             throw new CHttpException(404,'The requested page does not exist.');
  42.         return $model;
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement