Corrections des modules+repos et TESTS 'user' 'cluster' 'machine' 'userDefault/create' 'machineDefault/create'
This commit is contained in:
parent
352ff86efb
commit
e8bc1a72bf
|
@ -33,6 +33,7 @@
|
||||||
return ['ModuleError' => ManagerError::ModuleError];
|
return ['ModuleError' => ManagerError::ModuleError];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [2] Creation du groupe de meme nom que la machine
|
/* [2] Creation du groupe de meme nom que la machine
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$create_group = new Repo('cluster/create', [
|
$create_group = new Repo('cluster/create', [
|
||||||
|
@ -46,7 +47,6 @@
|
||||||
if( $id_group === false )
|
if( $id_group === false )
|
||||||
return ['ModuleError' => ManagerError::ModuleError];
|
return ['ModuleError' => ManagerError::ModuleError];
|
||||||
|
|
||||||
|
|
||||||
/* [3] Association au groupe
|
/* [3] Association au groupe
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$assoc_goup = new Repo('cluster/link', [
|
$assoc_goup = new Repo('cluster/link', [
|
||||||
|
|
|
@ -44,8 +44,6 @@
|
||||||
]);
|
]);
|
||||||
$id_user = $create_user->answer();
|
$id_user = $create_user->answer();
|
||||||
|
|
||||||
var_dump($create_user);
|
|
||||||
|
|
||||||
// Si une erreur est retournee, on retourne une erreur
|
// Si une erreur est retournee, on retourne une erreur
|
||||||
if( $id_user === false )
|
if( $id_user === false )
|
||||||
return ['ModuleError' => ManagerError::ModuleError];
|
return ['ModuleError' => ManagerError::ModuleError];
|
||||||
|
@ -54,15 +52,15 @@
|
||||||
|
|
||||||
/* [3] Creation du groupe de meme nom que l'username
|
/* [3] Creation du groupe de meme nom que l'username
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$create_group = new Repo('cluster/create', [
|
$create_cluster = new Repo('cluster/create', [
|
||||||
$_SESSION['WAREHOUSE']['id'],
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
$username,
|
$username,
|
||||||
clusterRepo::USER_CLASS
|
clusterRepo::USER_CLASS
|
||||||
]);
|
]);
|
||||||
$id_group = $create_group->answer();
|
$id_cluster = $create_cluster->answer();
|
||||||
|
|
||||||
// Si une erreur est retournee, on retourne une erreur
|
// Si une erreur est retournee, on retourne une erreur
|
||||||
if( $id_group === false )
|
if( $id_cluster === false )
|
||||||
return ['ModuleError' => ManagerError::ModuleError];
|
return ['ModuleError' => ManagerError::ModuleError];
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,15 +70,15 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$assoc_goup = new Repo('cluster/link', [
|
$assoc_goup = new Repo('cluster/link', [
|
||||||
$_SESSION['WAREHOUSE']['id'],
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
$id_group,
|
$id_cluster,
|
||||||
$id_user,
|
$id_user,
|
||||||
clusterRepo::USER_CLASS
|
clusterRepo::USER_CLASS
|
||||||
]);
|
]);
|
||||||
$id_assoc = $assoc_goup->answer();
|
$assoc_err = $assoc_goup->answer();
|
||||||
|
|
||||||
// Si une erreur est retournee, on retourne une erreur
|
// Si une erreur est retournee, on retourne une erreur
|
||||||
if( $id_assoc === false )
|
if( $assoc_err != ManagerError::Success )
|
||||||
return ['ModuleError' => ManagerError::ModuleError];
|
return ['ModuleError' => $assoc_err];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,7 +86,7 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
return [
|
return [
|
||||||
'id_user' => $id_user,
|
'id_user' => $id_user,
|
||||||
'id_cluster' => $id_group
|
'id_cluster' => $id_cluster
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,7 @@
|
||||||
* @id_entity<int> UID de la machine ou de l'utilisateur
|
* @id_entity<int> UID de la machine ou de l'utilisateur
|
||||||
* @class<int> Spefication du type d'entite (0=user;1=machine)
|
* @class<int> Spefication du type d'entite (0=user;1=machine)
|
||||||
*
|
*
|
||||||
* @return association<int> Renvoie l'UID de l'association cree
|
* @return error<int> Renvoie le code 'ManagerError'
|
||||||
* Renvoie FALSE si une erreur occure
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function link($id_warehouse, $id_cluster, $id_entity, $class){
|
public static function link($id_warehouse, $id_cluster, $id_entity, $class){
|
||||||
|
@ -130,7 +129,7 @@
|
||||||
|
|
||||||
// Si n'existe pas on retourne FALSE
|
// Si n'existe pas on retourne FALSE
|
||||||
if( !is_array($check_cluster_merge) )
|
if( !is_array($check_cluster_merge) )
|
||||||
return ManagerError::ModuleError;
|
return ManagerError::RepoError;
|
||||||
|
|
||||||
// Sinon, on retourne son id
|
// Sinon, on retourne son id
|
||||||
return ManagerError::Success;
|
return ManagerError::Success;
|
||||||
|
@ -150,7 +149,7 @@
|
||||||
* @id_entity<int> UID de la machine ou de l'utilisateur
|
* @id_entity<int> UID de la machine ou de l'utilisateur
|
||||||
* @class<int> Spefication du type d'entite (0=user;1=machine)
|
* @class<int> Spefication du type d'entite (0=user;1=machine)
|
||||||
*
|
*
|
||||||
* @return status<Boolean> Retourne si oui ou non l'association a bien ete supprimee
|
* @return error<int> Renvoie le code 'ManagerError'
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function unlink($id_warehouse, $id_cluster, $id_entity, $class){
|
public static function unlink($id_warehouse, $id_cluster, $id_entity, $class){
|
||||||
|
@ -245,11 +244,9 @@
|
||||||
*/
|
*/
|
||||||
public static function getAll($id_warehouse){
|
public static function getAll($id_warehouse){
|
||||||
// On ecrit la requete
|
// On ecrit la requete
|
||||||
$request = Database::getPDO()->prepare("SELECT c.*, count(cm.id_cluster_merge) as count
|
$request = Database::getPDO()->prepare("SELECT *
|
||||||
FROM cluster as c, cluster_merge as cm
|
FROM cluster as c
|
||||||
WHERE cm.id_cluster = c.id_cluster
|
WHERE c.id_warehouse = :id_warehouse
|
||||||
AND c.id_warehouse = :id_warehouse
|
|
||||||
GROUP BY c.id_cluster
|
|
||||||
ORDER BY c.name ASC");
|
ORDER BY c.name ASC");
|
||||||
|
|
||||||
// On execute la requete
|
// On execute la requete
|
||||||
|
@ -279,11 +276,9 @@
|
||||||
public static function getById($id_warehouse, $id){
|
public static function getById($id_warehouse, $id){
|
||||||
// On ecrit la requete
|
// On ecrit la requete
|
||||||
$request = Database::getPDO()->prepare("SELECT c.*
|
$request = Database::getPDO()->prepare("SELECT c.*
|
||||||
FROM cluster as c, cluster_merge as cm
|
FROM cluster as c
|
||||||
WHERE cm.id_cluster = c.id_cluster
|
WHERE c.id_warehouse = :id_warehouse
|
||||||
AND c.id_warehouse = :id_warehouse
|
AND c.id_cluster = :id");
|
||||||
AND c.id_cluster = :id
|
|
||||||
ORDER BY c.id ASC");
|
|
||||||
|
|
||||||
// On execute la requete
|
// On execute la requete
|
||||||
$request->execute([
|
$request->execute([
|
||||||
|
@ -319,11 +314,9 @@
|
||||||
public static function getByName($id_warehouse, $name){
|
public static function getByName($id_warehouse, $name){
|
||||||
// On ecrit la requete
|
// On ecrit la requete
|
||||||
$request = Database::getPDO()->prepare("SELECT c.*
|
$request = Database::getPDO()->prepare("SELECT c.*
|
||||||
FROM cluster as c, cluster_merge as cm
|
FROM cluster as c
|
||||||
WHERE cm.id_cluster = c.id_cluster
|
WHERE c.id_warehouse = :id_warehouse
|
||||||
AND c.id_warehouse = :id_warehouse
|
AND c.name = :name");
|
||||||
AND c.name = :name
|
|
||||||
ORDER BY c.name ASC");
|
|
||||||
|
|
||||||
// On execute la requete
|
// On execute la requete
|
||||||
$request->execute([
|
$request->execute([
|
||||||
|
|
|
@ -24,8 +24,9 @@
|
||||||
$check_unique = self::getByName($id_warehouse, $name) === false;
|
$check_unique = self::getByName($id_warehouse, $name) === false;
|
||||||
|
|
||||||
// Si une machine a deja ce nom, on renvoie une erreur
|
// Si une machine a deja ce nom, on renvoie une erreur
|
||||||
if( !$check_unique )
|
if( !$check_unique ){
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* [2] Creation de la machine
|
/* [2] Creation de la machine
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
|
|
||||||
/* [3] On retourne l'id_user ou FALSE si erreur
|
/* [3] On retourne l'id_user ou FALSE si erreur
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$check_user = self::getByCode($code);
|
$check_user = self::getByCode($id_warehouse, $code);
|
||||||
|
|
||||||
// Si n'existe pas on retourne FALSE
|
// Si n'existe pas on retourne FALSE
|
||||||
if( $check_user === false )
|
if( $check_user === false )
|
||||||
|
@ -238,7 +238,7 @@
|
||||||
|
|
||||||
/* [2] On verifie que l'utilisateur n'existe plus
|
/* [2] On verifie que l'utilisateur n'existe plus
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
return ( self::getById($id_user) === false );
|
return ( self::getById($id_warehouse, $id_user) === false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function insertUsersFromJSON(){
|
function insertUsersFromJSON(){
|
||||||
$json = ResourceDispatcher::getResource('f/json/generated_users/conf');
|
$json = file_get_contents(__ROOT__.'/config/generated_users.json');
|
||||||
$json = json_decode( $json, true );
|
$json = json_decode( $json, true );
|
||||||
|
|
||||||
// Pour chaque entree
|
// Pour chaque entree
|
||||||
|
@ -29,17 +29,19 @@
|
||||||
|
|
||||||
// Creation de la requete
|
// Creation de la requete
|
||||||
$request = new ModuleRequest('userDefault/create', [
|
$request = new ModuleRequest('userDefault/create', [
|
||||||
$user['code'],
|
'code' => $user['code'],
|
||||||
$user['username'],
|
'username' => $user['username'],
|
||||||
$user['firstname'],
|
'firstname' => $user['firstname'],
|
||||||
$user['lastname'],
|
'lastname' => $user['lastname'],
|
||||||
$user['email'],
|
'mail' => $user['email'],
|
||||||
$user['password'],
|
'password' => $user['password'],
|
||||||
$user['status']
|
'status' => $user['status']
|
||||||
]);
|
]);
|
||||||
$answer = $request->dispatch();
|
$answer = $request->dispatch();
|
||||||
|
|
||||||
// Debug error
|
// Debug error
|
||||||
var_dump( $answer->error == ManagerError::Success );
|
if( $answer->error != ManagerError::Success )
|
||||||
|
var_dump( $answer->error );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -56,7 +58,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function insertMachinesFromJSON(){
|
function insertMachinesFromJSON(){
|
||||||
$json = ResourceDispatcher::getResource('f/json/generated_machines/conf');
|
$json = file_get_contents(__ROOT__.'/config/generated_machines.json');
|
||||||
$json = json_decode( $json, true );
|
$json = json_decode( $json, true );
|
||||||
|
|
||||||
// Pour chaque entree
|
// Pour chaque entree
|
||||||
|
@ -64,12 +66,13 @@
|
||||||
|
|
||||||
// Creation de la requete
|
// Creation de la requete
|
||||||
$request = new ModuleRequest('machineDefault/create', [
|
$request = new ModuleRequest('machineDefault/create', [
|
||||||
$machine['code'],
|
'name' => $machine['name']
|
||||||
$machine['name']
|
|
||||||
]);
|
]);
|
||||||
$answer = $request->dispatch();
|
$answer = $request->dispatch();
|
||||||
|
|
||||||
// Debug error
|
// Debug error
|
||||||
var_dump( $answer->error == ManagerError::Success );
|
if( $answer->error != ManagerError::Success )
|
||||||
|
var_dump( $answer->error );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -127,6 +127,7 @@
|
||||||
foreach($clusters as $cluster)
|
foreach($clusters as $cluster)
|
||||||
if( $cluster['name'] != $user['username'] ) // Si c'est le groupe personnel, on ne l'affiche pas
|
if( $cluster['name'] != $user['username'] ) // Si c'est le groupe personnel, on ne l'affiche pas
|
||||||
echo "<span>".$cluster['name']."<span class='rem-group' data-group='".$cluster['id_cluster']."' data-user='".$user['id_user']."'></span></span>";
|
echo "<span>".$cluster['name']."<span class='rem-group' data-group='".$cluster['id_cluster']."' data-user='".$user['id_user']."'></span></span>";
|
||||||
|
|
||||||
echo "<span class='add-group' data-user='".$user['id_user']."'>+</span>";
|
echo "<span class='add-group' data-user='".$user['id_user']."'>+</span>";
|
||||||
echo"</span>";
|
echo"</span>";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue