diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/PurgeFileCommand.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/PurgeFileCommand.php index 02bd32f1..782cfd74 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/PurgeFileCommand.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/PurgeFileCommand.php @@ -194,8 +194,9 @@ class PurgeFileCommand extends Command foreach (iterator_to_array($finder) as $file) { $name = $file->getRelativePathname(); if($name!="logo.png") { - $entity=$this->em->getRepository("CadolesCoreBundle:Niveau01")->findBy(["logo"=>"uploads/niveau01/".$name]); - if(!$entity) { + $logo=$this->em->getRepository("CadolesCoreBundle:Niveau01")->findBy(["logo"=>"uploads/niveau01/".$name]); + $header=$this->em->getRepository("CadolesCoreBundle:Niveau01")->findBy(["header"=>"uploads/niveau01/".$name]); + if(!$logo&&!$header) { $this->writeln($name); $url=$directory."/".$name; if($fs->exists($url)) { diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/Niveau01Controller.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/Niveau01Controller.php index d33cf22c..e881dfa4 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/Niveau01Controller.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/Niveau01Controller.php @@ -43,20 +43,35 @@ class Niveau01Controller extends Controller $draw= $request->query->get('draw'); $order= $request->query->get('order'); + // Modo ? + $ismodo=false; + if($this->getUser()->getRole()=="ROLE_MODO") { + $ismodo=true; + } + // Nombre total d'enregistrement - $total = $em->createQueryBuilder()->select('COUNT(table)')->from($this->labelentity,'table')->getQuery()->getSingleScalarResult(); + if($ismodo) + $total = $em->createQueryBuilder()->select('COUNT(table)')->from("CadolesCoreBundle:UserModo",'table')->where("table.user = :user")->setParameter("user", $this->getUser())->getQuery()->getSingleScalarResult(); + else + $total = $em->createQueryBuilder()->select('COUNT(table)')->from($this->labelentity,'table')->getQuery()->getSingleScalarResult(); // Nombre d'enregistrement filtré if($search["value"]=="") $totalf = $total; else { - $totalf= $em->createQueryBuilder() + $qb = $em->createQueryBuilder() ->select('COUNT(table)') ->from($this->labelentity,'table') ->where('table.label LIKE :value') - ->setParameter("value", "%".$search["value"]."%") - ->getQuery() - ->getSingleScalarResult(); + ->setParameter("value", "%".$search["value"]."%"); + if($ismodo) + $qb ->from("CadolesCoreBundle:UserModo","usermodo") + ->andwhere("usermodo.user = :user") + ->andWhere("usermodo.niveau01=table") + ->setParameter("user", $this->getUser()); + + + $totalf = $qb->getQuery()->getSingleScalarResult(); } // Construction du tableau de retour @@ -70,8 +85,15 @@ class Niveau01Controller extends Controller // Parcours des Enregistrement $qb = $em->createQueryBuilder(); $qb->select('table')->from($this->labelentity,'table'); + if($ismodo) { + $qb->from("CadolesCoreBundle:UserModo","usermodo") + ->where("usermodo.user = :user") + ->andWhere("usermodo.niveau01=table") + ->setParameter("user", $this->getUser()); + } + if($search["value"]!="") { - $qb ->where('table.label LIKE :value') + $qb ->andwhere('table.label LIKE :value') ->setParameter("value", "%".$search["value"]."%"); } switch($order[0]["column"]) { @@ -84,7 +106,7 @@ class Niveau01Controller extends Controller foreach($datas as $data) { $action ="$data->getId()))."'>"; - if($data->getId()>0) $action.="$data->getId()))."'>"; + if($data->getId()>0&&!$ismodo) $action.="$data->getId()))."'>"; array_push($output["data"],array($action,$data->getLabel())); } @@ -97,6 +119,10 @@ class Niveau01Controller extends Controller // Initialisation de l'enregistrement $data = new Niveau01(); + // Interdit pour les modos + if($this->getUser()->getRole()=="ROLE_MODO") + throw $this->createNotFoundException('Permission denied'); + // Création du formulaire $form = $this->createForm(Niveau01Type::class,$data,array( "mode" => "submit", @@ -136,10 +162,16 @@ class Niveau01Controller extends Controller public function updateAction($id,Request $request) { + $em = $this->getDoctrine()->getManager(); + // Récupération de l'enregistrement courant $data=$this->getData($id); - // Vérifier que cet enregistrement est modifiable + // Modification modo que si niveau modéré + if($this->getUser()->getRole()=="ROLE_MODO") { + $usermodo=$em->getRepository("CadolesCoreBundle:UserModo")->findOneBy(["user"=>$this->getUser(),"niveau01"=>$data]); + if(!$usermodo) throw $this->createNotFoundException('Permission denied'); + } // Création du formulaire $form = $this->createForm(Niveau01Type::class,$data,array( @@ -156,7 +188,6 @@ class Niveau01Controller extends Controller // Sur validation if ($form->get('submit')->isClicked() && $form->isValid()) { - $em = $this->getDoctrine()->getManager(); $data = $form->getData(); // Sauvegarde @@ -184,7 +215,9 @@ class Niveau01Controller extends Controller // Récupération de l'enregistrement courant $data=$this->getData($id); - // Vérifier que cet enregistrement est supprimable + // Interdit pour les modos + if($this->getUser()->getRole()=="ROLE_MODO") + throw $this->createNotFoundException('Permission denied'); // Création du formulaire $form = $this->createForm(Niveau01Type::class,$data,array( @@ -228,6 +261,15 @@ class Niveau01Controller extends Controller ]); } + public function headerAction() + { + return $this->render('CadolesCoreBundle:Niveau01:header.html.twig',[ + 'useheader' => false, + 'usemenu' => false, + 'usesidebar' => false, + ]); + } + protected function getDatas() { $em = $this->getDoctrine()->getManager(); diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/Niveau02Controller.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/Niveau02Controller.php index a64c1b4a..5daf5e9a 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/Niveau02Controller.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/Niveau02Controller.php @@ -43,22 +43,45 @@ class Niveau02Controller extends Controller $draw= $request->query->get('draw'); $order= $request->query->get('order'); + // Modo ? + $ismodo=false; + if($this->getUser()->getRole()=="ROLE_MODO") { + $ismodo=true; + } + + // Nombre total d'enregistrement - $total = $em->createQueryBuilder()->select('COUNT(table)')->from($this->labelentity,'table')->getQuery()->getSingleScalarResult(); + if($ismodo) { + $total = $em->createQueryBuilder()->select('COUNT(table)') + ->from($this->labelentity,'table') + ->from("CadolesCoreBundle:UserModo","usermodo") + ->Where("table.niveau01=usermodo.niveau01") + ->andWhere("usermodo.user=:user") + ->setParameter("user",$this->getUser()) + ->getQuery()->getSingleScalarResult(); + } + else + $total = $em->createQueryBuilder()->select('COUNT(table)')->from($this->labelentity,'table')->getQuery()->getSingleScalarResult(); // Nombre d'enregistrement filtré if($search["value"]=="") $totalf = $total; else { - $totalf= $em->createQueryBuilder() + $qb = $em ->createQueryBuilder() ->select('COUNT(table)') ->from($this->labelentity,'table') ->from("CadolesCoreBundle:Niveau01",'nv1') ->where('table.niveau01=nv1.id') ->andwhere('table.label LIKE :value or nv1.label LIKE :value') - ->setParameter("value", "%".$search["value"]."%") - ->getQuery() - ->getSingleScalarResult(); + ->setParameter("value", "%".$search["value"]."%"); + if($ismodo) { + $qb ->from("CadolesCoreBundle:UserModo","usermodo") + ->andwhere("table.niveau01=usermodo.niveau01") + ->andWhere("usermodo.user=:user") + ->setParameter("user",$this->getUser()); + } + + $totalf = $qb->getQuery()->getSingleScalarResult(); } // Construction du tableau de retour @@ -79,6 +102,13 @@ class Niveau02Controller extends Controller $qb ->andwhere('table.label LIKE :value or nv1.label LIKE :value') ->setParameter("value", "%".$search["value"]."%"); } + if($ismodo) { + $qb->from("CadolesCoreBundle:UserModo","usermodo") + ->andWhere("table.niveau01=usermodo.niveau01") + ->andWhere("usermodo.user=:user") + ->setParameter("user",$this->getUser()); + } + switch($order[0]["column"]) { case 1 : $qb->orderBy('nv1.label',$order[0]["dir"]); @@ -107,7 +137,7 @@ class Niveau02Controller extends Controller $data = new Niveau02(); // Création du formulaire - $form = $this->createForm(Niveau02Type::class,$data,array("mode"=>"submit")); + $form = $this->createForm(Niveau02Type::class,$data,array("mode"=>"submit","user"=>$this->getUser())); // Récupération des data du formulaire $form->handleRequest($request); @@ -141,13 +171,19 @@ class Niveau02Controller extends Controller public function updateAction($id,Request $request) { + $em = $this->getDoctrine()->getManager(); + // Récupération de l'enregistrement courant $data=$this->getData($id); - // Vérifier que cet enregistrement est modifiable + // Suppression modo que si niveau modéré + if($this->getUser()->getRole()=="ROLE_MODO") { + $usermodo=$em->getRepository("CadolesCoreBundle:UserModo")->findOneBy(["user"=>$this->getUser(),"niveau01"=>$data->getNiveau01()]); + if(!$usermodo) throw $this->createNotFoundException('Permission denied'); + } // Création du formulaire - $form = $this->createForm(Niveau02Type::class,$data,array("mode"=>"update")); + $form = $this->createForm(Niveau02Type::class,$data,array("mode"=>"update","user"=>$this->getUser())); // Récupération des data du formulaire $form->handleRequest($request); @@ -157,7 +193,6 @@ class Niveau02Controller extends Controller // Sur validation if ($form->get('submit')->isClicked() && $form->isValid()) { - $em = $this->getDoctrine()->getManager(); $data = $form->getData(); // Sauvegarde @@ -182,13 +217,19 @@ class Niveau02Controller extends Controller public function deleteAction($id,Request $request) { + $em = $this->getDoctrine()->getManager(); + // Récupération de l'enregistrement courant $data=$this->getData($id); - // Vérifier que cet enregistrement est supprimable + // Suppression modo que si niveau modéré + if($this->getUser()->getRole()=="ROLE_MODO") { + $usermodo=$em->getRepository("CadolesCoreBundle:UserModo")->findOneBy(["user"=>$this->getUser(),"niveau01"=>$data->getNiveau01()]); + if(!$usermodo) throw $this->createNotFoundException('Permission denied'); + } // Création du formulaire - $form = $this->createForm(Niveau02Type::class,$data,array("mode"=>"delete")); + $form = $this->createForm(Niveau02Type::class,$data,array("mode"=>"delete","user"=>$this->getUser())); // Récupération des data du formulaire $form->handleRequest($request); @@ -198,7 +239,6 @@ class Niveau02Controller extends Controller // Sur validation if ($form->get('submit')->isClicked() && $form->isValid()) { - $em = $this->getDoctrine()->getManager(); $em->remove($data); $em->flush(); diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Niveau01.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Niveau01.php index d822d2c7..da3c7c63 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Niveau01.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Niveau01.php @@ -44,6 +44,36 @@ class Niveau01 */ private $logo; + /** + * @ORM\Column(type="text", nullable=true) + */ + private $header; + + /** + * @ORM\Column(type="text", nullable=true) + */ + private $colormain; + + /** + * @ORM\Column(type="text", nullable=true) + */ + private $fontcolorhover; + + /** + * @ORM\Column(type="text", nullable=true) + */ + private $colorbody; + + /** + * @ORM\Column(type="text", nullable=true) + */ + private $fontfacetitle; + + /** + * @ORM\Column(type="text", nullable=true) + */ + private $fontfacebody; + /** * @ORM\Column(type="text", nullable=true) */ @@ -465,4 +495,148 @@ class Niveau01 { return $this->alerts; } + + /** + * Set header + * + * @param string $header + * + * @return Niveau01 + */ + public function setHeader($header) + { + $this->header = $header; + + return $this; + } + + /** + * Get header + * + * @return string + */ + public function getHeader() + { + return $this->header; + } + + /** + * Set colormain + * + * @param string $colormain + * + * @return Niveau01 + */ + public function setColormain($colormain) + { + $this->colormain = $colormain; + + return $this; + } + + /** + * Get colormain + * + * @return string + */ + public function getColormain() + { + return $this->colormain; + } + + /** + * Set fontcolorhover + * + * @param string $fontcolorhover + * + * @return Niveau01 + */ + public function setFontcolorhover($fontcolorhover) + { + $this->fontcolorhover = $fontcolorhover; + + return $this; + } + + /** + * Get fontcolorhover + * + * @return string + */ + public function getFontcolorhover() + { + return $this->fontcolorhover; + } + + /** + * Set colorbody + * + * @param string $colorbody + * + * @return Niveau01 + */ + public function setColorbody($colorbody) + { + $this->colorbody = $colorbody; + + return $this; + } + + /** + * Get colorbody + * + * @return string + */ + public function getColorbody() + { + return $this->colorbody; + } + + /** + * Set fontfacetitle + * + * @param string $fontfacetitle + * + * @return Niveau01 + */ + public function setFontfacetitle($fontfacetitle) + { + $this->fontfacetitle = $fontfacetitle; + + return $this; + } + + /** + * Get fontfacetitle + * + * @return string + */ + public function getFontfacetitle() + { + return $this->fontfacetitle; + } + + /** + * Set fontfacebody + * + * @param string $fontfacebody + * + * @return Niveau01 + */ + public function setFontfacebody($fontfacebody) + { + $this->fontfacebody = $fontfacebody; + + return $this; + } + + /** + * Get fontfacebody + * + * @return string + */ + public function getFontfacebody() + { + return $this->fontfacebody; + } } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/EventListener/sessionListener.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/EventListener/sessionListener.php index bc702779..eafe98ca 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/EventListener/sessionListener.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/EventListener/sessionListener.php @@ -283,6 +283,25 @@ if(!is_null($niveau01->getLogo())) $session->set("sublogo", $niveau01->getLogo()); + if(!is_null($niveau01->getHeader())) + $session->set("header", $niveau01->getHeader()); + + if(!is_null($niveau01->getColormain())) + $session->set("colormain", $niveau01->getColormain()); + + if(!is_null($niveau01->getFontcolorhover())) + $session->set("fontcolorhover", $niveau01->getFontcolorhover()); + + if(!is_null($niveau01->getColorbody())) + $session->set("colorbody", $niveau01->getColorbody()); + + if(!is_null($niveau01->getFontfacebody())) + $session->set("fontfacebody", $niveau01->getFontfacebody()); + + if(!is_null($niveau01->getFontfacetitle())) + $session->set("fontfacetitle", $niveau01->getFontfacetitle()); + + } } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/Niveau01Type.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/Niveau01Type.php index ccdf3290..b5c8715a 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/Niveau01Type.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/Niveau01Type.php @@ -57,7 +57,68 @@ class Niveau01Type extends AbstractType ) ); + $choices=array( + "Helvetica" => "Helvetica", + "Peacesans" => "Peacesans", + "Acme-Regular" => "Acme-Regular", + "Redressed" => "Redressed", + "Roboto-Regular" => "Roboto-Regular", + "Justanotherhand-Regular" => "Justanotherhand-Regular", + "Lato-Regular" => "Lato-Regular", + + "ABeeZee-Regular" => "ABeeZee-Regular", + "AlfaSlabOne-Regular" => "AlfaSlabOne-Regular", + "Anton-Regular" => "Anton-Regular", + "FredokaOne-Regular" => "FredokaOne-Regular", + "Overpass-Black" => "Overpass-Black", + "Righteous-Regular" => "Righteous-Regular", + "Signika-Regular" => "Signika-Regular", + "Teko-Bold" => "Teko-Bold", + "LuckiestGuy-Regular" => "LuckiestGuy-Regular", + + "Baloo-Regular" => "Baloo-Regular", + "CarterOne-Regular" => "CarterOne-Regular", + "Chewy-Regular" => "Chewy-Regular", + "Courgette-Regular" => "Courgette-Regular", + "LexendDeca-Regular" => "LexendDeca-Regular", + "RubikMonoOne-Regular" => "RubikMonoOne-Regular", + "SigmarOne-Regular" => "SigmarOne-Regular", + "Viga-Regular" => "Viga-Regular", + ); + + $builder->add('colormain', + TextType::class, + array("label" => "Couleur principale", + "attr" => array("class" => "pick-a-color form-control"), + 'required' => false)); + + $builder->add('fontcolorhover', + TextType::class, + array("label" => "Couleur de texte sur couleur Principale", + "attr" => array("class" => "pick-a-color form-control"), + 'required' => false)); + + $builder->add('colorbody', + TextType::class, + array("label" => "Couleur de fond des pages", + "attr" => array("class" => "pick-a-color form-control"), + 'required' => false)); + + $builder->add("fontfacebody", ChoiceType::class, + array("label" =>"Police principale", + "attr" => array("class" => "form-control"), + 'required' => false, + "choices" => $choices)); + + $builder->add("fontfacetitle", ChoiceType::class, + array("label" =>"Police pour les titres", + "attr" => array("class" => "form-control"), + 'required' => false, + "choices" => $choices)); + + $builder->add('logo',HiddenType::class); + $builder->add('header',HiddenType::class); // Si masteridentity = LDAP alors on demande obligatoirement le filtre des utilisateurs qui appartiennent à ce niveau01 if($options["masteridentity"]=="LDAP") diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/Niveau02Type.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/Niveau02Type.php index a879ab5a..48d3b3df 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/Niveau02Type.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/Niveau02Type.php @@ -18,6 +18,7 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityManager; +use Doctrine\ORM\Query\Expr\Join; class Niveau02Type extends AbstractType { @@ -31,16 +32,37 @@ class Niveau02Type extends AbstractType ) ); - $builder->add('niveau01', - EntityType::class, - array( - "class" => "CadolesCoreBundle:Niveau01", - "label" => $session->get('labelniveau01'), - "choice_label" => "label", - "disabled" => ($options["mode"]!="submit"?true:false), - "attr" => array("class" => "form-control", "style" => "margin-bottom:15px","readonly" => ($options["mode"]!="submit"?true:false)) - ) - ); + if($options["user"]->getRole()=="ROLE_MODO") { + $userid=$options["user"]->getId(); + $builder->add('niveau01', + EntityType::class, + array( + "class" => "CadolesCoreBundle:Niveau01", + "label" => $session->get('labelniveau01'), + "choice_label" => "label", + "disabled" => ($options["mode"]!="submit"?true:false), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px","readonly" => ($options["mode"]!="submit"?true:false)), + "query_builder"=> function (EntityRepository $er) use($userid) { + $result=$er->createQueryBuilder("table")->innerJoin("CadolesCoreBundle:UserModo", "usermodo", Join::WITH, "table.id = usermodo.niveau01"); + $result->andWhere("usermodo.user = :userid"); + $result->setParameter('userid', $userid); + return $result; + }, + ) + ); + } + else { + $builder->add('niveau01', + EntityType::class, + array( + "class" => "CadolesCoreBundle:Niveau01", + "label" => $session->get('labelniveau01'), + "choice_label" => "label", + "disabled" => ($options["mode"]!="submit"?true:false), + "attr" => array("class" => "form-control", "style" => "margin-bottom:15px","readonly" => ($options["mode"]!="submit"?true:false)) + ) + ); + } $builder->add('label', TextType::class, array( @@ -73,7 +95,8 @@ class Niveau02Type extends AbstractType { $resolver->setDefaults(array( 'data_class' => 'Cadoles\CoreBundle\Entity\Niveau02', - 'mode' => "string" + 'mode' => "string", + 'user' => 'Cadoles\CoreBundle\Entity\User', )); } } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml index cb6a5d13..bbfe07fd 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml @@ -327,6 +327,9 @@ cadoles_core_config_niveau01_logo: path: /config/niveau01/logo defaults: { _controller: CadolesCoreBundle:Niveau01:logo } +cadoles_core_config_niveau01_header: + path: /config/niveau01/header + defaults: { _controller: CadolesCoreBundle:Niveau01:header } #== Niveau02 ============================================================================================================= cadoles_core_config_niveau02: diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/themes/transnum/function.html.twig b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/themes/transnum/function.html.twig index a5dc1715..668fe9b9 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/themes/transnum/function.html.twig +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/themes/transnum/function.html.twig @@ -1,14 +1,14 @@ {% set logo = "transnum-logo.png" %} {% set fgheader = "" %} -{% set header = "transnum-header.png" %} +{% set header = "" %} {% set heightheader = "" %} -{% set colormain = "2176ad" %} +{% set colormain = "" %} {% set fontcolorhover = "" %} -{% set colorbody = "eeeeee" %} +{% set colorbody = "" %} -{% set fontfacetitle = "LexendDeca-Regular" %} +{% set fontfacetitle = "" %} {% set fontfacebody = "" %} {{ diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Niveau01/edit.html.twig b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Niveau01/edit.html.twig index b7799e5b..b5418f21 100755 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Niveau01/edit.html.twig +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Niveau01/edit.html.twig @@ -53,15 +53,56 @@ {% if masteridentity=="SSO" %} {{ form_row(form.attributes) }} {% endif %} + + -