modif alogo de check + notification à revoir

This commit is contained in:
Prof Langues 2020-10-08 10:33:53 +02:00
parent a2b2896d80
commit 5dfbe9a60d
1 changed files with 34 additions and 32 deletions

View File

@ -562,7 +562,7 @@ class user extends common {
// Lecture du CSV et construction du tableau // Lecture du CSV et construction du tableau
$file = $this->getInput('userImportCSVFile',helper::FILTER_STRING_SHORT, true); $file = $this->getInput('userImportCSVFile',helper::FILTER_STRING_SHORT, true);
$filePath = self::FILE_DIR . 'source/' . $file; $filePath = self::FILE_DIR . 'source/' . $file;
if (file_exists ($filePath)) { if ($file AND file_exists($filePath)) {
$rows = array_map(function($row) { return str_getcsv($row, $this->getInput('userImportSeparator') ); }, file($filePath)); $rows = array_map(function($row) { return str_getcsv($row, $this->getInput('userImportSeparator') ); }, file($filePath));
$header = array_shift($rows); $header = array_shift($rows);
$csv = array(); $csv = array();
@ -571,17 +571,18 @@ class user extends common {
} }
// Stockage des données // Stockage des données
foreach($csv as $item ) { foreach($csv as $item ) {
// Nettoyage de l'identifiant
$userId = helper::filter($item['id'] , helper::FILTER_ID);
// N'insére que les utilisateurs dont l'id n'existe pas // N'insére que les utilisateurs dont l'id n'existe pas
// Vérifier la présence des champs // Vérifier la présence des champs
if( !$this->getData(['user', $userId]) if( array_key_exists('id', $item)
AND $item['prenom'] AND array_key_exists('prenom',$item)
AND $item['nom'] AND array_key_exists('nom',$item)
AND $item['groupe'] AND array_key_exists('groupe',$item)
AND $item['email'] AND array_key_exists('email',$item)
AND $userId ) AND !$this->getData(['user', $item['id']])
)
{ {
// Nettoyage de l'identifiant
$userId = helper::filter($item['id'] , helper::FILTER_ID);
// Enregistre le user // Enregistre le user
$this->setData([ $this->setData([
'user', 'user',
@ -600,11 +601,6 @@ class user extends common {
"accessTimer" => null, "accessTimer" => null,
"accessCsrf" => null "accessCsrf" => null
]]); ]]);
$item['notification'] = template::ico('check');
} else {
$item['notification'] = template::ico('cancel');
}
// Création du tableau de confirmation // Création du tableau de confirmation
self::$users[] = [ self::$users[] = [
$userId, $userId,
@ -615,12 +611,9 @@ class user extends common {
$item['email'], $item['email'],
$item['notification'] $item['notification']
]; ];
}
$notification = 'importation effectuée' ;
$success = true;
// Envoi du mail // Envoi du mail
if ($this->getInput('userImportNotification',self::FILTER_BOOLEAN)) { if ($this->getInput('userImportNotification',helper::FILTER_BOOLEAN) === true) {
$this->sendMail( $sent = $this->sendMail(
$item['email'], $item['email'],
'Compte créé sur ' . $this->getData(['config', 'title']), 'Compte créé sur ' . $this->getData(['config', 'title']),
'Bonjour <strong>' . $item['prenom'] . ' ' . $item['nom'] . '</strong>,<br><br>' . 'Bonjour <strong>' . $item['prenom'] . ' ' . $item['nom'] . '</strong>,<br><br>' .
@ -628,7 +621,16 @@ class user extends common {
'<strong>Identifiant du compte :</strong> ' . $userId . '<br>' . '<strong>Identifiant du compte :</strong> ' . $userId . '<br>' .
'<small>Un mot de passe provisoire vous été attribué, à la première connexion cliquez sur Mot de passe Oublié.</small>' '<small>Un mot de passe provisoire vous été attribué, à la première connexion cliquez sur Mot de passe Oublié.</small>'
); );
$item['notification'] = $sent === true ? 'Mail' : template::ico('check') ;
} else {
$item['notification'] = template::ico('check');
} }
} else {
$item['notification'] = template::ico('cancel');
}
}
$notification = 'importation effectuée' ;
$success = true;
} else { } else {
$notification = 'Erreur de lecture, vérifiez les permissions'; $notification = 'Erreur de lecture, vérifiez les permissions';
$success = false; $success = false;