prise en compte des param des champs users dans la vue user et l'appartenance aux groupes

This commit is contained in:
afornerot 2021-04-26 15:38:56 +02:00
parent 33841459d9
commit 635f44a894
4 changed files with 41 additions and 12 deletions

View File

@ -494,6 +494,13 @@ class GroupController extends Controller
$datas=$qb->setFirstResult($start)->setMaxResults($length)->getQuery()->getResult(); $datas=$qb->setFirstResult($start)->setMaxResults($length)->getQuery()->getResult();
$user=$this->getUser(); $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) { foreach($datas as $data) {
// Propriétaire // Propriétaire
$usergroup=$em->getRepository("CadolesCoreBundle:UserGroup")->findOneBy(["user"=>$data->getId(),"group"=>$id]); $usergroup=$em->getRepository("CadolesCoreBundle:UserGroup")->findOneBy(["user"=>$data->getId(),"group"=>$id]);
@ -522,12 +529,18 @@ class GroupController extends Controller
} }
// Visite // Visite
$visite=""; if($fgviewvisite) {
if($usergroup->getVisitedate()) { $visite="";
$visite=$usergroup->getVisitedate()->format("d/m/Y H:i")."<br>nb = ".$usergroup->getVisitecpt(); if($usergroup->getVisitedate()) {
$visite=$usergroup->getVisitedate()->format("d/m/Y H:i")."<br>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 // Retour
@ -1018,6 +1031,14 @@ class GroupController extends Controller
// idreturn ? // idreturn ?
$idreturn=$request->get("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 // Affichage du formulaire
return $this->render($this->labelentity.':users.html.twig', [ return $this->render($this->labelentity.':users.html.twig', [
'useheader' => true, 'useheader' => true,
@ -1026,6 +1047,7 @@ class GroupController extends Controller
'access' => $access, 'access' => $access,
$this->labeldata => $data, $this->labeldata => $data,
'idreturn' => $idreturn, 'idreturn' => $idreturn,
'fgviewvisite' => $fgviewvisite,
]); ]);
} }

View File

@ -841,12 +841,15 @@ class UserController extends Controller
public function viewAction($id, Request $request) public function viewAction($id, Request $request)
{ {
$user=$this->getData($id); $user=$this->getData($id);
$fields=$this->getDefaultDatauser();
return $this->render('CadolesCoreBundle:User:view.html.twig', [ return $this->render('CadolesCoreBundle:User:view.html.twig', [
'useheader' => false, 'useheader' => false,
'usemenu' => false, 'usemenu' => false,
'usesidebar' => false, 'usesidebar' => false,
"user" => $user 'user' => $user,
'fields' => $fields,
]); ]);
} }

View File

@ -36,7 +36,9 @@
<th width="70px" class="no-sort">Avatar</th> <th width="70px" class="no-sort">Avatar</th>
<th width="200px">Login</th> <th width="200px">Login</th>
<th>Email</th> <th>Email</th>
{% if fgviewvisite %}
<th class="no-sort no-visible">Visite</th> <th class="no-sort no-visible">Visite</th>
{% endif %}
{% if group.fgcanshare %} {% if group.fgcanshare %}
<th class="no-sort no-visible">Permissions</th> <th class="no-sort no-visible">Permissions</th>
{% endif %} {% endif %}
@ -63,7 +65,9 @@
<th width="70px" class="no-sort">Avatar</th> <th width="70px" class="no-sort">Avatar</th>
<th width="200px">Login</th> <th width="200px">Login</th>
<th>Email</th> <th>Email</th>
{% if fgviewvisite %}
<th class="no-sort">Visite</th> <th class="no-sort">Visite</th>
{% endif %}
{% if group.fgcanshare %} {% if group.fgcanshare %}
<th class="no-sort">Permissions</th> <th class="no-sort">Permissions</th>
{% endif %} {% endif %}

View File

@ -11,16 +11,16 @@
<br>L'utilisateur souhaite masquer ses informations personnelles. <br>L'utilisateur souhaite masquer ses informations personnelles.
{% else %} {% else %}
{%if user.lastname %}<b>Nom</b> = {{ user.lastname }}<br>{%endif%} {%if user.lastname %}<b>Nom</b> = {{ user.lastname }}<br>{%endif%}
{%if user.firstname %}<b>Prénom</b> = {{ user.firstname }}<br>{%endif%} {%if user.firstname and not fields["firstname"]["perm"]==0 %}<b>{{fields["firstname"]["label"]}}</b> = {{ user.firstname }}<br>{%endif%}
{%if user.email %}<b>Email</b> = <a href='mailto:{{ user.email }}'>{{ user.email }}</a><br>{%endif%} {%if user.email %}<b>Email</b> = <a href='mailto:{{ user.email }}'>{{ user.email }}</a><br>{%endif%}
{%if user.telephonenumber %}<b>Téléphone</b> = {{ user.telephonenumber }}<br>{%endif%} {%if user.telephonenumber and not fields["telephonenumber"]["perm"]==0 %}<b>{{fields["telephonenumber"]["label"]}}</b> = {{ user.telephonenumber }}<br>{%endif%}
{%if user.niveau01 %}<b>{{ labelniveau01 }}</b> = {{ user.niveau01.label }}<br>{%endif%} {%if user.niveau01 %}<b>{{ labelniveau01 }}</b> = {{ user.niveau01.label }}<br>{%endif%}
{%if viewniveau02 and user.niveau02%}<b>{{ labelniveau02 }}</b> = {{ user.niveau02.label }}<br>{% endif %} {%if viewniveau02 and user.niveau02%}<b>{{ labelniveau02 }}</b> = {{ user.niveau02.label }}<br>{% endif %}
{%if user.job %}<b>Métier</b> = {{ user.job }}<br>{%endif%} {%if user.job and not fields["job"]["perm"]==0 %}<b>{{fields["position"]["job"]}}</b> = {{ user.job }}<br>{%endif%}
{%if user.position %}<b>Fonction</b> = {{ user.position }}<br>{%endif%} {%if user.position and not fields["position"]["perm"]==0 %}<b>{{fields["position"]["label"]}}</b> = {{ user.position }}<br>{%endif%}
{%if user.postaladress %}<b>Adresse</b> = {{ user.postaladress }}<br>{%endif%} {%if user.postaladress and not fields["postaladress"]["perm"]==0 %}<b>{{fields["postaladress"]["label"]}}</b> = {{ user.postaladress }}<br>{%endif%}
{%if user.visitedate %}<b>Date de dernière visite</b> = {{ user.visitedate|date('d/m/Y H:i') }}<br>{%endif%} {%if user.visitedate and not fields["visite"]["perm"]==0 %}<b>Date de dernière visite</b> = {{ user.visitedate|date('d/m/Y H:i') }}<br>{%endif%}
{%if user.visitecpt %}<b>Nombre de visites</b> = {{ user.visitecpt }}<br>{%endif%} {%if user.visitecpt and not fields["visite"]["perm"]==0 %}<b>Nombre de visites</b> = {{ user.visitecpt }}<br>{%endif%}
<br> <br>
{% set fgtitle=false %} {% set fgtitle=false %}
{% for usergroup in user.groups %} {% for usergroup in user.groups %}