From e24145dfe7e9d31356f18d333cbffb257141c3de Mon Sep 17 00:00:00 2001 From: Polonkai Gergely Date: Tue, 28 Aug 2012 17:30:00 +0200 Subject: [PATCH] Made registration management working Signed-off-by: Gergely Polonkai --- app/config/config.yml | 2 +- .../Controller/DefaultController.php | 19 +++++++++++++++++++ .../views/Default/manageRegs.html.twig | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/config/config.yml b/app/config/config.yml index efd25ec..65fc6fa 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -65,4 +65,4 @@ swiftmailer: password: %mailer_password% spool: type: file - path: %kernel.root_dir%/spool + path: %kernel.root_dir%/../spool diff --git a/src/KekRozsak/AdminBundle/Controller/DefaultController.php b/src/KekRozsak/AdminBundle/Controller/DefaultController.php index a369364..133d6ae 100644 --- a/src/KekRozsak/AdminBundle/Controller/DefaultController.php +++ b/src/KekRozsak/AdminBundle/Controller/DefaultController.php @@ -5,6 +5,7 @@ namespace KekRozsak\AdminBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; +use Symfony\Component\Security\Core\Exception\AccessDeniedException; /** * @Route("/admin") @@ -17,7 +18,25 @@ class DefaultController extends Controller */ public function manageRegsAction() { + if (!$this->get('security.context')->isGranted('ROLE_ADMIN')) { + throw new AccessDeniedException('Ehhez a művelethez nincs jogosultságod.'); + } $users = $this->getDoctrine()->getEntityManager()->createQuery('SELECT u FROM KekRozsakSecurityBundle:User u WHERE u.acceptedBy IS NULL')->getResult(); + $request = $this->getRequest(); + + if ($request->getMethod() == 'POST') { + if (is_numeric($userid = $request->get('userid'))) { + if (($user = $this->getDoctrine()->getRepository('KekRozsakSecurityBundle:User')->findOneById($userid)) != null) { + $activeUser = $this->get('security.context')->getToken()->getUser(); + $user->setAcceptedBy($activeUser); + $em = $this->getDoctrine()->getEntityManager(); + $em->persist($user); + $em->flush(); + + return $this->redirect($this->generateUrl('KekRozsakAdminBundle_manage_regs')); + } + } + } return array( 'users' => $users, diff --git a/src/KekRozsak/AdminBundle/Resources/views/Default/manageRegs.html.twig b/src/KekRozsak/AdminBundle/Resources/views/Default/manageRegs.html.twig index a8cb3d2..e564689 100644 --- a/src/KekRozsak/AdminBundle/Resources/views/Default/manageRegs.html.twig +++ b/src/KekRozsak/AdminBundle/Resources/views/Default/manageRegs.html.twig @@ -23,6 +23,7 @@ {{ user.registeredAt|date('Y-m-d H:i') }}
+