From 465bfd03741a6a58a7b433b4140156c031b17999 Mon Sep 17 00:00:00 2001 From: afornerot Date: Fri, 11 Jun 2021 14:07:10 +0200 Subject: [PATCH] cacher les groupes aux users (fixes #32271) --- .../Controller/ConfigController.php | 13 ++-- .../CoreBundle/Controller/UserController.php | 71 ++++++++++++++++++- .../Resources/views/User/list.html.twig | 4 +- .../Resources/views/User/view.html.twig | 30 ++++---- .../PortalBundle/Command/InitDataCommand.php | 24 +++---- 5 files changed, 106 insertions(+), 36 deletions(-) diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/ConfigController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/ConfigController.php index 60f2d02f..5ca1909e 100755 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/ConfigController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/ConfigController.php @@ -326,10 +326,9 @@ class ConfigController extends Controller $fields["niveau02"]["perm"]=1; $fields["niveau02"]["label"]=$session->get('labelniveau02'); } - if(!array_key_exists("group",$fields)) { - $fields["group"]["perm"]=1; - $fields["group"]["label"]="Groupes"; - } + if(!array_key_exists("group",$fields)) $fields["group"]["perm"]=1; + $fields["group"]["label"]="Groupes (caché uniquement pour le rôle Utilisateur) "; + if(!array_key_exists("job",$fields)) { $fields["job"]["perm"]=1; $fields["job"]["label"]="Métier"; @@ -346,10 +345,8 @@ class ConfigController extends Controller $fields["telephonenumber"]["perm"]=1; $fields["telephonenumber"]["label"]="Téléphone"; } - if(!array_key_exists("visitedate",$fields)) { - $fields["visitedate"]["perm"]=1; - $fields["visitedate"]["label"]="Visite"; - } + if(!array_key_exists("visitedate",$fields)) $fields["visitedate"]["perm"]=1; + $fields["visitedate"]["label"]="Visite (caché uniquement pour les rôles Animateur et Utilisateur) "; if(!$session->get('viewniveau02')) unset($fields["niveau02"]); 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 1530a64a..601e1c5f 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php @@ -842,7 +842,7 @@ class UserController extends Controller public function viewAction($id, Request $request) { $user=$this->getData($id); - $fields=$this->getDefaultDatauser(); + $fields=$this->getDefaultDatausers(); return $this->render('CadolesCoreBundle:User:view.html.twig', [ 'useheader' => false, @@ -1456,7 +1456,76 @@ class UserController extends Controller if(!array_key_exists("visite",$fields)) { $fields["visite"]["perm"]=1; $fields["visite"]["label"]="Visite"; + } + + + return $fields; + } + + protected function getDefaultDatausers() + { + $em = $this->getDoctrine()->getManager(); + $session=$this->get('session'); + $config=$em->getRepository('CadolesCoreBundle:Config')->find("datausers"); + $fields=$config->getValue(); + + $fields=json_decode($fields, true); + if(!is_array($fields)) $fields=[]; + + // Valeur par défaut 0=caché / 3=visible + if(!array_key_exists("avatar",$fields)) { + $fields["avatar"]["perm"]=1; + $fields["avatar"]["label"]="Avatar"; + } + if(!array_key_exists("login",$fields)) { + $fields["login"]["perm"]=1; + $fields["login"]["label"]="Login"; + } + if(!array_key_exists("lastname",$fields)) { + $fields["lastname"]["perm"]=1; + $fields["lastname"]["label"]="Nom"; + } + if(!array_key_exists("firstname",$fields)) { + $fields["firstname"]["perm"]=1; + $fields["firstname"]["label"]="Prenom"; + } + if(!array_key_exists("email",$fields)) { + $fields["email"]["perm"]=1; + $fields["email"]["label"]="Email"; + } + if(!array_key_exists("niveau01",$fields)) { + $fields["niveau01"]["perm"]=1; + $fields["niveau01"]["label"]=$session->get('labelniveau01'); } + if(!array_key_exists("niveau02",$fields)) { + $fields["niveau02"]["perm"]=1; + $fields["niveau02"]["label"]=$session->get('labelniveau02'); + } + if(!array_key_exists("group",$fields)) $fields["group"]["perm"]=1; + $fields["group"]["label"]="Groupes (caché uniquement pour le rôle Utilisateur) "; + + if(!array_key_exists("job",$fields)) { + $fields["job"]["perm"]=1; + $fields["job"]["label"]="Métier"; + } + if(!array_key_exists("position",$fields)) { + $fields["position"]["perm"]=1; + $fields["position"]["label"]="Fonction"; + } + if(!array_key_exists("role",$fields)) { + $fields["role"]["perm"]=1; + $fields["role"]["label"]="Rôles"; + } + if(!array_key_exists("telephonenumber",$fields)) { + $fields["telephonenumber"]["perm"]=1; + $fields["telephonenumber"]["label"]="Téléphone"; + } + if(!array_key_exists("visitedate",$fields)) $fields["visitedate"]["perm"]=1; + $fields["visitedate"]["label"]="Visite (caché uniquement pour les rôles Animateur et Utilisateur) "; + + if(!$session->get('viewniveau02')) + unset($fields["niveau02"]); + return $fields; } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/User/list.html.twig b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/User/list.html.twig index 17dff5e9..cfef4208 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/User/list.html.twig +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/User/list.html.twig @@ -42,10 +42,10 @@ td { font-size: 10px; } {% if viewniveau02 %} {{ labelniveau02 }} {% endif %} - Groupes + Groupes Métier Fonction - Visite + Visite Rôle 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 b50b48ff..e3203752 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 @@ -19,20 +19,24 @@ {%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 %} - {% if usergroup.group.fgcanshare %} - {% if not fgtitle %} -
Groupes de Travail
- {% set fgtitle=true %} + + {%if user.visitedate and (not fields["visitedate"]["perm"]==0 or (not is_granted('ROLE_USER') and not is_granted('ROLE_ANIM'))) %}Date de dernière visite = {{ user.visitedate|date('d/m/Y H:i') }}
{%endif%} + {%if user.visitecpt and (not fields["visitedate"]["perm"]==0 or (not is_granted('ROLE_USER') and not is_granted('ROLE_ANIM'))) %}Nombre de visites = {{ user.visitecpt }}
{%endif%} + + {% if not fields["group"].perm==0 or not is_granted('ROLE_USER') %} +
+ {% set fgtitle=false %} + {% for usergroup in user.groups %} + {% if usergroup.group.fgcanshare %} + {% if not fgtitle %} +
Groupes de Travail
+ {% set fgtitle=true %} + {% endif %} + + {{ usergroup.group.label }}
{% endif %} - - {{ usergroup.group.label }}
- {% endif %} - {% endfor %} + {% endfor %} + {% endif %} {% endif %} {% endif %} diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Command/InitDataCommand.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Command/InitDataCommand.php index 099ce279..44e87fa4 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Command/InitDataCommand.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Command/InitDataCommand.php @@ -1026,15 +1026,15 @@ class InitDataCommand extends ContainerAwareCommand //== WIDGET ============================================================================================================================================ $output->writeln(' > Creation Widget'); - // Widget URL + // Widget Page web $entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-2000); if(!$entityWidget) $entityWidget = new Widget(); $entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_ribbon.png"]); $entityWidget->setId(-2000); $entityWidget->setRoworder(0); $entityWidget->setIcon($entityicon); - $entityWidget->setName('URL'); - $entityWidget->setDescription("Affiche le contenu d'une url"); + $entityWidget->setName('Page web'); + $entityWidget->setDescription("Affiche le contenu d'une page web"); $entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_url"); $entityWidget->setHeight("630"); $entityWidget->setAutoajust(false); @@ -1106,15 +1106,15 @@ class InitDataCommand extends ContainerAwareCommand $em->persist($entityWidget); - // Widget Favoris + // Widget Liens $entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1960); if(!$entityWidget) $entityWidget = new Widget(); $entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_star.png"]); $entityWidget->setId(-1960); $entityWidget->setRoworder(0); $entityWidget->setIcon($entityicon); - $entityWidget->setName('Favoris'); - $entityWidget->setDescription("Création de Favoris"); + $entityWidget->setName('Liens'); + $entityWidget->setDescription("Bibliothèque de Liens"); $entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_bookmark"); $entityWidget->setHeight("630"); $entityWidget->setAutoajust(true); @@ -1126,7 +1126,7 @@ class InitDataCommand extends ContainerAwareCommand $em->persist($entityWidget); - // Widget Liens + // Widget Lien $entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1950); if(!$entityWidget) $entityWidget = new Widget(); $entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_bolt.png"]); @@ -1134,7 +1134,7 @@ class InitDataCommand extends ContainerAwareCommand $entityWidget->setRoworder(0); $entityWidget->setIcon($entityicon); $entityWidget->setName('Lien'); - $entityWidget->setDescription("Création d'un Lien"); + $entityWidget->setDescription("Création d'un Lien unique"); $entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_link"); $entityWidget->setHeight("200"); $entityWidget->setAutoajust(true); @@ -1146,14 +1146,14 @@ class InitDataCommand extends ContainerAwareCommand $em->persist($entityWidget); - // Widget Editor + // Widget Texte $entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1940); if(!$entityWidget) $entityWidget = new Widget(); $entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_compose.png"]); $entityWidget->setId(-1940); $entityWidget->setRoworder(0); $entityWidget->setIcon($entityicon); - $entityWidget->setName('Editeur'); + $entityWidget->setName('Texte'); $entityWidget->setDescription("Votre propre texte à éditer"); $entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_editor"); $entityWidget->setHeight("630"); @@ -1317,14 +1317,14 @@ class InitDataCommand extends ContainerAwareCommand $em->persist($entityWidget); } - // Widget Information + // Widget Informations $entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1860); if(!$entityWidget) $entityWidget = new Widget(); $entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_info.png"]); $entityWidget->setId(-1860); $entityWidget->setRoworder(0); $entityWidget->setIcon($entityicon); - $entityWidget->setName('Information Page'); + $entityWidget->setName('Informations'); $entityWidget->setDescription("Afficher les informations associées à la page"); $entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_info"); $entityWidget->setHeight("630");