コード例 #1
0
ファイル: UserController.php プロジェクト: sindotnet/cona
 /**
  * Updates an existing User model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $searchModel = new CompanySearch();
     $dataProvider = $searchModel->searchByAdmin(Yii::$app->request->queryParams);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         //Change Pass
         $userpost = Yii::$app->request->post('User');
         if (strlen($userpost['new_password']) > 0) {
             $model->password = sha1($userpost['new_password']);
             //sha1($userpost['new_password']);
             $model->save();
             //Change Pass
         }
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'dataProvider' => $dataProvider, 'searchModel' => $searchModel]);
     }
 }