
Untitled
By: a guest on
Mar 1st, 2012 | syntax:
PHP | size: 1.03 KB | hits: 102 | expires: Never
public function actionChangePassword()
{
$model=$this->loadModel();
$params=array('userid' => $model->id);
if(isset($_POST['User']))
{
$model->attributes=$_POST['User'];
if($model->save())
$this->redirect(array('index'));
}
$model->password=NULL;
$model->passwordRepeat=NULL;
/*$params = User::model()->findByPk(Yii::app()->user->id);*/
if(Yii::app()->user->checkAccess('Profile.ChangePassword',array('userid'=>$params)))
{
}
$this->render('_form',array('model'=>$model));
}
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
private function loadModel()
{
if(isset($_GET['id']))
$id = $_GET['id'];
else
$id = Yii::app()->user->id;
$model=User::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}