Fixed namespace use list
Signed-off-by: Gergely Polonkai <polesz@w00d5t0ck.info>
This commit is contained in:
parent
c1532101ac
commit
16112a74ab
@ -6,6 +6,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
|
||||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||||
|
use JMS\DiExtraBundle\Annotation as DI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/admin")
|
* @Route("/admin")
|
||||||
@ -13,7 +14,14 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
|||||||
class DefaultController extends Controller
|
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()
|
* @Template()
|
||||||
*/
|
*/
|
||||||
public function manageRegsAction()
|
public function manageRegsAction()
|
||||||
@ -44,33 +52,45 @@ class DefaultController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/csoport_jelentkezok", name="KekRozsakAdminBundle_groupJoinRequests")
|
* @Route("/csoport-jelentkezok.html", name="KekRozsakAdminBundle_groupJoinRequests")
|
||||||
* @Template()
|
* @Template()
|
||||||
*/
|
*/
|
||||||
public function groupJoinRequestsAction()
|
public function groupJoinRequestsAction()
|
||||||
{
|
{
|
||||||
$user = $this->get('security.context')->getToken()->getUser();
|
$user = $this->securityContext->getToken()->getUser();
|
||||||
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Group');
|
|
||||||
$myGroups = $groupRepo->findByLeader($user);
|
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$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->getMethod() == 'POST') {
|
||||||
if ($request->request->has('group') && $request->request->has('user')) {
|
if ($request->request->has('group') && $request->request->has('user')) {
|
||||||
$userRepo = $this->getDoctrine()->getRepository('KekRozsakSecurityBundle:User');
|
$userRepo = $this->getDoctrine()->getRepository('KekRozsakSecurityBundle:User');
|
||||||
$aUser = $userRepo->findOneById($request->request->get('user'));
|
$aUser = $userRepo->findOneById($request->request->get('user'));
|
||||||
$aGroup = $groupRepo->findOneById($request->request->get('group'));
|
$aGroup = $groupRepo->findOneById($request->request->get('group'));
|
||||||
if ($aUser && $aGroup) {
|
if ($aUser && $aGroup) {
|
||||||
$membershipRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:UserGroupMembership');
|
if (
|
||||||
$membershipObject = $membershipRepo->findOneBy(array('user' => $aUser, 'group' => $aGroup));
|
($aGroup->getLeader() == $user)
|
||||||
if ($membershipObject) {
|
|| $this->securityContext->isGranted('ROLE_ADMIN')
|
||||||
$membershipObject->setMembershipAcceptedAt(new \DateTime('now'));
|
) {
|
||||||
$membershipObject->setMembershipAcceptedBy($user);
|
$membershipRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:UserGroupMembership');
|
||||||
|
$membershipObject = $membershipRepo->findOneBy(array('user' => $aUser, 'group' => $aGroup));
|
||||||
|
if ($membershipObject) {
|
||||||
|
$membershipObject->setMembershipAcceptedAt(new \DateTime('now'));
|
||||||
|
$membershipObject->setMembershipAcceptedBy($user);
|
||||||
|
|
||||||
$em = $this->getDoctrine()->getEntityManager();
|
$em = $this->getDoctrine()->getEntityManager();
|
||||||
$em->persist($membershipObject);
|
$em->persist($membershipObject);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('KekRozsakAdminBundle_groupJoinRequests'));
|
return $this->redirect($this->generateUrl('KekRozsakAdminBundle_groupJoinRequests'));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new AccessDeniedException('Csak a csoport vezetője hagyhatja jóvá a jelentkezéseket!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user