Fixed namespace use list

Signed-off-by: Gergely Polonkai <polesz@w00d5t0ck.info>
This commit is contained in:
Gergely Polonkai (W00d5t0ck) 2012-08-28 19:23:42 +02:00
parent c1532101ac
commit 16112a74ab

View File

@ -6,6 +6,7 @@ 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;
use JMS\DiExtraBundle\Annotation as DI;
/**
* @Route("/admin")
@ -13,7 +14,14 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
class DefaultController extends Controller
{
/**
* @Route("/manage_regs", name="KekRozsakAdminBundle_manage_regs")
* @var Symfony\Component\Security\Core\SecurityContext $securityContext
*
* @DI\Inject("security.context")
*/
private $securityContext;
/**
* @Route("/regisztraltak.html", name="KekRozsakAdminBundle_manage_regs")
* @Template()
*/
public function manageRegsAction()
@ -44,22 +52,31 @@ class DefaultController extends Controller
}
/**
* @Route("/csoport_jelentkezok", name="KekRozsakAdminBundle_groupJoinRequests")
* @Route("/csoport-jelentkezok.html", name="KekRozsakAdminBundle_groupJoinRequests")
* @Template()
*/
public function groupJoinRequestsAction()
{
$user = $this->get('security.context')->getToken()->getUser();
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Group');
$myGroups = $groupRepo->findByLeader($user);
$user = $this->securityContext->getToken()->getUser();
$request = $this->getRequest();
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Group');
if ($this->securityContext->isGranted('ROLE_ADMIN') === false) {
$myGroups = $groupRepo->findByLeader($user);
} else {
$myGroups = $groupRepo->findAll();
}
if ($request->getMethod() == 'POST') {
if ($request->request->has('group') && $request->request->has('user')) {
$userRepo = $this->getDoctrine()->getRepository('KekRozsakSecurityBundle:User');
$aUser = $userRepo->findOneById($request->request->get('user'));
$aGroup = $groupRepo->findOneById($request->request->get('group'));
if ($aUser && $aGroup) {
if (
($aGroup->getLeader() == $user)
|| $this->securityContext->isGranted('ROLE_ADMIN')
) {
$membershipRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:UserGroupMembership');
$membershipObject = $membershipRepo->findOneBy(array('user' => $aUser, 'group' => $aGroup));
if ($membershipObject) {
@ -72,6 +89,9 @@ class DefaultController extends Controller
return $this->redirect($this->generateUrl('KekRozsakAdminBundle_groupJoinRequests'));
}
} else {
throw new AccessDeniedException('Csak a csoport vezetője hagyhatja jóvá a jelentkezéseket!');
}
}
}
}