2016-07-11 15:44:18 +00:00
|
|
|
<?php
|
|
|
|
|
2016-10-18 14:03:03 +00:00
|
|
|
namespace viewer\view\user;
|
|
|
|
use \api\core\ModuleRequest;
|
|
|
|
use \api\core\Authentification;
|
2016-10-18 17:09:47 +00:00
|
|
|
use \error\core\Error;
|
2016-07-11 15:44:18 +00:00
|
|
|
|
2016-08-06 09:32:50 +00:00
|
|
|
class user_view{
|
2016-07-11 15:44:18 +00:00
|
|
|
|
2017-01-06 14:51:11 +00:00
|
|
|
public static function render(){
|
|
|
|
/* [1] Init Twig
|
|
|
|
=========================================================*/
|
|
|
|
$loader = new \Twig_Loader_Filesystem(__BUILD__.'/viewer/view');
|
|
|
|
$twig = new \Twig_Environment($loader, []);
|
|
|
|
|
2016-07-11 16:14:18 +00:00
|
|
|
|
2017-01-06 14:51:11 +00:00
|
|
|
/* [2] Store variables
|
2016-07-11 16:14:18 +00:00
|
|
|
=========================================================*/
|
2017-01-06 14:51:11 +00:00
|
|
|
$variables = [
|
|
|
|
'p_icon' => [
|
|
|
|
'remove' => file_get_contents( __PUBLIC__.'/src/static/sub-menu-side/remove.svg' ),
|
|
|
|
'edit' => file_get_contents( __PUBLIC__.'/src/static/sub-menu-side/edit.svg' ),
|
|
|
|
'card' => file_get_contents( __PUBLIC__.'/src/static/container/card.svg' ),
|
|
|
|
'mail' => file_get_contents( __PUBLIC__.'/src/static/container/mail.svg' ),
|
|
|
|
'group' => file_get_contents( __PUBLIC__.'/src/static/container/group.svg' )
|
|
|
|
],
|
|
|
|
|
|
|
|
'p_theme' => $_SESSION['WAREHOUSE']['theme']
|
|
|
|
];
|
|
|
|
|
|
|
|
/* [3] Store functions
|
|
|
|
=========================================================*/
|
|
|
|
$twig->addFunction(new \Twig_Function('f_users', function(){
|
|
|
|
|
|
|
|
$request = new ModuleRequest('userDefault/getAll'); // On utilise la methode 'getAll' du module 'userDefault'
|
|
|
|
$answer = $request->dispatch(); // On recupere la reponse
|
2016-07-11 16:14:18 +00:00
|
|
|
|
2017-01-06 14:51:11 +00:00
|
|
|
// si erreur, on affiche rien
|
|
|
|
if( $answer->error != Error::Success )
|
|
|
|
return [];
|
2016-07-11 16:14:18 +00:00
|
|
|
|
2017-01-06 14:51:11 +00:00
|
|
|
return $answer->get('users');
|
|
|
|
}));
|
2016-07-11 16:14:18 +00:00
|
|
|
|
2017-01-06 14:51:11 +00:00
|
|
|
$twig->addFunction(new \Twig_Function('f_clusters', function($id_user){
|
|
|
|
$clustersReq = new ModuleRequest('userDefault/getClusters', [ 'id_user' => $id_user ]);
|
2016-07-11 16:14:18 +00:00
|
|
|
$clustersRes = $clustersReq->dispatch();
|
|
|
|
|
|
|
|
/* (2) Gestion si erreur */
|
2017-01-06 14:51:11 +00:00
|
|
|
if( $clustersRes->error != Error::Success )
|
|
|
|
return [];
|
2016-07-12 08:40:51 +00:00
|
|
|
|
2017-01-06 14:51:11 +00:00
|
|
|
return $clustersRes->get('clusters');
|
|
|
|
}));
|
2016-07-12 08:40:51 +00:00
|
|
|
|
2016-07-11 16:14:18 +00:00
|
|
|
|
2017-01-06 14:51:11 +00:00
|
|
|
/* [4] Build the whole stuff
|
|
|
|
=========================================================*/
|
|
|
|
return $twig->render('user/user_view.twig', [
|
|
|
|
'p_icon' => $variables['p_icon'],
|
|
|
|
'p_theme' => $variables['p_theme']
|
|
|
|
]);
|
2016-07-11 15:44:18 +00:00
|
|
|
}
|
|
|
|
|
2016-07-11 16:14:18 +00:00
|
|
|
|
2016-07-11 15:44:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|