diff --git a/.env b/.env index 3e36884..ecd7fb1 100644 --- a/.env +++ b/.env @@ -104,6 +104,9 @@ PROXY_USE=0 PROXY_HOST= PROXY_PORT= +# Audit +AUDIT_USE=0 + # Sonde statistic SONDE_USE=0 SONDE_URL= diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index a0a2977..31787fa 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -15,6 +15,7 @@ twig: appNiveau02label: '%appNiveau02label%' sondeUse: '%sondeUse%' sondeUrl: '%sondeUrl%' + auditUse: '%auditUse%' when@test: twig: diff --git a/config/routes.yaml b/config/routes.yaml index 3c504b1..f86600f 100644 --- a/config/routes.yaml +++ b/config/routes.yaml @@ -99,7 +99,7 @@ app_admin_config_logo: controller: App\Controller\ConfigController::logo defaults: { access: admin } -#== Theme ================================================================================================================ +#== Theme ======================================================================================================= #-- Access admin app_admin_theme: @@ -112,13 +112,13 @@ app_admin_theme_select: controller: App\Controller\ThemeController::select defaults: { name: "", access: admin } -#== API ================================================================================================================== +#== API ========================================================================================================= #-- Access visiteur app_rest: path: /docrest controller: App\Controller\HomeController::docrest -#== Cron ================================================================================================================= +#== Cron ======================================================================================================== #-- Access admin app_admin_cron: path: /admin/cron @@ -160,6 +160,25 @@ app_user_crop02: path: /user/crop02/{type}/{reportinput} controller: App\Controller\CropController::crop02 +#== Audit ======================================================================================================= + +#--Access admin +app_admin_audit_renderid: + path: /admin/audit/{entityname}/{entityid} + controller: App\Controller\AuditController::auditrender + defaults: { access: admin } + +#--Access admin +app_admin_audit_render: + path: /admin/audit/{entityname} + controller: App\Controller\AuditController::list + defaults: { access: admin } + +#--Access modo +app_modo_audit_renderid: + path: /modo/audit/{entityname}/{entityid} + controller: App\Controller\AuditController::auditrender + defaults: { access: modo } #== Niveau01 ==================================================================================================== #-- Access admin @@ -408,7 +427,7 @@ app_user_group_userout: controller: App\Controller\GroupController::userout defaults: { access: user } -#== Whitelist ============================================================================================================ +#== Whitelist =================================================================================================== #-- Access admin app_admin_whitelist: path: /admin/whitelist diff --git a/config/services.yaml b/config/services.yaml index 4f82c94..94423db 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -95,6 +95,8 @@ parameters: sondeUse: '%env(resolve:SONDE_USE)%' sondeUrl: '%env(resolve:SONDE_URL)%' + auditUse: '%env(resolve:AUDIT_USE)%' + services: _defaults: autowire: true # Automatically injects dependencies in your services. diff --git a/migrations/Version20220726082214.php b/migrations/Version20220726082214.php new file mode 100644 index 0000000..8b2841b --- /dev/null +++ b/migrations/Version20220726082214.php @@ -0,0 +1,34 @@ +addSql('CREATE TABLE audit (id INT NOT NULL, entityname VARCHAR(250) NOT NULL, entityid VARCHAR(250) NOT NULL, datesubmit TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, username VARCHAR(250) NOT NULL, description TEXT DEFAULT NULL, detail TEXT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX search_idx ON audit (entityname, entityid, datesubmit)'); + $this->addSql('COMMENT ON COLUMN audit.detail IS \'(DC2Type:array)\''); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('DROP TABLE audit'); + } +} diff --git a/src/Command/CronCommand.php b/src/Command/CronCommand.php index 887f783..e347d4a 100644 --- a/src/Command/CronCommand.php +++ b/src/Command/CronCommand.php @@ -72,7 +72,6 @@ class CronCommand extends Command $now=new \DateTime(); $cron->setStartexecdate($now); //$cron->setStatut(1); - $this->em->persist($cron); $this->em->flush(); // Récupération de la commande @@ -109,7 +108,6 @@ class CronCommand extends Command // Statut OK/KO $cron->setStatut(($returnCode==Command::FAILURE?0:1)); - $this->em->persist($cron); $this->em->flush(); } diff --git a/src/Command/SynchroCommand.php b/src/Command/SynchroCommand.php index d0a18a4..a2fd0e9 100644 --- a/src/Command/SynchroCommand.php +++ b/src/Command/SynchroCommand.php @@ -496,6 +496,11 @@ class SynchroCommand extends Command $filter="gidnumber=".$group->getId(); $ldapentrys=$this->ldap->search($filter,$attributes,$this->basegroup); if(empty($ldapentrys)) { + $filter=str_replace("*",$group->getLabel(),$this->filtergroup); + $ldapentrys=$this->ldap->search($filter,$attributes,$this->baseniveau01); + } + + if(empty($ldapentrys)) { $this->writeln($group->getLabel()." = SUBMIT"); $this->ldap->addGroup($group); } @@ -522,6 +527,11 @@ class SynchroCommand extends Command foreach($niveau02s as $niveau02) { $filter="gidnumber=".$niveau02->getId(); $ldapentrys=$this->ldap->search($filter,$attributes,$this->baseniveau02); + if(empty($ldapentrys)) { + $filter=str_replace("*",$niveau02->getLabel(),$this->filtergroup); + $ldapentrys=$this->ldap->search($filter,$attributes,$this->baseniveau01); + } + if(empty($ldapentrys)) { $this->writeln($niveau02->getLabel()." = SUBMIT"); $this->ldap->addNiveau02($niveau02); @@ -554,6 +564,11 @@ class SynchroCommand extends Command $filter="gidnumber=".$niveau01->getId(); $ldapentrys=$this->ldap->search($filter,$attributes,$this->baseniveau01); + if(empty($ldapentrys)) { + $filter=str_replace("*",$niveau01->getLabel(),$this->filtergroup); + $ldapentrys=$this->ldap->search($filter,$attributes,$this->baseniveau01); + } + if(empty($ldapentrys)) { $this->writeln($niveau01->getLabel()." = SUBMIT"); $this->ldap->addNiveau01($niveau01); diff --git a/src/Controller/AuditController.php b/src/Controller/AuditController.php new file mode 100644 index 0000000..726ce18 --- /dev/null +++ b/src/Controller/AuditController.php @@ -0,0 +1,59 @@ +getRepository($this->entity)->findBy(["entityname"=>$entityname]); + + return $this->render($this->twig.'list.html.twig',[ + $this->data."s" => $datas, + "entityname" => $entityname, + "useheader"=>true, + "usemenu"=>false, + "usesidebar"=>true, + ]); + } + + public function auditrender($entityname,$entityid,$access,ManagerRegistry $em): Response + { + $datas = $em->getRepository($this->entity)->findBy(["entityname"=>$entityname,"entityid"=>$entityid]); + + /* + if($entityname=="User") { + $user=$em->getRepository("App\Entity\User")->find($entityid); + if($user) { + foreach($user->getModos() as $usermodo) { + $auditusermods=$em->getRepository($this->entity)->findBy(["entityname"=>"UserModo","entityid"=>$usermodo->getId()]); + foreach($auditusermods as $auditusermod) { + $usermodo=$em->getRepository("App\Entity\UserModo")->find($auditusermod->getEntityid()); + $niveau01=$em->getRepository("App\Entity\Niveau01")->find($usermodo->getNiveau01()->getId()); + + $auditusermod->setDescription($auditusermod->getDescription()." UserModo"); + $auditusermod->setDetail([$niveau01->getId()." = ".$niveau01->getLabel()]); + } + $datas=array_merge($datas,$auditusermods); + } + } + } + */ + + return $this->render($this->twig.'render.html.twig',[ + $this->data."s" => $datas, + ]); + } +} \ No newline at end of file diff --git a/src/Controller/ConfigController.php b/src/Controller/ConfigController.php index bbf5ffa..2c940e6 100644 --- a/src/Controller/ConfigController.php +++ b/src/Controller/ConfigController.php @@ -22,6 +22,7 @@ class ConfigController extends AbstractController "useheader"=>true, "usemenu"=>false, "usesidebar"=>true, + "access"=>$access, ]); } diff --git a/src/Controller/CronController.php b/src/Controller/CronController.php index 3a3848f..04d0dfa 100644 --- a/src/Controller/CronController.php +++ b/src/Controller/CronController.php @@ -20,12 +20,13 @@ class CronController extends AbstractController private $twig="Cron/"; private $route="app_admin_cron"; - public function list(): Response + public function list($access): Response { return $this->render($this->twig.'list.html.twig',[ "useheader"=>true, "usemenu"=>false, "usesidebar"=>true, + "access"=>$access, ]); } @@ -104,7 +105,7 @@ class CronController extends AbstractController return new JsonResponse($output); } - public function update($id,Request $request,ManagerRegistry $em): Response + public function update($id,$access,Request $request,ManagerRegistry $em): Response { // Initialisation de l'enregistrement $data=$em->getRepository($this->entity)->find($id); @@ -134,7 +135,8 @@ class CronController extends AbstractController 'usesidebar' => true, $this->data => $data, 'mode' => 'update', - 'form' => $form->createView() + 'form' => $form->createView(), + 'access' => $access, ]); } diff --git a/src/Controller/Niveau01Controller.php b/src/Controller/Niveau01Controller.php index 45202c2..a6f29b4 100644 --- a/src/Controller/Niveau01Controller.php +++ b/src/Controller/Niveau01Controller.php @@ -19,12 +19,13 @@ class Niveau01Controller extends AbstractController private $twig="Niveau01/"; private $route="app_admin_niveau01"; - public function list(): Response + public function list($access): Response { return $this->render($this->twig.'list.html.twig',[ "useheader"=>true, "usemenu"=>false, "usesidebar"=>true, + "access"=>$access, ]); } @@ -100,7 +101,7 @@ class Niveau01Controller extends AbstractController } - public function submit(Request $request,ManagerRegistry $em): Response + public function submit($access,Request $request,ManagerRegistry $em): Response { // Initialisation de l'enregistrement $data = new Entity(); @@ -137,10 +138,11 @@ class Niveau01Controller extends AbstractController "mode"=>"submit", "form"=>$form->createView(), $this->data=>$data, + "access"=>$access, ]); } - public function update($id,Request $request,ManagerRegistry $em): Response + public function update($id,$access,Request $request,ManagerRegistry $em): Response { // Initialisation de l'enregistrement $data=$em->getRepository($this->entity)->find($id); @@ -173,11 +175,12 @@ class Niveau01Controller extends AbstractController 'usesidebar' => true, $this->data => $data, 'mode' => 'update', - 'form' => $form->createView() + 'form' => $form->createView(), + "access" => $access ]); } - public function delete($id,Request $request,ManagerRegistry $em): Response + public function delete($id,$access,Request $request,ManagerRegistry $em): Response { // Récupération de l'enregistrement courant $data=$em->getRepository($this->entity)->find($id); diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php index 17b8b9f..5362ff6 100755 --- a/src/Controller/RegistrationController.php +++ b/src/Controller/RegistrationController.php @@ -219,7 +219,7 @@ class RegistrationController extends AbstractController $data->setStatut($idstatut); // Sur erreur - $this->getErrorForm(null,$form,$request,$data,"submit",$idstatut); + $this->getErrorForm(null,$form,$request,$data,"submit",$idstatut,$em); // Sur validation if ($form->get('submit')->isClicked() && $form->isValid()) { @@ -710,7 +710,7 @@ class RegistrationController extends AbstractController throw $this->createAccessDeniedException('Permission denied'); } - protected function getErrorForm($id,$form,$request,$data,$mode,$idstatut) { + protected function getErrorForm($id,$form,$request,$data,$mode,$idstatut,$em) { if ($form->get('submit')->isClicked() && $mode=="submit") { // Si validation par administrateur demander une motivation $appmoderegistration = $this->getParameter('appModeregistration'); @@ -718,7 +718,7 @@ class RegistrationController extends AbstractController // On recherche le domaine du mail dans la liste blanche $email=explode("@",$data->getEmail()); $domaine=end($email); - $whitelist = $this->getDoctrine()->getManager()->getRepository("App\Entity\Whitelist")->findBy(["label"=>$domaine]); + $whitelist = $em->getManager()->getRepository("App\Entity\Whitelist")->findBy(["label"=>$domaine]); if(!$whitelist) $form->addError(new FormError("Attention, le suffixe de votre adresse mail n’est pas dans la liste des administrations autorisées, merci de bien vouloir privilégier votre adresse professionnelle si vous en avez une.
Si ce n’est pas le cas, il faut que vous renseigniez la case motivation de votre demande")); } diff --git a/src/Controller/WhitelistController.php b/src/Controller/WhitelistController.php index cb73aff..735419b 100644 --- a/src/Controller/WhitelistController.php +++ b/src/Controller/WhitelistController.php @@ -18,12 +18,13 @@ class WhitelistController extends AbstractController private $twig="Whitelist/"; private $route="app_admin_whitelist"; - public function list(): Response + public function list($access): Response { return $this->render($this->twig.'list.html.twig',[ "useheader"=>true, "usemenu"=>false, "usesidebar"=>true, + "access"=>$access, ]); } @@ -98,7 +99,7 @@ class WhitelistController extends AbstractController return new JsonResponse($output); } - public function submit(Request $request,ManagerRegistry $em): Response + public function submit($access,Request $request,ManagerRegistry $em): Response { // Initialisation de l'enregistrement $data = new Entity(); @@ -129,10 +130,11 @@ class WhitelistController extends AbstractController "mode"=>"submit", "form"=>$form->createView(), $this->data=>$data, + "access"=>$access, ]); } - public function update($id,Request $request,ManagerRegistry $em): Response + public function update($id,$access,Request $request,ManagerRegistry $em): Response { // Initialisation de l'enregistrement $data=$em->getRepository($this->entity)->find($id); @@ -160,11 +162,12 @@ class WhitelistController extends AbstractController 'usesidebar' => true, $this->data => $data, 'mode' => 'update', - 'form' => $form->createView() + 'form' => $form->createView(), + "access"=>$access, ]); } - public function delete($id,Request $request,ManagerRegistry $em): Response + public function delete($id,$access,Request $request,ManagerRegistry $em): Response { // Récupération de l'enregistrement courant $data=$em->getRepository($this->entity)->find($id); diff --git a/src/Entity/Audit.php b/src/Entity/Audit.php new file mode 100644 index 0000000..1f79860 --- /dev/null +++ b/src/Entity/Audit.php @@ -0,0 +1,132 @@ +id; + } + + public function getEntityname(): ?string + { + return $this->entityname; + } + + public function setEntityname(string $entityname): self + { + $this->entityname = $entityname; + + return $this; + } + + public function getEntityid(): ?string + { + return $this->entityid; + } + + public function setEntityid(string $entityid): self + { + $this->entityid = $entityid; + + return $this; + } + + public function getDatesubmit(): ?\DateTimeInterface + { + return $this->datesubmit; + } + + public function setDatesubmit(\DateTimeInterface $datesubmit): self + { + $this->datesubmit = $datesubmit; + + return $this; + } + + public function getUsername(): ?string + { + return $this->username; + } + + public function setUsername(string $username): self + { + $this->username = $username; + + return $this; + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function setDescription(?string $description): self + { + $this->description = $description; + + return $this; + } + + public function getDetail(): array + { + return $this->detail; + } + + public function setDetail(?array $detail): self + { + $this->detail = $detail; + + return $this; + } + +} + diff --git a/src/EventListener/AllSubscriber.php b/src/EventListener/AllSubscriber.php index c07479f..67f30e1 100644 --- a/src/EventListener/AllSubscriber.php +++ b/src/EventListener/AllSubscriber.php @@ -5,15 +5,32 @@ namespace App\EventListener; use Doctrine\Bundle\DoctrineBundle\EventSubscriber\EventSubscriberInterface; use Doctrine\ORM\Events; use Doctrine\Persistence\Event\LifecycleEventArgs; +use Doctrine\ORM\Event\OnFlushEventArgs; +use Doctrine\ORM\EntityManagerInterface; +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; +use Doctrine\ORM\Proxy\Proxy; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; + +use App\Entity\Audit as Audit; class AllSubscriber implements EventSubscriberInterface { private $entity; + private $token; + private $params; + + public function __construct(EntityManagerInterface $em, TokenStorageInterface $token,ParameterBagInterface $params) + { + $this->em = $em; + $this->token = $token; + $this->params = $params; + } public function getSubscribedEvents(): array { return [ Events::preRemove, + Events::onFlush, ]; } @@ -25,4 +42,156 @@ class AllSubscriber implements EventSubscriberInterface if($this->entity->getId()<0) throw new \Exception("Impossible de supprimer cet enregistrement. C'est un enregistrement système"); } + + public function onFlush(OnFlushEventArgs $eventArgs): void + { + $this->entity = $eventArgs->getEntityManager(); + + if ($this->entity instanceof Audit||!$this->params->get("auditUse")) return; + $this->audit(); + } + + private function audit() { + $token = $this->token->getToken(); + if(!$token)$user="job"; + else { + $user=$token->getUser(); + if($user!="anon.") $user = $user->getUsername(); + else $user="job"; + } + + $uow = $this->em->getUnitOfWork(); + $uow->computeChangeSets(); + + foreach ($uow->getScheduledEntityInsertions() as $entity) { + $metaCar = $this->em->getClassMetadata(get_class($entity)); + $className=str_replace("App\\Entity\\","",$metaCar->getName()); + + $nameold=""; + if($metaCar->hasField("name")) + $nameold=" = ".$entity>getName(); + elseif($metaCar->hasField("label")) + $nameold=" = ".$entity->getLabel(); + elseif($metaCar->hasField("username")) + $nameold=" = ".$entity->getUsername(); + + $audit=new Audit(); + $audit->setDatesubmit(new \DateTime("now")); + $audit->setEntityname($className); + $audit->setEntityid($entity->getId()); + $audit->setUsername($user); + $audit->setDescription("SUBMIT"); + $audit->setDetail(["id"=>$entity->getId().$nameold]); + + $this->em->persist($audit); + $uow->computeChangeSet($this->em->getClassMetadata(get_class($audit)), $audit); + } + + foreach ($uow->getScheduledEntityDeletions() as $entity) { + $metaCar = $this->em->getClassMetadata(get_class($entity)); + $className=str_replace("App\\Entity\\","",$metaCar->getName()); + + $nameold=""; + if($metaCar->hasField("name")) + $nameold=" = ".$entity>getName(); + elseif($metaCar->hasField("label")) + $nameold=" = ".$entity->getLabel(); + elseif($metaCar->hasField("username")) + $nameold=" = ".$entity->getUsername(); + + $audit=new Audit(); + $audit->setDatesubmit(new \DateTime("now")); + $audit->setEntityname($className); + $audit->setEntityid($entity->getId()); + $audit->setUsername($user); + $audit->setDescription("DELETE"); + $audit->setDetail(["id"=>$entity->getId().$nameold]); + + $this->em->persist($audit); + $uow->computeChangeSet($this->em->getClassMetadata(get_class($audit)), $audit); + } + + foreach ($uow->getScheduledEntityUpdates() as $entity) { + $changeSet = $uow->getEntityChangeSet($entity); + + // Unaudit field + $className = str_replace("App\\Entity\\","",$this->em->getClassMetadata(get_class($entity))->getName()); + switch($className) { + case "Audit": + $changeSet=null; + break; + + case "User": + unset($changeSet["visitecpt"]); + unset($changeSet["visitedate"]); + unset($changeSet["preference"]); + unset($changeSet["keyvalue"]); + unset($changeSet["keyexpire"]); + unset($changeSet["apikey"]); + unset($changeSet["password"]); + unset($changeSet["passwordplain"]); + unset($changeSet["salt"]); + break; + + + default: + unset($changeSet["apikey"]); + break; + } + + if ($changeSet) { + $mychange=[]; + foreach($changeSet as $key => $value) { + // Le champs modifié est-il une entité + $isentity0=($value[0]&&is_object($value[0])&&get_class($value[0])&&get_class($value[0])!="DateTime"); + $isentity1=($value[1]&&is_object($value[1])&&get_class($value[1])&&get_class($value[1])!="DateTime"); + + if($isentity0||$isentity1) { + $nameold=""; + if($isentity0) { + $metaCar = $this->em->getClassMetadata(get_class($value[0])); + if($metaCar->hasField("name")) + $nameold=" = ".$value[0]->getName(); + elseif($metaCar->hasField("label")) + $nameold=" = ".$value[0]->getLabel(); + elseif($metaCar->hasField("username")) + $nameold=" = ".$value[0]->getUsername(); + + $nameold= $value[0]->getId().$nameold; + } + + + $namenew=""; + if($isentity1) { + $metaCar = $this->em->getClassMetadata(get_class($value[1])); + if($metaCar->hasField("name")) + $namenew=" = ".$value[1]->getName(); + elseif($metaCar->hasField("label")) + $namenew=" = ".$value[1]->getLabel(); + elseif($metaCar->hasField("username")) + $namenew=" = ".$value[1]->getUsername(); + + $namenew= $value[1]->getId().$namenew; + } + + $mychange[$key]=[$nameold,$namenew]; + } + else $mychange[$key]=$value; + + } + $audit=new Audit(); + $audit->setDatesubmit(new \DateTime("now")); + $audit->setEntityname($className); + $audit->setEntityid($entity->getId()); + $audit->setUsername($user); + $audit->setDescription("UPDATE"); + $audit->setDetail($mychange); + + $this->em->persist($audit); + $uow->computeChangeSet($this->em->getClassMetadata(get_class($audit)), $audit); + } + } + } + + } diff --git a/src/EventListener/GroupSubscriber.php b/src/EventListener/GroupSubscriber.php index c36aaeb..45594dc 100644 --- a/src/EventListener/GroupSubscriber.php +++ b/src/EventListener/GroupSubscriber.php @@ -117,8 +117,10 @@ class GroupSubscriber implements EventSubscriberInterface // Le propriétaire passe manager $usergroups=$this->em->getRepository("App\Entity\UserGroup")->findBy(["group"=>$group,"rolegroup"=>"100"]); foreach($usergroups as $usergroup) { - $usergroup->setRolegroup(90); - $this->em->flush(); + if($usergroup->getUser()!=$group->getOwner()) { + $usergroup->setRolegroup(90); + $this->em->flush(); + } } // Le propriétaire prend son role dans le groupe @@ -129,10 +131,14 @@ class GroupSubscriber implements EventSubscriberInterface $usergroup->setUser($group->getOwner()); $usergroup->setGroup($group); $usergroup->setApikey(Uuid::uuid4()); + $usergroup->setRolegroup(100); + $this->em->persist($usergroup); + $this->em->flush(); + } + elseif($usergroup->getRolegroup()!=100) { + $usergroup->setRolegroup(100); + $this->em->flush(); } - $usergroup->setRolegroup(100); - $this->em->persist($usergroup); - $this->em->flush(); } } } diff --git a/src/Repository/AuditRepository.php b/src/Repository/AuditRepository.php new file mode 100644 index 0000000..c58b15d --- /dev/null +++ b/src/Repository/AuditRepository.php @@ -0,0 +1,33 @@ +getEntityManager()->persist($entity); + + if ($flush) { + $this->getEntityManager()->flush(); + } + } + + public function remove(Audit $entity, bool $flush = false): void + { + $this->getEntityManager()->remove($entity); + + if ($flush) { + $this->getEntityManager()->flush(); + } + } +} diff --git a/src/Service/AppSession.php b/src/Service/AppSession.php index 0bcf9f6..795f222 100644 --- a/src/Service/AppSession.php +++ b/src/Service/AppSession.php @@ -49,6 +49,7 @@ // Préférence par défaut $session->set("fgheader", true); + $session->set("fgaudit", false); // Préférence if($curentuser!="anon.") { @@ -59,6 +60,12 @@ $fgheader=($preference["fgheader"][0]=="true"); $session->set("fgheader", $fgheader); } + + // Préférence audit + if(array_key_exists("fgaudit",$preference)) { + $fgaudit=($preference["fgaudit"][0]=="true"); + $session->set("fgaudit", $fgaudit); + } } } diff --git a/templates/Audit/list.html.twig b/templates/Audit/list.html.twig new file mode 100644 index 0000000..ad0d0cb --- /dev/null +++ b/templates/Audit/list.html.twig @@ -0,0 +1,66 @@ +{% extends "base.html.twig" %} + +{% block body %} +

+AUDIT {{ entityname }} +

+ +
+
+ Audit +
+ +
+ + + + + + + + + + + + + {% for audit in audits|reverse %} + + + + + + + + {% endfor %} + +
DateParActionIdDétail
{{audit.datesubmit|date("d/m/Y H:i")}}{{audit.username}}{{audit.description}}{{audit.entityid}} + + {% for key, detail in audit.detail %} + {% if audit.description=="UPDATE" %} + {{key}} = + de {%if detail[0] is empty%}null {%else%}{{detail[0]|join(', ')}}{%endif%} + à {%if detail[1] is empty%}null {%else%} {{detail[1]|join(', ')}}{%endif%} +
+ {% else %} + id {{detail}} + {% endif %} + {% endfor %} +
+
+
+
+ +{% endblock %} + +{% block localscript %} + +{% endblock %} \ No newline at end of file diff --git a/templates/Audit/render.html.twig b/templates/Audit/render.html.twig new file mode 100644 index 0000000..777aa47 --- /dev/null +++ b/templates/Audit/render.html.twig @@ -0,0 +1,68 @@ + +
+
+ Audit +
+ {%if not app.session.get("fgaudit")%}Afficher{%else%}Masquer{%endif%}
+
+ +
+ + + + + + + + + + + + {% for audit in audits|reverse %} + + + + + + + {% endfor %} + +
DateParActionDétail
{{audit.datesubmit|date("d/m/Y H:i")}}{{audit.username}}{{audit.description}} + + {% for key, detail in audit.detail %} + {% if audit.description=="UPDATE" %} + {{key}} = + de {%if detail[0] is empty%}null {%else%}{{detail[0]|join(', ')}}{%endif%} + à {%if detail[1] is empty%}null {%else%} {{detail[1]|join(', ')}}{%endif%} +
+ {% else %} + id {{detail}} + {% endif %} + {% endfor %} +
+
+
+
+ + \ No newline at end of file diff --git a/templates/Config/list.html.twig b/templates/Config/list.html.twig index 0cd5dd6..7679626 100644 --- a/templates/Config/list.html.twig +++ b/templates/Config/list.html.twig @@ -5,6 +5,10 @@ CONFIGURATIONS +{% if auditUse and (access=="admin" or access=="audit") %} + Audit +

+{% endif %}
diff --git a/templates/Cron/edit.html.twig b/templates/Cron/edit.html.twig index 0021824..f35e003 100644 --- a/templates/Cron/edit.html.twig +++ b/templates/Cron/edit.html.twig @@ -45,6 +45,13 @@ {{ form_row(form.nextexecdate) }}
+ + + {% if auditUse and mode=="update" and (access=="admin" or access=="modo" or access=="audit") %} +
+ {{ render(path("app_"~access~"_audit_renderid",{entityname:"Cron",entityid:cron.id})) }} +
+ {% endif %} {{ form_end(form) }} {% endblock %} diff --git a/templates/Cron/list.html.twig b/templates/Cron/list.html.twig index 697a335..d7208eb 100644 --- a/templates/Cron/list.html.twig +++ b/templates/Cron/list.html.twig @@ -4,6 +4,10 @@

CRON JOBS

+ {% if auditUse and (access=="admin" or access=="audit") %} + Audit +

+ {% endif %}
diff --git a/templates/Group/edit.html.twig b/templates/Group/edit.html.twig index 4667318..aa00858 100755 --- a/templates/Group/edit.html.twig +++ b/templates/Group/edit.html.twig @@ -75,6 +75,12 @@
+ + {% if auditUse and mode=="update" and (access=="admin" or access=="modo" or access=="audit") %} +
+ {{ render(path("app_"~access~"_audit_renderid",{entityname:"Group",entityid:group.id})) }} +
+ {% endif %} {{ form_end(form) }} {% endblock %} diff --git a/templates/Group/list.html.twig b/templates/Group/list.html.twig index e1dad74..6f4ead3 100644 --- a/templates/Group/list.html.twig +++ b/templates/Group/list.html.twig @@ -3,12 +3,18 @@ {% block body %}

Gestion des Groupes

+

{%if access=="admin" %} -

Ajouter

+ Ajouter {%elseif access=="user" and app.session.get("submitgroup") %} -

Ajouter

+ Ajouter {% endif %} - + + {% if auditUse and (access=="admin" or access=="audit") %} + Audit + {% endif %} +

+
Liste des Groupes diff --git a/templates/Niveau01/edit.html.twig b/templates/Niveau01/edit.html.twig index 61e9d92..29fdf13 100755 --- a/templates/Niveau01/edit.html.twig +++ b/templates/Niveau01/edit.html.twig @@ -74,6 +74,12 @@ {% endif %}
+ + {% if auditUse and mode=="update" and (access=="admin" or access=="modo" or access=="audit") %} +
+ {{ render(path("app_"~access~"_audit_renderid",{entityname:"Niveau01",entityid:niveau01.id})) }} +
+ {% endif %} {{ form_end(form) }} {% endblock %} diff --git a/templates/Niveau01/list.html.twig b/templates/Niveau01/list.html.twig index 614b0d8..bcc2571 100644 --- a/templates/Niveau01/list.html.twig +++ b/templates/Niveau01/list.html.twig @@ -3,7 +3,12 @@ {% block body %}

Gestion des {{ appNiveau01label }}s

-

Ajouter

+

+ Ajouter + {% if auditUse and (access=="admin" or access=="audit") %} + Audit + {% endif %} +

diff --git a/templates/Niveau02/edit.html.twig b/templates/Niveau02/edit.html.twig index 24be361..3b66b80 100755 --- a/templates/Niveau02/edit.html.twig +++ b/templates/Niveau02/edit.html.twig @@ -56,5 +56,12 @@ {% endif %}
+ + + {% if auditUse and mode=="update" and (access=="admin" or access=="modo" or access=="audit") %} +
+ {{ render(path("app_"~access~"_audit_renderid",{entityname:"Niveau02",entityid:niveau02.id})) }} +
+ {% endif %} {{ form_end(form) }} {% endblock %} diff --git a/templates/Niveau02/list.html.twig b/templates/Niveau02/list.html.twig index e125ab0..5cbdc44 100644 --- a/templates/Niveau02/list.html.twig +++ b/templates/Niveau02/list.html.twig @@ -3,7 +3,12 @@ {% block body %}

Gestion des {{ appNiveau02label }}s

-

Ajouter

+

+ Ajouter + {% if auditUse and (access=="admin" or access=="audit") %} + Audit + {% endif %} +

diff --git a/templates/Registration/edit.html.twig b/templates/Registration/edit.html.twig index 7df9eef..5035046 100755 --- a/templates/Registration/edit.html.twig +++ b/templates/Registration/edit.html.twig @@ -144,6 +144,10 @@ {{ form_row(form.telephonenumber) }}
+ + {% if auditUse and mode=="update" and (access=="admin" or access=="modo" or access=="audit") %} + {{ render(path("app_"~access~"_audit_renderid",{entityname:"Registration",entityid:registration.id})) }} + {% endif %} {% endif %} diff --git a/templates/Registration/list.html.twig b/templates/Registration/list.html.twig index 48760dd..d892637 100644 --- a/templates/Registration/list.html.twig +++ b/templates/Registration/list.html.twig @@ -3,6 +3,13 @@ {% block body %}

Gestion des Inscriptions

+ {% if auditUse and (access=="admin" or access=="audit") %} + Audit +
+
+ {% endif %} + +
Liste des Inscription diff --git a/templates/User/edit.html.twig b/templates/User/edit.html.twig index afb12d8..9d32dba 100755 --- a/templates/User/edit.html.twig +++ b/templates/User/edit.html.twig @@ -247,10 +247,14 @@
- + {% if auditUse and mode=="update" and (access=="admin" or access=="modo" or access=="audit") %} + {{ render(path("app_"~access~"_audit_renderid",{entityname:"User",entityid:user.id})) }} + {% endif %} + +