From 7ce296fd2988fb42ec6594b57bd14a8c222ab52a Mon Sep 17 00:00:00 2001 From: afornerot Date: Mon, 21 Oct 2019 14:09:24 +0200 Subject: [PATCH] gestion visible et ajout colonne telephone (fixes #15 #16) --- .../Controller/ConfigController.php | 3 + .../CoreBundle/Controller/UserController.php | 177 ++++++++++-------- .../Resources/views/User/list.html.twig | 1 + 3 files changed, 108 insertions(+), 73 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 2f1b7ab1..c0ee499c 100755 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/ConfigController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/ConfigController.php @@ -317,6 +317,9 @@ class ConfigController extends Controller $fields["role"]["perm"]=1; $fields["role"]["label"]="Rôles"; + + $fields["telephonenumber"]["perm"]=1; + $fields["telephonenumber"]["label"]="Téléphone"; } else { $fields=json_decode($fields, true); 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 03b3265b..55353335 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php @@ -65,71 +65,92 @@ class UserController extends Controller $draw= $request->query->get('draw'); $order= $request->query->get('order'); $viewniveau02=$this->getParameter('viewniveau02'); + $fields=$this->getDefaultDatauser(); + $fgusevisible=!($fields["visible"]["perm"]==0); // Nombre total d'enregistrement - if($this->isGranted('ROLE_ADMIN')||$access=="user") - $total = $em->createQueryBuilder()->select('COUNT(user)')->from($this->labelentity,'user')->getQuery()->getSingleScalarResult(); - elseif($this->isGranted('ROLE_MODO')) { - $usermodo=$this->get('security.token_storage')->getToken()->getUser()->getId(); - $total = $em->createQueryBuilder() - ->select('COUNT(user)') - ->from($this->labelentity,'user') - ->from("CadolesCoreBundle:UserModo",'usermodo') - ->where("usermodo.niveau01 = user.niveau01") - ->andWhere("usermodo.user = :userid") - ->setParameter("userid", $usermodo) - ->getQuery()->getSingleScalarResult(); + if($access=="config") { + if($this->isGranted('ROLE_ADMIN')) { + $total = $em->createQueryBuilder()->select('COUNT(user)')->from($this->labelentity,'user')->getQuery()->getSingleScalarResult(); + } + elseif($this->isGranted('ROLE_MODO')) { + $usermodo=$this->get('security.token_storage')->getToken()->getUser()->getId(); + $total = $em->createQueryBuilder() + ->select('COUNT(user)') + ->from($this->labelentity,'user') + ->from("CadolesCoreBundle:UserModo",'usermodo') + ->where("usermodo.niveau01 = user.niveau01") + ->andWhere("usermodo.user = :userid") + ->setParameter("userid", $usermodo) + ->getQuery()->getSingleScalarResult(); + } + } + else { + if($fgusevisible) { + $total = $em->createQueryBuilder()->select('COUNT(user)')->from($this->labelentity,'user')->where('user.visible=true')->getQuery()->getSingleScalarResult(); + } + else { + $total = $em->createQueryBuilder()->select('COUNT(user)')->from($this->labelentity,'user')->getQuery()->getSingleScalarResult(); + } } - elseif($this->isGranted('ROLE_ANIM')||$this->isGranted('ROLE_USER')) { - $niveau01=$this->get('security.token_storage')->getToken()->getUser()->getNiveau01(); - $total = $em->createQueryBuilder() - ->select('COUNT(user)') - ->from($this->labelentity,'user') - ->where("user.niveau01 = :niveau01") - ->setParameter("niveau01", $niveau01) - ->getQuery()->getSingleScalarResult(); - } // Nombre d'enregistrement filtré if($search["value"]=="") $totalf = $total; else { - if($this->isGranted('ROLE_ADMIN')||$access=="user") - $totalf= $em->createQueryBuilder() - ->select('COUNT(user)') - ->from('CadolesCoreBundle:User','user') - ->from('CadolesCoreBundle:Niveau01', 'niveau01') - ->where('user.niveau01=niveau01.id') - ->andWhere('user.username LIKE :value OR user.firstname LIKE :value OR user.lastname LIKE :value OR user.email LIKE :value OR user.role LIKE :value OR niveau01.label LIKE :value') - ->setParameter("value", "%".$search["value"]."%") - ->getQuery() - ->getSingleScalarResult(); - elseif($this->isGranted('ROLE_MODO')) - $totalf= $em->createQueryBuilder() - ->select('COUNT(user)') - ->from('CadolesCoreBundle:User','user') - ->from('CadolesCoreBundle:Niveau01', 'niveau01') - ->from('CadolesCoreBundle:UserModo', 'usermodo') - ->where('user.niveau01=niveau01.id') - ->andWhere('user.username LIKE :value OR user.firstname LIKE :value OR user.lastname LIKE :value OR user.email LIKE :value OR user.role LIKE :value OR niveau01.label LIKE :value') - ->andwhere("usermodo.niveau01 = user.niveau01") - ->andWhere("usermodo.user = :userid") - ->setParameter("userid", $usermodo) - ->setParameter("value", "%".$search["value"]."%") - ->getQuery() - ->getSingleScalarResult(); - elseif($this->isGranted('ROLE_ANIM')||$this->isGranted('ROLE_USER')) - $totalf= $em->createQueryBuilder() - ->select('COUNT(user)') - ->from('CadolesCoreBundle:User','user') - ->from('CadolesCoreBundle:Niveau01', 'niveau01') - ->where('user.niveau01=niveau01.id') - ->andWhere('user.username LIKE :value OR user.firstname LIKE :value OR user.lastname LIKE :value OR user.email LIKE :value OR user.role LIKE :value OR niveau01.label LIKE :value') - ->andWhere("user.niveau01 = :niveau01") - ->setParameter("niveau01", $niveau01) - ->setParameter("value", "%".$search["value"]."%") - ->getQuery() - ->getSingleScalarResult(); + if($access=="config") { + if($this->isGranted('ROLE_ADMIN')) { + $totalf= $em->createQueryBuilder() + ->select('COUNT(user)') + ->from('CadolesCoreBundle:User','user') + ->from('CadolesCoreBundle:Niveau01', 'niveau01') + ->where('user.niveau01=niveau01.id') + ->andWhere('user.username LIKE :value OR user.firstname LIKE :value OR user.lastname LIKE :value OR user.email LIKE :value OR user.role LIKE :value OR niveau01.label LIKE :value') + ->setParameter("value", "%".$search["value"]."%") + ->getQuery() + ->getSingleScalarResult(); + } + elseif($this->isGranted('ROLE_MODO')) { + $totalf= $em->createQueryBuilder() + ->select('COUNT(user)') + ->from('CadolesCoreBundle:User','user') + ->from('CadolesCoreBundle:Niveau01', 'niveau01') + ->from('CadolesCoreBundle:UserModo', 'usermodo') + ->where('user.niveau01=niveau01.id') + ->andWhere('user.username LIKE :value OR user.firstname LIKE :value OR user.lastname LIKE :value OR user.email LIKE :value OR user.role LIKE :value OR niveau01.label LIKE :value') + ->andwhere("usermodo.niveau01 = user.niveau01") + ->andWhere("usermodo.user = :userid") + ->setParameter("userid", $usermodo) + ->setParameter("value", "%".$search["value"]."%") + ->getQuery() + ->getSingleScalarResult(); + } + } + else { + if($fgusevisible) { + $totalf= $em->createQueryBuilder() + ->select('COUNT(user)') + ->from('CadolesCoreBundle:User','user') + ->from('CadolesCoreBundle:Niveau01', 'niveau01') + ->where('user.niveau01=niveau01.id') + ->andWhere('user.visible=true') + ->andWhere('user.username LIKE :value OR user.firstname LIKE :value OR user.lastname LIKE :value OR user.email LIKE :value OR user.role LIKE :value OR niveau01.label LIKE :value') + ->setParameter("value", "%".$search["value"]."%") + ->getQuery() + ->getSingleScalarResult(); + } + else { + $totalf= $em->createQueryBuilder() + ->select('COUNT(user)') + ->from('CadolesCoreBundle:User','user') + ->from('CadolesCoreBundle:Niveau01', 'niveau01') + ->where('user.niveau01=niveau01.id') + ->andWhere('user.username LIKE :value OR user.firstname LIKE :value OR user.lastname LIKE :value OR user.email LIKE :value OR user.role LIKE :value OR niveau01.label LIKE :value') + ->setParameter("value", "%".$search["value"]."%") + ->getQuery() + ->getSingleScalarResult(); + } + } } // Construction du tableau de retour @@ -142,23 +163,24 @@ class UserController extends Controller // Parcours des Enregistrement $qb = $em->createQueryBuilder(); - if($this->isGranted('ROLE_ADMIN')||$access=="user") { + if($access=="config") { + if($this->isGranted('ROLE_ADMIN')) { + $qb->select('user')->from($this->labelentity,'user')->from('CadolesCoreBundle:Niveau01','niveau01'); + $qb->where('user.niveau01=niveau01.id'); + } + elseif($this->isGranted('ROLE_MODO')) { + $qb->select('user')->from($this->labelentity,'user')->from('CadolesCoreBundle:Niveau01','niveau01')->from('CadolesCoreBundle:UserModo', 'usermodo'); + $qb->where('user.niveau01=niveau01.id') + ->andwhere("usermodo.niveau01 = user.niveau01") + ->andWhere("usermodo.user = :userid") + ->setParameter("userid", $usermodo); + } + } + else { $qb->select('user')->from($this->labelentity,'user')->from('CadolesCoreBundle:Niveau01','niveau01'); $qb->where('user.niveau01=niveau01.id'); + if($fgusevisible) $qb->andWhere('user.visible=true'); } - elseif($this->isGranted('ROLE_MODO')) { - $qb->select('user')->from($this->labelentity,'user')->from('CadolesCoreBundle:Niveau01','niveau01')->from('CadolesCoreBundle:UserModo', 'usermodo'); - $qb->where('user.niveau01=niveau01.id') - ->andwhere("usermodo.niveau01 = user.niveau01") - ->andWhere("usermodo.user = :userid") - ->setParameter("userid", $usermodo); - } - elseif($this->isGranted('ROLE_ANIM')||$this->isGranted('ROLE_USER')) { - $qb->select('user')->from($this->labelentity,'user')->from('CadolesCoreBundle:Niveau01','niveau01'); - $qb->where('user.niveau01=niveau01.id') - ->andwhere("user.niveau01 = :niveau01") - ->setParameter("niveau01", $niveau01); - } if($search["value"]!="") { $qb ->andWhere('user.username LIKE :value OR user.firstname LIKE :value OR user.lastname LIKE :value OR user.email LIKE :value OR user.role LIKE :value OR niveau01.label LIKE :value') @@ -184,10 +206,14 @@ class UserController extends Controller break; case 6 : + $qb->orderBy('user.telephonenumber',$order[0]["dir"]); + break; + + case 7 : $qb->orderBy('niveau01.label',$order[0]["dir"]); break; - case 9 : + case 10 : $qb->orderBy('user.role',$order[0]["dir"]); break; } @@ -211,10 +237,14 @@ class UserController extends Controller break; case 5 : + $qb->orderBy('user.telephonenumber',$order[0]["dir"]); + break; + + case 6 : $qb->orderBy('niveau01.label',$order[0]["dir"]); break; - case 7 : + case 8 : $qb->orderBy('user.role',$order[0]["dir"]); break; } @@ -245,6 +275,7 @@ class UserController extends Controller array_push($tmp,$data->getLastname()); array_push($tmp,$data->getFirstname()); array_push($tmp,"".$data->getEmail().""); + array_push($tmp,$data->getTelephonenumber()); array_push($tmp,$data->getNiveau01()->getLabel()); if($viewniveau02) array_push($tmp,($data->getNiveau02()!==null?$data->getNiveau02()->getLabel():"")); array_push($tmp,$groups); 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 731b9d9b..8e1498c9 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 @@ -32,6 +32,7 @@ Nom Prénom Email + Téléphone {{ labelniveau01 }} {% if viewniveau02 %} {{ labelniveau02 }}