104 lines
2.6 KiB
PHP
104 lines
2.6 KiB
PHP
|
<?php
|
|||
|
|
|||
|
namespace manager\view\group;
|
|||
|
use \manager\View;
|
|||
|
use \manager\ModuleRequest;
|
|||
|
use \manager\Authentification;
|
|||
|
use \manager\ManagerError;
|
|||
|
|
|||
|
class userChoice{
|
|||
|
|
|||
|
public static function template($type=null){
|
|||
|
|
|||
|
switch($type){
|
|||
|
case 'userlist': return "
|
|||
|
<tr>
|
|||
|
<td>@username</td>
|
|||
|
<td>@firstname @lastname</td>
|
|||
|
<td>@code</td>
|
|||
|
<td>
|
|||
|
|
|||
|
<input type='checkbox' value='@id_user' @already_in>
|
|||
|
|
|||
|
</td>
|
|||
|
|
|||
|
</tr>
|
|||
|
";
|
|||
|
break;
|
|||
|
|
|||
|
|
|||
|
default: return "
|
|||
|
<table class='check-table'>
|
|||
|
@userlist
|
|||
|
</table>";
|
|||
|
break;
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public static function view($params){
|
|||
|
// On vérifie les paramètres
|
|||
|
if( !isset($params['id_cluster']) && !is_number($params['id_cluster']) )
|
|||
|
return "<span class='error'>Une erreur est survenue, veuilez contacter le webmaster si cette erreur persiste.</span>";
|
|||
|
|
|||
|
|
|||
|
$view = '';
|
|||
|
|
|||
|
/* [1] On récupère la liste des utilisateurs
|
|||
|
=========================================================*/
|
|||
|
$request = new ModuleRequest('userDefault/getAll'); // On utilise la methode 'getAll' du module 'userDefault'
|
|||
|
$answer = $request->dispatch(); // On recupere la reponse
|
|||
|
|
|||
|
// si erreur, on affiche l'explicitation
|
|||
|
if( $answer->error != ManagerError::Success )
|
|||
|
return "<span class='error'>Une erreur est survenue, veuilez contacter le webmaster si cette erreur persiste.</span>";
|
|||
|
|
|||
|
$USERLIST = $answer->get('users');
|
|||
|
|
|||
|
/* [2] On récupère la liste des membres
|
|||
|
=========================================================*/
|
|||
|
$get_members = new ModuleRequest('clusterDefault/getMembers', [
|
|||
|
'id_cluster' => $params['id_cluster']
|
|||
|
]);
|
|||
|
$members_response = $get_members->dispatch();
|
|||
|
|
|||
|
// On récupère la liste des UID uniquement
|
|||
|
$members_id = [];
|
|||
|
foreach($members_response->get('members') as $member)
|
|||
|
$members_id[] = $member['id_member'];
|
|||
|
|
|||
|
|
|||
|
|
|||
|
foreach($USERLIST as $u=>$user)
|
|||
|
$USERLIST[$u]['already_in'] = in_array($user['id_user'], $members_id) ? 'checked' : '';
|
|||
|
|
|||
|
|
|||
|
$view_user = View::replaceMultiple(
|
|||
|
self::template('userlist'),
|
|||
|
$USERLIST, [
|
|||
|
'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(), [ 'userlist' => $view_user ]);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
?>
|