2016-07-16 10:41:21 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace manager\view\group;
|
|
|
|
use \manager\View;
|
|
|
|
use \manager\ModuleRequest;
|
|
|
|
use \manager\ManagerError;
|
|
|
|
use \manager\Authentification;
|
|
|
|
use \manager\repo\cluster as clusterRepo;
|
|
|
|
|
|
|
|
class groupChoice{
|
|
|
|
|
|
|
|
public static function template($type=null){
|
|
|
|
|
|
|
|
switch($type){
|
|
|
|
case 'clusterlist': return "
|
|
|
|
<option value='@id_cluster'>@name (@type)</option>";
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default: return "
|
|
|
|
<form class='neutral' id='choose-cluster'>
|
|
|
|
<select data-name='cluster'>
|
2016-07-16 10:42:42 +00:00
|
|
|
<option value='.' selected disabled>Groupe à modifier</option>
|
2016-07-16 10:41:21 +00:00
|
|
|
@clusters
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<button id='choose-cluster'>Modifier la composition</button>
|
|
|
|
</form>";
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function view($params){
|
|
|
|
/* [0] Initialisation des variables (vues)
|
|
|
|
=========================================================*/
|
|
|
|
$view = '';
|
|
|
|
$cluster_view = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* [1] On récupére tous les groupes
|
|
|
|
=========================================================*/
|
|
|
|
/* (1) On récupère les groupe */
|
|
|
|
$getClustersRequest = new ModuleRequest('clusterDefault/getAll');
|
|
|
|
$getClustersResponse = $getClustersRequest->dispatch();
|
|
|
|
|
|
|
|
/* (2) Si on ne le trouve pas, on retourne une erreur */
|
|
|
|
if( $getClustersResponse->error != ManagerError::Success )
|
|
|
|
return View::$htmlError;
|
|
|
|
|
|
|
|
/* (3) On récupère les données du groupe */
|
|
|
|
$CLUSTERLIST = $getClustersResponse->get('clusters');
|
|
|
|
|
|
|
|
/* (4) On ajoute le type de groupe textuel */
|
|
|
|
foreach($CLUSTERLIST as $c=>$cluster)
|
|
|
|
$CLUSTERLIST[$c]['type'] = ($cluster['class']==clusterRepo::USER_CLASS) ? 'utilisateurs' : 'machines';
|
|
|
|
|
|
|
|
|
|
|
|
/* [2] On construit la vue des groupes
|
|
|
|
=========================================================*/
|
|
|
|
$cluster_view = View::replaceMultiple(
|
|
|
|
self::template('clusterlist'),
|
|
|
|
$CLUSTERLIST
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return View::replaceSingle(
|
|
|
|
self::template(), [
|
|
|
|
'clusters' => $cluster_view
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|