From 635f44a894d945ee87a997a688c048cccbba7f4d Mon Sep 17 00:00:00 2001 From: afornerot Date: Mon, 26 Apr 2021 15:38:56 +0200 Subject: [PATCH] prise en compte des param des champs users dans la vue user et l'appartenance aux groupes --- .../CoreBundle/Controller/GroupController.php | 30 ++++++++++++++++--- .../CoreBundle/Controller/UserController.php | 5 +++- .../Resources/views/Group/users.html.twig | 4 +++ .../Resources/views/User/view.html.twig | 14 ++++----- 4 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php index f60ffc2e..fd139666 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php @@ -494,6 +494,13 @@ class GroupController extends Controller $datas=$qb->setFirstResult($start)->setMaxResults($length)->getQuery()->getResult(); $user=$this->getUser(); + $config=$em->getRepository('CadolesCoreBundle:Config')->find("datausers"); + $fields=$config->getValue(); + $fields=json_decode($fields,true); + if(!is_array($fields)) $fields=[]; + if(!array_key_exists("visite",$fields)) $fields["visite"]["perm"]=0; + $fgviewvisite=($fields["visite"]["perm"]==1); + foreach($datas as $data) { // Propriétaire $usergroup=$em->getRepository("CadolesCoreBundle:UserGroup")->findOneBy(["user"=>$data->getId(),"group"=>$id]); @@ -522,12 +529,18 @@ class GroupController extends Controller } // Visite - $visite=""; - if($usergroup->getVisitedate()) { - $visite=$usergroup->getVisitedate()->format("d/m/Y H:i")."
nb = ".$usergroup->getVisitecpt(); + if($fgviewvisite) { + $visite=""; + if($usergroup->getVisitedate()) { + $visite=$usergroup->getVisitedate()->format("d/m/Y H:i")."
nb = ".$usergroup->getVisitecpt(); + } } + if($fgviewvisite) + $tmp=array("DT_RowId"=>"user".$data->getId(),$action,$avatar,$data->getUsername(),$data->getEmail(),$visite,$rolegroup); + else + $tmp=array("DT_RowId"=>"user".$data->getId(),$action,$avatar,$data->getUsername(),$data->getEmail(),$rolegroup); - array_push($output["data"],array("DT_RowId"=>"user".$data->getId(),$action,$avatar,$data->getUsername(),$data->getEmail(),$visite,$rolegroup)); + array_push($output["data"],$tmp); } // Retour @@ -1018,6 +1031,14 @@ class GroupController extends Controller // idreturn ? $idreturn=$request->get("idreturn"); + $em = $this->getDoctrine()->getManager(); + $config=$em->getRepository('CadolesCoreBundle:Config')->find("datausers"); + $fields=$config->getValue(); + $fields=json_decode($fields,true); + if(!is_array($fields)) $fields=[]; + if(!array_key_exists("visite",$fields)) $fields["visite"]["perm"]=0; + $fgviewvisite=($fields["visite"]["perm"]==1); + // Affichage du formulaire return $this->render($this->labelentity.':users.html.twig', [ 'useheader' => true, @@ -1026,6 +1047,7 @@ class GroupController extends Controller 'access' => $access, $this->labeldata => $data, 'idreturn' => $idreturn, + 'fgviewvisite' => $fgviewvisite, ]); } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php index fe9c4613..3e67d727 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php @@ -841,12 +841,15 @@ class UserController extends Controller public function viewAction($id, Request $request) { $user=$this->getData($id); + $fields=$this->getDefaultDatauser(); return $this->render('CadolesCoreBundle:User:view.html.twig', [ 'useheader' => false, 'usemenu' => false, 'usesidebar' => false, - "user" => $user + 'user' => $user, + 'fields' => $fields, + ]); } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/users.html.twig b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/users.html.twig index b0ef7f1e..a66b182c 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/users.html.twig +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/users.html.twig @@ -36,7 +36,9 @@ Avatar Login Email + {% if fgviewvisite %} Visite + {% endif %} {% if group.fgcanshare %} Permissions {% endif %} @@ -63,7 +65,9 @@ Avatar Login Email + {% if fgviewvisite %} Visite + {% endif %} {% if group.fgcanshare %} Permissions {% endif %} diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/User/view.html.twig b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/User/view.html.twig index 341f3c4c..b50b48ff 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/User/view.html.twig +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/User/view.html.twig @@ -11,16 +11,16 @@
L'utilisateur souhaite masquer ses informations personnelles. {% else %} {%if user.lastname %}Nom = {{ user.lastname }}
{%endif%} - {%if user.firstname %}Prénom = {{ user.firstname }}
{%endif%} + {%if user.firstname and not fields["firstname"]["perm"]==0 %}{{fields["firstname"]["label"]}} = {{ user.firstname }}
{%endif%} {%if user.email %}Email = {{ user.email }}
{%endif%} - {%if user.telephonenumber %}Téléphone = {{ user.telephonenumber }}
{%endif%} + {%if user.telephonenumber and not fields["telephonenumber"]["perm"]==0 %}{{fields["telephonenumber"]["label"]}} = {{ user.telephonenumber }}
{%endif%} {%if user.niveau01 %}{{ labelniveau01 }} = {{ user.niveau01.label }}
{%endif%} {%if viewniveau02 and user.niveau02%}{{ labelniveau02 }} = {{ user.niveau02.label }}
{% endif %} - {%if user.job %}Métier = {{ user.job }}
{%endif%} - {%if user.position %}Fonction = {{ user.position }}
{%endif%} - {%if user.postaladress %}Adresse = {{ user.postaladress }}
{%endif%} - {%if user.visitedate %}Date de dernière visite = {{ user.visitedate|date('d/m/Y H:i') }}
{%endif%} - {%if user.visitecpt %}Nombre de visites = {{ user.visitecpt }}
{%endif%} + {%if user.job and not fields["job"]["perm"]==0 %}{{fields["position"]["job"]}} = {{ user.job }}
{%endif%} + {%if user.position and not fields["position"]["perm"]==0 %}{{fields["position"]["label"]}} = {{ user.position }}
{%endif%} + {%if user.postaladress and not fields["postaladress"]["perm"]==0 %}{{fields["postaladress"]["label"]}} = {{ user.postaladress }}
{%endif%} + {%if user.visitedate and not fields["visite"]["perm"]==0 %}Date de dernière visite = {{ user.visitedate|date('d/m/Y H:i') }}
{%endif%} + {%if user.visitecpt and not fields["visite"]["perm"]==0 %}Nombre de visites = {{ user.visitecpt }}
{%endif%}
{% set fgtitle=false %} {% for usergroup in user.groups %}