118 lines
2.9 KiB
PHP
118 lines
2.9 KiB
PHP
|
<?php
|
|||
|
|
|||
|
namespace manager\view\user;
|
|||
|
use \manager\View;
|
|||
|
use \manager\ModuleRequest;
|
|||
|
use \manager\Authentification;
|
|||
|
use \manager\ManagerError;
|
|||
|
|
|||
|
class groups{
|
|||
|
|
|||
|
public static function template($type=null){
|
|||
|
|
|||
|
switch($type){
|
|||
|
case 'user': return "
|
|||
|
<span>
|
|||
|
@username
|
|||
|
<span class='rem-member' data-member='@id_user' data-cluster='@id_user_cluster'></span>
|
|||
|
</span>";
|
|||
|
break;
|
|||
|
|
|||
|
|
|||
|
case 'user_cluster': return "
|
|||
|
<article class='inline-box' id='@id_user_cluster'>
|
|||
|
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name <span>#@name</span></span>
|
|||
|
<span class='link_remove' data-cluster='@id_user_cluster'>@icon_remove</span>
|
|||
|
|
|||
|
<span class='link_edit' data-cluster='@id_user_cluster'>@icon_edit</span>
|
|||
|
|
|||
|
<span class='code'>
|
|||
|
@icon_type
|
|||
|
<span>utilisateurs (@count)</span>
|
|||
|
</span>
|
|||
|
|
|||
|
<span class='groups'>
|
|||
|
@icon_group
|
|||
|
@users
|
|||
|
<span class='add-member' data-cluster='@id_user_cluster'>+</span>
|
|||
|
</span>
|
|||
|
|
|||
|
</article>";
|
|||
|
break;
|
|||
|
|
|||
|
|
|||
|
default: return "
|
|||
|
<input type='text' class='searchbar' placeholder='Recherche'>
|
|||
|
@clusterlist";
|
|||
|
break;
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public static function view($params){
|
|||
|
$view = '';
|
|||
|
|
|||
|
/* [1] On récupère la liste des utilisateurs
|
|||
|
=========================================================*/
|
|||
|
$request = new ModuleRequest('clusterDefault/getAll', [
|
|||
|
'class' => 0
|
|||
|
]);
|
|||
|
$answer = $request->dispatch();
|
|||
|
|
|||
|
// si erreur, on affiche l'explicitation
|
|||
|
if( $answer->error != ManagerError::Success )
|
|||
|
return View::$htmlError;
|
|||
|
|
|||
|
$CLUSTERLIST = $answer->get('clusters');
|
|||
|
|
|||
|
|
|||
|
foreach($CLUSTERLIST as $c=>$cluster){
|
|||
|
$usersReq = new ModuleRequest('clusterDefault/getMembers', [
|
|||
|
'id_cluster' => $cluster['id_user_cluster'],
|
|||
|
'class' => 0
|
|||
|
]);
|
|||
|
$usersRes = $usersReq->dispatch();
|
|||
|
|
|||
|
/* (2) Gestion si erreur */
|
|||
|
if( $usersRes->error == ManagerError::Success ) $users = $usersRes->get('members');
|
|||
|
else $users = [];
|
|||
|
|
|||
|
$CLUSTERLIST[$c]['count'] = count($users);
|
|||
|
|
|||
|
$CLUSTERLIST[$c]['users'] = View::replaceMultiple(
|
|||
|
self::template('user'),
|
|||
|
$users,
|
|||
|
[ 'id_user_cluster' => $cluster['id_user_cluster'] ]
|
|||
|
);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
$view_cluster = View::replaceMultiple(
|
|||
|
self::template('user_cluster'),
|
|||
|
$CLUSTERLIST, [
|
|||
|
'icon_remove' => file_get_contents( __ROOT__.'/src/static/sub-menu-side/remove.svg' ),
|
|||
|
'icon_edit' => file_get_contents( __ROOT__.'/src/static/sub-menu-side/edit.svg' ),
|
|||
|
'icon_card' => file_get_contents( __ROOT__.'/src/static/container/card.svg' ),
|
|||
|
'icon_mail' => file_get_contents( __ROOT__.'/src/static/container/mail.svg' ),
|
|||
|
'icon_group' => file_get_contents( __ROOT__.'/src/static/container/group.svg' ),
|
|||
|
]);
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
return View::replaceSingle(self::template(), [ 'clusterlist' => $view_cluster ]);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
?>
|