2016-07-18 14:46:06 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
2016-10-18 14:03:03 +00:00
|
|
|
|
namespace viewer\view\user;
|
|
|
|
|
use \viewer\core\Viewer;
|
|
|
|
|
use \api\core\ModuleRequest;
|
|
|
|
|
use \api\core\Authentification;
|
2016-10-18 17:09:47 +00:00
|
|
|
|
use \error\core\Error;
|
2016-07-18 14:46:06 +00:00
|
|
|
|
|
2016-08-06 09:32:50 +00:00
|
|
|
|
class user_groups{
|
2016-07-18 14:46:06 +00:00
|
|
|
|
|
|
|
|
|
public static function template($type=null){
|
|
|
|
|
|
|
|
|
|
switch($type){
|
|
|
|
|
case 'user': return "
|
|
|
|
|
<span>
|
|
|
|
|
@username
|
2016-07-20 23:13:48 +00:00
|
|
|
|
<span class='rem-member' data-member='@id_user' data-cluster='@id_cluster'></span>
|
2016-07-18 14:46:06 +00:00
|
|
|
|
</span>";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'user_cluster': return "
|
|
|
|
|
<article class='inline-box' id='@id_user_cluster'>
|
2016-07-20 23:19:19 +00:00
|
|
|
|
|
2016-07-20 15:33:38 +00:00
|
|
|
|
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name</span>
|
2016-07-18 14:46:06 +00:00
|
|
|
|
<span class='link_remove' data-cluster='@id_user_cluster'>@icon_remove</span>
|
|
|
|
|
|
2016-07-20 23:19:19 +00:00
|
|
|
|
<span class='link_edit' data-cluster='@id_user_cluster'>@icon_edit</span>
|
|
|
|
|
|
2016-07-18 14:46:06 +00:00
|
|
|
|
<span class='code'>
|
|
|
|
|
@icon_type
|
2016-07-18 14:53:01 +00:00
|
|
|
|
<span>@count utilisateurs</span>
|
2016-07-18 14:46:06 +00:00
|
|
|
|
</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
|
2016-10-18 17:09:47 +00:00
|
|
|
|
if( $answer->error != Error::Success )
|
2016-10-18 14:03:03 +00:00
|
|
|
|
return Viewer::$htmlError;
|
2016-07-18 14:46:06 +00:00
|
|
|
|
|
|
|
|
|
$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 */
|
2016-10-18 17:09:47 +00:00
|
|
|
|
if( $usersRes->error == Error::Success ) $users = $usersRes->get('members');
|
2016-07-18 14:46:06 +00:00
|
|
|
|
else $users = [];
|
|
|
|
|
|
|
|
|
|
$CLUSTERLIST[$c]['count'] = count($users);
|
|
|
|
|
|
2016-10-18 14:03:03 +00:00
|
|
|
|
$CLUSTERLIST[$c]['users'] = Viewer::replaceMultiple(
|
2016-07-18 14:46:06 +00:00
|
|
|
|
self::template('user'),
|
|
|
|
|
$users,
|
2016-07-20 23:13:48 +00:00
|
|
|
|
[ 'id_cluster' => $cluster['id_user_cluster'] ]
|
2016-07-18 14:46:06 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-10-18 14:03:03 +00:00
|
|
|
|
$view_cluster = Viewer::replaceMultiple(
|
2016-07-18 14:46:06 +00:00
|
|
|
|
self::template('user_cluster'),
|
|
|
|
|
$CLUSTERLIST, [
|
2016-10-18 14:03:03 +00:00
|
|
|
|
'icon_remove' => file_get_contents( __PUBLIC__.'/src/static/sub-menu-side/remove.svg' ),
|
|
|
|
|
'icon_edit' => file_get_contents( __PUBLIC__.'/src/static/sub-menu-side/edit.svg' ),
|
|
|
|
|
'icon_type' => file_get_contents( __PUBLIC__.'/src/static/menu-side/users.svg' ),
|
|
|
|
|
'icon_group' => file_get_contents( __PUBLIC__.'/src/static/container/group.svg' ),
|
2016-07-18 14:46:06 +00:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-18 14:03:03 +00:00
|
|
|
|
return Viewer::replaceSingle(self::template(), [ 'clusterlist' => $view_cluster ]);
|
2016-07-18 14:46:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|