SMMP/build/viewer/view/user/groups.php

84 lines
2.0 KiB
PHP
Executable File

<?php
namespace viewer\view\user;
use \viewer\core\Viewer;
use \api\core\ModuleRequest;
use \api\core\Authentification;
use \error\core\Error;
class groups{
public static function render(){
/* [1] Init Twig
=========================================================*/
$loader = new \Twig_Loader_Filesystem(__BUILD__.'/viewer/view');
$twig = new \Twig_Environment($loader, []);
/* [2] Store variables
=========================================================*/
$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' ),
'type' => file_get_contents( __PUBLIC__.'/src/static/container/type.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_clusters', function(){
$request = new ModuleRequest('clusterDefault/getAll', [
'class' => 0
]);
$answer = $request->dispatch();
// si erreur, on affiche rien par défaut
if( $answer->error != Error::Success )
return [];
return $answer->get('clusters');
}));
$twig->addFunction(new \Twig_Function('f_users', function($id_cluster){
$usersReq = new ModuleRequest('clusterDefault/getMembers', [
'id_cluster' => (int) $id_cluster,
'class' => 0
]);
$usersRes = $usersReq->dispatch();
// si erreur, on affiche rien par défaut
if( $usersRes->error != Error::Success )
return [];
return $usersRes->get('members');
}));
/* [4] Build the whole stuff
=========================================================*/
return $twig->render('user/groups.twig', [
'p_icon' => $variables['p_icon'],
'p_theme' => $variables['p_theme']
]);
}
}
?>