module ok reste les tests et les notifications
This commit is contained in:
parent
3d140e1a36
commit
7aad2deb53
@ -19,6 +19,7 @@ class user extends common {
|
|||||||
'delete' => self::GROUP_ADMIN,
|
'delete' => self::GROUP_ADMIN,
|
||||||
'import' => self::GROUP_ADMIN,
|
'import' => self::GROUP_ADMIN,
|
||||||
'index' => self::GROUP_ADMIN,
|
'index' => self::GROUP_ADMIN,
|
||||||
|
'csvstring_to_array' => self::GROUP_ADMIN,
|
||||||
'edit' => self::GROUP_MEMBER,
|
'edit' => self::GROUP_MEMBER,
|
||||||
'logout' => self::GROUP_MEMBER,
|
'logout' => self::GROUP_MEMBER,
|
||||||
'forgot' => self::GROUP_VISITOR,
|
'forgot' => self::GROUP_VISITOR,
|
||||||
@ -542,11 +543,42 @@ class user extends common {
|
|||||||
* Importation CSV d'utilisateurs
|
* Importation CSV d'utilisateurs
|
||||||
*/
|
*/
|
||||||
public function import() {
|
public function import() {
|
||||||
|
// Soumission du formulaire
|
||||||
|
if($this->isPost()) {
|
||||||
|
// Lecture du CSV et construction du tableau
|
||||||
|
$file = helper::baseUrl(false) . self::FILE_DIR . 'source/' . $this->getInput('userImportCSVFile',helper::FILTER_STRING_SHORT, true);
|
||||||
|
$rows = array_map(function($row) { return str_getcsv($row, ';'); }, file($file));
|
||||||
|
$header = array_shift($rows);
|
||||||
|
$csv = array();
|
||||||
|
foreach($rows as $row) {
|
||||||
|
$csv[] = array_combine($header, $row);
|
||||||
|
}
|
||||||
|
// Stockage des données
|
||||||
|
foreach($csv as $item ) {
|
||||||
|
$userId = $item['id'];
|
||||||
|
if($this->getData(['user', $userId])) {
|
||||||
|
self::$inputNotices['userAddId'] = 'Identifiant déjà utilisé';
|
||||||
|
$check=false;
|
||||||
|
}
|
||||||
|
$this->setData([
|
||||||
|
'user',
|
||||||
|
$userId,
|
||||||
|
[
|
||||||
|
'firstname' => $item['prenom'],
|
||||||
|
'forgot' => 0,
|
||||||
|
'group' => $item['groupe'],
|
||||||
|
'lastname' => $item['nom'],
|
||||||
|
'mail' => $item['email'],
|
||||||
|
'password' => uniqid()
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'title' => 'Importation d\'utilisateurs',
|
'title' => 'Importation',
|
||||||
'view' => 'import'
|
'view' => 'import'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,12 +1,33 @@
|
|||||||
<?php echo template::formOpen('userImportForm'); ?>
|
<?php echo template::formOpen('userImportForm'); ?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col2">
|
<div class="col2">
|
||||||
<?php echo template::button('userImportBack', [
|
<?php echo template::button('userImportBack', [
|
||||||
'class' => 'buttonGrey',
|
'class' => 'buttonGrey',
|
||||||
'href' => helper::baseUrl() . 'user',
|
'href' => helper::baseUrl() . 'user',
|
||||||
'ico' => 'left',
|
'ico' => 'left',
|
||||||
'value' => 'Retour'
|
'value' => 'Retour'
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col2 offset8">
|
||||||
|
<?php echo template::submit('userImportSubmit'); ?>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col12">
|
||||||
|
<div class="block">
|
||||||
|
<h4>Importation de fichier plat CSV</h4>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col6">
|
||||||
|
bla bla expliquant le format d'import à respecter
|
||||||
|
</div>
|
||||||
|
<div class="col6">
|
||||||
|
<?php echo template::file('userImportCSVFile', [
|
||||||
|
'label' => 'Liste d\'utilisateurs :'
|
||||||
|
]); ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<?php echo template::formClose(); ?>
|
<?php echo template::formClose(); ?>
|
4
site/export.csv
Normal file
4
site/export.csv
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
1;"Haddock";"Archibald";"Muséum d'histoire naturelle";"Décoratrice";"Rue de l'Ecole-de-Médecine ";1205;"Genève";111;"ah@free.fr";
|
||||||
|
2;"Castafiore";"Bianca";"Musée de Saint-Imier";"Conservatrice";"Heideweg 45 ";2503;"Biel/Bienne";222;"bc@free.fr";
|
||||||
|
3;"Lampion";"Séraphin";"Musée Charles Clos Olsommer";"Conservatrice et commissaire d'exposition";"Zudannazstrasse 4 ";3970;"Salgesch";333;"sl@laposte.net";
|
||||||
|
4;"Tournesol";"Trypho";"Fondation de l'Hermitage";"Chargée de projets d'exposition";2;" route du Signal CP 42";1000;"Lausanne 8 Bellevaux";444;"tt@ac-toulouse.fr"
|
|
BIN
site/tmp/5f79e3644fdca.png
Normal file
BIN
site/tmp/5f79e3644fdca.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
BIN
site/tmp/5f79e3644fdd8.png
Normal file
BIN
site/tmp/5f79e3644fdd8.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
BIN
site/tmp/5f79e380687eb.png
Normal file
BIN
site/tmp/5f79e380687eb.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
BIN
site/tmp/5f79e380687ee.png
Normal file
BIN
site/tmp/5f79e380687ee.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
Loading…
Reference in New Issue
Block a user