fix [PHRAS-75] csv user import is broken

This commit is contained in:
Nicolas Le Goff
2014-04-15 17:59:41 +02:00
parent 721fd9e909
commit 0883c95fb4
2 changed files with 11 additions and 4 deletions

View File

@@ -667,7 +667,7 @@ class Users implements ControllerProviderInterface
if ($loginToAdd === "") {
$out['errors'][] = sprintf(_("Login line %d is empty"), $nbLine + 1);
} elseif (in_array($loginToAdd, $loginNew)) {
$out['errors'][] = sprintf(_("Login %s is already defined in the file at line %d"), $loginToAdd, $i);
$out['errors'][] = sprintf(_("Login %s is already defined in the file at line %d"), $loginToAdd, $nbLine + 1);
} else {
if (\User_Adapter::get_usr_id_from_login($app, $loginToAdd)) {
$out['errors'][] = sprintf(_("Login %s already exists in database"), $loginToAdd);
@@ -693,7 +693,7 @@ class Users implements ControllerProviderInterface
$passwordToVerif = $value;
if ($passwordToVerif === "") {
$out['errors'][] = sprintf(_("Password is empty at line %d"), $i);
$out['errors'][] = sprintf(_("Password is empty at line %d"), $nbLine + 1);
} else {
$pwdValid = true;
}

View File

@@ -27,7 +27,7 @@ class CSVServiceProvider implements ServiceProviderInterface
$app['csv.exporter.config'] = $app->share(function () {
$config = new ExporterConfig();
return $config
->setDelimiter(",")
->setDelimiter(";")
->setEnclosure('"')
->setEscape("\\")
->setToCharset('UTF-8')
@@ -40,7 +40,14 @@ class CSVServiceProvider implements ServiceProviderInterface
});
$app['csv.lexer.config'] = $app->share(function ($app) {
return new LexerConfig();
$lexer = new LexerConfig();
$lexer->setDelimiter(';')
->setEnclosure('"')
->setEscape("\\")
->setToCharset('UTF-8')
->setFromCharset('UTF-8');
return $lexer;
});
$app['csv.lexer'] = $app->share(function ($app) {