Beispiel #1
0
 public function apply()
 {
     $user = User::findOne($this->id);
     $user->money = $this->money;
     $user->save();
     return true;
 }
Beispiel #2
0
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = User::findByUsername($this->username);
     }
     return $this->_user;
 }
Beispiel #3
0
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 protected function getUser()
 {
     if ($this->_user === null) {
         $this->_user = User::findByUsername($this->username);
     }
     return $this->_user;
 }
Beispiel #4
0
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 protected function getUser()
 {
     if ($this->_user === null) {
         $this->_user = User::findByEmail($this->email);
     }
     return $this->_user;
 }
 /**
  * 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.');
     }
 }
Beispiel #6
0
 /**
  * Creates a form model given a token.
  *
  * @param  string                          $token
  * @param  array                           $config name-value pairs that will be used to initialize the object properties
  * @throws \yii\base\InvalidParamException if token is empty or not valid
  */
 public function __construct($token, $config = [])
 {
     if (empty($token) || !is_string($token)) {
         throw new InvalidParamException('Password reset token cannot be blank.');
     }
     $this->_user = User::findByPasswordResetToken($token);
     if (!$this->_user) {
         throw new InvalidParamException('Wrong password reset token.');
     }
     parent::__construct($config);
 }
 /**
  * Sends an email with a link, for resetting the password.
  *
  * @return boolean whether the email was send
  */
 public function sendEmail()
 {
     /* @var $user User */
     $user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $this->email]);
     if ($user) {
         if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
             $user->generatePasswordResetToken();
         }
         if ($user->save()) {
             return \Yii::$app->mailer->compose(['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user])->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot'])->setTo($this->email)->setSubject('Password reset for ' . \Yii::$app->name)->send();
         }
     }
     return false;
 }
Beispiel #8
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'email', $this->email]);
     return $dataProvider;
 }
 /**
  * Updates an existing AuthAssignment model.
  * @param string $item_name
  * @param integer $user_id
  * @return mixed
  */
 public function actionUpdate($item_name, $user_id)
 {
     $model = $this->findModel($item_name, $user_id);
     if (Yii::$app->request->isPost) {
         $model->load(Yii::$app->request->post());
         Yii::$app->response->format = 'json';
         if ($model->save()) {
             return Yii::$app->params['response']['success'];
         } else {
             return ActiveForm::validate($model);
         }
     } else {
         return $this->renderAjax('update', ['model' => $model, 'users' => User::getAllForLists(), 'authItems' => AuthItem::getAllForLists2()]);
     }
 }
Beispiel #10
0
 public function search($params)
 {
     $query = User::find()->joinWith(['authItem' => function ($query) {
         $query->joinWith('ruleName', true, 'LEFT JOIN');
     }], true, 'INNER JOIN');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->current->getPageSize()]]);
     $dataProvider->sort->attributes['status'] = ['asc' => ['user.status' => SORT_DESC], 'desc' => ['user.status' => SORT_ASC]];
     $dataProvider->sort->attributes['authItem.description'] = ['asc' => ['auth_item.description' => SORT_ASC], 'desc' => ['auth_item.description' => SORT_DESC], 'default' => SORT_ASC, 'label' => 'test'];
     $dataProvider->sort->attributes['authItem.ruleName.name'] = ['asc' => ['auth_rule.name' => SORT_ASC], 'desc' => ['auth_rule.name' => SORT_DESC]];
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['user.status' => $this->status]);
     $query->andFilterWhere(['like', 'user.username', $this->username])->andFilterWhere(['like', 'user.email', $this->email])->andFilterWhere(['like', 'auth_item.description', $this->{'authItem.description'}])->andFilterWhere(['like', 'auth_rule.name', $this->{'authItem.ruleName.name'}]);
     return $dataProvider;
 }
Beispiel #11
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUsers()
 {
     return $this->hasMany(User::className(), ['name' => 'role']);
 }
Beispiel #12
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getOwner()
 {
     return $this->hasOne(User::className(), ['id' => 'owner_id']);
 }
Beispiel #13
0
 public function run()
 {
     return $this->render('send-in-work', ['users' => User::getAllForLists(), 'subdivisions' => Subdivision::getAllForLists()]);
 }
Beispiel #14
0
<div class="box box-primary">
    <div class="box-body">

        <?php 
$form = ActiveForm::begin();
?>
            <div class="row">
                <div class="col-md-4">
                    <?php 
echo $form->field($model, 'username')->textInput(['maxlength' => true]);
?>
                    <?php 
echo $form->field($model, 'email')->textInput(['maxlength' => true]);
?>
                    <?php 
echo $form->field($model, 'role')->dropDownlist(User::getRoleArray());
?>
                    <?php 
echo $form->field($model, 'status')->checkbox();
?>
                    <hr/>
                    <?php 
echo $form->field($model, 'newPassword')->passwordInput();
?>
                    <?php 
echo $form->field($model, 'newPasswordRepeat')->passwordInput();
?>
                </div>
            </div>
    
        <div class="form-group">
Beispiel #15
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function searchConnection($params)
 {
     $query = User::find()->where(['flag_login' => 1]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // echo "masuk";die();
         //     // uncomment the following line if you do not want to return any records when validation fails
         //     // $query->where('0=1');
         return $dataProvider;
     }
     return $dataProvider;
 }
Beispiel #16
0
 public function studentsEmail($id)
 {
     $user = User::findOne($id);
     return $user->email;
 }
Beispiel #17
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('Запрашиваемая страница не существует.');
     }
 }