112 lines
3.4 KiB
PHP
Executable File
112 lines
3.4 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class HomeController extends AbstractController
|
|
{
|
|
public function home(Request $request, ManagerRegistry $em)
|
|
{
|
|
if ($request->getSession()->get('fgforceconnect') && !$this->getUser()) {
|
|
return $this->redirectToRoute('app_login');
|
|
}
|
|
|
|
// Récupération de la page encours
|
|
$id = $request->query->get('id');
|
|
|
|
// Calcul des pages de l'utilisateur
|
|
$em->getRepository("App\Entity\Page")->getPagesUser($this->getUser(), $id, $pagecurrent, $pagesportal, $pagesuser, $groups);
|
|
|
|
// si aucune page = page par défaut
|
|
if ($pagecurrent) {
|
|
return $this->render('Page/pages.html.twig', [
|
|
'useheader' => true,
|
|
'usemenu' => true,
|
|
'usesidebar' => false,
|
|
'entity' => $pagecurrent,
|
|
'access' => 'all',
|
|
'pagesportal' => $pagesportal,
|
|
'pagesuser' => $pagesuser,
|
|
'groups' => $groups,
|
|
'canadd' => true,
|
|
'widgetsuser' => $em->getRepository("App\Entity\Widget")->getWidgetAccess('all'),
|
|
'widgetsgroup' => $em->getRepository("App\Entity\Widget")->getWidgetAccess('group'),
|
|
]);
|
|
}
|
|
|
|
if (!$this->getUser()) {
|
|
return $this->render('Home/home.html.twig', [
|
|
'useheader' => true,
|
|
'usemenu' => false,
|
|
'usesidebar' => false,
|
|
'maxsize' => 1000,
|
|
]);
|
|
}
|
|
if ($this->getUser()->hasRole('ROLE_USER')) {
|
|
return $this->redirectToRoute('app_user_home');
|
|
}
|
|
|
|
if ($this->getUser()->hasRole('ROLE_MANAGER')) {
|
|
return $this->redirectToRoute('app_manager_home');
|
|
}
|
|
|
|
if ($this->getUser()->hasRole('ROLE_MASTER')) {
|
|
return $this->redirectToRoute('app_master_home');
|
|
}
|
|
|
|
if ($this->getUser()->hasRole('ROLE_MODO')) {
|
|
return $this->redirectToRoute('app_modo_home');
|
|
}
|
|
|
|
if ($this->getUser()->hasRole('ROLE_ADMIN')) {
|
|
return $this->redirectToRoute('app_admin_home');
|
|
}
|
|
}
|
|
|
|
public function homeuser($access): Response
|
|
{
|
|
return $this->render('Page/default.html.twig', [
|
|
'useheader' => true,
|
|
'usemenu' => false,
|
|
'usesidebar' => false,
|
|
]);
|
|
}
|
|
|
|
public function homemaster($access): Response
|
|
{
|
|
return $this->render('Page/default.html.twig', [
|
|
'useheader' => true,
|
|
'usemenu' => false,
|
|
'usesidebar' => false,
|
|
]);
|
|
}
|
|
|
|
public function homemanager($access): Response
|
|
{
|
|
return $this->redirectToRoute('app_manager_user');
|
|
}
|
|
|
|
public function homemodo($access): Response
|
|
{
|
|
return $this->redirectToRoute('app_modo_niveau02');
|
|
}
|
|
|
|
public function homeadmin($access): Response
|
|
{
|
|
return $this->redirectToRoute('app_admin_config');
|
|
}
|
|
|
|
public function docrest(): Response
|
|
{
|
|
return $this->render('Home/docrest.html.twig', [
|
|
'useheader' => true,
|
|
'usemenu' => false,
|
|
'usesidebar' => true,
|
|
]);
|
|
}
|
|
}
|