modifs jean 1

This commit is contained in:
fredtempez 2020-12-03 14:06:12 +01:00
parent 384c620ae7
commit 53a2b8c270
1 changed files with 25 additions and 10 deletions

View File

@ -598,21 +598,36 @@ class user extends common {
// Traitement des données // Traitement des données
foreach($csv as $item ) { foreach($csv as $item ) {
// Données valides // Données valides
if( array_key_exists('id', $item) //if( array_key_exists('id', $item)
AND array_key_exists('prenom',$item) if( array_key_exists('prenom',$item)
AND array_key_exists('nom',$item) AND array_key_exists('nom',$item)
AND array_key_exists('groupe',$item) //AND array_key_exists('groupe',$item)
AND array_key_exists('email',$item) AND array_key_exists('email',$item)
AND $item['nom'] AND $item['nom']
AND $item['prenom'] AND $item['prenom']
AND $item['id'] //AND $item['id']
AND $item['email'] AND $item['email']
AND $item['groupe'] //AND $item['groupe']
) { ) {
// Validation du groupe if ( !array_key_exists('id', $item)) {
$item['groupe'] = (int) $item['groupe']; // Génération de l'identifiant à partir des deux premières lettres du prénom et du nom
$item['groupe'] = ( $item['groupe'] >= self::GROUP_BANNED AND $item['groupe'] <= self::GROUP_ADMIN ) $item['id'] = substr($item['prenom'],0,2) . substr($item['nom'],0,2);
? $item['groupe'] : 1; }
// Validation du groupe ou groupe inexistant valant 1 (membre)
if (!array_key_exists('groupe',$item)) {
$item['groupe'] = (int) $item['groupe'];
$item['groupe'] = ( $item['groupe'] >= self::GROUP_BANNED AND $item['groupe'] <= self::GROUP_ADMIN )
? $item['groupe'] : 1;
} else {
// Définition du groupe (membre)
$item['groupe'] = 1;
}
// Suppression d'espaces éventuels au début ou à la fin
$item['email'] = str_replace(' ', '', $item['email']);
$item['id'] = str_replace(' ', '', $item['id']);
$item['groupe'] = str_replace(' ', '', $item['groupe']);
// L'utilisateur existe // L'utilisateur existe
if ( $this->getData(['user',helper::filter($item['id'] , helper::FILTER_ID)])) if ( $this->getData(['user',helper::filter($item['id'] , helper::FILTER_ID)]))
{ {
@ -625,7 +640,7 @@ class user extends common {
$item['prenom'], $item['prenom'],
self::$groups[$item['groupe']], self::$groups[$item['groupe']],
$item['prenom'], $item['prenom'],
$item['email'], helper::filter($item['email'] , helper::FILTER_MAIL),
$item['notification'] $item['notification']
]; ];
// L'utilisateur n'existe pas // L'utilisateur n'existe pas