コード例 #1
0
 public function getContragentCod()
 {
     $user = User::findOne($this->user_id);
     if (!empty($user)) {
         return $user->cod;
     } else {
         return '(пусто)';
     }
 }
コード例 #2
0
ファイル: UserTest.php プロジェクト: cleverid/seokeys
 public function testSaveNewPassword()
 {
     /** @var User $model */
     $model = User::findOne($this->users[0]['id']);
     $model->scenario = User::SCENARIO_ADMIN_UPDATE;
     $model->newPassword = '******';
     $model->newPasswordRepeat = 'new-password';
     expect('model is saved', $model->save())->true();
     expect('password is correct', $model->validatePassword('new-password'))->true();
 }
コード例 #3
0
 public function actionUpdate()
 {
     if (\Yii::$app->request->isGet) {
         $model = User::findOne(\Yii::$app->request->get('id'));
         if (!$model) {
             jump_error('数据不存在!', '/');
         }
     } else {
         if (\Yii::$app->request->isPost) {
             $model = new User();
             $post = \Yii::$app->request->post();
             if ($model->updateOne($post[$model->formName()]['id'], $post)) {
                 jump_success('修改成功!');
             } else {
                 jump_error('修改失败!');
             }
         }
     }
     return $this->render('update', ['model' => $model]);
 }
コード例 #4
0
ファイル: User.php プロジェクト: xiaohongyang/yii_shop
 /**
  * 更新一个用户的信息
  *
  * @param $id
  * @param $params
  * @return bool
  */
 public function updateOne($id, $params)
 {
     $model = User::findOne($id);
     $model->scenario = 'update';
     if ($model->load($params) && $model->validate()) {
         return $model->save();
     }
     return false;
 }
コード例 #5
0
 /**
  * Finds the User model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return User the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = User::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #6
0
 /**
  * 配置用户权限组
  *
  * @return string
  */
 public function actionAssign_ment_edit()
 {
     $model = new Auth_assignment();
     if (\Yii::$app->request->isGet) {
         $user_id = \Yii::$app->request->get('user_id');
         if (!$user_id || !User::find($user_id)) {
             jump_error(t_arr('app', ['data', 'does not', 'exists'], '', '!'));
         }
         //角色列表
         $assignMents = $model->getAssignmentByUserid($user_id);
         $assignMentSelectArray = [];
         if (is_array($assignMents) && count($assignMents)) {
             foreach ($assignMents as $_key => $_value) {
                 $assignMentSelectArray[] = $_key;
             }
         }
         //所有角色{}
         $allRolesArray = $model->getAllRoles2SelectArray();
         //用户信息
         $user = User::findOne($user_id);
         return $this->render('assign_ment_edit', ['model' => $model, 'user' => $user, 'assignMentSelectArray' => $assignMentSelectArray, 'allRolesArray' => $allRolesArray]);
     } else {
         if (\Yii::$app->request->isPost) {
             $rs = $model->assign_user_create(\Yii::$app->request->post());
             if ($rs) {
                 jump_success(t_arr('app', ['update', 'success'], '', '!'));
             } else {
                 jump_error(t_arr('app', ['update', 'fail'], '', '!'));
             }
         }
     }
 }
コード例 #7
0
 /**
  * Finds the User model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return User the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = User::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException(self::EXCEPTION_MESS);
     }
 }