The SSH host key has changed on 8 April, 2022 to this one: SHA256:573uTBSeh74kvOo0HJXi5ijdzRm8me27suzNEDlGyrQ

Refactored code to comply with PSR-*

Signed-off-by: Gergely POLONKAI <polesz@w00d5t0ck.info>
master
Gergely POLONKAI 10 years ago
parent de00a6ad21
commit fab08cad6f
  1. 112
      src/KekRozsak/AdminBundle/Controller/DefaultController.php
  2. 4
      src/KekRozsak/AdminBundle/Resources/config/services.xml
  3. 54
      src/KekRozsak/AdminBundle/Resources/views/Default/groupJoinRequests.html.twig
  4. 42
      src/KekRozsak/AdminBundle/Resources/views/Default/manageRegs.html.twig
  5. 39
      src/KekRozsak/FrontBundle/Controller/ArticleController.php
  6. 241
      src/KekRozsak/FrontBundle/Controller/BookController.php
  7. 88
      src/KekRozsak/FrontBundle/Controller/DefaultController.php
  8. 186
      src/KekRozsak/FrontBundle/Controller/DocumentController.php
  9. 152
      src/KekRozsak/FrontBundle/Controller/EventController.php
  10. 137
      src/KekRozsak/FrontBundle/Controller/ForumController.php
  11. 290
      src/KekRozsak/FrontBundle/Controller/GroupController.php
  12. 462
      src/KekRozsak/FrontBundle/Entity/Article.php
  13. 622
      src/KekRozsak/FrontBundle/Entity/Book.php
  14. 302
      src/KekRozsak/FrontBundle/Entity/BookCopy.php
  15. 521
      src/KekRozsak/FrontBundle/Entity/Document.php
  16. 808
      src/KekRozsak/FrontBundle/Entity/Event.php
  17. 309
      src/KekRozsak/FrontBundle/Entity/ForumPost.php
  18. 472
      src/KekRozsak/FrontBundle/Entity/ForumTopic.php
  19. 349
      src/KekRozsak/FrontBundle/Entity/ForumTopicGroup.php
  20. 672
      src/KekRozsak/FrontBundle/Entity/Group.php
  21. 341
      src/KekRozsak/FrontBundle/Entity/News.php
  22. 802
      src/KekRozsak/FrontBundle/Entity/UserData.php
  23. 355
      src/KekRozsak/FrontBundle/Entity/UserGroupMembership.php
  24. 58
      src/KekRozsak/FrontBundle/Extensions/Slugifier.php
  25. 37
      src/KekRozsak/FrontBundle/Form/Extension/HelpMessageTypeExtension.php
  26. 30
      src/KekRozsak/FrontBundle/Form/Type/DocumentType.php
  27. 58
      src/KekRozsak/FrontBundle/Form/Type/ForumPostType.php
  28. 28
      src/KekRozsak/FrontBundle/Form/Type/GroupType.php
  29. 158
      src/KekRozsak/FrontBundle/Form/Type/UserDataType.php
  30. 32
      src/KekRozsak/FrontBundle/Resources/config/services.xml
  31. 64
      src/KekRozsak/FrontBundle/Resources/public/css/forum.css
  32. 10
      src/KekRozsak/FrontBundle/Resources/public/css/group.css
  33. 102
      src/KekRozsak/FrontBundle/Resources/public/css/popup.css
  34. 46
      src/KekRozsak/FrontBundle/Resources/views/Book/ajaxData.html.twig
  35. 246
      src/KekRozsak/FrontBundle/Resources/views/Book/list.html.twig
  36. 76
      src/KekRozsak/FrontBundle/Resources/views/Box/Events.html.twig
  37. 24
      src/KekRozsak/FrontBundle/Resources/views/Box/Login.html.twig
  38. 39
      src/KekRozsak/FrontBundle/Resources/views/Box/UserProfile.html.twig
  39. 6
      src/KekRozsak/FrontBundle/Resources/views/Default/userprofile.html.twig
  40. 4
      src/KekRozsak/FrontBundle/Resources/views/Document/create.html.twig
  41. 4
      src/KekRozsak/FrontBundle/Resources/views/Document/edit.html.twig
  42. 2
      src/KekRozsak/FrontBundle/Resources/views/Document/view.html.twig
  43. 16
      src/KekRozsak/FrontBundle/Resources/views/Event/ajaxList.html.twig
  44. 2
      src/KekRozsak/FrontBundle/Resources/views/Event/list.html.twig
  45. 4
      src/KekRozsak/FrontBundle/Resources/views/Event/view.html.twig
  46. 12
      src/KekRozsak/FrontBundle/Resources/views/Form/user_form.html.twig
  47. 70
      src/KekRozsak/FrontBundle/Resources/views/Forum/postList.html.twig
  48. 44
      src/KekRozsak/FrontBundle/Resources/views/Forum/topicGroupList.html.twig
  49. 36
      src/KekRozsak/FrontBundle/Resources/views/Forum/topicList.html.twig
  50. 3
      src/KekRozsak/FrontBundle/Resources/views/Group/create.html.twig
  51. 39
      src/KekRozsak/FrontBundle/Resources/views/Group/documents.html.twig
  52. 80
      src/KekRozsak/FrontBundle/Resources/views/Group/list.html.twig
  53. 9
      src/KekRozsak/FrontBundle/Resources/views/Group/members.html.twig
  54. 6
      src/KekRozsak/FrontBundle/Resources/views/Group/view.html.twig
  55. 171
      src/KekRozsak/FrontBundle/Twig/TwigBBExtension.php
  56. 254
      src/KekRozsak/SecurityBundle/Controller/DefaultController.php
  57. 12
      src/KekRozsak/SecurityBundle/DependencyInjection/Compiler/OverrideServiceCompilerPass.php
  58. 318
      src/KekRozsak/SecurityBundle/Entity/Role.php
  59. 760
      src/KekRozsak/SecurityBundle/Entity/User.php
  60. 126
      src/KekRozsak/SecurityBundle/Form/Type/UserType.php
  61. 10
      src/KekRozsak/SecurityBundle/KekRozsakSecurityBundle.php
  62. 30
      src/KekRozsak/SecurityBundle/Resources/config/services.xml
  63. 12
      src/KekRozsak/SecurityBundle/Resources/views/Default/ajaxUserdata.html.twig
  64. 6
      src/KekRozsak/SecurityBundle/Resources/views/Default/login.html.twig
  65. 2
      src/KekRozsak/SecurityBundle/Resources/views/Default/regSuccess.html.twig
  66. 8
      src/KekRozsak/SecurityBundle/Resources/views/Default/registration.html.twig
  67. 43
      src/KekRozsak/SecurityBundle/Security/AuthSuccess.php
  68. 16
      src/KekRozsak/SecurityBundle/Service/CryptEncoder.php
  69. 65
      src/KekRozsak/SecurityBundle/Twig/UserDataSpanExtension.php

@ -11,68 +11,66 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
*/
class DefaultController extends Controller
{
/**
* @Route("/manage_regs", name="KekRozsakAdminBundle_manage_regs")
* @Template()
*/
public function manageRegsAction()
{
$users = $this->getDoctrine()->getEntityManager()->createQuery('SELECT u FROM KekRozsakSecurityBundle:User u WHERE u.acceptedBy IS NULL')->getResult();
/**
* @Route("/manage_regs", name="KekRozsakAdminBundle_manage_regs")
* @Template()
*/
public function manageRegsAction()
{
$users = $this->getDoctrine()->getEntityManager()->createQuery('SELECT u FROM KekRozsakSecurityBundle:User u WHERE u.acceptedBy IS NULL')->getResult();
return array(
'users' => $users,
);
}
return array(
'users' => $users,
);
}
/**
* @Route("/csoport_jelentkezok", name="KekRozsakAdminBundle_groupJoinRequests")
* @Template()
*/
public function groupJoinRequestsAction()
{
$user = $this->get('security.context')->getToken()->getUser();
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Group');
$myGroups = $groupRepo->findByLeader($user);
/**
* @Route("/csoport_jelentkezok", name="KekRozsakAdminBundle_groupJoinRequests")
* @Template()
*/
public function groupJoinRequestsAction()
{
$user = $this->get('security.context')->getToken()->getUser();
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Group');
$myGroups = $groupRepo->findByLeader($user);
$request = $this->getRequest();
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)
{
$membershipRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:UserGroupMembership');
$membershipObject = $membershipRepo->findOneBy(array('user' => $aUser, 'group' => $aGroup));
if ($membershipObject)
{
$membershipObject->setMembershipAcceptedAt(new \DateTime('now'));
$membershipObject->setMembershipAcceptedBy($user);
$request = $this->getRequest();
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) {
$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->persist($membershipObject);
$em->flush();
$em = $this->getDoctrine()->getEntityManager();
$em->persist($membershipObject);
$em->flush();
return $this->redirect($this->generateUrl('KekRozsakAdminBundle_groupJoinRequests'));
}
}
}
}
return $this->redirect($this->generateUrl('KekRozsakAdminBundle_groupJoinRequests'));
}
}
}
}
return array(
'groups' => $myGroups,
);
}
return array(
'groups' => $myGroups,
);
}
/**
* @Route("/csoport_jelentkezok/elutasit", name="KekRozsakAdminBundle_groupJoinDecline")
* @Template()
*/
public function groupJoinDeclineAction()
{
return array(
);
}
/**
* @Route("/csoport_jelentkezok/elutasit", name="KekRozsakAdminBundle_groupJoinDecline")
* @Template()
*/
public function groupJoinDeclineAction()
{
// TODO: A reason must be written to decline a join request!
return array(
);
}
}

@ -1,4 +1,6 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
</container>

@ -6,38 +6,38 @@
<h3>Csoport jelentkezők</h3>
<p>Az alábbi listán az általad vezetett csoportokba frissen jelentkezőket láthatod. A mellettük lévő ikonokra kattintva hagyhatod jóvá, illetve utasísthatod el a jelentkezésüket. Amennyiben ez utóbbi mellett döntesz, egy rövid üzenetet is írnod kell az elutasítás okáról.</p>
<table>
<thead>
<tr>
<td colspan="2">Csoport / Jelentkező</td>
<td></td>
</tr>
</thead>
<tbody>
<thead>
<tr>
<td colspan="2">Csoport / Jelentkező</td>
<td></td>
</tr>
</thead>
<tbody>
{% for group in groups %}
<tr>
<td class="ikon">[ikon]</td>
<td colspan="2">{{ group.name }}</td>
</tr>
<tr>
<td class="ikon">[ikon]</td>
<td colspan="2">{{ group.name }}</td>
</tr>
{% for request in group.members %}
{% if not group.isMember(request.user) %}
<tr>
<td colspan="2">{{ request.user|userdataspan }}</td>
<td>
<form method="post" action="{{ path('KekRozsakAdminBundle_groupJoinRequests') }}">
<input type="hidden" name="user" value="{{ request.user.id }}" />
<input type="hidden" name="group" value="{{ group.id }}" />
<button type="submit">[jóváhagyó ikon]</button>
</form>
<form method="post" action="{{ path('KekRozsakAdminBundle_groupJoinDecline') }}">
<input type="hidden" name="user" value="{{ request.user.id }}" />
<input type="hidden" name="group" value="{{ group.id }}" />
<button type="submit">[elutasító ikon]</button>
</form>
</td>
</tr>
<tr>
<td colspan="2">{{ request.user|userdataspan }}</td>
<td>
<form method="post" action="{{ path('KekRozsakAdminBundle_groupJoinRequests') }}">
<input type="hidden" name="user" value="{{ request.user.id }}" />
<input type="hidden" name="group" value="{{ group.id }}" />
<button type="submit">[jóváhagyó ikon]</button>
</form>
<form method="post" action="{{ path('KekRozsakAdminBundle_groupJoinDecline') }}">
<input type="hidden" name="user" value="{{ request.user.id }}" />
<input type="hidden" name="group" value="{{ group.id }}" />
<button type="submit">[elutasító ikon]</button>
</form>
</td>
</tr>
{% endif %}
{% endfor %}
{% endfor %}
</tbody>
</tbody>
</table>
{% endblock content %}

@ -6,29 +6,29 @@
<h3>Jelentkezők</h3>
{% if users|length > 0 %}
<table>
<thead>
<tr>
<td>Felhasználónév</td>
<td>E-mail cím</td>
<td>Fórum-név</td>
<td>Regisztráció ideje</td>
</tr>
</thead>
<tbody>
<thead>
<tr>
<td>Felhasználónév</td>
<td>E-mail cím</td>
<td>Fórum-név</td>
<td>Regisztráció ideje</td>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td>{{ user.username }}</td>
<td>{{ user.email }}</td>
<td>{{ user|userdataspan }}</td>
<td>{{ user.registeredAt|date('Y-m-d H:i') }}</td>
<td>
<form method="post" action="">
<button type="submit">Engedélyezem</button>
</form>
</td>
</tr>
<tr>
<td>{{ user.username }}</td>
<td>{{ user.email }}</td>
<td>{{ user|userdataspan }}</td>
<td>{{ user.registeredAt|date('Y-m-d H:i') }}</td>
<td>
<form method="post" action="">
<button type="submit">Engedélyezem</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</tbody>
</table>
{% endif %}
{%endblock content %}

@ -12,21 +12,28 @@ use KekRozsak\FrontBundle\Entity\Article;
class ArticleController extends Controller
{
/**
* @Route("/cikk/{slug}", name="KekRozsakFrontBundle_articleView")
* @Template()
* @ParamConverter("article")
*
* @param KekRozsak\FrontBundle\Entity\Article $article
*/
public function viewAction(Article $article)
{
$scontext = $this->get('security.context');
if ((!is_object($scontext->getToken()) || !is_object($scontext->getToken()->getUser())) && !$article->isPublic())
throw new AccessDeniedException('A cikk megtekintéséhez be kell jelentkezned!');
/**
* @Route("/cikk/{slug}", name="KekRozsakFrontBundle_articleView")
* @Template()
* @ParamConverter("article")
*
* @param KekRozsak\FrontBundle\Entity\Article $article
*/
public function viewAction(Article $article)
{
$scontext = $this->get('security.context');
if (
(
!is_object($scontext->getToken())
|| !is_object($scontext->getToken()->getUser())
)
&& !$article->isPublic()
) {
throw new AccessDeniedException('A cikk megtekintéséhez be kell jelentkezned!');
}
return array(
'article' => $article,
);
}
return array(
'article' => $article,
);
}
}

@ -13,123 +13,126 @@ use KekRozsak\FrontBundle\Entity\BookCopy;
class BookController extends Controller
{
/**
* @Route("/konyvtar", name="KekRozsakFrontBundle_bookList")
* @Template()
*/
public function listAction()
{
$query = $this->getDoctrine()->getEntityManager()->createQuery('SELECT b FROM KekRozsakFrontBundle:Book b ORDER BY b.author ASC, b.title ASC, b.year ASC');
$books = $query->getResult();
return array(
'books' => $books,
);
}
/**
* @Route("/konyvadat/{id}/ajax.{_format}", name="KekRozsakFrontBundle_bookAjaxData", defaults={"_format": "html"}, options={"expose": true})
* @Template()
* @ParamConverter("book")
*/
public function ajaxDataAction(Book $book)
{
return array(
'book' => $book,
);
}
/**
* @Route("/konyv/torles/{id}", name="KekRozsakFrontBundle_bookDeleteCopy", requirements={"id": "\d+"}, options={"expose": true})
* @ParamConverter("book")
*/
public function ajaxDeleteBookAction(Book $book)
{
$copies = $book->getUsersCopies($this->get('security.context')->getToken()->getUser());
$em = $this->getDoctrine()->getEntityManager();
$copies->forAll(function($key, $copy) use ($book, $em) {
$book->removeCopy($copy);
$em->remove($copy);
});
$em->persist($book);
$em->flush();
return new Response();
}
/**
* @Route("/konyv/ujpeldany/{id}", name="KekRozsakFrontBundle_bookAddCopy", requirements={"id": "\d+"}, options={"expose": true})
* @ParamConverter("book")
*/
public function ajaxAddBookAction(Book $book)
{
$user = $this->get('security.context')->getToken()->getUser();
$copies = $book->getUsersCopies($user);
if ($copies->count() == 0)
{
$copy = new BookCopy($book, $user);
$em = $this->getDoctrine()->getEntityManager();
$em->persist($copy);
$em->flush();
}
return new Response();
}
/**
* @Route("/konyv/kolcsonozheto/{id}/{newValue}", name="KekRozsakFrontBundle_bookSetCopyBorrowable", requirements={"id": "\d+"}, options={"expose": true})
* @ParamConverter("book")
*/
public function ajaxSetBookCopyBorrowableAction(Book $book, $newValue)
{
$user = $this->get('security.context')->getToken()->getUser();
$copies = $book->getUsersCopies($user);
$em = $this->getDoctrine()->getEntityManager();
$copies->forAll(function($key, $copy) use ($em, $newValue) {
$copy->setBorrowable($newValue);
$em->persist($copy);
});
$em->flush();
return new Response();
}
/**
* @Route("/konyv/megveheto/{id}/{newValue}", name="KekRozsakFrontBundle_bookSetCopyForSale", requirements={"id": "\d+"}, options={"expose": true})
* @ParamConverter("book")
*/
public function ajaxSetBookCopyForSaleAction(Book $book, $newValue)
{
$user = $this->get('security.context')->getToken()->getUser();
$copies = $book->getUsersCopies($user);
$em = $this->getDoctrine()->getEntityManager();
$copies->forAll(function($key, $copy) use ($em, $newValue) {
$copy->setBuyable($newValue);
$em->persist($copy);
});
$em->flush();
return new Response();
}
/**
* @Route("/konyv/szeretnek/{id}/{wantToBuy}", name="KekRozsakFrontBundle_bookWantOne", requirements={"id": "\d+"}, options={"expose": true})
* @ParamConverter("book")
*/
public function ajaxWantABookAction(Book $book, $wantToBuy)
{
$user = $this->get('security.context')->getToken()->getUser();
if ($wantToBuy)
{
$book->addWouldBuy($user);
}
else
{
$book->addWouldBorrow($user);
}
$em = $this->getDoctrine()->getEntityManager();
$em->persist($book);
$em->flush();
return new Response();
}
}
/**
* @Route("/konyvtar", name="KekRozsakFrontBundle_bookList")
* @Template()
*/
public function listAction()
{
$query = $this->getDoctrine()->getEntityManager()->createQuery('SELECT b FROM KekRozsakFrontBundle:Book b ORDER BY b.author ASC, b.title ASC, b.year ASC');
$books = $query->getResult();
return array(
'books' => $books,
);
}
/**
* @Route("/konyvadat/{id}/ajax.{_format}", name="KekRozsakFrontBundle_bookAjaxData", defaults={"_format": "html"}, options={"expose": true})
* @Template()
* @ParamConverter("book")
*/
public function ajaxDataAction(Book $book)
{
return array(
'book' => $book,
);
}
/**
* @Route("/konyv/torles/{id}", name="KekRozsakFrontBundle_bookDeleteCopy", requirements={"id": "\d+"}, options={"expose": true})
* @ParamConverter("book")
*/
public function ajaxDeleteBookAction(Book $book)
{
$copies = $book->getUsersCopies($this->get('security.context')->getToken()->getUser());
$em = $this->getDoctrine()->getEntityManager();
$copies->forAll(function($key, $copy) use ($book, $em)
{
$book->removeCopy($copy);
$em->remove($copy);
});
$em->persist($book);
$em->flush();
return new Response();
}
/**
* @Route("/konyv/ujpeldany/{id}", name="KekRozsakFrontBundle_bookAddCopy", requirements={"id": "\d+"}, options={"expose": true})
* @ParamConverter("book")
*/
public function ajaxAddCopyAction(Book $book)
{
$user = $this->get('security.context')->getToken()->getUser();
$copies = $book->getUsersCopies($user);
if ($copies->count() == 0) {
$copy = new BookCopy($book, $user);
$em = $this->getDoctrine()->getEntityManager();
$em->persist($copy);
$em->flush();
}
return new Response();
}
/**
* @Route("/konyv/kolcsonozheto/{id}/{newValue}", name="KekRozsakFrontBundle_bookSetCopyBorrowable", requirements={"id": "\d+"}, options={"expose": true})
* @ParamConverter("book")
*/
public function ajaxSetBookCopyBorrowableAction(Book $book, $newValue)
{
$user = $this->get('security.context')->getToken()->getUser();
$copies = $book->getUsersCopies($user);
$em = $this->getDoctrine()->getEntityManager();
$copies->forAll(function($key, $copy) use ($em, $newValue)
{
$copy->setBorrowable($newValue);
$em->persist($copy);
});
$em->flush();
return new Response();
}
/**
* @Route("/konyv/megveheto/{id}/{newValue}", name="KekRozsakFrontBundle_bookSetCopyForSale", requirements={"id": "\d+"}, options={"expose": true})
* @ParamConverter("book")
*/
public function ajaxSetBookCopyForSaleAction(Book $book, $newValue)
{
$user = $this->get('security.context')->getToken()->getUser();
$copies = $book->getUsersCopies($user);
$em = $this->getDoctrine()->getEntityManager();
$copies->forAll(function($key, $copy) use ($em, $newValue)
{
$copy->setBuyable($newValue);
$em->persist($copy);
});
$em->flush();
return new Response();
}
/**
* @Route("/konyv/szeretnek/{id}/{wantToBuy}", name="KekRozsakFrontBundle_bookWantOne", requirements={"id": "\d+"}, options={"expose": true})
* @ParamConverter("book")
*/
public function ajaxWantABookAction(Book $book, $wantToBuy)
{
$user = $this->get('security.context')->getToken()->getUser();
if ($wantToBuy) {
$book->addWouldBuy($user);
} else {
$book->addWouldBorrow($user);
}
$em = $this->getDoctrine()->getEntityManager();
$em->persist($book);
$em->flush();
return new Response();
}
}

@ -15,50 +15,58 @@ use KekRozsak\SecurityBundle\Form\Type\UserType;
class DefaultController extends Controller
{
/**
* @Route("/", name="KekRozsakFrontBundle_homepage")
*/
public function homepageAction()
{
$mainPageArticle = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Article')->findOneBy(array('mainPage' => true), true, array('createdAt', 'DESC'), 1);
if (!$mainPageArticle)
throw $this->createNotFoundException('A keresett cikk nem létezik!');
/**
* @Route("/", name="KekRozsakFrontBundle_homepage")
*/
public function homepageAction()
{
$mainPageArticle = $this
->getDoctrine()
->getRepository('KekRozsakFrontBundle:Article')
->findOneBy(
array('mainPage' => true),
true,
array('createdAt', 'DESC'),
1
);
if (!$mainPageArticle) {
throw $this->createNotFoundException('A keresett cikk nem létezik!');
}
return $this->forward('KekRozsakFrontBundle:Article:view', array('slug' => $mainPageArticle->getSlug()));
}
return $this->forward('KekRozsakFrontBundle:Article:view', array('slug' => $mainPageArticle->getSlug()));
}
/**
* @Route("/profil", name="KekRozsakFrontBundle_profile_edit")
* @Template("KekRozsakFrontBundle:Default:userprofile.html.twig")
*/
public function profileEditAction()
{
$user = $this->get('security.context')->getToken()->getUser();
/**
* @Route("/profil", name="KekRozsakFrontBundle_profile_edit")
* @Template("KekRozsakFrontBundle:Default:userprofile.html.twig")
*/
public function profileEditAction()
{
$user = $this->get('security.context')->getToken()->getUser();
$oldPassword = $user->getPassword();
$form = $this->createForm(new UserType(), $user);
$saveSuccess = false;
$request = $this->getRequest();
$oldPassword = $user->getPassword();
$form = $this->createForm(new UserType(), $user);
$saveSuccess = false;
$request = $this->getRequest();
if ($request->getMethod() == 'POST')
{
$form->bind($request);
if ($form->isValid())
{
if ($user->getPassword() == '')
$user->setPassword($oldPassword);
else
$user->setPassword($this->get('security.encoder_factory')->getEncoder($user)->encodePassword($user->getPassword(), $user->getSalt()));
if ($request->getMethod() == 'POST') {
$form->bind($request);
if ($form->isValid()) {
if ($user->getPassword() == '') {
$user->setPassword($oldPassword);
} else {
$user->setPassword($this->get('security.encoder_factory')->getEncoder($user)->encodePassword($user->getPassword(), $user->getSalt()));
}
$em = $this->getDoctrine()->getEntityManager();
$em->persist($user);
$em->flush();
}
}
$em = $this->getDoctrine()->getEntityManager();
$em->persist($user);
$em->flush();
}
}
return array(
'form' => $form->createView(),
'saveSuccess' => $saveSuccess,
);
}
return array(
'form' => $form->createView(),
'saveSuccess' => $saveSuccess,
);
}
}

@ -13,93 +13,101 @@ use KekRozsak\FrontBundle\Extensions\Slugifier;
class DocumentController extends Controller
{
/**
* @Route("/dokumentum/{slug}.{_format}", name="KekRozsakFrontBundle_documentView", defaults={"_format": "html"}, requirements={"_format": "html|pdf"})
* @Template()
* @ParamConverter("document")
*/
public function viewAction(Document $document, $_format)
{
$templateParams = array(
'document' => $document,
);
if ($_format == 'pdf')
{
$html = $this->renderView('KekRozsakFrontBundle:Document:pdfView.html.twig', $templateParams);
return $this->get('io_tcpdf')->quick_pdf($html);
}
return $templateParams;
}
/**
* @Route("/dokumentumok/uj/", name="KekRozsakFrontBundle_documentCreate")
* @Template()
*/
public function createAction()
{
$document = new Document();
$document->setSlug('n-a');
$form = $this->createForm(new DocumentType(), $document);
$request = $this->getRequest();
if ($request->getMethod() == 'POST')
{
$form->bind($request);
if ($form->isValid())
{
/* TODO: move these lines into life cycle events */
$slugifier = new Slugifier();
$document->setSlug($slugifier->slugify($document->getTitle()));
$document->setCreatedAt(new \DateTime('now'));
$document->setCreatedBy($this->get('security.context')->getToken()->getUser());
$em = $this->getDoctrine()->getEntityManager();
$em->persist($document);
$em->flush();
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_documentView', array('slug' => $document->getSlug())));
}
}
return array(
'form' => $form->createView(),
);
}
/**
* @Route("/dokumentum/{slug}/szerkesztes", name="KekRozsakFrontBundle_documentEdit")
* @Template()
* @ParamConverter("document")
*/
public function editAction(Document $document)
{
$form = $this->createForm(new DocumentType(), $document);
$request = $this->getRequest();
if ($request->getMethod() == 'POST')
{
$form->bind($request);
if ($form->isValid())
{
/* TODO: move these lines into life cycle events */
$slugifier = new Slugifier();
$document->setSlug($slugifier->slugify($document->getTitle()));
// TODO: add updatedAt, updatedBy, updateReason, etc.
$em = $this->getDoctrine()->getEntityManager();
$em->persist($document);
$em->flush();
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_documentView', array('slug' => $document->getSlug())));
}
}
return array(
'document' => $document,
'form' => $form->createView(),
);
}
/**
* @Route("/dokumentum/{slug}.{_format}", name="KekRozsakFrontBundle_documentView", defaults={"_format": "html"}, requirements={"_format": "html|pdf"})
* @Template()
* @ParamConverter("document")
*/
public function viewAction(Document $document, $_format)
{
$templateParams = array(
'document' => $document,
);
if ($_format == 'pdf') {
$html = $this->renderView(
'KekRozsakFrontBundle:Document:pdfView.html.twig',
$templateParams
);
return $this->get('io_tcpdf')->quick_pdf($html);
}
return $templateParams;
}
/**
* @Route("/dokumentumok/uj/", name="KekRozsakFrontBundle_documentCreate")
* @Template()
*/
public function createAction()
{
$document = new Document();
$document->setSlug('n-a');
$form = $this->createForm(new DocumentType(), $document);
$request = $this->getRequest();
if ($request->getMethod() == 'POST') {
$form->bind($request);
if ($form->isValid()) {
// TODO: move these lines into life cycle events
$slugifier = new Slugifier();
$document->setSlug($slugifier->slugify($document->getTitle()));
$document->setCreatedAt(new \DateTime('now'));
$document->setCreatedBy($this->get('security.context')->getToken()->getUser());
$em = $this->getDoctrine()->getEntityManager();
$em->persist($document);
$em->flush();
return $this->redirect(
$this->generateUrl(
'KekRozsakFrontBundle_documentView',
array('slug' => $document->getSlug())
)
);
}
}
return array(
'form' => $form->createView(),
);
}
/**
* @Route("/dokumentum/{slug}/szerkesztes", name="KekRozsakFrontBundle_documentEdit")
* @Template()
* @ParamConverter("document")
*/
public function editAction(Document $document)
{
$form = $this->createForm(new DocumentType(), $document);
$request = $this->getRequest();
if ($request->getMethod() == 'POST') {
$form->bind($request);
if ($form->isValid()) {
// TODO: move these lines into life cycle events
$slugifier = new Slugifier();
$document->setSlug($slugifier->slugify($document->getTitle()));
// TODO: add updatedAt, updatedBy, updateReason, etc.
$em = $this->getDoctrine()->getEntityManager();
$em->persist($document);
$em->flush();
return $this->redirect(
$this->generateUrl(
'KekRozsakFrontBundle_documentView',
array('slug' => $document->getSlug())
)
);
}
}
return array(
'document' => $document,
'form' => $form->createView(),
);
}
}

@ -12,89 +12,91 @@ use KekRozsak\FrontBundle\Entity\Event;
class EventController extends Controller
{
/**
* @Route("/esesmeny/{startDate}/{eventSlug}", name="KekRozsakFrontBundle_eventView")
* @Template()
* @ParamConverter("event", class="KekRozsakFrontBundle:Event", options={"mapping"={"eventSlug" = "slug", "startDate"="startDate"}})
* @ParamConverter("startDate", class="DateTime", options={"format"="Y-m-d"})
*/
public function viewAction(\DateTime $startDate, Event $event)
{
if ($event->getGroup() !== null)
{
if (!$event->getGroup()->isMember($this->get('security.context')->getToken()->getUser()))
throw new AccessDeniedException('Ehhez az eseményhez nem csatlakozhatsz, mivel a csoportjának nem vagy tagja.');
}
/**
* @Route("/esesmeny/{startDate}/{eventSlug}", name="KekRozsakFrontBundle_eventView")
* @Template()
* @ParamConverter("event", class="KekRozsakFrontBundle:Event", options={"mapping"={"eventSlug" = "slug", "startDate"="startDate"}})
* @ParamConverter("startDate", class="DateTime", options={"format"="Y-m-d"})
*/
public function viewAction(\DateTime $startDate, Event $event)
{
if ($event->getGroup() !== null) {
if (!$event->getGroup()->isMember($this->get('security.context')->getToken()->getUser())) {
throw new AccessDeniedException('Ehhez az eseményhez nem csatlakozhatsz, mivel a csoportjának nem vagy tagja.');
}
}
return array(
'event' => $event,
);
}
return array(
'event' => $event,
);
}
/**
* @Route("/esemeny/{startDate}/{eventSlug}/csatlakozas", name="KekRozsakFrontBundle_eventJoin")
* @Template()
* @ParamConverter("event", class="KekRozsakFrontBundle:Event", options={"mapping"={"eventSlug": "slug", "startDate": "startDate"}})
* @ParamConverter("startDate", class="DateTime", options={"format"="Y-m-d"})
*/
public function joinAction(\DateTime $startDate, Event $event)
{
$user = $this->get('security.context')->getToken()->getUser();
/**
* @Route("/esemeny/{startDate}/{eventSlug}/csatlakozas", name="KekRozsakFrontBundle_eventJoin")
* @Template()
* @ParamConverter("event", class="KekRozsakFrontBundle:Event", options={"mapping"={"eventSlug": "slug", "startDate": "startDate"}})
* @ParamConverter("startDate", class="DateTime", options={"format"="Y-m-d"})
*/
public function joinAction(\DateTime $startDate, Event $event)
{
if ($event->getGroup() !== null)
{
if (!$event->getGroup()->isMember($this->get('security.context')->getToken()->getUser()))
throw new AccessDeniedException('Ehhez az eseményhez nem csatlakozhatsz, mivel a csoportjának nem vagy tagja.');
}
if ($event->getGroup() !== null) {
if (!$event->getGroup()->isMember($user)) {
throw new AccessDeniedException('Ehhez az eseményhez nem csatlakozhatsz, mivel a csoportjának nem vagy tagja.');
}
}
$event->addAttendee($this->get('security.context')->getToken()->getUser());
$event->addAttendee($user);
$em = $this->getDoctrine()->getEntityManager();
$em->persist($event);
$em->flush();
$em = $this->getDoctrine()->getEntityManager();
$em->persist($event);
$em->flush();
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_eventView', array(
'eventDate' => $eventDate,
'eventSlug' => $eventSlug,
)));
}
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_eventView', array(
'eventDate' => $eventDate,
'eventSlug' => $eventSlug,
)));
}
/**
* @Route("/esemenyek/{date}", name="KekRozsakFrontBundle_eventList", defaults={"date": null})
* @Template()
*/
public function listAction($date = null)
{
$realDate = null;
/**
* @Route("/esemenyek/{date}", name="KekRozsakFrontBundle_eventList", defaults={"date": null})
* @Template()
*/
public function listAction($date = null)
{
$realDate = null;
if ($date === null) {
$query = $this->getDoctrine()->getEntityManager()->createQuery('SELECT e FROM KekRozsakFrontBundle:Event e WHERE e.cancelled = FALSE AND (e.startDate >= :day OR (e.startDate <= :day AND e.endDate >= :day))');
$query->setParameter('day', new \DateTime('now'), \Doctrine\DBAL\Types\Type::DATE);
} else {
$realDate = \DateTime::createFromFormat('Y-m-d', $date);
$query = $this->getDoctrine()->getEntityManager()->createQuery('SELECT e FROM KekRozsakFrontBundle:Event e WHERE e.cancelled = FALSE AND ((e.startDate < :day AND e.endDate >= :day) OR e.startDate = :day)');
$query->setParameter('day', $realDate, \Doctrine\DBAL\Types\Type::DATE);
}
$events = $query->getResult();
if ($date === null) {
$query = $this->getDoctrine()->getEntityManager()->createQuery('SELECT e FROM KekRozsakFrontBundle:Event e WHERE e.cancelled = FALSE AND (e.startDate >= :day OR (e.startDate <= :day AND e.endDate >= :day))');
$query->setParameter('day', new \DateTime('now'), \Doctrine\DBAL\Types\Type::DATE);
} else {
$realDate = \DateTime::createFromFormat('Y-m-d', $date);
$query = $this->getDoctrine()->getEntityManager()->createQuery('SELECT e FROM KekRozsakFrontBundle:Event e WHERE e.cancelled = FALSE AND ((e.startDate < :day AND e.endDate >= :day) OR e.startDate = :day)');
$query->setParameter('day', $realDate, \Doctrine\DBAL\Types\Type::DATE);
}
$events = $query->getResult();
return array(
'day' => $realDate,
'events' => $events,
);
}
return array(
'day' => $realDate,
'events' => $events,
);
}
/**
* @Route("/esemenyek/{date}/ajax-lista.{_format}", name="KekRozsakFrontBundle_eventAjaxList", requirements={"_format": "html"})
* @Template()
* @ParamConverter("date", options={"format": "Y-m-d"})
*/
public function ajaxListAction(\DateTime $date)
{
$query = $this->getDoctrine()->getEntityManager()->createQuery('SELECT e FROM KekRozsakFrontBundle:Event e WHERE e.cancelled = FALSE AND ((e.startDate < :day AND e.endDate >= :day) OR e.startDate = :day)');
$query->setParameter('day', $date, \Doctrine\DBAL\Types\Type::DATE);
$events = $query->getResult();
/**
* @Route("/esemenyek/{date}/ajax-lista.{_format}", name="KekRozsakFrontBundle_eventAjaxList", requirements={"_format": "html"})
* @Template()
* @ParamConverter("date", options={"format": "Y-m-d"})
*/
public function ajaxListAction(\DateTime $date)
{
$query = $this->getDoctrine()->getEntityManager()->createQuery('SELECT e FROM KekRozsakFrontBundle:Event e WHERE e.cancelled = FALSE AND ((e.startDate < :day AND e.endDate >= :day) OR e.startDate = :day)');
$query->setParameter('day', $date, \Doctrine\DBAL\Types\Type::DATE);
$events = $query->getResult();
return array(
'day' => $date,
'events' => $events,
);
}
return array(
'day' => $date,
'events' => $events,
);
}
}

@ -17,77 +17,90 @@ use KekRozsak\FrontBundle\Form\Type\ForumPostType;
*/
class ForumController extends Controller
{
/**
* @Route("", name="KekRozsakFrontBundle_forumTopicGroupList")
* @Template()
*/
public function topicGroupListAction()
{
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumTopicGroup');
/**
* @Route("", name="KekRozsakFrontBundle_forumTopicGroupList")
* @Template()
*/
public function topicGroupListAction()
{
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumTopicGroup');
// TODO: ORDER the topic list by last post date
$topicGroups = $groupRepo->findAll();
// TODO: ORDER the topic list by last post date
$topicGroups = $groupRepo->findAll();
return array(
'topicGroups' => $topicGroups,
);
}
return array(
'topicGroups' => $topicGroups,
);
}
/**
* @Route("/{slug}", name="KekRozsakFrontBundle_forumTopicList")
* @Template()
* @ParamConverter("topicGroup")
*/
public function topicListAction(ForumTopicgRoup $topicGroup)
{
return array(
'topicGroup' => $topicGroup,
);
}
/**
* @Route("/{slug}", name="KekRozsakFrontBundle_forumTopicList")
* @Template()
* @ParamConverter("topicGroup")
*/
public function topicListAction(ForumTopicgRoup $topicGroup)
{
return array(
'topicGroup' => $topicGroup,
);
}
/**
* @Route("/{topicGroupSlug}/{topicSlug}", name="KekRozsakFrontBundle_forumPostList")
* @Template()
* @ParamConverter("topic", options={"mapping"={"topicGroup"="topicGroup", "topicSlug"="slug"}})
* @ParamConverter("topicGroup", options={"mapping"={"topicGroupSlug"="slug"}})
*/
public function postListAction(ForumTopicGroup $topicGroup, ForumTopic $topic)
{
// Get the list of posts in the requested topic
$postRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumPost');
$posts = $postRepo->findBy(array('topic' => $topic), array('createdAt' => 'DESC') /* TODO: , limit, offset */);
/**
* @Route("/{topicGroupSlug}/{topicSlug}", name="KekRozsakFrontBundle_forumPostList")
* @Template()
* @ParamConverter("topic", options={"mapping"={"topicGroup"="topicGroup", "topicSlug"="slug"}})
* @ParamConverter("topicGroup", options={"mapping"={"topicGroupSlug"="slug"}})
*/
public function postListAction(ForumTopicGroup $topicGroup, ForumTopic $topic)
{
// Get the list of posts in the requested topic
$postRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumPost');
$posts = $postRepo->findBy(
array('topic' => $topic),
array('createdAt' => 'DESC')
/* TODO: , limit, offset */
);
// Create an empty post object for posting
$post = new ForumPost();
$form = $this->createForm(new ForumPostType($topicGroup->getId(), $topic->getId()), $post);
// Create an empty post object for posting
$post = new ForumPost();
$form = $this->createForm(
new ForumPostType(
$topicGroup->getId(),
$topic->getId()
),
$post
);
$request = $this->getRequest();
if ($request->getMethod() == 'POST')
{
$form->bind($request);
if ($form->isValid())
{
$post->setCreatedAt(new \DateTime('now'));
$post->setCreatedBy($this->get('security.context')->getToken()->getUser());
$post->setTopic($topic);
$request = $this->getRequest();
if ($request->getMethod() == 'POST') {
$form->bind($request);
if ($form->isValid()) {
$post->setCreatedAt(new \DateTime('now'));
$post->setCreatedBy($this->get('security.context')->getToken()->getUser());
$post->setTopic($topic);
$em = $this->getDoctrine()->getEntityManager();
$em->persist($post);
$em->persist($topic);
$em->flush();
$em = $this->getDoctrine()->getEntityManager();
$em->persist($post);
$em->persist($topic);
$em->flush();
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_forumPostList', array(
return $this->redirect(
$this->generateUrl(
'KekRozsakFrontBundle_forumPostList',
array(
'topicGroupSlug' => $topicGroup->getSlug(),
'topicSlug' => $topic->getSlug(),
)));
}
}
)
)
);
}
}
return array(
'topicGroup' => $topicGroup,
'topic' => $topic,
'posts' => $posts,
'form' => $form->createView(),
);
}
return array(
'topicGroup' => $topicGroup,
'topic' => $topic,
'posts' => $posts,
'form' => $form->createView(),
);
}
}

@ -16,151 +16,147 @@ use KekRozsak\FrontBundle\Extensions\Slugifier;
class GroupController extends Controller
{
/**
* @Route("/csoportok", name="KekRozsakFrontBundle_groupList")
* @Template()
*/
public function listAction()
{
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Group');
$groups = $groupRepo->findAll(array('name' => 'ASC'));
return array(
'groups' => $groups,
);
}
/**
* @Route("/csoport/{slug}", name="KekRozsakFrontBundle_groupView")
* @Template()
* @ParamConverter("group")
*/
public function viewAction(Group $group)
{
return array(
'group' => $group,
);
}
/**
* @Route("/csoport/{slug}/tagok", name="KekRozsakFrontBundle_groupMembers")
* @Template()
* @ParamConverter("group")
*/
public function membersAction(Group $group)
{
return array(
'group' => $group,
);
}
/**
* @Route("/csoport/{slug}/dokumentumok", name="KekRozsakFrontBundle_groupDocuments")
* @Template()
* @ParamConverter("group")
*/
public function documentsAction(Group $group)
{
return array(
'group' => $group,
);
}
/**
* @Route("/csoport/{slug}/belepes", name="KekRozsakFrontBundle_groupJoin")
* @Template()
* @ParamConverter("group")
*/
public function joinAction(Group $group)
{
$user = $this->get('security.context')->getToken()->getUser();
if ($group->isMember($user))
{
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_groupView', array('slug' => $group->getSlug())));
}
if ($group->isRequested($user))
{
return array(
'isRequested' => true,
'needApproval' => false,
'group' => $group,
);
}
$membership = new UserGroupMembership($user, $group);
$membership->setUser($user);
$membership->setGroup($group);
$membership->setMembershipRequestedAt(new \DateTime('now'));
if ($group->isOpen())
{
$membership->setMembershipAcceptedAt(new \DateTime('now'));
}
$em = $this->getDoctrine()->getEntityManager();
$em->persist($membership);
$em->flush();
if ($group->isOpen())
{
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_groupView', array('slug' => $group->getSlug())));
}
else
{
$message = \Swift_Message::newInstance()
->setSubject('Új jelentkező a csoportodban (' . $group->getName() . '): ' . $user->getDisplayName())
// TODO: Make this a config parameter!
->setFrom('info@blueroses.hu')
->setTo($group->getLeader()->getEmail())
->setBody($this->renderView('KekRozsakFrontBundle:Email:groupJoinRequest.txt.twig', array('user' => $user, 'group' => $group)));
$this->get('mailer')->send($message);
return array(
'isRequested' => false,
'needApproval' => true,
'group' => $group,
);
}
}
/**
* @Route("/csoportok/uj", name="KekRozsakFrontBundle_groupCreate")
* @Template()
*/
public function createAction()
{
$group = new Group();
$form = $this->createForm(new GroupType(), $group);
$request = $this->getRequest();
if ($request->getMethod() == 'POST')
{
$form->bind($request);
if ($form->isValid())
{
$slugifier = new Slugifier();
$user = $this->get('security.context')->getToken()->getUser();
$group->setCreatedBy($user);
$group->setSlug($slugifier->slugify($group->getName()));
$group->setCreatedAt(new \DateTime('now'));
$group->setOpen(true);
$em = $this->getDoctrine()->getEntityManager();
$em->persist($group);
$em->flush();
$membership = new UserGroupMembership($user, $group);
$em->persist($membership);
$em->flush();
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_groupList'));
}
}
return array(
'form' => $form->createView(),
);
}
/**
* @Route("/csoportok", name="KekRozsakFrontBundle_groupList")
* @Template()
*/
public function listAction()
{
$groupRepo = $this
->getDoctrine()
->getRepository('KekRozsakFrontBundle:Group');
$groups = $groupRepo->findAll(array('name' => 'ASC'));
return array(
'groups' => $groups,
);
}
/**
* @Route("/csoport/{slug}", name="KekRozsakFrontBundle_groupView")
* @Template()
* @ParamConverter("group")
*/
public function viewAction(Group $group)
{
return array(
'group' => $group,
);
}
/**
* @Route("/csoport/{slug}/tagok", name="KekRozsakFrontBundle_groupMembers")
* @Template()
* @ParamConverter("group")
*/
public function membersAction(Group $group)
{
return array(
'group' => $group,
);
}
/**
* @Route("/csoport/{slug}/dokumentumok", name="KekRozsakFrontBundle_groupDocuments")
* @Template()
* @ParamConverter("group")
*/
public function documentsAction(Group $group)
{
return array(
'group' => $group,
);
}
/**
* @Route("/csoport/{slug}/belepes", name="KekRozsakFrontBundle_groupJoin")
* @Template()
* @ParamConverter("group")
*/
public function joinAction(Group $group)
{
$user = $this->get('security.context')->getToken()->getUser();
if ($group->isMember($user)) {
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_groupView', array('slug' => $group->getSlug())));
}
if ($group->isRequested($user)) {
return array(
'isRequested' => true,
'needApproval' => false,
'group' => $group,
);
}
$membership = new UserGroupMembership($user, $group);
$membership->setUser($user);
$membership->setGroup($group);
$membership->setMembershipRequestedAt(new \DateTime('now'));
if ($group->isOpen()) {
$membership->setMembershipAcceptedAt(new \DateTime('now'));
}
$em = $this->getDoctrine()->getEntityManager();
$em->persist($membership);
$em->flush();
if ($group->isOpen()) {
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_groupView', array('slug' => $group->getSlug())));
} else {
$message = \Swift_Message::newInstance()
->setSubject('Új jelentkező a csoportodban (' . $group->getName() . '): ' . $user->getDisplayName())
// TODO: Make this a config parameter!
->setFrom('info@blueroses.hu')
->setTo($group->getLeader()->getEmail())
->setBody($this->renderView('KekRozsakFrontBundle:Email:groupJoinRequest.txt.twig', array('user' => $user, 'group' => $group)));
$this->get('mailer')->send($message);
return array(
'isRequested' => false,
'needApproval' => true,
'group' => $group,
);
}
}
/**
* @Route("/csoportok/uj", name="KekRozsakFrontBundle_groupCreate")
* @Template()
*/
public function createAction()
{
$group = new Group();
$form = $this->createForm(new GroupType(), $group);
$request = $this->getRequest();
if ($request->getMethod() == 'POST') {
$form->bind($request);
if ($form->isValid()) {
$slugifier = new Slugifier();
$user = $this->get('security.context')->getToken()->getUser();
$group->setCreatedBy($user);
$group->setSlug($slugifier->slugify($group->getName()));
$group->setCreatedAt(new \DateTime('now'));
$group->setOpen(true);
$em = $this->getDoctrine()->getEntityManager();
$em->persist($group);
$em->flush();
$membership = new UserGroupMembership($user, $group);
$em->persist($membership);
$em->flush();
return $this->redirect(
$this->generateUrl('KekRozsakFrontBundle_groupList')
);
}
}
return array(
'form' => $form->createView(),
);
}
}

@ -12,247 +12,273 @@ use KekRozsak\SecurityBundle\Entity\User;
*/
class Article
{
/**
* @var integer $id
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
protected $id;
/**
* The ID of the Article
*
* @var integer $id
*
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
protected $id;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* @var KekRozsak\SecurityBundle\Entity\User $createdBy
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
* @ORM\JoinColumn(name="created_by_id")
*/
protected $createdBy;
/**
* The User who created the Article
*
* @var KekRozsak\SecurityBundle\Entity\User $createdBy
*
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
* @ORM\JoinColumn(name="created_by_id")
*/
protected $createdBy;
/**
* Set createdBy
*
* @param KekRozsak\SecurityBundle\Entity\User $createdBy
* @return Article
*/
public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy)
{
$this->createdBy = $createdBy;
return $this;
}
/**
* Set createdBy
*
* @param KekRozsak\SecurityBundle\Entity\User $createdBy
* @return Article
*/
public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy)
{
$this->createdBy = $createdBy;
return $this;
}
/**
* Get createdBy
*
* @return KekRozsak\SecurityBundle\Entity\User
*/
public function getCreatedBy()
{
return $this->createdBy;
}
/**
* Get createdBy
*
* @return KekRozsak\SecurityBundle\Entity\User
*/
public function getCreatedBy()
{
return $this->createdBy;
}