cacher les groupes aux users (fixes #32271)

This commit is contained in:
afornerot 2021-06-11 14:07:10 +02:00
parent 2a2dfc55bb
commit 465bfd0374
5 changed files with 106 additions and 36 deletions

View File

@ -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"]);

View File

@ -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;
}

View File

@ -42,10 +42,10 @@ td { font-size: 10px; }
{% if viewniveau02 %}
<th class="no-sort {% if fields["niveau02"] is defined and fields["niveau02"].perm==0 %}no-visible{% endif %}">{{ labelniveau02 }}</th>
{% endif %}
<th class="no-sort {% if fields["group"] is defined and fields["group"].perm==0 %}no-visible{% endif %}">Groupes</th>
<th class="no-sort {% if fields["group"] is defined and fields["group"].perm==0 and is_granted('ROLE_USER') %}no-visible{% endif %}">Groupes</th>
<th class="{% if fields["job"] is defined and fields["job"].perm==0 %}no-visible{% endif %}">Métier</th>
<th class="{% if fields["position"] is defined and fields["position"].perm==0 %}no-visible{% endif %}">Fonction</th>
<th class="{% if fields["visitedate"] is defined and fields["visitedate"].perm==0 %}no-visible{% endif %}">Visite</th>
<th class="{% if fields["visitedate"] is defined and fields["visitedate"].perm==0 and (is_granted('ROLE_USER') or is_granted('ROLE_ANIM')) %}no-visible{% endif %}">Visite</th>
<th class="{% if fields["role"] is defined and fields["role"].perm==0 %}no-visible{% endif %}">Rôle</th>
</tr>
</thead>

View File

@ -19,20 +19,24 @@
{%if user.job and not fields["job"]["perm"]==0 %}<b>{{fields["position"]["job"]}}</b> = {{ user.job }}<br>{%endif%}
{%if user.position and not fields["position"]["perm"]==0 %}<b>{{fields["position"]["label"]}}</b> = {{ user.position }}<br>{%endif%}
{%if user.postaladress and not fields["postaladress"]["perm"]==0 %}<b>{{fields["postaladress"]["label"]}}</b> = {{ user.postaladress }}<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 and not fields["visite"]["perm"]==0 %}<b>Nombre de visites</b> = {{ user.visitecpt }}<br>{%endif%}
<br>
{% set fgtitle=false %}
{% for usergroup in user.groups %}
{% if usergroup.group.fgcanshare %}
{% if not fgtitle %}
<br><b>Groupes de Travail</b><br>
{% set fgtitle=true %}
{%if user.visitedate and (not fields["visitedate"]["perm"]==0 or (not is_granted('ROLE_USER') and not is_granted('ROLE_ANIM'))) %}<b>Date de dernière visite</b> = {{ user.visitedate|date('d/m/Y H:i') }}<br>{%endif%}
{%if user.visitecpt and (not fields["visitedate"]["perm"]==0 or (not is_granted('ROLE_USER') and not is_granted('ROLE_ANIM'))) %}<b>Nombre de visites</b> = {{ user.visitecpt }}<br>{%endif%}
{% if not fields["group"].perm==0 or not is_granted('ROLE_USER') %}
<br>
{% set fgtitle=false %}
{% for usergroup in user.groups %}
{% if usergroup.group.fgcanshare %}
{% if not fgtitle %}
<br><b>Groupes de Travail</b><br>
{% set fgtitle=true %}
{% endif %}
{{ usergroup.group.label }}<br>
{% endif %}
{{ usergroup.group.label }}<br>
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
{% endif %}
{% endif %}
</div>

View File

@ -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");