Made registration management working

Signed-off-by: Gergely Polonkai <polesz@w00d5t0ck.info>
This commit is contained in:
Polonkai Gergely 2012-08-28 17:30:00 +02:00
parent 41c85703b3
commit e24145dfe7
3 changed files with 21 additions and 1 deletions

View File

@ -65,4 +65,4 @@ swiftmailer:
password: %mailer_password%
spool:
type: file
path: %kernel.root_dir%/spool
path: %kernel.root_dir%/../spool

View File

@ -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,

View File

@ -23,6 +23,7 @@
<td>{{ user.registeredAt|date('Y-m-d H:i') }}</td>
<td>
<form method="post" action="">
<input type="hidden" name="userid" value="{{ user.id }}" />
<button type="submit">Engedélyezem</button>
</form>
</td>