Gestion de l'affichage des tokens (BDD/Repo)
This commit is contained in:
parent
1e224f3719
commit
8aba0f373f
|
@ -1,6 +1,11 @@
|
|||
{
|
||||
"Personnes": [
|
||||
"getById"
|
||||
],
|
||||
|
||||
|
||||
"token": [
|
||||
"getAll"
|
||||
]
|
||||
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace manager\repo;
|
||||
use \manager\Database;
|
||||
|
||||
class Token{
|
||||
|
||||
/* Gestion de la table Token (pour secu) et des derivations
|
||||
*
|
||||
* 1. Gestion de la verification
|
||||
* - check(token, id_personne)
|
||||
*
|
||||
* 3. Gestion de la
|
||||
* - merge(idA, idB)
|
||||
*
|
||||
* 4. Gestion de creation
|
||||
* - create(pseudo, nom, prenom, facebook, telephone)
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* RENVOIE LES DONNEES D'UN UTILISATEUR D'UID DONNE
|
||||
*
|
||||
* @id_personne<int> UID de la personne en question
|
||||
*
|
||||
* @return personne<Array> Tableau associatif contenant les informations utiles de la personne
|
||||
* @return FALSE<boolean> Si une erreur occure ou qu'aucune personne n'est trouvee, retourne FALSE
|
||||
*
|
||||
*/
|
||||
public static function getById($id_personne=null){
|
||||
/* [0] Verification des INPUT
|
||||
=========================================================*/
|
||||
if( !Database::check('id', $id_personne) ) return false;
|
||||
|
||||
/* [1] On prepare et execute la requete
|
||||
=========================================================*/
|
||||
$request = Database::getPDO()->prepare("SELECT idPersonne as id, pseudo, nom, prenom, id_facebook, telephone
|
||||
FROM Personnes
|
||||
WHERE idPersonne = :uid");
|
||||
$request->execute(array(
|
||||
':uid' => $id_personne
|
||||
));
|
||||
|
||||
|
||||
/* [2] On recupere le resultat
|
||||
=========================================================*/
|
||||
// si aucun resultat, on retourne FALSE
|
||||
if( ($personne=$request->fetch()) === false ) return false;
|
||||
|
||||
|
||||
/* [3] On retourne les donnees
|
||||
=========================================================*/
|
||||
return Database::delNumeric( $personne, true );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace manager\repo;
|
||||
use \manager\Database;
|
||||
|
||||
class token{
|
||||
|
||||
/* Gestion de la table Token (pour secu) et des derivations
|
||||
*
|
||||
* 1. Gestion des access
|
||||
* - getById(id_token)
|
||||
* - getAll()
|
||||
*
|
||||
* 2. Gestion de la verification
|
||||
* - check(token, id_personne)
|
||||
*
|
||||
* 3. Gestion de la
|
||||
* - merge(idA, idB)
|
||||
*
|
||||
* 4. Gestion de creation
|
||||
* - create(pseudo, nom, prenom, facebook, telephone)
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* RETOURNE LA LISTE DE TOUS LES TOKENS
|
||||
*
|
||||
* @return tokens<Array> Liste de tous les tokens
|
||||
*
|
||||
*/
|
||||
public static function getAll(){
|
||||
/* [1] On prepare et execute la requete
|
||||
=========================================================*/
|
||||
$request = Database::getPDO()->query("SELECT id_token as id, name, token, creation, expires
|
||||
FROM api_token
|
||||
ORDER BY creation ASC");
|
||||
|
||||
/* [2] On recupere et retourne les donnees
|
||||
=========================================================*/
|
||||
return Database::delNumeric( $request->fetchAll() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -1,8 +1,17 @@
|
|||
<?php define('__ROOT__', dirname(dirname(__FILE__)) );
|
||||
require_once __ROOT__.'/manager/autoloader.php';
|
||||
use \manager\Repo;
|
||||
use \manager\ModuleRequest;
|
||||
use \manager\ManagerError;
|
||||
use \manager\ResourceDispatcher;
|
||||
|
||||
|
||||
|
||||
/* [1] On recupere les tokens
|
||||
=========================================================*/
|
||||
$req_tokens = new Repo('token/getAll');
|
||||
$tokens = $req_tokens->answer();
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
@ -24,29 +33,22 @@
|
|||
<!-- Conteneur de la liste des elements -->
|
||||
<ul data-list>
|
||||
|
||||
<!-- Element #1 de la liste -->
|
||||
<li data-element>
|
||||
<div><span data-prefix='Type'>token</span></div>
|
||||
<div>
|
||||
<span>name</span>
|
||||
<span data-prefix='Creation'>date de création</span>
|
||||
<span data-prefix='Expiration'>date d'expiration</span>
|
||||
<span data-prefix='Token'>90:31:ec:16:02:99:90:df:72:5f:02:f1:ad:d5:76:c7</span>
|
||||
</div>
|
||||
<button>Supprimer</button>
|
||||
</li>
|
||||
<!-- Elements de la liste -->
|
||||
<?php
|
||||
foreach($tokens as $token){
|
||||
echo "<li data-element data-id='".$token['id']."'>";
|
||||
echo "<div><span data-prefix='Type'>token</span></div>";
|
||||
echo "<div>";
|
||||
echo "<span>".$token['name']."</span>";
|
||||
echo "<span data-prefix='Creation'>date de création</span>";
|
||||
echo "<span data-prefix='Expiration'>date d'expiration</span>";
|
||||
echo "<span data-prefix='Token'>90:31:ec:16:02:99:90:df:72:5f:02:f1:ad:d5:76:c7</span>";
|
||||
echo "</div>";
|
||||
echo "<button>Supprimer</button>";
|
||||
echo "</li>";
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Element #2 de la liste -->
|
||||
<li data-element>
|
||||
<div><span data-prefix='Type'>token</span></div>
|
||||
<div>
|
||||
<span>name</span>
|
||||
<span data-prefix='Creation'>date de création</span>
|
||||
<span data-prefix='Expiration'>date d'expiration</span>
|
||||
<span data-prefix='Token'>90:31:ec:16:02:99:90:df:72:5f:02:f1:ad:d5:76:c7</span>
|
||||
</div>
|
||||
<button>Supprimer</button>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</section>
|
||||
|
|
Loading…
Reference in New Issue