mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
Merge remote-tracking branch 'origin/master' into issue520_reference_address_update
This commit is contained in:
@@ -54,7 +54,7 @@ class CenterController extends AbstractController
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$center = $em->getRepository('ChillMainBundle:Center')->find($id);
|
||||
$center = $em->getRepository(\Chill\MainBundle\Entity\Center::class)->find($id);
|
||||
|
||||
if (!$center) {
|
||||
throw $this->createNotFoundException('Unable to find Center entity.');
|
||||
@@ -75,7 +75,7 @@ class CenterController extends AbstractController
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$entities = $em->getRepository('ChillMainBundle:Center')->findAll();
|
||||
$entities = $em->getRepository(\Chill\MainBundle\Entity\Center::class)->findAll();
|
||||
|
||||
return $this->render('@ChillMain/Center/index.html.twig', [
|
||||
'entities' => $entities,
|
||||
@@ -105,7 +105,7 @@ class CenterController extends AbstractController
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$center = $em->getRepository('ChillMainBundle:Center')->find($id);
|
||||
$center = $em->getRepository(\Chill\MainBundle\Entity\Center::class)->find($id);
|
||||
|
||||
if (!$center) {
|
||||
throw $this->createNotFoundException('Unable to find Center entity.');
|
||||
@@ -125,7 +125,7 @@ class CenterController extends AbstractController
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$center = $em->getRepository('ChillMainBundle:Center')->find($id);
|
||||
$center = $em->getRepository(\Chill\MainBundle\Entity\Center::class)->find($id);
|
||||
|
||||
if (!$center) {
|
||||
throw $this->createNotFoundException('Unable to find Center entity.');
|
||||
|
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class LocationController extends CRUDController
|
||||
@@ -29,4 +30,9 @@ class LocationController extends CRUDController
|
||||
{
|
||||
$query->where('e.availableForUsers = true'); //TODO not working
|
||||
}
|
||||
|
||||
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
|
||||
{
|
||||
return $query->addOrderBy('e.name', 'DESC');
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@ use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Repository\NotificationRepository;
|
||||
use Chill\MainBundle\Security\Authorization\NotificationVoter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -31,14 +32,19 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/notification")
|
||||
*/
|
||||
class NotificationController extends AbstractController
|
||||
{
|
||||
private LoggerInterface $chillLogger;
|
||||
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
private LoggerInterface $logger;
|
||||
|
||||
private NotificationHandlerManager $notificationHandlerManager;
|
||||
|
||||
private NotificationRepository $notificationRepository;
|
||||
@@ -51,6 +57,8 @@ class NotificationController extends AbstractController
|
||||
|
||||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
LoggerInterface $chillLogger,
|
||||
LoggerInterface $logger,
|
||||
Security $security,
|
||||
NotificationRepository $notificationRepository,
|
||||
NotificationHandlerManager $notificationHandlerManager,
|
||||
@@ -58,6 +66,8 @@ class NotificationController extends AbstractController
|
||||
TranslatorInterface $translator
|
||||
) {
|
||||
$this->em = $em;
|
||||
$this->logger = $logger;
|
||||
$this->chillLogger = $chillLogger;
|
||||
$this->security = $security;
|
||||
$this->notificationRepository = $notificationRepository;
|
||||
$this->notificationHandlerManager = $notificationHandlerManager;
|
||||
@@ -150,6 +160,52 @@ class NotificationController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{id}/access_key", name="chill_main_notification_grant_access_by_access_key")
|
||||
*/
|
||||
public function getAccessByAccessKey(Notification $notification, Request $request): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
|
||||
|
||||
if (!$this->security->getUser() instanceof User) {
|
||||
throw new AccessDeniedHttpException('You must be authenticated and a user to create a notification');
|
||||
}
|
||||
|
||||
foreach (['accessKey'/*, 'email'*/] as $param) {
|
||||
if (!$request->query->has($param)) {
|
||||
throw new BadRequestHttpException("Missing {$param} parameter");
|
||||
}
|
||||
}
|
||||
|
||||
if ($notification->getAccessKey() !== $request->query->getAlnum('accessKey')) {
|
||||
throw new AccessDeniedHttpException('access key is invalid');
|
||||
}
|
||||
|
||||
/*
|
||||
desactivated due to escaped '&' in email links
|
||||
if (!in_array($request->query->get('email'), $notification->getAddressesEmails(), true)) {
|
||||
return (new Response('The email address is no more associated with this notification'))
|
||||
->setStatusCode(Response::HTTP_FORBIDDEN);
|
||||
}
|
||||
*/
|
||||
|
||||
$notification->addAddressee($this->security->getUser());
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
$logMsg = '[Notification] a user is granted access to notification trough an access key';
|
||||
$context = [
|
||||
'notificationId' => $notification->getId(),
|
||||
'email' => $request->query->get('email'),
|
||||
'user' => $this->security->getUser()->getId(),
|
||||
];
|
||||
|
||||
$this->logger->info($logMsg, $context);
|
||||
$this->chillLogger->info($logMsg, $context);
|
||||
|
||||
return $this->redirectToRoute('chill_main_notification_show', ['id' => $notification->getId()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/inbox", name="chill_main_notification_my")
|
||||
*/
|
||||
|
@@ -87,7 +87,7 @@ class PermissionsGroupController extends AbstractController
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id);
|
||||
$permissionsGroup = $em->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)->find($id);
|
||||
|
||||
if (!$permissionsGroup) {
|
||||
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
|
||||
@@ -203,8 +203,8 @@ class PermissionsGroupController extends AbstractController
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($pgid);
|
||||
$roleScope = $em->getRepository('ChillMainBundle:RoleScope')->find($rsid);
|
||||
$permissionsGroup = $em->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)->find($pgid);
|
||||
$roleScope = $em->getRepository(\Chill\MainBundle\Entity\RoleScope::class)->find($rsid);
|
||||
|
||||
if (!$permissionsGroup) {
|
||||
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
|
||||
@@ -269,7 +269,7 @@ class PermissionsGroupController extends AbstractController
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id);
|
||||
$permissionsGroup = $em->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)->find($id);
|
||||
|
||||
if (!$permissionsGroup) {
|
||||
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
|
||||
@@ -319,7 +319,7 @@ class PermissionsGroupController extends AbstractController
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$entities = $em->getRepository('ChillMainBundle:PermissionsGroup')->findAll();
|
||||
$entities = $em->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)->findAll();
|
||||
|
||||
return $this->render('@ChillMain/PermissionsGroup/index.html.twig', [
|
||||
'entities' => $entities,
|
||||
@@ -349,7 +349,7 @@ class PermissionsGroupController extends AbstractController
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id);
|
||||
$permissionsGroup = $em->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)->find($id);
|
||||
|
||||
if (!$permissionsGroup) {
|
||||
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
|
||||
@@ -405,7 +405,7 @@ class PermissionsGroupController extends AbstractController
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$permissionsGroup = $em
|
||||
->getRepository('ChillMainBundle:PermissionsGroup')
|
||||
->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)
|
||||
->find($id);
|
||||
|
||||
if (!$permissionsGroup) {
|
||||
@@ -469,7 +469,7 @@ class PermissionsGroupController extends AbstractController
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$roleScope = $em->getRepository('ChillMainBundle:RoleScope')
|
||||
$roleScope = $em->getRepository(\Chill\MainBundle\Entity\RoleScope::class)
|
||||
->findOneBy(['role' => $role, 'scope' => $scope]);
|
||||
|
||||
if (null === $roleScope) {
|
||||
|
@@ -54,7 +54,7 @@ class ScopeController extends AbstractController
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$scope = $em->getRepository('ChillMainBundle:Scope')->find($id);
|
||||
$scope = $em->getRepository(\Chill\MainBundle\Entity\Scope::class)->find($id);
|
||||
|
||||
if (!$scope) {
|
||||
throw $this->createNotFoundException('Unable to find Scope entity.');
|
||||
@@ -75,7 +75,7 @@ class ScopeController extends AbstractController
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$entities = $em->getRepository('ChillMainBundle:Scope')->findAll();
|
||||
$entities = $em->getRepository(\Chill\MainBundle\Entity\Scope::class)->findAll();
|
||||
|
||||
return $this->render('@ChillMain/Scope/index.html.twig', [
|
||||
'entities' => $entities,
|
||||
@@ -105,7 +105,7 @@ class ScopeController extends AbstractController
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$scope = $em->getRepository('ChillMainBundle:Scope')->find($id);
|
||||
$scope = $em->getRepository(\Chill\MainBundle\Entity\Scope::class)->find($id);
|
||||
|
||||
if (!$scope) {
|
||||
throw $this->createNotFoundException('Unable to find Scope entity.');
|
||||
@@ -125,7 +125,7 @@ class ScopeController extends AbstractController
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$scope = $em->getRepository('ChillMainBundle:Scope')->find($id);
|
||||
$scope = $em->getRepository(\Chill\MainBundle\Entity\Scope::class)->find($id);
|
||||
|
||||
if (!$scope) {
|
||||
throw $this->createNotFoundException('Unable to find Scope entity.');
|
||||
|
@@ -22,7 +22,6 @@ use Chill\MainBundle\Search\UnknowSearchNameException;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
@@ -122,7 +121,7 @@ class SearchController extends AbstractController
|
||||
|
||||
public function searchAction(Request $request, $_format)
|
||||
{
|
||||
$pattern = $request->query->get('q', '');
|
||||
$pattern = trim($request->query->get('q', ''));
|
||||
|
||||
if ('' === $pattern) {
|
||||
switch ($_format) {
|
||||
@@ -216,7 +215,7 @@ class SearchController extends AbstractController
|
||||
$types = $request->query->get('type', []);
|
||||
|
||||
if (count($types) === 0) {
|
||||
throw new BadRequestException('The request must contains at '
|
||||
throw new BadRequestHttpException('The request must contains at '
|
||||
. ' one type');
|
||||
}
|
||||
|
||||
|
@@ -61,7 +61,7 @@ class UserController extends CRUDController
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$user = $em->getRepository('ChillMainBundle:User')->find($uid);
|
||||
$user = $em->getRepository(\Chill\MainBundle\Entity\User::class)->find($uid);
|
||||
|
||||
if (!$user) {
|
||||
throw $this->createNotFoundException('Unable to find User entity.');
|
||||
@@ -118,13 +118,13 @@ class UserController extends CRUDController
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$user = $em->getRepository('ChillMainBundle:User')->find($uid);
|
||||
$user = $em->getRepository(\Chill\MainBundle\Entity\User::class)->find($uid);
|
||||
|
||||
if (!$user) {
|
||||
throw $this->createNotFoundException('Unable to find User entity.');
|
||||
}
|
||||
|
||||
$groupCenter = $em->getRepository('ChillMainBundle:GroupCenter')
|
||||
$groupCenter = $em->getRepository(\Chill\MainBundle\Entity\GroupCenter::class)
|
||||
->find($gcid);
|
||||
|
||||
if (!$groupCenter) {
|
||||
@@ -330,7 +330,7 @@ class UserController extends CRUDController
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$groupCenterManaged = $em->getRepository('ChillMainBundle:GroupCenter')
|
||||
$groupCenterManaged = $em->getRepository(\Chill\MainBundle\Entity\GroupCenter::class)
|
||||
->findOneBy([
|
||||
'center' => $groupCenter->getCenter(),
|
||||
'permissionsGroup' => $groupCenter->getPermissionsGroup(),
|
||||
|
@@ -25,7 +25,6 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
@@ -144,7 +143,7 @@ class WorkflowController extends AbstractController
|
||||
public function getAccessByAccessKey(EntityWorkflowStep $entityWorkflowStep, Request $request): Response
|
||||
{
|
||||
if (null === $accessKey = $request->query->get('accessKey', null)) {
|
||||
throw new BadRequestException('accessKey is missing');
|
||||
throw new BadRequestHttpException('accessKey is missing');
|
||||
}
|
||||
|
||||
if (!$this->getUser() instanceof User) {
|
||||
|
Reference in New Issue
Block a user