public function actionUpdate($id)
 {
     $extendedRights = \Yii::$app->getModule('extendedrights');
     $user = $extendedRights->userModel;
     $user = $user::findOne(['id' => $id]);
     $fields = UserFields::find()->asArray()->all();
     if (isset($_POST['username'])) {
         $user->username = $_POST['username'];
         $user->email = $_POST['email'];
         if (!empty($_POST['password']) && $_POST['password'] != '*****') {
             $user->setPassword($_POST['password']);
         }
         $user->save(false);
         if (isset($_POST['UserFields']) and count($_POST['UserFields']) > 0) {
             foreach ($_POST['UserFields'] as $key => $postValue) {
                 $value = UserValues::findOne(['idField' => $key, 'idUser' => $user->id]);
                 if ($value === null) {
                     $value = new UserValues();
                     $value->idField = $key;
                     $value->idUser = $user->id;
                 }
                 $value->fieldValue = trim($postValue);
                 $value->save();
             }
         }
         $this->redirect(['index']);
     }
     return $this->render('update', ['user' => $user, 'fields' => $fields]);
 }
 /**
  * Find all User Profiles
  *
  * @return UserProfile[]
  */
 public static function findAll()
 {
     $userModel = ExtendedRights::getInstance()->userModel;
     $profiles = [];
     $users = $userModel::find()->all();
     if (count($users) > 0) {
         foreach ($users as $user) {
             /** @var UserProfile $profile */
             $profile = new UserProfile();
             $profile->id = $user->id;
             $profile->username = $user->username;
             $profile->email = $user->email;
             /** @var array $profileFields */
             $profileFields = UserFields::find()->asArray()->all();
             if (count($profileFields) > 0) {
                 foreach ($profileFields as $field) {
                     $value = '';
                     /** @var UserValues $values */
                     $values = UserValues::findOne(['idUser' => $profile->id, 'idField' => $field['id']]);
                     if ($values !== null) {
                         $value = $values->fieldValue;
                     }
                     $fieldName = $field['fieldName'];
                     $profile->{$fieldName} = $value;
                 }
             }
             $profiles[] = $profile;
         }
     }
     return $profiles;
 }
 public function actionIndex()
 {
     return $this->render('index', ['fields' => UserFields::find()->asArray()->all()]);
 }