Skip to content

Commit

Permalink
Fixed issue #18061: Import users via JSON always shows "Wrong definit…
Browse files Browse the repository at this point in the history
…ion!" (#2400)
  • Loading branch information
Shnoulle committed May 6, 2022
1 parent 63a6c36 commit 28e2913
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions application/controllers/UserManagementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ public function actionRenderUserImport(string $importFormat = 'csv')
$allowFileType = ".csv";

if ($importFormat == 'json') {
$importNote = sprintf(gT("Wrong definition! Please make sure that your JSON arrays contains the fields '%s', '%s', '%s', '%s', and '%s'"), '<b>users_name</b>', '<b>full_name</b>', '<b>email</b>', '<b>lang</b>', '<b>password</b>');
$importNote = sprintf(gT("Please make sure that your JSON arrays contains the fields '%s', '%s', '%s', '%s', and '%s'"), '<b>users_name</b>', '<b>full_name</b>', '<b>email</b>', '<b>lang</b>', '<b>password</b>');
$allowFileType = ".json,application/json";
}

Expand All @@ -656,11 +656,7 @@ public function actionImportUsers(string $importFormat = 'csv'): string
);
}

$overwriteUsers = false;

if (isset($_POST['overwrite'])) {
$overwriteUsers = true;
}
$overwriteUsers = boolval(App()->getRequest()->getPost('overwrite'));

switch ($importFormat) {
case "json":
Expand All @@ -670,7 +666,11 @@ public function actionImportUsers(string $importFormat = 'csv'): string
default:
$aNewUsers = UserParser::getDataFromCSV($_FILES); //importFormat default is csv ...
}

if (empty($aNewUsers)) {
Yii::app()->setFlashMessage(gT("No user definition found in file."), 'error');
$this->redirect(['userManagement/index']);
App()->end();
}
$created = [];
$updated = [];

Expand Down Expand Up @@ -723,7 +723,7 @@ public function actionImportUsers(string $importFormat = 'csv'): string
}

Yii::app()->setFlashMessage(gT("Users imported successfully."), 'success');
$this->redirect('index');
$this->redirect(['userManagement/index']);
}


Expand Down

0 comments on commit 28e2913

Please sign in to comment.