2017-01-11 15:28:21 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace api\module;
|
|
|
|
use \database\core\DatabaseDriver;
|
|
|
|
use \manager\sessionManager;
|
|
|
|
use \error\core\Error;
|
2017-02-21 14:16:21 +00:00
|
|
|
use \error\core\Err;
|
2017-01-11 15:28:21 +00:00
|
|
|
use \database\core\Repo;
|
|
|
|
|
|
|
|
class historyDefault{
|
|
|
|
|
2017-01-30 17:39:21 +00:00
|
|
|
public function __construct(){}
|
|
|
|
public function __destruct(){}
|
2017-01-11 15:28:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* CREATION D'UNE NOUVELLE ENTREE DANS LA BDD
|
|
|
|
*
|
|
|
|
* @id_user<int> UID de l'utilisateur
|
|
|
|
* @id_machine<int> UID la machine
|
|
|
|
* @id_action<int> UID de l'action
|
|
|
|
* @timestamp<int> timestamp de l'action
|
|
|
|
*
|
|
|
|
* @return status<Boolean> Retourne si oui ou non, tout s'est bien passe
|
|
|
|
*
|
|
|
|
*/
|
2017-01-30 17:39:21 +00:00
|
|
|
public function create($params){
|
2017-01-11 15:28:21 +00:00
|
|
|
extract($params);
|
|
|
|
|
|
|
|
/* [1] Creation de l'utilisateur
|
|
|
|
=========================================================*/
|
|
|
|
$create_entry = new Repo('history/create', [
|
2017-02-20 07:21:34 +00:00
|
|
|
$id_user,
|
2017-01-11 15:28:21 +00:00
|
|
|
$id_machine,
|
|
|
|
$id_action,
|
|
|
|
$timestamp
|
|
|
|
]);
|
|
|
|
$id_entry = $create_entry->answer();
|
|
|
|
|
|
|
|
// Si une erreur est retournee, on retourne une erreur
|
|
|
|
if( $id_entry === false )
|
2017-02-21 14:16:21 +00:00
|
|
|
return ['error' => new Error(Err::ModuleError)];
|
2017-01-11 15:28:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* [2] Gestion du retour
|
|
|
|
=========================================================*/
|
|
|
|
return [
|
|
|
|
'id_history' => $id_entry
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* RENVOIE UN UTILISATEUR EN FONCTION D'UN MOT CLE
|
|
|
|
*
|
|
|
|
* @keywords<String> Element de recherche
|
|
|
|
*
|
|
|
|
* @return users<Array> Retourne la liste des utilisateurs trouves
|
|
|
|
*
|
|
|
|
*/
|
2017-01-30 17:39:21 +00:00
|
|
|
public function search($params){
|
2017-01-11 15:28:21 +00:00
|
|
|
extract($params);
|
|
|
|
|
|
|
|
// On recupere les donnees
|
|
|
|
$user = new Repo('history/search', [
|
|
|
|
$_SESSION['WAREHOUSE']['id'],
|
|
|
|
$keywords
|
|
|
|
]);
|
|
|
|
|
|
|
|
return [ 'history' => $user->answer() ];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* RENVOIE LA LISTE EXHAUSTIVE DES ACCES
|
|
|
|
*
|
|
|
|
* @return history<Array> Liste des entrées de l'historique
|
|
|
|
*
|
|
|
|
*/
|
2017-01-30 17:39:21 +00:00
|
|
|
public function getAll(){
|
2017-01-11 15:28:21 +00:00
|
|
|
// On recupere les donnees
|
|
|
|
$entries = new Repo('history/getAll', [ $_SESSION['WAREHOUSE']['id'] ]);
|
|
|
|
|
|
|
|
return [ 'history' => $entries->answer() ];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* SUPPRIME UNE ENTREE
|
|
|
|
*
|
|
|
|
* @id_history<int> UID de l'entree en question
|
|
|
|
*
|
|
|
|
* @return status<Boolean> Retourne si oui ou non tout s'est bien deroule
|
|
|
|
*
|
|
|
|
*/
|
2017-01-30 17:39:21 +00:00
|
|
|
public function delete($params){
|
2017-01-11 15:28:21 +00:00
|
|
|
extract($params);
|
|
|
|
|
|
|
|
/* [1] On supprime l'utilisateur
|
|
|
|
=========================================================*/
|
|
|
|
$del_entry = new Repo('history/delete', [
|
|
|
|
$_SESSION['WAREHOUSE']['id'],
|
|
|
|
$id_history
|
|
|
|
]);
|
|
|
|
$deleted_entry = $del_entry->answer();
|
|
|
|
|
|
|
|
|
|
|
|
return [ 'status' => $deleted_entry ];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|