Renommage du repo 'association' en 'action_merge'
This commit is contained in:
parent
cb98676365
commit
1383249def
|
@ -237,6 +237,15 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"init": {
|
||||||
|
"description": "Données d'initialisation d'une machine.",
|
||||||
|
"permissions": ["warehouse"],
|
||||||
|
"parameters": {},
|
||||||
|
"output": {
|
||||||
|
"data": { "description": "Données d'initialisation.", "type": "array<mixed>" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
"create": {
|
"create": {
|
||||||
"description": "Création d'une nouvelle machine.",
|
"description": "Création d'une nouvelle machine.",
|
||||||
"permissions": ["warehouse", "admin"],
|
"permissions": ["warehouse", "admin"],
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
"association": [
|
"action_merge": [
|
||||||
"addPermission",
|
"addPermission",
|
||||||
"removePermission",
|
"removePermission",
|
||||||
|
|
||||||
|
@ -60,6 +60,15 @@
|
||||||
"getByIdTarget"
|
"getByIdTarget"
|
||||||
],
|
],
|
||||||
|
|
||||||
|
"action": [
|
||||||
|
"getById",
|
||||||
|
"removePermission",
|
||||||
|
|
||||||
|
"getAll",
|
||||||
|
"getById",
|
||||||
|
"getByIdTarget"
|
||||||
|
],
|
||||||
|
|
||||||
"permission": [
|
"permission": [
|
||||||
"getAll",
|
"getAll",
|
||||||
"getById"
|
"getById"
|
||||||
|
|
|
@ -353,6 +353,46 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* SYNCHRONISE UNE MACHINE
|
/* SYNCHRONISE UNE MACHINE
|
||||||
*
|
*
|
||||||
* @token<String> Token de synchronisation de la machine
|
* @token<String> Token de synchronisation de la machine
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace manager\repo;
|
||||||
|
use \manager\Database;
|
||||||
|
use \manager\Repo;
|
||||||
|
use \manager\ManagerError;
|
||||||
|
use \manager\repo\cluster as clusterRepo;
|
||||||
|
|
||||||
|
class action extends parentRepo{
|
||||||
|
|
||||||
|
protected static function table_name(){ static $table_name = 'action'; return $table_name; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
|
@ -6,21 +6,21 @@
|
||||||
use \manager\ManagerError;
|
use \manager\ManagerError;
|
||||||
use \manager\repo\cluster as clusterRepo;
|
use \manager\repo\cluster as clusterRepo;
|
||||||
|
|
||||||
class association extends parentRepo{
|
class action_merge extends parentRepo{
|
||||||
|
|
||||||
protected static function table_name(){ static $table_name = 'association'; return $table_name; }
|
protected static function table_name(){ static $table_name = 'action_merge'; return $table_name; }
|
||||||
|
|
||||||
|
|
||||||
/* AJOUT D'UNE PERMISSION ENTRE 2 GROUPES (UTIL -> MACHINE)
|
/* AJOUT D'UNE PERMISSION ENTRE 2 GROUPES (UTIL -> MACHINE)
|
||||||
*
|
*
|
||||||
* @id_target<int> UID d'un groupe MACHINE
|
* @id_target<int> UID d'un groupe MACHINE
|
||||||
* @id_source<int> UID d'un groupe UTILISATEUR
|
* @id_source<int> UID d'un groupe UTILISATEUR
|
||||||
* @id_permission<int> UID d'une PERMISSION
|
* @id_action<int> UID d'une ACTION
|
||||||
*
|
*
|
||||||
* @return error<ManagerError> Retourne l'erreur 'ManagerError' associée
|
* @return error<ManagerError> Retourne l'erreur 'ManagerError' associée
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function addPermission($id_target, $id_source, $id_permission){
|
public static function addPermission($id_target, $id_source, $id_action){
|
||||||
|
|
||||||
/* [1] On vérifie l'existance du groupe 'target'
|
/* [1] On vérifie l'existance du groupe 'target'
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
@ -58,14 +58,14 @@
|
||||||
return ManagerError::NoMatchFound;
|
return ManagerError::NoMatchFound;
|
||||||
|
|
||||||
|
|
||||||
/* [3] On vérifie l'existance de la permission
|
/* [3] On vérifie l'existance de l'action
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) On rédige la requête */
|
/* (1) On rédige la requête */
|
||||||
$permissionCheckR = new Repo('permission/getById', [ $id_permission ]);
|
$actionCheckR = new Repo('action/getById', [ $id_action ]);
|
||||||
$permissionCheck = $permissionCheckR->answer();
|
$actionCheck = $actionCheckR->answer();
|
||||||
|
|
||||||
/* (2) Si aucun résultat, on retourne une erreur */
|
/* (2) Si aucun résultat, on retourne une erreur */
|
||||||
if( $permissionCheck === false )
|
if( $actionCheck === false )
|
||||||
return ManagerError::NoMatchFound;
|
return ManagerError::NoMatchFound;
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,21 +79,21 @@
|
||||||
|
|
||||||
/* (3) Si les données sont identiques pour au moins une entrée, on retourne un succès */
|
/* (3) Si les données sont identiques pour au moins une entrée, on retourne un succès */
|
||||||
foreach($checkAlready as $s=>$sameTarget)
|
foreach($checkAlready as $s=>$sameTarget)
|
||||||
if( $sameTarget['id_source'] == $id_source && $sameTarget['id_permission'] == $id_permission )
|
if( $sameTarget['id_source'] == $id_source && $sameTarget['id_action'] == $id_action )
|
||||||
return ManagerError::Success;
|
return ManagerError::Success;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* [5] On ajoute la permission
|
/* [5] On ajoute la action
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) On effectue l'insertion */
|
/* (1) On effectue l'insertion */
|
||||||
$insert = Database::getPDO()->prepare("INSERT INTO association(id_association, id_target, id_source, id_permission)
|
$insert = Database::getPDO()->prepare("INSERT INTO action_merge(id_action_merge, id_target, id_source, id_action)
|
||||||
VALUES(DEFAULT, :id_target, :id_source, :id_permission)");
|
VALUES(DEFAULT, :id_target, :id_source, :id_action)");
|
||||||
$inserted = $insert->execute([
|
$inserted = $insert->execute([
|
||||||
':id_target' => $id_target,
|
':id_target' => $id_target,
|
||||||
':id_source' => $id_source,
|
':id_source' => $id_source,
|
||||||
':id_permission' => $id_permission
|
':id_action' => $id_action
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/* (2) Si erreur SQL, on retourne une erreur */
|
/* (2) Si erreur SQL, on retourne une erreur */
|
||||||
|
@ -116,12 +116,12 @@
|
||||||
*
|
*
|
||||||
* @id_target<int> UID d'un groupe MACHINE
|
* @id_target<int> UID d'un groupe MACHINE
|
||||||
* @id_source<int> UID d'un groupe UTILISATEUR
|
* @id_source<int> UID d'un groupe UTILISATEUR
|
||||||
* @id_permission<int> UID d'une PERMISSION
|
* @id_action<int> UID d'une PERMISSION
|
||||||
*
|
*
|
||||||
* @return error<ManagerError> Retourne l'erreur 'ManagerError' associée
|
* @return error<ManagerError> Retourne l'erreur 'ManagerError' associée
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function removePermission($id_target, $id_source, $id_permission){
|
public static function removePermission($id_target, $id_source, $id_action){
|
||||||
|
|
||||||
/* [1] On vérifie que l'entrée existe
|
/* [1] On vérifie que l'entrée existe
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
@ -134,8 +134,8 @@
|
||||||
|
|
||||||
/* (3) Si les données sont identiques pour au moins une entrée, on peut supprimer */
|
/* (3) Si les données sont identiques pour au moins une entrée, on peut supprimer */
|
||||||
foreach($checkExists as $s=>$sameTarget)
|
foreach($checkExists as $s=>$sameTarget)
|
||||||
if( $sameTarget['id_source'] == $id_source && $sameTarget['id_permission'] == $id_permission )
|
if( $sameTarget['id_source'] == $id_source && $sameTarget['id_action'] == $id_action )
|
||||||
$existingId = $sameTarget['id_association'];
|
$existingId = $sameTarget['id_action_merge'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (3) Si on a pas trouvé, on retourne une erreur */
|
/* (3) Si on a pas trouvé, on retourne une erreur */
|
||||||
|
@ -143,19 +143,19 @@
|
||||||
return ManagerError::NoMatchFound;
|
return ManagerError::NoMatchFound;
|
||||||
|
|
||||||
|
|
||||||
/* [2] On supprime la permission
|
/* [2] On supprime la action
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) On effectue la suppression */
|
/* (1) On effectue la suppression */
|
||||||
$delete = Database::getPDO()->prepare("DELETE FROM association
|
$delete = Database::getPDO()->prepare("DELETE FROM action_merge
|
||||||
WHERE id_association = :id_association
|
WHERE id_action_merge = :id_action_merge
|
||||||
AND id_target = :id_target
|
AND id_target = :id_target
|
||||||
AND id_source = :id_source
|
AND id_source = :id_source
|
||||||
AND id_permission = :id_permission");
|
AND id_action = :id_action");
|
||||||
$deleted = $delete->execute([
|
$deleted = $delete->execute([
|
||||||
':id_association' => $existingId,
|
':id_action_merge' => $existingId,
|
||||||
':id_target' => $id_target,
|
':id_target' => $id_target,
|
||||||
':id_source' => $id_source,
|
':id_source' => $id_source,
|
||||||
':id_permission' => $id_permission
|
':id_action' => $id_action
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/* (2) Si erreur SQL, on retourne une erreur */
|
/* (2) Si erreur SQL, on retourne une erreur */
|
|
@ -337,12 +337,13 @@
|
||||||
|
|
||||||
|
|
||||||
debug();
|
debug();
|
||||||
$req = new Repo('association/removePermission', [
|
$req = new Repo('action_merge/removePermission', [
|
||||||
205,
|
205,
|
||||||
2,
|
2,
|
||||||
1
|
1
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
var_dump( $req->error );
|
||||||
var_dump( $req->answer() );
|
var_dump( $req->answer() );
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue