From 8f85f5eb5e47e9d25cc2513eedfaf97886ef2065 Mon Sep 17 00:00:00 2001 From: afornerot Date: Tue, 23 Jun 2020 14:53:16 +0200 Subject: [PATCH] retour sur page groupe blog et calendrier (ref #168) --- .../Controller/BlogController.php | 21 +++++++++++- .../Controller/BlogarticleController.php | 34 +++++++++++++++++-- .../Controller/CalendarController.php | 22 +++++++++++- .../Controller/ProjectController.php | 3 +- .../Controller/ProjecttaskController.php | 2 +- .../Resources/views/Blog/view.html.twig | 7 +++- .../views/Blogarticle/edit.html.twig | 6 +++- .../views/Blogarticle/view.html.twig | 7 +++- .../Resources/views/Calendar/view.html.twig | 24 +++++++++---- .../views/Pagewidget/viewblog.html.twig | 7 ++-- .../views/Pagewidget/viewcalendar.html.twig | 2 +- .../views/Pagewidget/viewproject.html.twig | 2 +- .../Resources/views/Project/view.html.twig | 13 ++++--- 13 files changed, 124 insertions(+), 26 deletions(-) diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/BlogController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/BlogController.php index 255f8aa5..1d1953b9 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/BlogController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/BlogController.php @@ -352,6 +352,23 @@ class BlogController extends Controller if (!$entity) throw $this->createNotFoundException('Unable to find entity.'); } + // On recherche la premiere page associé au groupe du blog + $idpage=null; + $idgroup=null; + if($id!=0) { + $groups=$entity->getGroups(); + if($groups[0]) { + if($groups[0]->getFgcanshare()) { + $pages=$groups[0]->getPages(); + if($pages) { + $idpage=$pages[0]->getId(); + $groups=$pages[0]->getGroups(); + $idgroup=$groups[0]->getId(); + } + } + } + } + // Permissions $user=$this->getUser(); if($access=="config") { @@ -402,7 +419,9 @@ class BlogController extends Controller 'blogs' => $blogs, 'countarticles' => $count, 'pagination' => $pagination, - 'page' => $page + 'page' => $page, + 'idpage' => $idpage, + 'idgroup' => $idgroup ]); } diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/BlogarticleController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/BlogarticleController.php index af464a4a..f30d3d98 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/BlogarticleController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/BlogarticleController.php @@ -44,6 +44,13 @@ class BlogarticleController extends Controller $entity = new Blogarticle(); $blog=$em->getRepository("CadolesPortalBundle:Blog")->find($idblog); if($blog) $entity->setBlog($blog); + + $pageid=$request->get("page"); + if($pageid) { + $page=$em->getRepository("CadolesPortalBundle:Page")->find($pageid); + $groups=$page->getGroups(); + $idgroup=$groups[0]->getId(); + } $form = $this->entityForm($entity,$access); $form->handleRequest($request); @@ -68,7 +75,10 @@ class BlogarticleController extends Controller } } - return $this->redirect($this->generateUrl('cadoles_portal_'.$access.'_blogarticle_view',["id"=>$entity->getId()])); + if(is_null($pageid)) + return $this->redirect($this->generateUrl('cadoles_portal_'.$access.'_blogarticle_view',["id"=>$entity->getId()])); + else + return $this->redirect($this->generateUrl('cadoles_portal_'.$access.'_page_view',["id"=>$pageid,"usage"=>"group","group"=>$idgroup])); } return $this->render($this->labelentity.':edit.html.twig', [ @@ -79,7 +89,8 @@ class BlogarticleController extends Controller 'entity' => $entity, 'mode' => "submit", 'access' => $access, - 'form' => $form->createView() + 'form' => $form->createView(), + 'pageid' => $pageid ]); } @@ -160,6 +171,21 @@ class BlogarticleController extends Controller $entity = $em->getRepository($this->labelentity)->find($id); if (!$entity) throw $this->createNotFoundException('Unable to find entity.'); + // On recherche la premiere page associé au groupe du blog + $groups=$entity->getBlog()->getGroups(); + $idpage=null; + $idgroup=null; + if($groups[0]) { + if($groups[0]->getFgcanshare()) { + $pages=$groups[0]->getPages(); + if($pages) { + $idpage=$pages[0]->getId(); + $groups=$pages[0]->getGroups(); + $idgroup=$groups[0]->getId(); + } + } + } + // Permissions $user=$this->getUser(); if($access=="config") { @@ -200,7 +226,9 @@ class BlogarticleController extends Controller 'canupdate' => $canupdate, 'canadd' => $canadd, 'blogs' => $blogs, - 'blogarticles' => $blogarticles + 'blogarticles' => $blogarticles, + 'idpage' => $idpage, + 'idgroup' => $idgroup, ]); } diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/CalendarController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/CalendarController.php index 5a8b7eff..48f3fd6a 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/CalendarController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/CalendarController.php @@ -332,6 +332,23 @@ class CalendarController extends Controller if (!$entity) throw $this->createNotFoundException('Unable to find entity.'); } + // On recherche la premiere page associé au groupe du calendrier + $idpage=null; + $idgroup=null; + if($id!=0) { + $groups=$entity->getGroups(); + if($groups[0]) { + if($groups[0]->getFgcanshare()) { + $pages=$groups[0]->getPages(); + if($pages) { + $idpage=$pages[0]->getId(); + $groups=$pages[0]->getGroups(); + $idgroup=$groups[0]->getId(); + } + } + } + } + // Permissions if($access=="config") { $canupdate = true; @@ -371,7 +388,10 @@ class CalendarController extends Controller 'entity' => $entity, 'access' => $access, 'canupdate' => $canupdate, - 'calendars' => $calendars + 'calendars' => $calendars, + 'idpage' => $idpage, + 'idgroup' => $idgroup + ]); } diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/ProjectController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/ProjectController.php index fbdc9164..896560e0 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/ProjectController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/ProjectController.php @@ -354,9 +354,10 @@ class ProjectController extends Controller // On recherche la premiere page associé au groupe du projet $idpage=null; + $idgroup=null; if($id!=0) { $groups=$entity->getGroups(); - if($groups) { + if($groups[0]) { if($groups[0]->getFgcanshare()) { $pages=$groups[0]->getPages(); if($pages) { diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/ProjecttaskController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/ProjecttaskController.php index 063af716..5e629360 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/ProjecttaskController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/ProjecttaskController.php @@ -202,7 +202,7 @@ class ProjecttaskController extends Controller $groups=$entity->getProject()->getGroups(); $idpage=null; $idgroup=null; - if($groups) { + if($groups[0]) { if($groups[0]->getFgcanshare()) { $pages=$groups[0]->getPages(); if($pages) { diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Blog/view.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Blog/view.html.twig index af11487b..559e32d5 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Blog/view.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Blog/view.html.twig @@ -11,7 +11,12 @@ {% else %} -
+
+ {% if not idpage is empty %} + Revenir sur le Groupe + {% endif %} +
+