コード例 #1
0
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $this->email]);
     }
     return $this->_user;
 }
コード例 #2
0
 protected function findFreeUsername($username, $n = '')
 {
     $exists = User::findOne(['username' => $username . $n]);
     if ($exists) {
         $n = $n == '' ? 2 : $n + 1;
         return $this->findFreeUsername($username, $n);
     }
     return $username . $n;
 }
コード例 #3
0
 /**
  * @param int $id User ID
  *
  * @throws \yii\web\NotFoundHttpException
  * @return string
  */
 public function actionSet($id)
 {
     $user = User::findOne($id);
     if (!$user) {
         throw new NotFoundHttpException('User not found');
     }
     $permissionsByGroup = [];
     $permissions = Permission::find()->andWhere([Yii::$app->getModule('user')->auth_item_table . '.name' => array_keys(Permission::getUserPermissions($user->id))])->joinWith('group')->all();
     foreach ($permissions as $permission) {
         $permissionsByGroup[@$permission->group->name][] = $permission;
     }
     return $this->renderIsAjax('set', compact('user', 'permissionsByGroup'));
 }
コード例 #4
0
 public function getUser()
 {
     return User::findOne(['email' => $this->email]);
 }
コード例 #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 ($this->_model === false) {
         $this->_model = User::findOne($id);
     }
     if ($this->_model !== null) {
         return $this->_model;
     }
     throw new NotFoundHttpException('The requested page does not exist.');
 }