94 lines
2.0 KiB
PHP
Executable File
94 lines
2.0 KiB
PHP
Executable File
<?php define('__ROOT__', dirname(dirname(__FILE__)) );
|
|
|
|
require_once __ROOT__.'/manager/database.php';
|
|
require_once __ROOT__.'/manager/user.php';
|
|
require_once __ROOT__.'/manager/groups.php';
|
|
|
|
debug();
|
|
|
|
/* LECTURE DU JSON */
|
|
$sampleFile = file_get_contents('../src/userlistSample.json');
|
|
$sample = JSON_decode($sampleFile);
|
|
|
|
/*** CRÉATION D'UTILISATEUR ***/
|
|
|
|
|
|
foreach( $sample as $user ){
|
|
$answer1 = new stdClass();
|
|
$answer2 = new stdClass();
|
|
$request1 = new stdClass();
|
|
$request1->level_1 = 'create';
|
|
|
|
$request2 = new stdClass();
|
|
$request2->level_1 = 'add';
|
|
|
|
|
|
foreach($user as $k=>$v)
|
|
switch($k){
|
|
case 'pseudo': $request1->username = $v; break;
|
|
case 'prenom': $request1->prenom = $v; break;
|
|
case 'nom': $request1->nom = $v; break;
|
|
case 'email': $request1->email = $v; break;
|
|
case 'password': $request1->password = sha1($v); break;
|
|
case 'droits': $request1->droits = $v; break;
|
|
}
|
|
|
|
user_switch_level_1($request1, $answer1);
|
|
|
|
echo $request1->username;
|
|
|
|
if( $answer1->request == 'success' ){
|
|
|
|
/* AJOUT A UN GROUPE */
|
|
$request2->etudiant = $request1->username; // utilisateur.username
|
|
$request2->groupe = chr(rand(65,70)); // groupe entre A - F
|
|
|
|
groups_switch_level_1($request2, $answer2);
|
|
echo 'yeah';
|
|
|
|
if( $answer2->request == 'success' )
|
|
echo '['.$request2->groupe.']<br>';
|
|
else
|
|
echo '[ERROR_2: '.$answer2->request.']<br>';
|
|
|
|
}else
|
|
echo ' [ERROR_1: '.$answer1->request.']<br>';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// user_switch_level_1($request, $answer);
|
|
|
|
|
|
|
|
// echo var_dump( $answer );
|
|
|
|
// echo '<br><br><br><br><br><br><br>It works !';
|
|
|
|
|
|
|
|
|
|
|
|
/*** AJOUT D'UN UTILISATEUR À UN GROUPE ***/
|
|
|
|
//
|
|
|
|
// $request = new stdClass();
|
|
// $answer = new stdClass();
|
|
|
|
// $request->level_1 = 'add';
|
|
// $request->utilisateur = 'fvg1856a'; // utilisateur.username
|
|
// $request->groupe = 'A'; // groupe.nom
|
|
|
|
|
|
// groups_switch_level_1($request, $answer);
|
|
|
|
// echo var_dump( $answer );
|
|
|
|
// echo "<br><br><br><br><br><br><br>It works !";
|
|
|
|
|
|
?>
|