minmod corrections
This commit is contained in:
parent
0132f45b1b
commit
bbcad9c909
|
@ -226,7 +226,7 @@
|
|||
|
||||
"sync": {
|
||||
"description": "Synchronisation d'une machine.",
|
||||
"permissions": [],
|
||||
"permissions": ["warehouse"],
|
||||
"parameters": {
|
||||
"token": { "description": "Code d'accès évolutif dynamique.", "type": "hash" },
|
||||
"data": { "description": "Données (dépendent des modules).", "type": "array<mixed>" }
|
||||
|
|
|
@ -188,13 +188,15 @@
|
|||
|
||||
cursor: default;
|
||||
|
||||
&.add-group{
|
||||
&.add-group,
|
||||
&.add-member{
|
||||
border-radius: 3px;
|
||||
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
& > span.rem-group{
|
||||
& > span.rem-group,
|
||||
& > span.rem-member{
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: -1px;
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -280,21 +280,21 @@
|
|||
|
||||
|
||||
|
||||
/* RENVOIE LES GROUPES D'UN UTILISATEUR DONNE
|
||||
/* RENVOIE LES MEMBRES D'UN GROUPE DONNE
|
||||
*
|
||||
* @id_user<int> UID de l'utilisateur en question
|
||||
* @id_cluster<int> UID du groupe en question
|
||||
*
|
||||
* @return clusters<Array> Groupes de l'utilisateur donne
|
||||
* @return members<Array> Membres du groupe donne
|
||||
*
|
||||
*/
|
||||
public static function getClusters($params){
|
||||
public static function getMembers($params){
|
||||
extract($params);
|
||||
|
||||
|
||||
// On recupere les donnees
|
||||
$request = new Repo('user/getClusters', [
|
||||
$request = new Repo('cluster/getMembers', [
|
||||
$_SESSION['WAREHOUSE']['id'],
|
||||
$id_user
|
||||
$id_cluster
|
||||
]);
|
||||
$answer = $request->answer();
|
||||
|
||||
|
@ -303,7 +303,7 @@
|
|||
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
||||
|
||||
|
||||
return [ 'clusters' => $answer ];
|
||||
return [ 'members' => $answer ];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -384,7 +384,7 @@
|
|||
public static function sync($params){
|
||||
extract($params);
|
||||
|
||||
$checkToken = new Repo('machine/checkToken', [$token]);
|
||||
$checkToken = new Repo('machine/checkToken', [ $_SESSION['WAREHOUSE']['id'], $token ]);
|
||||
|
||||
return [
|
||||
'tokenResult' => $checkToken->answer()
|
||||
|
|
|
@ -239,7 +239,7 @@
|
|||
*
|
||||
* @id_warehouse<int> UID de l'entrepot
|
||||
*
|
||||
* @return clusters<int> Renvoie la liste des groupes
|
||||
* @return clusters<Array> Renvoie la liste des groupes
|
||||
* Renvoie FALSE si une erreur occure
|
||||
*
|
||||
*/
|
||||
|
@ -267,21 +267,108 @@
|
|||
|
||||
|
||||
|
||||
/* RENVOIE LA LISTE D'UN GROUPE SPECIFIQUE
|
||||
*
|
||||
* @id_warehouse<int> UID de l'entrepot
|
||||
* @id<int> UID du groupe
|
||||
*
|
||||
* @return cluster<Array> Renvoie le groupe correspondant
|
||||
* Renvoie FALSE si une erreur occure
|
||||
*
|
||||
*/
|
||||
public static function getById($id_warehouse, $id){
|
||||
// On ecrit la requete
|
||||
$request = Database::getPDO()->prepare("SELECT c.*
|
||||
FROM cluster as c, cluster_merge as cm
|
||||
WHERE cm.id_cluster = c.id_cluster
|
||||
AND c.id_warehouse = :id_warehouse
|
||||
AND c.id_cluster = :id
|
||||
ORDER BY c.id ASC");
|
||||
|
||||
// On execute la requete
|
||||
$request->execute([
|
||||
':id_warehouse' => $id_warehouse,
|
||||
':id' => $id
|
||||
]);
|
||||
|
||||
$fetch = $request->fetch();
|
||||
|
||||
// Si aucun résultat
|
||||
if( $fetch == false )
|
||||
return false;
|
||||
|
||||
// On retourne en supprimant les indices numeriques
|
||||
return Database::delNumeric( $fetch, true );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* RENVOIE LA LISTE D'UN GROUPE SPECIFIQUE
|
||||
*
|
||||
* @id_warehouse<int> UID de l'entrepot
|
||||
* @name<String> Nom du groupe
|
||||
*
|
||||
* @return cluster<Array> Renvoie le groupe correspondant
|
||||
* Renvoie FALSE si une erreur occure
|
||||
*
|
||||
*/
|
||||
public static function getByName($id_warehouse, $name){
|
||||
// On ecrit la requete
|
||||
$request = Database::getPDO()->prepare("SELECT c.*
|
||||
FROM cluster as c, cluster_merge as cm
|
||||
WHERE cm.id_cluster = c.id_cluster
|
||||
AND c.id_warehouse = :id_warehouse
|
||||
AND c.name = :name
|
||||
ORDER BY c.name ASC");
|
||||
|
||||
// On execute la requete
|
||||
$request->execute([
|
||||
':id_warehouse' => $id_warehouse,
|
||||
':name' => $name
|
||||
]);
|
||||
|
||||
$fetch = $request->fetch();
|
||||
|
||||
// Si aucun résultat
|
||||
if( $fetch == false )
|
||||
return false;
|
||||
|
||||
// On retourne en supprimant les indices numeriques
|
||||
return Database::delNumeric( $fetch, true );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* RENVOIE LES MEMBRES D'UN GROUPE DONNE
|
||||
*
|
||||
* @id_warehouse<int> UID de l'entrepot
|
||||
* @id_cluster<int> UID du groupe en question
|
||||
*
|
||||
* @return members<Array> Retourne la liste des membres du groupe
|
||||
*
|
||||
*/
|
||||
public static function getMembers($id_cluster){
|
||||
public static function getMembers($id_warehouse, $id_cluster){
|
||||
/* [1] On recupere la liste des associations
|
||||
=========================================================*/
|
||||
$get_members = Database::getPDO()->prepare("SELECT * FROM cluster_merge
|
||||
WHERE id_cluster = :id_cluster
|
||||
$get_members = Database::getPDO()->prepare("SELECT id_entity as id_member, c.class
|
||||
FROM cluster_merge as cm, cluster as c
|
||||
WHERE cm.id_cluster = c.id_cluster
|
||||
AND c.id_cluster = :id_cluster
|
||||
AND c.id_warehouse = :id_warehouse
|
||||
ORDER BY id_cluster_merge");
|
||||
$get_members->execute([ ':id_cluster' => $id_cluster ]);
|
||||
$get_members->execute([
|
||||
':id_warehouse' => $id_warehouse,
|
||||
':id_cluster' => $id_cluster
|
||||
]);
|
||||
|
||||
$members = Database::delNumeric( $get_members->fetchAll() );
|
||||
|
||||
|
@ -291,20 +378,30 @@
|
|||
|
||||
/* (1) On recupere les informations utilisateur */
|
||||
if( $member['class'] == self::USER_CLASS ){
|
||||
$get_user = userRepo::getById( $member['id_entity'] );
|
||||
$get_user = userRepo::getById( $id_warehouse, $member['id_member'] );
|
||||
|
||||
// Si on a bien recu les informations, on les ajoute
|
||||
if( $get_user !== false )
|
||||
$members[$i] = array_merge($member, $get_user );
|
||||
if( $get_user !== false ){
|
||||
$members[$i] = [
|
||||
'id_member' => $get_user['id_user'],
|
||||
'name' => $get_user['username'],
|
||||
'class' => self::USER_CLASS
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/* (2) On recupere les informations machine */
|
||||
}elseif( $member['class'] == self::MACHINE_CLASS ){
|
||||
$get_machine = machineRepo::getById( $member['id_entity'] );
|
||||
$get_machine = machineRepo::getById( $id_warehouse, $member['id_member'] );
|
||||
|
||||
// Si on a bien recu les informations, on les ajoute
|
||||
if( $get_machine !== false )
|
||||
$members[$i] = array_merge($member, $get_machine );
|
||||
if( $get_machine !== false ){
|
||||
$members[$i] = [
|
||||
'id_member' => $get_machine['id_machine'],
|
||||
'name' => $get_machine['name'],
|
||||
'class' => self::MACHINE_CLASS
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -137,8 +137,8 @@
|
|||
/* [1] Verification de l'unicite de code+name (si differents)
|
||||
=========================================================*/
|
||||
// On recupere les machine ayant le meme code ou name (si existent)
|
||||
$getbycode = self::getByCode($code);
|
||||
$getbyname = self::getByName($name);
|
||||
$getbycode = self::getByCode($id_warehouse, $code);
|
||||
$getbyname = self::getByName($id_warehouse, $name);
|
||||
|
||||
$check_unique = is_array($getbycode) && $getbycode['id_machine'] == $id_machine || !is_array($getbycode);
|
||||
$check_unique = $check_unique && is_array($getbyname) && $getbyname['id_machine'] == $id_machine || !is_array($getbyname);
|
||||
|
@ -165,7 +165,7 @@
|
|||
|
||||
/* [3] On retourne si tout a ete modifie, si erreur
|
||||
=========================================================*/
|
||||
$check_machine = self::getById($id_machine);
|
||||
$check_machine = self::getById($id_warehouse, $id_machine);
|
||||
|
||||
$checker = $check_machine['id_machine'] == $id_machine;
|
||||
$checker = $checker && $check_machine['code'] == $code;
|
||||
|
@ -204,7 +204,7 @@
|
|||
|
||||
/* [2] On verifie que la machine n'existe plus
|
||||
=========================================================*/
|
||||
return ( self::getById($id_machine) === false );
|
||||
return ( self::getById($id_warehouse, $id_machine) === false );
|
||||
}
|
||||
|
||||
|
||||
|
@ -335,6 +335,46 @@
|
|||
|
||||
|
||||
|
||||
/* RETOURNE UNE MACHINE SPECIFIQUE
|
||||
*
|
||||
* @id_warehouse<id> UID de l'entrepot
|
||||
* @token<String> Token de la machine
|
||||
*
|
||||
* @return machine<Array> Données de la machine
|
||||
* FALSE si aucun résultat
|
||||
*
|
||||
*/
|
||||
public static function getByToken($id_warehouse, $token){
|
||||
/* [1] On rédige/execute la requête
|
||||
=========================================================*/
|
||||
$get = Database::getPDO()->prepare("SELECT m.id_machine, m.code, m.name
|
||||
FROM machine as m
|
||||
WHERE m.id_warehouse = :id_warehouse
|
||||
AND m.token = :token");
|
||||
$get->execute([
|
||||
':id_warehouse' => $id_warehouse,
|
||||
':token' => $token
|
||||
]);
|
||||
|
||||
/* [2] Gestion des données
|
||||
=========================================================*/
|
||||
$found = $get->fetch();
|
||||
|
||||
// Si aucun résultat
|
||||
if( $found === false )
|
||||
return false;
|
||||
|
||||
return Database::delNumeric( $found, true );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* RETOURNE TOUTES LES MACHINES DE L'ENTREPOT
|
||||
*
|
||||
* @id_warehouse<id> UID de l'entrepot
|
||||
|
@ -367,12 +407,12 @@
|
|||
* @return status<Boolean> VRAI si le token est correct, sinon FALSE
|
||||
*
|
||||
*/
|
||||
public static function checkToken($token){
|
||||
public static function checkToken($id_warehouse, $token){
|
||||
/* [1] On vérifie le token
|
||||
=========================================================*/
|
||||
$hash = sessionManager::secure_hash($token);
|
||||
|
||||
$byToken = self::getByToken($hash);
|
||||
$byToken = self::getByToken($id_warehouse, $hash);
|
||||
|
||||
// Si aucun résultat, erreur
|
||||
if( count($byToken) < 1 )
|
||||
|
|
|
@ -97,12 +97,14 @@
|
|||
|
||||
<!-- CORPS DE LA PAGE -->
|
||||
<div id='FORM'>
|
||||
<span></span>
|
||||
<span>[<?= $_SESSION['WAREHOUSE']['name']; ?>] Authentification</span>
|
||||
<input type='text' placeholder='Identifiant' id='admin-name'>
|
||||
<input type='password' placeholder="Mot de passe" id='admin-password'>
|
||||
|
||||
<input type='button' value='AUTHENTIFICATION' id='admin-submit'>
|
||||
<span id='err-box'></span>
|
||||
<span></span>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -140,7 +142,7 @@
|
|||
|
||||
// Si erreur de module
|
||||
if( response.ModuleError != 0 ){
|
||||
errBox.innerHTML = 'Erreur interne! Contactez le webmaster.';
|
||||
errBox.innerHTML = 'Format des champs incorrect.';
|
||||
aPassword.value = '';
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -64,16 +64,25 @@
|
|||
|
||||
// Si aucune erreur, on affiche les resultats
|
||||
else{
|
||||
debug();
|
||||
|
||||
// Barre de recherche
|
||||
echo "<input type='text' class='searchbar' placeholder='Recherche'>";
|
||||
|
||||
// Liste des utilisateurs
|
||||
// TODO: Récupérer la liste des utilisateurs et machines en implémentant 'clusterDefault/getMembers'
|
||||
// mettre dans la variable '$members'
|
||||
|
||||
foreach($answer->get('clusters') as $cluster){
|
||||
|
||||
// Liste des membres
|
||||
$get_membersReq = new ModuleRequest('clusterDefault/getMembers', ['id_cluster' => $cluster['id_cluster']] );
|
||||
$get_membersRes = $get_membersReq->dispatch();
|
||||
|
||||
// Si erreur, valeur par d
|
||||
if( $get_membersRes->error != ManagerError::Success )
|
||||
$members = [];
|
||||
else
|
||||
$members = $get_membersRes->get('members');
|
||||
|
||||
|
||||
|
||||
echo "<article class='inline-box' id='".$cluster['id_cluster']."'>";
|
||||
|
||||
// Prenom Nom
|
||||
|
@ -106,9 +115,9 @@
|
|||
echo "<span class='mail'>";
|
||||
echo file_get_contents( __ROOT__.'/src/static/container/mail.svg' );
|
||||
|
||||
echo "<a href='mailto:".$cluster['mail']."'><span>";
|
||||
echo "<span>";
|
||||
echo $cluster['count'].' membre(s)';
|
||||
echo "</span></a>";
|
||||
echo "</span>";
|
||||
echo"</span>";
|
||||
|
||||
// Groupes de la machine
|
||||
|
|
|
@ -97,12 +97,14 @@
|
|||
|
||||
<!-- CORPS DE LA PAGE -->
|
||||
<div id='FORM'>
|
||||
<span></span>
|
||||
<span>Connexion au Parc</span>
|
||||
<input type='text' placeholder='Identifiant' id='warehouse-name'>
|
||||
<input type='password' placeholder="Code d'accès" id='warehouse-password'>
|
||||
|
||||
<input type='button' value='CONNEXION' id='warehouse-submit'>
|
||||
<span id='err-box'></span>
|
||||
<span></span>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -139,7 +141,7 @@
|
|||
|
||||
// Si erreur de module
|
||||
if( response.ModuleError != 0 ){
|
||||
errBox.innerHTML = 'Erreur interne! Contactez le webmaster.';
|
||||
errBox.innerHTML = 'Format des champs incorrect.';
|
||||
wPassword.value = '';
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue