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

119 lines
2.9 KiB
PHP
Raw Normal View History

2016-07-11 15:44:18 +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-11 15:44:18 +00:00
2016-08-06 09:32:50 +00:00
class user_view{
2016-07-11 15:44:18 +00:00
2016-07-12 10:06:46 +00:00
public static function template($type=null){
switch($type){
case 'cluster': return "
<span>
@name
<span class='rem-group' data-group='@id_user_cluster' data-user='@id_user'></span>
</span>";
break;
case 'user': return "
<article class='inline-box' id='@id_user'>
2016-07-12 10:06:46 +00:00
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@firstname @lastname <span>#@username</span></span>
<span class='link_remove' data-user='@id_user'>@icon_remove</span>
<span class='link_edit' data-user='@id_user'>@icon_edit</span>
<span class='code'>
@icon_card
<span>@code</span>
</span>
<span class='mail'>
2016-07-12 10:06:46 +00:00
@icon_mail
<a href='mailto:@mail'>
<span>@mail</span>
</a>
</span>
<span class='groups'>
@icon_group
@grouplist
</span>
</article>";
break;
default: return "
<input type='text' class='searchbar' placeholder='Recherche'>
@userlist";
break;
}
2016-07-11 15:44:18 +00:00
}
2016-07-12 10:06:46 +00:00
public static function view($params){
$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
2016-10-18 17:09:47 +00:00
if( $answer->error != Error::Success )
2016-10-18 14:03:03 +00:00
return Viewer::$htmlError;
$USERLIST = $answer->get('users');
foreach($USERLIST as $u=>$user){
$clustersReq = new ModuleRequest('userDefault/getClusters', [ 'id_user' => $user['id_user'] ]);
$clustersRes = $clustersReq->dispatch();
/* (2) Gestion si erreur */
2016-10-18 17:09:47 +00:00
if( $clustersRes->error == Error::Success ) $clusters = $clustersRes->get('clusters');
else $clusters = [];
2016-10-18 14:03:03 +00:00
$USERLIST[$u]['grouplist'] = Viewer::replaceMultiple(
2016-07-12 10:06:46 +00:00
self::template('cluster'),
$clusters,
[ 'id_user' => $user['id_user'] ]
);
}
2016-10-18 14:03:03 +00:00
$view_user = Viewer::replaceMultiple(
2016-07-12 10:06:46 +00:00
self::template('user'),
$USERLIST, [
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_card' => file_get_contents( __PUBLIC__.'/src/static/container/card.svg' ),
'icon_mail' => file_get_contents( __PUBLIC__.'/src/static/container/mail.svg' ),
'icon_group' => file_get_contents( __PUBLIC__.'/src/static/container/group.svg' ),
]);
2016-10-18 14:03:03 +00:00
return Viewer::replaceSingle(self::template(), [ 'userlist' => $view_user ]);
2016-07-11 15:44:18 +00:00
}
2016-07-11 15:44:18 +00:00
}
?>