From fab08cad6f2d96760367ae34095e394a975fed1e Mon Sep 17 00:00:00 2001 From: Gergely POLONKAI Date: Thu, 16 Aug 2012 15:52:41 +0200 Subject: [PATCH] Refactored code to comply with PSR-* Signed-off-by: Gergely POLONKAI --- .../Controller/DefaultController.php | 112 ++- .../AdminBundle/Resources/config/services.xml | 4 +- .../views/Default/groupJoinRequests.html.twig | 54 +- .../views/Default/manageRegs.html.twig | 42 +- .../Controller/ArticleController.php | 39 +- .../FrontBundle/Controller/BookController.php | 221 ++--- .../Controller/DefaultController.php | 88 +- .../Controller/DocumentController.php | 160 ++-- .../Controller/EventController.php | 164 ++-- .../Controller/ForumController.php | 137 +-- .../Controller/GroupController.php | 254 +++--- src/KekRozsak/FrontBundle/Entity/Article.php | 462 +++++----- src/KekRozsak/FrontBundle/Entity/Book.php | 562 +++++++------ src/KekRozsak/FrontBundle/Entity/BookCopy.php | 272 +++--- src/KekRozsak/FrontBundle/Entity/Document.php | 521 ++++++------ src/KekRozsak/FrontBundle/Entity/Event.php | 794 +++++++++--------- .../FrontBundle/Entity/ForumPost.php | 307 ++++--- .../FrontBundle/Entity/ForumTopic.php | 426 +++++----- .../FrontBundle/Entity/ForumTopicGroup.php | 315 +++---- src/KekRozsak/FrontBundle/Entity/Group.php | 612 +++++++------- src/KekRozsak/FrontBundle/Entity/News.php | 309 +++---- src/KekRozsak/FrontBundle/Entity/UserData.php | 724 ++++++++-------- .../Entity/UserGroupMembership.php | 323 +++---- .../FrontBundle/Extensions/Slugifier.php | 58 +- .../Extension/HelpMessageTypeExtension.php | 37 +- .../FrontBundle/Form/Type/DocumentType.php | 30 +- .../FrontBundle/Form/Type/ForumPostType.php | 58 +- .../FrontBundle/Form/Type/GroupType.php | 28 +- .../FrontBundle/Form/Type/UserDataType.php | 158 ++-- .../FrontBundle/Resources/config/services.xml | 32 +- .../Resources/public/css/forum.css | 64 +- .../Resources/public/css/group.css | 10 +- .../Resources/public/css/popup.css | 102 +-- .../Resources/views/Book/ajaxData.html.twig | 46 +- .../Resources/views/Book/list.html.twig | 246 +++--- .../Resources/views/Box/Events.html.twig | 76 +- .../Resources/views/Box/Login.html.twig | 24 +- .../Resources/views/Box/UserProfile.html.twig | 39 +- .../views/Default/userprofile.html.twig | 6 +- .../Resources/views/Document/create.html.twig | 4 +- .../Resources/views/Document/edit.html.twig | 4 +- .../Resources/views/Document/view.html.twig | 2 +- .../Resources/views/Event/ajaxList.html.twig | 16 +- .../Resources/views/Event/list.html.twig | 2 +- .../Resources/views/Event/view.html.twig | 4 +- .../Resources/views/Form/user_form.html.twig | 12 +- .../Resources/views/Forum/postList.html.twig | 70 +- .../views/Forum/topicGroupList.html.twig | 44 +- .../Resources/views/Forum/topicList.html.twig | 36 +- .../Resources/views/Group/create.html.twig | 3 +- .../Resources/views/Group/documents.html.twig | 39 +- .../Resources/views/Group/list.html.twig | 80 +- .../Resources/views/Group/members.html.twig | 9 +- .../Resources/views/Group/view.html.twig | 6 +- .../FrontBundle/Twig/TwigBBExtension.php | 171 ++-- .../Controller/DefaultController.php | 224 ++--- .../Compiler/OverrideServiceCompilerPass.php | 12 +- src/KekRozsak/SecurityBundle/Entity/Role.php | 286 ++++--- src/KekRozsak/SecurityBundle/Entity/User.php | 678 ++++++++------- .../SecurityBundle/Form/Type/UserType.php | 126 +-- .../KekRozsakSecurityBundle.php | 10 +- .../Resources/config/services.xml | 30 +- .../views/Default/ajaxUserdata.html.twig | 12 +- .../Resources/views/Default/login.html.twig | 6 +- .../views/Default/regSuccess.html.twig | 2 +- .../views/Default/registration.html.twig | 8 +- .../SecurityBundle/Security/AuthSuccess.php | 43 +- .../SecurityBundle/Service/CryptEncoder.php | 16 +- .../Twig/UserDataSpanExtension.php | 55 +- 69 files changed, 5253 insertions(+), 4673 deletions(-) diff --git a/src/KekRozsak/AdminBundle/Controller/DefaultController.php b/src/KekRozsak/AdminBundle/Controller/DefaultController.php index fbe512c..0e7c16e 100644 --- a/src/KekRozsak/AdminBundle/Controller/DefaultController.php +++ b/src/KekRozsak/AdminBundle/Controller/DefaultController.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( + ); + } } diff --git a/src/KekRozsak/AdminBundle/Resources/config/services.xml b/src/KekRozsak/AdminBundle/Resources/config/services.xml index 6800790..edd12d2 100644 --- a/src/KekRozsak/AdminBundle/Resources/config/services.xml +++ b/src/KekRozsak/AdminBundle/Resources/config/services.xml @@ -1,4 +1,6 @@ - + diff --git a/src/KekRozsak/AdminBundle/Resources/views/Default/groupJoinRequests.html.twig b/src/KekRozsak/AdminBundle/Resources/views/Default/groupJoinRequests.html.twig index 401d606..99b80c4 100644 --- a/src/KekRozsak/AdminBundle/Resources/views/Default/groupJoinRequests.html.twig +++ b/src/KekRozsak/AdminBundle/Resources/views/Default/groupJoinRequests.html.twig @@ -6,38 +6,38 @@

Csoport jelentkezők

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.

- - - - - - - + + + + + + + {% for group in groups %} - - - - + + + + {% for request in group.members %} {% if not group.isMember(request.user) %} - - - - + + + + {% endif %} {% endfor %} {% endfor %} - +
Csoport / Jelentkező
Csoport / Jelentkező
[ikon]{{ group.name }}
[ikon]{{ group.name }}
{{ request.user|userdataspan }} -
- - - -
-
- - - -
-
{{ request.user|userdataspan }} +
+ + + +
+
+ + + +
+
{% endblock content %} diff --git a/src/KekRozsak/AdminBundle/Resources/views/Default/manageRegs.html.twig b/src/KekRozsak/AdminBundle/Resources/views/Default/manageRegs.html.twig index c79f0e0..a8cb3d2 100644 --- a/src/KekRozsak/AdminBundle/Resources/views/Default/manageRegs.html.twig +++ b/src/KekRozsak/AdminBundle/Resources/views/Default/manageRegs.html.twig @@ -6,29 +6,29 @@

Jelentkezők

{% if users|length > 0 %} - - - - - - - - - + + + + + + + + + {% for user in users %} - - - - - - - + + + + + + + {% endfor %} - +
FelhasználónévE-mail címFórum-névRegisztráció ideje
FelhasználónévE-mail címFórum-névRegisztráció ideje
{{ user.username }}{{ user.email }}{{ user|userdataspan }}{{ user.registeredAt|date('Y-m-d H:i') }} -
- -
-
{{ user.username }}{{ user.email }}{{ user|userdataspan }}{{ user.registeredAt|date('Y-m-d H:i') }} +
+ +
+
{% endif %} {%endblock content %} diff --git a/src/KekRozsak/FrontBundle/Controller/ArticleController.php b/src/KekRozsak/FrontBundle/Controller/ArticleController.php index 4735d94..afb6e12 100644 --- a/src/KekRozsak/FrontBundle/Controller/ArticleController.php +++ b/src/KekRozsak/FrontBundle/Controller/ArticleController.php @@ -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, + ); + } } diff --git a/src/KekRozsak/FrontBundle/Controller/BookController.php b/src/KekRozsak/FrontBundle/Controller/BookController.php index 39fad41..3ee37fc 100644 --- a/src/KekRozsak/FrontBundle/Controller/BookController.php +++ b/src/KekRozsak/FrontBundle/Controller/BookController.php @@ -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'); + /** + * @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(); + $books = $query->getResult(); - return array( - 'books' => $books, - ); - } + 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("/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(); + /** + * @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(); - } + 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(); - } + /** + * @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(); - } + 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/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(); - /** - * @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(); - } + 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("/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(); + } } - diff --git a/src/KekRozsak/FrontBundle/Controller/DefaultController.php b/src/KekRozsak/FrontBundle/Controller/DefaultController.php index 0d065a0..eed66ed 100644 --- a/src/KekRozsak/FrontBundle/Controller/DefaultController.php +++ b/src/KekRozsak/FrontBundle/Controller/DefaultController.php @@ -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, + ); + } } diff --git a/src/KekRozsak/FrontBundle/Controller/DocumentController.php b/src/KekRozsak/FrontBundle/Controller/DocumentController.php index bf382bc..109fa05 100644 --- a/src/KekRozsak/FrontBundle/Controller/DocumentController.php +++ b/src/KekRozsak/FrontBundle/Controller/DocumentController.php @@ -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, - ); + /** + * @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); - } + if ($_format == 'pdf') { + $html = $this->renderView( + 'KekRozsakFrontBundle:Document:pdfView.html.twig', + $templateParams + ); + return $this->get('io_tcpdf')->quick_pdf($html); + } - return $templateParams; - } + 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(); + /** + * @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 ($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()); + 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(); + $em = $this->getDoctrine()->getEntityManager(); + $em->persist($document); + $em->flush(); - return $this->redirect($this->generateUrl('KekRozsakFrontBundle_documentView', array('slug' => $document->getSlug()))); - } - } + return $this->redirect( + $this->generateUrl( + 'KekRozsakFrontBundle_documentView', + array('slug' => $document->getSlug()) + ) + ); + } + } - return array( - 'form' => $form->createView(), - ); - } + 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(); + /** + * @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. + 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(); + $em = $this->getDoctrine()->getEntityManager(); + $em->persist($document); + $em->flush(); - return $this->redirect($this->generateUrl('KekRozsakFrontBundle_documentView', array('slug' => $document->getSlug()))); - } - } + return $this->redirect( + $this->generateUrl( + 'KekRozsakFrontBundle_documentView', + array('slug' => $document->getSlug()) + ) + ); + } + } - return array( - 'document' => $document, - 'form' => $form->createView(), - ); - } + return array( + 'document' => $document, + 'form' => $form->createView(), + ); + } } diff --git a/src/KekRozsak/FrontBundle/Controller/EventController.php b/src/KekRozsak/FrontBundle/Controller/EventController.php index d53dfeb..dea096c 100644 --- a/src/KekRozsak/FrontBundle/Controller/EventController.php +++ b/src/KekRozsak/FrontBundle/Controller/EventController.php @@ -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.'); - } - - 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) - { - 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.'); - } - - $event->addAttendee($this->get('security.context')->getToken()->getUser()); - - $em = $this->getDoctrine()->getEntityManager(); - $em->persist($event); - $em->flush(); - - 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; - - 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); + /** + * @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.'); } - $events = $query->getResult(); + } - return array( - 'day' => $realDate, - 'events' => $events, - ); - } + return array( + 'event' => $event, + ); + } - /** - * @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("/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(); - return array( - 'day' => $date, - 'events' => $events, - ); - } + 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($user); + + $em = $this->getDoctrine()->getEntityManager(); + $em->persist($event); + $em->flush(); + + 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; + + 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, + ); + } + + /** + * @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, + ); + } } diff --git a/src/KekRozsak/FrontBundle/Controller/ForumController.php b/src/KekRozsak/FrontBundle/Controller/ForumController.php index 44c04ef..7289e3a 100644 --- a/src/KekRozsak/FrontBundle/Controller/ForumController.php +++ b/src/KekRozsak/FrontBundle/Controller/ForumController.php @@ -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(), + ); + } } diff --git a/src/KekRozsak/FrontBundle/Controller/GroupController.php b/src/KekRozsak/FrontBundle/Controller/GroupController.php index efe6ffb..6b96f3c 100644 --- a/src/KekRozsak/FrontBundle/Controller/GroupController.php +++ b/src/KekRozsak/FrontBundle/Controller/GroupController.php @@ -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')); + /** + * @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, - ); - } + 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}", 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}/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}/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(); + /** + * @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->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, - ); - } + 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')); - } + $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(); + $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); + 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, - ); - } - } + 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(); + /** + * @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(); + 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); + $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(); + $em = $this->getDoctrine()->getEntityManager(); + $em->persist($group); + $em->flush(); - $membership = new UserGroupMembership($user, $group); - $em->persist($membership); - $em->flush(); + $membership = new UserGroupMembership($user, $group); + $em->persist($membership); + $em->flush(); - return $this->redirect($this->generateUrl('KekRozsakFrontBundle_groupList')); - } - } + return $this->redirect( + $this->generateUrl('KekRozsakFrontBundle_groupList') + ); + } + } - return array( - 'form' => $form->createView(), - ); - } + return array( + 'form' => $form->createView(), + ); + } } diff --git a/src/KekRozsak/FrontBundle/Entity/Article.php b/src/KekRozsak/FrontBundle/Entity/Article.php index 146ca08..78291b1 100644 --- a/src/KekRozsak/FrontBundle/Entity/Article.php +++ b/src/KekRozsak/FrontBundle/Entity/Article.php @@ -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; + } - /** - * @var DateTime $createdAt - * @ORM\Column(type="datetime", name="created_at", nullable=false) - */ - protected $createdAt; + /** + * The timestamp when the Article was created + * + * @var DateTime $createdAt + * + * @ORM\Column(type="datetime", name="created_at", nullable=false) + */ + protected $createdAt; - /** - * Set createdAt - * - * @param DateTime $createdAt - * @return Article - */ - public function setCreatedAt(\DateTime $createdAt) - { - $this->createdAt = $createdAt; - return $this; - } + /** + * Set createdAt + * + * @param DateTime $createdAt + * @return Article + */ + public function setCreatedAt(\DateTime $createdAt) + { + $this->createdAt = $createdAt; + return $this; + } - /** - * Get createdAt - * - * @return DateTime - */ - public function getCreatedAt() - { - return $this->createdAt; - } + /** + * Get createdAt + * + * @return DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } - /** - * @var string $title - * @ORM\Column(type="string", length=100, nullable=false, unique=true) - */ - protected $title; + /** + * The title of the Article + * + * @var string $title + * + * @ORM\Column(type="string", length=100, nullable=false, unique=true) + */ + protected $title; - /** - * Set title - * - * @param string $title - * @return Article - */ - public function setTitle($title) - { - $this->title = $title; - return $this; - } + /** + * Set title + * + * @param string $title + * @return Article + */ + public function setTitle($title) + { + $this->title = $title; + return $this; + } - /** - * Get title - * - * @return string - */ - public function getTitle() - { - return $this->title; - } + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } - /** - * @var string $slug - * @ORM\Column(type="string", length=100, nullable=false, unique=true) - */ - protected $slug; + /** + * The slugified title of the Article + * + * @var string $slug + * + * @ORM\Column(type="string", length=100, nullable=false, unique=true) + */ + protected $slug; - /** - * Set slug - * - * @param string $slug - * @return Article - */ - public function setSlug($slug) - { - $this->slug = $slug; - return $this; - } + /** + * Set slug + * + * @param string $slug + * @return Article + */ + public function setSlug($slug) + { + $this->slug = $slug; + return $this; + } - /** - * Get slug - * - * @return string - */ - public function getSlug() - { - return $this->slug; - } + /** + * Get slug + * + * @return string + */ + public function getSlug() + { + return $this->slug; + } - /** - * @var string $text - * @ORM\Column(type="text", nullable=false) - */ - protected $text; + /** + * The content of the Article + * + * @var string $text + * + * @ORM\Column(type="text", nullable=false) + */ + protected $text; - /** - * Set text - * - * @param string $text - * @return Article - */ - public function setText($text) - { - $this->text = $text; - return $this; - } + /** + * Set text + * + * @param string $text + * @return Article + */ + public function setText($text) + { + $this->text = $text; + return $this; + } - /** - * Get text - * - * return string - */ - public function getText() - { - return $this->text; - } + /** + * Get text + * + * return string + */ + public function getText() + { + return $this->text; + } - /** - * @var boolean $mainPage - * @ORM\Column(type="boolean", name="main_page") - */ - protected $mainPage; + /** + * TRUE if the article should display on the main mage + * + * @var boolean $mainPage + * + * @ORM\Column(type="boolean", name="main_page") + */ + protected $mainPage; - /** - * Set mainPage - * - * @param boolean $mainPage - * @return Article - */ - public function setMainPage($mainPage) - { - $this->mainPage = $mainPage; - return $this; - } + /** + * Set mainPage + * + * @param boolean $mainPage + * @return Article + */ + public function setMainPage($mainPage) + { + $this->mainPage = $mainPage; + return $this; + } - /** - * Get mainPage - * - * @return boolean - */ - public function getMainPage() - { - return $this->mainPage; - } + /** + * Get mainPage + * + * @return boolean + */ + public function getMainPage() + { + return $this->mainPage; + } - /** - * @var boolean public - * @ORM\Column(type="boolean", nullable=false) - */ - protected $public; + /** + * TRUE if the article is viewable by anyone + * + * @var boolean public + * + * @ORM\Column(type="boolean", nullable=false) + */ + protected $public; - /** - * Set public - * - * @param boolean $public - * @return Article - */ - public function setPublic($public = false) - { - $this->public = $public; - return $this; - } + /** + * Set public + * + * @param boolean $public + * @return Article + */ + public function setPublic($public = false) + { + $this->public = $public; + return $this; + } - /** - * Get public - * - * @return boolean - */ - public function isPublic() - { - return $this->public; - } + /** + * Get public + * + * @return boolean + */ + public function isPublic() + { + return $this->public; + } - /** - * @var string $source - * @ORM\Column(type="string", nullable=true) - */ - protected $source; + /** + * The source of the Article, if any + * + * @var string $source + * + * @ORM\Column(type="string", nullable=true) + */ + protected $source; - /** - * Set source - * - * @param string $source - * @return Article - */ - public function setSource($source = null) - { - $this->source = $source; - return $this; - } + /** + * Set source + * + * @param string $source + * @return Article + */ + public function setSource($source = null) + { + $this->source = $source; + return $this; + } - /** - * Get source - * - * @return string - */ - public function getSource() - { - return $this->source; - } + /** + * Get source + * + * @return string + */ + public function getSource() + { + return $this->source; + } } - diff --git a/src/KekRozsak/FrontBundle/Entity/Book.php b/src/KekRozsak/FrontBundle/Entity/Book.php index c5ef106..27004ba 100644 --- a/src/KekRozsak/FrontBundle/Entity/Book.php +++ b/src/KekRozsak/FrontBundle/Entity/Book.php @@ -18,282 +18,348 @@ use KekRozsak\SecurityBundle\Entity\User; */ class Book { - public function __construct() - { - $this->copies = new ArrayCollection(); - $this->wouldBorrow = new ArrayCollection(); - $this->wouldBuy = new ArrayCollection(); - } + public function __construct() + { + $this->copies = new ArrayCollection(); + $this->wouldBorrow = new ArrayCollection(); + $this->wouldBuy = new ArrayCollection(); + } - /** - * @var integer $id - * - * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") - * @ORM\Column(type="integer") - */ - protected $id; + /** + * The ID of the Book + * + * @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 Doctrine\Common\Collections\ArrayCollection $copies - * - * @ORM\OneToMany(targetEntity="BookCopy", mappedBy="book") - */ - protected $copies; + /** + * The copies available for this Book + * + * @var Doctrine\Common\Collections\ArrayCollection $copies + * + * @ORM\OneToMany(targetEntity="BookCopy", mappedBy="book") + */ + protected $copies; - /** - * Remove a copy - * - * @param KekRozsak\FrontBundle\Entity\BookCopy $copy - * @return Book - */ - public function removeCopy(BookCopy $copy) - { - $this->copies->removeElement($copy); - } + /** + * Remove a copy + * + * @param KekRozsak\FrontBundle\Entity\BookCopy $copy + * @return Book + */ + public function removeCopy(BookCopy $copy) + { + $this->copies->removeElement($copy); + } - /** - * Get copies - * - * @return Doctrine\Common\Collections\ArrayCollection - */ - public function getCopies() - { - return $this->copies; - } + /** + * Get copies + * + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getCopies() + { + return $this->copies; + } - public function getCopiesBorrowed() - { - return $this->copies->filter(function($copy) { - return ($copy->getBorrower() !== null); - }); - } + /** + * Get the copies of this Book those are borrowed by someone + * + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getCopiesBorrowed() + { + return $this->copies->filter(function($copy) + { + return ($copy->getBorrower() !== null); + }); + } - public function getCopiesBorrowedByUser(User $user) - { - return $this->copies->filter(function($copy) use ($user) { - return ($copy->getBorrower() == $user); - }); - } + /** + * Get the copies of this Book those are borrowed by $user + * + * @param \KekRozsak\SecurityBundle\Entity\User $user + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getCopiesBorrowedByUser(User $user) + { + return $this->copies->filter(function($copy) use ($user) + { + return ($copy->getBorrower() == $user); + }); + } - public function getCopiesBorrowedReturnedByUser(User $user) - { - return $this->copies->filter(function($copy) use ($user) { - return ($copy->getBorrower() == $user) && ($copy->isBorrowerReturned()); - }); - } + /** + * Get the copies of this Book those are borrowed by $user, but marked as + * returned + * + * @param \KekRozsak\SecurityBundle\Entity\User $user + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getCopiesBorrowedReturnedByUser(User $user) + { + return $this->copies->filter(function($copy) use ($user) + { + return ($copy->getBorrower() == $user) && ($copy->isBorrowerReturned()); + }); + } - public function getCopiesBorrowable() - { - return $this->copies->filter(function($copy) { - return $copy->isBorrowable(); - }); - } + /** + * Get all the borrowable copies of this Book + * + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getCopiesBorrowable() + { + return $this->copies->filter(function($copy) { + return $copy->isBorrowable(); + }); + } - public function getUsersCopies(User $user) - { - return $this->copies->filter(function ($copy) use ($user) { - return ($copy->getOwner() == $user); - }); - } + /** + * Get $user's copies of this Book + * + * @param \KekRozsak\SecurityBundle\Entity\User $user + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getUsersCopies(User $user) + { + return $this->copies->filter(function ($copy) use ($user) + { + return ($copy->getOwner() == $user); + }); + } - public function getUsersCopiesBorrowable(User $user) - { - return $this->copies->filter(function($copy) use ($user) { - return (($copy->getOwner() == $user) && $copy->isBorrowable()); - }); - } + /** + * Get $user's borrowable copies of this Book + * + * @param \KekRozsak\SecurityBundle\Entity\User $user + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getUsersCopiesBorrowable(User $user) + { + return $this->copies->filter(function($copy) use ($user) + { + return (($copy->getOwner() == $user) && $copy->isBorrowable()); + }); + } - public function getUsersCopiesBuyable(User $user) - { - return $this->copies->filter(function($copy) use ($user) { - return (($copy->getOwner() == $user) && $copy->isBuyable()); - }); - } + /** + * Get $user's buyable copies of this Book + * + * @param \KekRozsak\SecurityBundle\Entity\User $user + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getUsersCopiesBuyable(User $user) + { + return $this->copies->filter(function($copy) use ($user) + { + return (($copy->getOwner() == $user) && $copy->isBuyable()); + }); + } - /** - * @var string $author - * - * @ORM\Column(type="string", length=100, nullable=false) - */ - protected $author; + /** + * The author of the Book + * + * @var string $author + * + * @ORM\Column(type="string", length=100, nullable=false) + */ + protected $author; - /** - * Set author - * - * @param string $author - * @return Book - */ - public function setAuthor($author) - { - $this->author = $author; - return $this; - } + /** + * Set author + * + * @param string $author + * @return Book + */ + public function setAuthor($author) + { + // TODO: Check if null! + $this->author = $author; + return $this; + } - /** - * Get author - * - * @return string - */ - public function getAuthor() - { - return $this->author; - } + /** + * Get author + * + * @return string + */ + public function getAuthor() + { + return $this->author; + } - /** - * @var string $title - * - * @ORM\Column(type="string", length=100, nullable=false) - */ - protected $title; + /** + * The title of the Book + * + * @var string $title + * + * @ORM\Column(type="string", length=100, nullable=false) + */ + protected $title; - /** - * Set title - * - * @param string $title - * @return Book - */ - public function setTitle($title) - { - $this->title = $title; - return $this; - } + /** + * Set title + * + * @param string $title + * @return Book + */ + public function setTitle($title) + { + // TODO: Check if null! + $this->title = $title; + return $this; + } - /** - * Get title - * - * @return string - */ - public function getTitle() - { - return $this->title; - } + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } - /** - * @var integer $year - * - * @ORM\Column(type="integer", nullable=false) - */ - protected $year; + /** + * The Book's year of publication + * + * @var integer $year + * + * @ORM\Column(type="integer", nullable=false) + */ + protected $year; - /** - * Set year - * - * @param integer $year - * @return Book - */ - public function setYear($year) - { - $this->year = $year; - return $this; - } + /** + * Set year + * + * @param integer $year + * @return Book + */ + public function setYear($year) + { + // TODO: Check if null! + $this->year = $year; + return $this; + } - /** - * Get year - * - * @return integer - */ - public function getYear() - { - return $this->year; - } + /** + * Get year + * + * @return integer + */ + public function getYear() + { + return $this->year; + } - /** - * @var boolean $commentable - * - * @ORM\Column(type="boolean", nullable=false) - */ - protected $commentable; + /** + * TRUE if comments can be written about the Book + * @var boolean $commentable + * + * @ORM\Column(type="boolean", nullable=false) + */ + protected $commentable; - /** - * @var Doctrine\Common\Collections\ArrayCollection $wouldBorrow - * - * @ORM\ManyToMany(targetEntity="KekRozsak\SecurityBundle\Entity\User") - * @ORM\JoinTable(name="book_would_borrow") - */ - protected $wouldBorrow; + /** + * Collection of Users who would like to borrow a copy + * + * @var Doctrine\Common\Collections\ArrayCollection $wouldBorrow + * + * @ORM\ManyToMany(targetEntity="KekRozsak\SecurityBundle\Entity\User") + * @ORM\JoinTable(name="book_would_borrow") + */ + protected $wouldBorrow; - /** - * Add a user for want-to-borrowers - * - * @param KekRozsak\SecurityBundle\Entity\User $user - * @return Book - */ - public function addWouldBorrow(User $user) - { - $this->wouldBorrow->add($user); - return $this; - } + /** + * Add a user for want-to-borrowers + * + * @param KekRozsak\SecurityBundle\Entity\User $user + * @return Book + */ + public function addWouldBorrow(User $user) + { + // TODO: Check if null! + $this->wouldBorrow->add($user); + return $this; + } - /** - * Get wouldBorrow list - * - * @return Doctrine\Common\Collections\ArrayCollection - */ - public function getWouldBorrow() - { - return $this->wouldBorrow; - } + /** + * Get wouldBorrow list + * + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getWouldBorrow() + { + return $this->wouldBorrow; + } - /** - * Check if specified user would borrow this book - * - * @param KekRozsak\SecurityBundle\Entity\User $user - * @return boolean - */ - public function userWouldBorrow(User $user) - { - return $this->wouldBorrow->contains($user); - } + /** + * Check if $user would like to borrow this book + * + * @param KekRozsak\SecurityBundle\Entity\User $user + * @return boolean + */ + public function userWouldBorrow(User $user) + { + return $this->wouldBorrow->contains($user); + } - /** - * @var Doctrine\Common\Collections\ArrayCollection $wouldBuy - * - * @ORM\ManyToMany(targetEntity="KekRozsak\SecurityBundle\Entity\User") - * @ORM\JoinTable(name="book_would_buy") - */ - protected $wouldBuy; + /** + * Collection of Users who would like to buy a copy of this book + * + * @var Doctrine\Common\Collections\ArrayCollection $wouldBuy + * + * @ORM\ManyToMany(targetEntity="KekRozsak\SecurityBundle\Entity\User") + * @ORM\JoinTable(name="book_would_buy") + */ + protected $wouldBuy; - /** - * Add a user for want-to-buyers - * - * @param KekRozsak\SecurityBundle\Entity\User $user - * @return Book - */ - public function addWouldBuy(User $user) - { - $this->wouldBuy->add($user); - return $this; - } + /** + * Add a user for want-to-buyers + * + * @param KekRozsak\SecurityBundle\Entity\User $user + * @return Book + */ + public function addWouldBuy(User $user) + { + $this->wouldBuy->add($user); + return $this; + } - /** - * Get wouldBuy list - * - * @return Doctrine\Common\Collections\ArrayCollection - */ - public function getWouldBuy() - { - return $this->wouldBuy; - } + /** + * Get wouldBuy list + * + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getWouldBuy() + { + return $this->wouldBuy; + } - /** - * Check if specified user would buy this book - * - * @param KekRozsak\SecurityBundle\Entity\User $user - * @return boolean - */ - public function userWouldBuy(User $user) - { - return $this->wouldBuy->contains($user); - } + /** + * Check if specified user would buy this book + * + * @param KekRozsak\SecurityBundle\Entity\User $user + * @return boolean + */ + public function userWouldBuy(User $user) + { + return $this->wouldBuy->contains($user); + } } diff --git a/src/KekRozsak/FrontBundle/Entity/BookCopy.php b/src/KekRozsak/FrontBundle/Entity/BookCopy.php index c2c84e3..90f4cf3 100644 --- a/src/KekRozsak/FrontBundle/Entity/BookCopy.php +++ b/src/KekRozsak/FrontBundle/Entity/BookCopy.php @@ -19,147 +19,163 @@ use KekRozsak\SecurityBundle\Entity\User; */ class BookCopy { - public function __construct(Book $book, User $owner) - { - $this->book = $book; - $this->owner = $owner; - $this->borrowable = false; - $this->buyable = false; - $this->borrower = null; - $this->borrowerReturned = true; - } + public function __construct(Book $book, User $owner) + { + $this->book = $book; + $this->owner = $owner; + $this->borrowable = false; + $this->buyable = false; + $this->borrower = null; + $this->borrowerReturned = true; + } - /** - * @var integer $id - * - * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") - * @ORM\Column(type="integer") - */ - protected $id; + /** + * The ID of the BookCopy + * + * @var integer $id + * + * @ORM\Id + * @ORM\GeneratedValue(strategy="AUTO") + * @ORM\Column(type="integer") + */ + protected $id; - /** - * @var KekRozsak\FrontBundle\Entity\Book $book - * - * @ORM\ManyToOne(targetEntity="Book", inversedBy="copies") - * @ORM\JoinColumn(nullable=false) - */ - protected $book; + /** + * The Book this BookCopy belongs to + * @var KekRozsak\FrontBundle\Entity\Book $book + * + * @ORM\ManyToOne(targetEntity="Book", inversedBy="copies") + * @ORM\JoinColumn(nullable=false) + */ + protected $book; - /** - * @var KekRozsak\SecurityBundle\Entity\User $owner - * - * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") - * @ORM\JoinColumn(nullable=false) - */ - protected $owner; + /** + * The User this BookCopy belongs to + * + * @var KekRozsak\SecurityBundle\Entity\User $owner + * + * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") + * @ORM\JoinColumn(nullable=false) + */ + protected $owner; - /** - * Get owner - * - * @return KekRozsak\SecurityBundle\Entity\User - */ - public function getOwner() - { - return $this->owner; - } + /** + * Get owner + * + * @return KekRozsak\SecurityBundle\Entity\User + */ + public function getOwner() + { + return $this->owner; + } - /** - * @var string $ownerComment - * - * @ORM\Column(type="text", name="owner_comment", nullable=true) - */ - protected $ownerComment; + /** + * The owner's comment about this BookCopy's Book + * + * @var string $ownerComment + * + * @ORM\Column(type="text", name="owner_comment", nullable=true) + */ + protected $ownerComment; - /** - * @var boolean $borrowable - * - * @ORM\Column(type="boolean", nullable=false) - */ - protected $borrowable; + /** + * TRUE if this BookCopy is borrowable + * + * @var boolean $borrowable + * + * @ORM\Column(type="boolean", nullable=false) + */ + protected $borrowable; - /** - * Set borrowable - * - * @param boolean $borrowable - * @return BookCopy - */ - public function setBorrowable($borrowable) - { - $this->borrowable = $borrowable; - return $this; - } + /** + * Set borrowable + * + * @param boolean $borrowable + * @return BookCopy + */ + public function setBorrowable($borrowable) + { + // TODO: Check if parameter is boolean! + $this->borrowable = $borrowable; + return $this; + } - /** - * Get borrowable - * - * @return boolean - */ - public function isBorrowable() - { - return $this->borrowable; - } + /** + * Get borrowable + * + * @return boolean + */ + public function isBorrowable() + { + return $this->borrowable; + } - /** - * @var boolean $buyable - * - * @ORM\Column(type="boolean", nullable=false) - */ - protected $buyable; + /** + * TRUE if this BookCopy is for sale + * + * @var boolean $buyable + * + * @ORM\Column(type="boolean", nullable=false) + */ + protected $buyable; - /** - * Set buyable - * - * @param boolean $buyable - * @return BookCopy - */ - public function setBuyable($buyable) - { - $this->buyable = $buyable; - return $this; - } + /** + * Set buyable + * + * @param boolean $buyable + * @return BookCopy + */ + public function setBuyable($buyable) + { + // Check if parameter is boolean! + $this->buyable = $buyable; + return $this; + } - /** - * Get borrowable - * - * @return boolean - */ - public function isBuyable() - { - return $this->buyable; - } + /** + * Get buyable + * + * @return boolean + */ + public function isBuyable() + { + return $this->buyable; + } - /** - * @var KekRozsak\SecurityBundle\Entity\User $borrower - * - * @ORM\OneToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") - */ - protected $borrower; + /** + * The User who is currently borrowing this BookCopy, or null + * + * @var KekRozsak\SecurityBundle\Entity\User $borrower + * + * @ORM\OneToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") + */ + protected $borrower; - /** - * Get borrower - * - * @return KekRozsak\SecurityBundle\Entity\User - */ - public function getBorrower() - { - return $this->borrower; - } + /** + * Get borrower + * + * @return KekRozsak\SecurityBundle\Entity\User + */ + public function getBorrower() + { + return $this->borrower; + } - /** - * @var boolean $borrowerReturned - * - * @ORM\Column(type="boolean", nullable=false, name="borrower_returned") - */ - protected $borrowerReturned; + /** + * TRUE if borrower says he/she returned this Copy to the owner + * @var boolean $borrowerReturned + * + * @ORM\Column(type="boolean", nullable=false, name="borrower_returned") + */ + protected $borrowerReturned; - /** - * Get borrowerReturned - * - * @return boolean - */ - public function isBorrowerReturned() - { - return $this->borrowerReturned(); - } + /** + * Get borrowerReturned + * + * @return boolean + */ + public function isBorrowerReturned() + { + return $this->borrowerReturned(); + } } diff --git a/src/KekRozsak/FrontBundle/Entity/Document.php b/src/KekRozsak/FrontBundle/Entity/Document.php index 9026d3b..028c4af 100644 --- a/src/KekRozsak/FrontBundle/Entity/Document.php +++ b/src/KekRozsak/FrontBundle/Entity/Document.php @@ -19,282 +19,305 @@ use KekRozsak\FrontBundle\Entity\Group; */ class Document { - public function __construct() - { - $this->groups = new ArrayCollection(); - } + public function __construct() + { + $this->groups = new ArrayCollection(); + } - /** - * @var integer $id - * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") - * @ORM\Column(type="integer") - */ - protected $id; + /** + * The ID of the Document + * + * @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 string $title - * @ORM\Column(type="string", length=150, unique=true, nullable=false) - * @Assert\NotBlank() - */ - protected $title; + /** + * The title of the Document + * + * @var string $title + * + * @ORM\Column(type="string", length=150, unique=true, nullable=false) + * @Assert\NotBlank() + */ + protected $title; - /** - * Set title - * - * @param string $title - * @return Document - */ - public function setTitle($title) - { - $this->title = $title; - return $this; - } + /** + * Set title + * + * @param string $title + * @return Document + */ + public function setTitle($title) + { + $this->title = $title; + return $this; + } - /** - * Get title - * - * @return string - */ - public function getTitle() - { - return $this->title; - } + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } - /** - * @var string $slug - * @ORM\Column(type="string", length=150, unique=true, nullable=false) - * @Assert\NotBlank() - */ - protected $slug; + /** + * The slugified title of this Document + * + * @var string $slug + * + * @ORM\Column(type="string", length=150, unique=true, nullable=false) + * @Assert\NotBlank() + */ + protected $slug; - /** - * Set slug - * - * @param string $slug - * @return Document - */ - public function setSlug($slug) - { - $this->slug = $slug; - return $this; - } + /** + * Set slug + * + * @param string $slug + * @return Document + */ + public function setSlug($slug) + { + $this->slug = $slug; + return $this; + } - /** - * Get slug - * - * @return string - */ - public function getSlug() - { - return $this->slug; - } + /** + * Get slug + * + * @return string + */ + public function getSlug() + { + return $this->slug; + } - /** - * @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 this Document + * + * @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 Document - */ - public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy) - { - $this->createdBy = $createdBy; - return $this; - } + /** + * Set createdBy + * + * @param KekRozsak\SecurityBundle\Entity\User $createdBy + * @return Document + */ + public function setCreatedBy(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; - } + /** + * The timestamp when the Document was created + * + * @var DateTime $createdat + * + * @ORM\Column(type="datetime", nullable=false, name="created_at") + */ + protected $createdAt; - /** - * @var DateTime $createdat - * @ORM\Column(type="datetime", nullable=false, name="created_at") - */ - protected $createdAt; + /** + * Set createdAt + * + * @param DateTime $createdAt + * @return Document + */ + public function setCreatedAt(\DateTime $createdAt) + { + $this->createdAt = $createdAt; + return $this; + } - /** - * Set createdAt - * - * @param DateTime $createdAt - * @return Document - */ - public function setCreatedAt(\DateTime $createdAt) - { - $this->createdAt = $createdAt; - return $this; - } + /** + * Get createdAt + * + * @return DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } - /** - * Get createdAt - * - * @return DateTime - */ - public function getCreatedAt() - { - return $this->createdAt; - } + /** + * The content of the Document + * + * @var string $content + * + * @ORM\Column(type="text", nullable=false) + */ + protected $content; - /** - * @var string $content - * @ORM\Column(type="text", nullable=false) - */ - protected $content; + /** + * Set content + * + * @param string $content + * @return Document + */ + public function setContent($content) + { + $this->content = $content; + return $this; + } - /** - * Set content - * - * @param string $content - * @return Document - */ - public function setContent($content) - { - $this->content = $content; - return $this; - } + /** + * Get content + * + * @return string + */ + public function getContent() + { + return $this->content; + } - /** - * Get content - * - * @return string - */ - public function getContent() - { - return $this->content; - } + /** + * @var Doctrine\Common\Collections\ArrayCollection $groups + * @ORM\ManyToMany(targetEntity="KekRozsak\FrontBundle\Entity\Group", mappedBy="documents") + */ + protected $groups; - /** - * @var Doctrine\Common\Collections\ArrayCollection $groups - * @ORM\ManyToMany(targetEntity="KekRozsak\FrontBundle\Entity\Group", mappedBy="documents") - */ - protected $groups; + /** + * Add a group + * + * @param KekRozsak\FrontBundle\Entity\Group $group + * @return Document + */ + public function addGroup(Group $group) + { + $this->groups[] = $group; + return $this; + } - /** - * Add a group - * - * @param KekRozsak\FrontBundle\Entity\Group $group - * @return Document - */ - public function addGroup(\KekRozsak\FrontBundle\Entity\Group $group) - { - $this->groups[] = $group; - return $this; - } + /** + * Get all groups + * + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getGroups() + { + return $this->group; + } - /** - * Get all groups - * - * @return Doctrine\Common\Collections\ArrayCollection - */ - public function getGroups() - { - return $this->group; - } + /** + * The User who last updated the Document + * + * @var KekRozsak\SecurityBundle\Entity\User $updatedBy + * + * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") + */ + protected $updatedBy; - /** - * @var KekRozsak\SecurityBundle\Entity\User $updatedBy - * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") - */ - protected $updatedBy; + /** + * Set updatedBy + * + * @param KekRozsak\SecurityBundle\Entity\User $updatedBy + * @return Document + */ + public function setUpdatedBy(User $updatedBy = null) + { + $this->updatedBy = $updatedBy; + return $this; + } - /** - * Set updatedBy - * - * @param KekRozsak\SecurityBundle\Entity\User $updatedBy - * @return Document - */ - public function setUpdatedBy(\KekRozsak\SecurityBundle\Entity\User $updatedBy = null) - { - $this->updatedBy = $updatedBy; - return $this; - } + /** + * Get updatedBy + * + * @return KekRozsak\SecurityBundle\Entity\User + */ + public function getUpdatedBy() + { + return $this->updatedBy; + } - /** - * Get updatedBy - * - * @return KekRozsak\SecurityBundle\Entity\User - */ - public function getUpdatedBy() - { - return $this->updatedBy; - } + /** + * The timestamp the Document was last updated + * + * @var DateTime $updatedAt + * + * @ORM\Column(type="datetime", nullable=true) + */ + protected $updatedAt; - /** - * @var DateTime $updatedAt - * @ORM\Column(type="datetime", nullable=true) - */ - protected $updatedAt; - - /** - * Set updatedAt - * - * @param DateTime $updatedAt - * @return Document - */ - public function setUpdatedAt(\DateTime $updatedAt = null) - { - $this->updatedAt = $updatedAt; - return $this; - } + /** + * Set updatedAt + * + * @param DateTime $updatedAt + * @return Document + */ + public function setUpdatedAt(\DateTime $updatedAt = null) + { + $this->updatedAt = $updatedAt; + return $this; + } - /** - * Get updatedAt - * - * @return DateTime - */ - public function getUpdatedAt() - { - return $this->updatedAt; - } + /** + * Get updatedAt + * + * @return DateTime + */ + public function getUpdatedAt() + { + return $this->updatedAt; + } - /** - * @var string updateReason - * @ORM\Column(type="text", nullable=true) - */ - protected $updateReason; + /** + * @var string updateReason + * @ORM\Column(type="text", nullable=true) + */ + protected $updateReason; - /** - * Set updateReason - * - * @param string $updateReason - * @return Document - */ - public function setUpdateReason($updateReason = null) - { - $this->updateReason = $updateReason; - return $this; - } + /** + * Set updateReason + * + * @param string $updateReason + * @return Document + */ + public function setUpdateReason($updateReason = null) + { + $this->updateReason = $updateReason; + return $this; + } - /** - * Get updateReason - * - * @return string - */ - public function getUpdateReason() - { - return $this->updateReason; - } + /** + * Get updateReason + * + * @return string + */ + public function getUpdateReason() + { + return $this->updateReason; + } } diff --git a/src/KekRozsak/FrontBundle/Entity/Event.php b/src/KekRozsak/FrontBundle/Entity/Event.php index 1bcc32d..148df8b 100644 --- a/src/KekRozsak/FrontBundle/Entity/Event.php +++ b/src/KekRozsak/FrontBundle/Entity/Event.php @@ -7,6 +7,9 @@ use Doctrine\Common\Collections\ArrayCollection; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert; +use KekRozsak\SecurityBundle\Entity\User; +use KekRozsak\FrontBundle\Entity\Group; + /** * @ORM\Entity * @ORM\Table(name="events") @@ -16,403 +19,432 @@ use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert; */ class Event { - /** - * @var integer $id - * - * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") - * @ORM\Column(type="integer") - */ - protected $id; + /** + * The ID of the Event + * + * @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 Event + * + * @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 Event - */ - public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy) - { - $this->createdBy = $createdBy; - return $this; - } + /** + * Set createdBy + * + * @param KekRozsak\SecurityBundle\Entity\User $createdBy + * @return Event + */ + public function setCreatedBy(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; + } - /** - * @var DateTime $startDate - * - * @ORM\Column(type="date", nullable=true, name="start_date", nullable=false) - */ - protected $startDate; + /** + * The date on which the Event starts + * + * @var DateTime $startDate + * + * @ORM\Column(type="date", nullable=true, name="start_date", nullable=false) + */ + protected $startDate; - /** - * Set startDate - * - * @param DateTime $startDate - * @return Event - */ - public function setStartDate(\DateTime $startDate = null) - { - $this->startDate = $startDate; - return $this; - } + /** + * Set startDate + * + * @param DateTime $startDate + * @return Event + */ + public function setStartDate(\DateTime $startDate = null) + { + $this->startDate = $startDate; + return $this; + } - /** - * Get startDate - * - * @return DateTime - */ - public function getStartDate() - { - return $this->startDate; - } + /** + * Get startDate + * + * @return DateTime + */ + public function getStartDate() + { + return $this->startDate; + } - /** - * @var DateTime $endDate - * - * @ORM\Column(type="date", nullable=true, name="end_date") - */ - protected $endDate; + /** + * The date on which the Event ends. May be null if same as $startDate + * + * @var DateTime $endDate + * + * @ORM\Column(type="date", nullable=true, name="end_date") + */ + protected $endDate; - /** - * Set endDate - * - * @param DateTime $endDate - * @return Event - */ - public function setEndDate(\DateTime $endDate) - { - $this->endDate = $endDate; - return $this; - } + /** + * Set endDate + * + * @param DateTime $endDate + * @return Event + */ + public function setEndDate(\DateTime $endDate = null) + { + // TODO: Check if endDate is later than startDate + $this->endDate = $endDate; + return $this; + } - /** - * Get endDate - * - * @return DateTime - */ - public function getEndDate() - { - return $this->endDate; - } + /** + * Get endDate + * + * @return DateTime + */ + public function getEndDate() + { + return $this->endDate; + } - /** - * @var Doctrine\Common\Collections\ArrayCollection $attendees - * - * @ORM\ManyToMany(targetEntity="KekRozsak\SecurityBundle\Entity\User") - * @ORM\JoinTable(name="event_attendees") - */ - protected $attendees; + /** + * An ArrayCollection of Users who wish to attend on this Event + * + * @var Doctrine\Common\Collections\ArrayCollection $attendees + * + * @ORM\ManyToMany(targetEntity="KekRozsak\SecurityBundle\Entity\User") + * @ORM\JoinTable(name="event_attendees") + */ + protected $attendees; - /** - * Add attendee - * - * @param KekRozsak\SecurityBundle\Entity\User $attendee - * @return Event - */ - public function addAttendee(\KekRozsak\SecurityBundle\Entity\User $attendee) - { - $this->attendees[] = $attendee; - return $this; - } + /** + * Add attendee + * + * @param KekRozsak\SecurityBundle\Entity\User $attendee + * @return Event + */ + public function addAttendee(User $attendee) + { + $this->attendees[] = $attendee; + return $this; + } - /** - * Get all attendees - * - * @return Doctrine\Common\Collections\ArrayCollection - */ - public function getAttendees() - { - return $this->attendees; - } + /** + * Get all attendees + * + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getAttendees() + { + return $this->attendees; + } - /** - * Check if a user is attending - * - * @param KekRozsak\SecurityBundle\Entity\User $user - * @return boolean - */ - public function isAttending(\KekRozsak\SecurityBundle\Entity\User $user) - { - $users = $this->attendees->filter(function ($attendee) use ($user) { - if ($attendee == $user) - return true; - }); - - return ($users->count() != 0); - } - - /** - * @var string $title - * - * @ORM\Column(type="string", length=150) - * - * @Assert\NotBlank() - */ - protected $title; - - /** - * Set title - * - * @param string $title - * @return Event - */ - public function setTitle($title) - { - $this->title = $title; - return $this; - } - - /** - * Get title - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * @var string $slug - * - * @ORM\Column(type="string", length=150) - * - * @Assert\NotBlank() - */ - protected $slug; - - /** - * Set slug - * - * @param string $slug - * @return Event - */ - public function setSlug($slug) - { - $this->slug = $slug; - return $this; - } - - /** - * Get slug - * - * @return string - */ - public function getSlug() - { - return $this->slug; - } - - /** - * @var string $description - * - * @ORM\Column(type="text") - * - * @Assert\NotBlank() - */ - protected $description; - - /** - * Set description - * - * @param string $description - * @return Event - */ - public function setDescription($description) - { - $this->description = $description; - return $this; - } - - /** - * Get description - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * @var KekRozsak\FrontBundle\Entity\Group $group - * - * @ORM\ManyToOne(targetEntity="KekRozsak\FrontBundle\Entity\Group") - */ - protected $group; - - /** - * Set group - * - * @param KekRozsak\FrontBundle\Entity\Group $group - * @return Event - */ - public function setGroup(\KekRozsak\FrontBundle\Entity\Group $group = null) - { - $this->group = $group; - return $this; - } - - /** - * Get group - * - * @return KekRozsak\FrontBundle\Entity\Group - */ - public function getGroup() - { - return $this->group; - } - - /** - * @var boolean $cancelled - * - * @ORM\Column(type="boolean", nullable=false) - */ - protected $cancelled; - - /** - * Set cancelled - * - * @param boolean $cancelled - * @return Event - */ - public function setCancelled($cancelled = false) - { - $this->cancelled = $cancelled; - return $this; - } - - /** - * Get cancelled - * - * @return boolean - */ - public function getCancelled() - { - return $this->cancelled; - } - - /** - * @var DateTime $startTime - * - * @ORM\Column(type="time", nullable=false, name="start_time") - */ - protected $startTime; - - /** - * Set startTime - * - * @param DateTime $startTime - * @return Event - */ - public function setStartTime(\DateTime $startTime) - { - $this->startTime = $startTime; - return $this; - } - - /** - * Get startTime - * - * @return DateTime - */ - public function getStartTime() - { - return $this->startTime; - } - - /** - * @var DateTime $endTime - * - * @ORM\Column(type="time", nullable=true, name="end_time") - */ - protected $endTime; - - /** - * Set endTime - * - * @param DateTime $endTime - * @return Event - */ - public function setEndTime(\DateTime $endTime) - { - $this->endTime = $endTime; - return $this; - } - - /** - * Get endTime - * - * @return DateTime - */ - public function getEndTime() - { - return $this->endTime; - } - - /** - * Check if an event will go on a specific date - * - * @param DateTime $date - * @return boolean - */ - public function isOnDate(\DateTime $date) - { - $date->setTime(0, 0, 0); - - return ( - ( - ($this->startDate == $date) - && ($this->endDate === null) - ) - || ( - ($this->startDate <= $date) - && ($this->endDate >= $date) - ) - ); - } - - /** - * Check if the event happened before a given date - * - * @param DateTime $date - * @return boolean - */ - public function isPast(\DateTime $date = null) + /** + * Check if a user is attending + * + * @param KekRozsak\SecurityBundle\Entity\User $user + * @return boolean + */ + public function isAttending(User $user) + { + $users = $this->attendees->filter(function ($attendee) use ($user) { - if ($date === null) - { - $date = new \DateTime('now'); + if ($attendee == $user) { + return true; } + }); - return ($this->endDate < $date); + return ($users->count() != 0); + } + + /** + * The title of the Event + * + * @var string $title + * + * @ORM\Column(type="string", length=150) + * + * @Assert\NotBlank() + */ + protected $title; + + /** + * Set title + * + * @param string $title + * @return Event + */ + public function setTitle($title) + { + // TODO: Check if empty or null! + $this->title = $title; + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Slugified title of the event + * + * @var string $slug + * + * @ORM\Column(type="string", length=150) + * + * @Assert\NotBlank() + */ + protected $slug; + + /** + * Set slug + * + * @param string $slug + * @return Event + */ + public function setSlug($slug) + { + // TODO: Check if empty or null! + $this->slug = $slug; + return $this; + } + + /** + * Get slug + * + * @return string + */ + public function getSlug() + { + return $this->slug; + } + + /** + * Description of the Event + * + * @var string $description + * + * @ORM\Column(type="text") + * + * @Assert\NotBlank() + */ + protected $description; + + /** + * Set description + * + * @param string $description + * @return Event + */ + public function setDescription($description) + { + // TODO: Check if empty! + $this->description = $description; + return $this; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @var KekRozsak\FrontBundle\Entity\Group $group + * + * @ORM\ManyToOne(targetEntity="KekRozsak\FrontBundle\Entity\Group") + */ + protected $group; + + /** + * Set group + * + * @param KekRozsak\FrontBundle\Entity\Group $group + * @return Event + */ + public function setGroup(Group $group = null) + { + $this->group = $group; + return $this; + } + + /** + * Get group + * + * @return KekRozsak\FrontBundle\Entity\Group + */ + public function getGroup() + { + return $this->group; + } + + /** + * TRUE if the Event is cancelled + * + * @var boolean $cancelled + * + * @ORM\Column(type="boolean", nullable=false) + */ + protected $cancelled; + + /** + * Set cancelled + * + * @param boolean $cancelled + * @return Event + */ + public function setCancelled($cancelled = false) + { + // TODO: Check if parameter is boolean + $this->cancelled = $cancelled; + return $this; + } + + /** + * Get cancelled + * + * @return boolean + */ + public function getCancelled() + { + return $this->cancelled; + } + + /** + * The time when the Event starts + * + * @var DateTime $startTime + * + * @ORM\Column(type="time", nullable=false, name="start_time") + */ + protected $startTime; + + /** + * Set startTime + * + * @param DateTime $startTime + * @return Event + */ + public function setStartTime(\DateTime $startTime) + { + $this->startTime = $startTime; + return $this; + } + + /** + * Get startTime + * + * @return DateTime + */ + public function getStartTime() + { + return $this->startTime; + } + + /** + * The time when the Event ends + * + * @var DateTime $endTime + * + * @ORM\Column(type="time", nullable=true, name="end_time") + */ + protected $endTime; + + /** + * Set endTime + * + * @param DateTime $endTime + * @return Event + */ + public function setEndTime(\DateTime $endTime = null) + { + // TODO: Check if endTime is later than startDate + startTime + $this->endTime = $endTime; + return $this; + } + + /** + * Get endTime + * + * @return DateTime + */ + public function getEndTime() + { + return $this->endTime; + } + + /** + * Check if an event will go on a specific date + * + * @param DateTime $date + * @return boolean + */ + public function isOnDate(\DateTime $date) + { + $date->setTime(0, 0, 0); + + return ( + ( + ($this->startDate == $date) + && ($this->endDate === null) + ) + || ( + ($this->startDate <= $date) + && ($this->endDate >= $date) + ) + ); + } + + /** + * Check if the event happened before a given date + * + * @param DateTime $date + * @return boolean + */ + public function isPast(\DateTime $date = null) + { + if ($date === null) { + $date = new \DateTime('now'); } + + return ($this->endDate < $date); + } } diff --git a/src/KekRozsak/FrontBundle/Entity/ForumPost.php b/src/KekRozsak/FrontBundle/Entity/ForumPost.php index f441a43..85c3f05 100644 --- a/src/KekRozsak/FrontBundle/Entity/ForumPost.php +++ b/src/KekRozsak/FrontBundle/Entity/ForumPost.php @@ -5,6 +5,7 @@ namespace KekRozsak\FrontBundle\Entity; use Doctrine\ORM\Mapping as ORM; use KekRozsak\FrontBundle\Entity\ForumTopic; +use KekRozsak\SecurityBundle\Entity\User; /** * @ORM\Entity @@ -13,146 +14,172 @@ use KekRozsak\FrontBundle\Entity\ForumTopic; */ class ForumPost { - /** - * @var integer $id - * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") - * @ORM\Column(type="integer") - */ - protected $id; + /** + * The ID of the ForumPost + * + * @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; - } - - /** - * @ORM\ManyToOne(targetEntity="\KekRozsak\SecurityBundle\Entity\User") - * @ORM\JoinColumn(name="created_by_id") - */ - protected $createdBy; - - /** - * Set createdBy - * - * @param \KekRozsak\SecurityBundle\Entity\User $createdBy - * @return ForumPost - */ - 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; - } - - /** - * @var DateTime $createdAt - * @ORM\Column(type="datetime", name="created_at") - */ - protected $createdAt; - - /** - * Set createdAt - * - * @param DateTime $createdAt - * @return ForumPost - */ - public function setCreatedAt(\DateTime $createdAt) - { - $this->createdAt = $createdAt; - } - - /** - * Get createdAt - * - * @return DateTime - */ - public function getCreatedAt() - { - return $this->createdAt; - } - - /** - * @var string $text - * @ORM\Column(type="text", nullable=false) - */ - protected $text; - - /** - * Set text - * - * @param string $text - * @return ForumPost - */ - public function setText($text) - { - $this->text = $text; - return $this; - } - - /** - * Get text - * - * @return string - */ - public function getText() - { - return $this->text; - } - - /** - * @var ForumTopic $topic - * @ORM\ManyToOne(targetEntity="ForumTopic", inversedBy="posts") - */ - protected $topic; - - /** - * Set topic - * - * @param ForumTopic $topic - * @return ForumPost - */ - public function setTopic(ForumTopic $topic) - { - $this->topic = $topic; - if (!$topic->getLastPost() || ($topic->getLastPost()->getCreatedAt() < $this->createdAt)) - $topic->setLastPost($this); - return $this; - } - - /** - * Get topic - * - * @return ForumTopic - */ - public function getTopic() - { - return $this->topic; - } - - /** - * Set createdAt before persisting - * - * @ORM\PrePersist - */ - public function setCreationTime() - { - if ($this->createdAt === null) - $this->createdAt = new \DateTime('now'); + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * The User who created this ForumPost + * + * @var KekRozsak\SecurityBundle\Entity\User $createBy + * + * @ORM\ManyToOne(targetEntity="\KekRozsak\SecurityBundle\Entity\User") + * @ORM\JoinColumn(name="created_by_id") + */ + protected $createdBy; + + /** + * Set createdBy + * + * @param \KekRozsak\SecurityBundle\Entity\User $createdBy + * @return ForumPost + */ + public function setCreatedBy(User $createdBy) + { + // TODO: Check if null! + $this->createdBy = $createdBy; + return $this; + } + + /** + * Get createdBy + * + * @return \KekRozsak\SecurityBundle\Entity\User + */ + public function getCreatedBy() + { + return $this->createdBy; + } + + /** + * The timestamp when the ForumPost was created + * + * @var DateTime $createdAt + * + * @ORM\Column(type="datetime", name="created_at") + */ + protected $createdAt; + + /** + * Set createdAt + * + * @param DateTime $createdAt + * @return ForumPost + */ + public function setCreatedAt(\DateTime $createdAt) + { + // TODO: Check if null! + $this->createdAt = $createdAt; + } + + /** + * Get createdAt + * + * @return DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * The content of the ForumPost + * + * @var string $text + * + * @ORM\Column(type="text", nullable=false) + */ + protected $text; + + /** + * Set text + * + * @param string $text + * @return ForumPost + */ + public function setText($text) + { + // TODO: Check if empty or null! + $this->text = $text; + return $this; + } + + /** + * Get text + * + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * The ForumTopic in which this ForumPost is + * + * @var ForumTopic $topic + * + * @ORM\ManyToOne(targetEntity="ForumTopic", inversedBy="posts") + */ + protected $topic; + + /** + * Set topic + * + * @param ForumTopic $topic + * @return ForumPost + */ + public function setTopic(ForumTopic $topic) + { + // Set this as the last post of $topic, if later than $topic's current + // last post + $this->topic = $topic; + if ( + !$topic->getLastPost() + || ($topic->getLastPost()->getCreatedAt() < $this->createdAt) + ) { + $topic->setLastPost($this); + } + + return $this; + } + + /** + * Get topic + * + * @return ForumTopic + */ + public function getTopic() + { + return $this->topic; + } + + /** + * Set createdAt before persisting + * + * @ORM\PrePersist + */ + public function setCreationTime() + { + if ($this->createdAt === null) { + $this->createdAt = new \DateTime('now'); } + } } - diff --git a/src/KekRozsak/FrontBundle/Entity/ForumTopic.php b/src/KekRozsak/FrontBundle/Entity/ForumTopic.php index 1dfe751..065f584 100644 --- a/src/KekRozsak/FrontBundle/Entity/ForumTopic.php +++ b/src/KekRozsak/FrontBundle/Entity/ForumTopic.php @@ -13,226 +13,254 @@ use KekRozsak\SecurityBundle\Entity\User; */ class ForumTopic { - public function __construct() - { - $this->posts = new ArrayCollection(); - } + public function __construct() + { + $this->posts = new ArrayCollection(); + } - /** - * @var integer $id - * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") - * @ORM\Column(type="integer") - */ - protected $id; + /** + * The ID of the ForumTopic + * + * @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 this ForumTopic + * + * @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 - * @return ForumTopic - */ - public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy) - { - $this->createdBy = $createdBy; - return $this; - } + /** + * Set createdBy + * + * @param KekRozsak\SecurityBundle\Entity\User + * @return ForumTopic + */ + public function setCreatedBy(User $createdBy) + { + // TODO: Check if null! + $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; + } + /** + * The timestamp when the ForumTopic was created + * + * @var DateTime $createdAt + * + * @ORM\Column(type="datetime", nullable=false, name="created_at") + */ + protected $createdAt; - /** - * @var DateTime $createdAt - * @ORM\Column(type="datetime", nullable=false, name="created_at") - */ - protected $createdAt; + /** + * Set createdAt + * + * @param DateTime $createdAt + * @return ForumTopic + */ + public function setCreatedAt(\DateTime $createdAt) + { + // TODO: Check if not null! + $this->createdAt = $createdAt; + return $this; + } - /** - * Set createdAt - * - * @param DateTime $createdAt - * @return ForumTopic - */ - public function setCreatedAt(\DateTime $createdAt) - { - $this->createdAt = $createdAt; - return $this; - } + /** + * Get createdAt + * + * @return DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } - /** - * Get createdAt - * - * @return DateTime - */ - public function getCreatedAt() - { - return $this->createdAt; - } + /** + * The ForumTopicGroup to which this ForumTopic belongs + * + * @var ForumTopicGroup $topicGroup + * + * @ORM\ManyToOne(targetEntity="ForumTopicGroup", inversedBy="topics") + * @ORM\JoinColumn(name="topic_group_id") + */ + protected $topicGroup; - /** - * @var ForumTopicGroup $topicGroup - * @ORM\ManyToOne(targetEntity="ForumTopicGroup", inversedBy="topics") - * @ORM\JoinColumn(name="topic_group_id") - */ - protected $topicGroup; + /** + * Set topicGroup + * + * @param ForumTopicGroup $topicGroup + * @return ForumTopic + */ + public function setTopicGroup(ForumTopicGroup $topicGroup) + { + // TODO: Check if not null! + $this->topicGroup = $topicGroup; + return $this; + } - /** - * Set topicGroup - * - * @param ForumTopicGroup $topicGroup - * @return ForumTopic - */ - public function setTopicGroup(ForumTopicGroup $topicGroup) - { - $this->topicGroup = $topicGroup; - return $this; - } + /** + * Get topicGroup + * + * @return ForumTopicGroup + */ + public function getTopicGroup() + { + return $this->topicGroup; + } - /** - * Get topicGroup - * - * @return ForumTopicGroup - */ - public function getTopicGroup() - { - return $this->topicGroup; - } + /** + * The slugified title of the ForumTopic + * + * @var string $slug + * + * @ORM\Column(type="string", length=100, nullable=false) + */ + protected $slug; - /** - * @var string $slug - * @ORM\Column(type="string", length=100, nullable=false) - */ - protected $slug; + /** + * Set slug + * + * @param string $slug + * @return ForumTopic + */ + public function setSlug($slug) + { + // TODO: Check if empty or null! + $this->slug = $slug; + return $this; + } - /** - * Set slug - * - * @param string $slug - * @return ForumTopic - */ - public function setSlug($slug) - { - $this->slug = $slug; - return $this; - } + /** + * Get slug + * + * @return string + */ + public function getSlug() + { + return $this->slug; + } - /** - * Get slug - * - * @return string - */ - public function getSlug() - { - return $this->slug; - } + /** + * The title of the ForumTopic + * + * @var string $title + * + * @ORM\Column(type="string", length=100, nullable=false) + */ + protected $title; - /** - * @var string $title - * @ORM\Column(type="string", length=100, nullable=false) - */ - protected $title; + /** + * Set title + * + * @param string $title + * @return ForumTopic + */ + public function setTitle($title) + { + // TODO: Check if empty or null! + $this->title = $title; + return $this; + } - /** - * Set title - * - * @param string $title - * @return ForumTopic - */ - public function setTitle($title) - { - $this->title = $title; - return $this; - } + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } - /** - * Get title - * - * @return string - */ - public function getTitle() - { - return $this->title; - } + /** + * The last Post of this ForumTopic, is any + * + * @var ForumPost $lastPost + * + * @ORM\OneToOne(targetEntity="ForumPost", cascade={"persist"}) + * @ORM\JoinColumn(name="last_post_id") + */ + protected $lastPost; - /** - * @var ForumPost $lastPost - * @ORM\OneToOne(targetEntity="ForumPost", cascade={"persist"}) - * @ORM\JoinColumn(name="last_post_id") - */ - protected $lastPost; + /** + * Set lastPost + * + * @param ForumPost $lastPost + * @return ForumTopic + */ + public function setLastPost($lastPost = null) + { + $this->lastPost = $lastPost; + } - /** - * Set lastPost - * - * @param ForumPost $lastPost - * @return ForumTopic - */ - public function setLastPost($lastPost = null) - { - $this->lastPost = $lastPost; - } + /** + * Get lastPost + * + * @return ForumPost + */ + public function getLastPost() + { + return $this->lastPost; + } - /** - * Get lastPost - * - * @return ForumPost - */ - public function getLastPost() - { - return $this->lastPost; - } + /** + * The list of all the ForumPosts in this topic + * + * @var ArrayCollection $topics; + * + * @ORM\OneToMany(targetEntity="ForumPost", mappedBy="topic", fetch="LAZY") + */ + protected $posts; - /** - * @var ArrayCollection $topics; - * @ORM\OneToMany(targetEntity="ForumPost", mappedBy="topic") - */ - protected $posts; + /** + * Add post + * + * @param ForumPost $post + * @return ForumTopic + */ + public function addPost(ForumPost $post) + { + // TODO: Check if null! + $this->posts[] = $post; + return $this; + } - /** - * Add post - * - * @param ForumPost $post - * @return ForumTopic - */ - public function addPost(ForumPost $post) - { - $this->posts[] = $post; - return $this; - } - - /** - * Get posts - * - * @return ArrayCollection - */ - public function getPosts() - { - return $this->posts; - } + /** + * Get posts + * + * @return ArrayCollection + */ + public function getPosts() + { + return $this->posts; + } } - diff --git a/src/KekRozsak/FrontBundle/Entity/ForumTopicGroup.php b/src/KekRozsak/FrontBundle/Entity/ForumTopicGroup.php index a8082a1..13dae36 100644 --- a/src/KekRozsak/FrontBundle/Entity/ForumTopicGroup.php +++ b/src/KekRozsak/FrontBundle/Entity/ForumTopicGroup.php @@ -14,168 +14,189 @@ use KekRozsak\SecurityBundle\Entity\User; */ class ForumTopicGroup { - public function __construct() - { - $this->topics = new ArrayCollection(); - } + public function __construct() + { + $this->topics = new ArrayCollection(); + } - /** - * @var integer $id - * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") - * @ORM\Column(type="integer") - */ - protected $id; + /** + * The ID of the ForumTopicGroup + * + * @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 this ForumTopicGroup + * + * @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 ForumTopicGroup - */ - public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy) - { - $this->createdBy = $createdBy; - return $this; - } + /** + * Set createdBy + * + * @param KekRozsak\SecurityBundle\Entity\User $createdBy + * @return ForumTopicGroup + */ + public function setCreatedBy(User $createdBy) + { + // TODO: Check if null! + $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; + } - /** - * @var DateTime $createdAt - * @ORM\Column(type="datetime", nullable=false) - */ - protected $createdAt; + /** + * The timestamp when this ForumTopicGroup was created + * + * @var DateTime $createdAt + * + * @ORM\Column(type="datetime", nullable=false) + */ + protected $createdAt; - /** - * Set createdAt - * - * @param DateTime $createdAt - * @return ForumTopicGroup - */ - public function setCreatedAt(\DateTime $createdAt) - { - $this->createdAt = $createdAt; - return $this; - } + /** + * Set createdAt + * + * @param DateTime $createdAt + * @return ForumTopicGroup + */ + public function setCreatedAt(\DateTime $createdAt) + { + // TODO: Check if null! + $this->createdAt = $createdAt; + return $this; + } - /** - * Get createdAt - * - * @return DateTime - */ - public function getCreatedAt() - { - return $this->createdAt; - } + /** + * Get createdAt + * + * @return DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } - /** - * @var string $slug - * @ORM\Column(type="string", length=100, nullable=false, unique=true) - */ - protected $slug; + /** + * The slugified title of this ForumTopicGroup + * + * @var string $slug + * + * @ORM\Column(type="string", length=100, nullable=false, unique=true) + */ + protected $slug; - /** - * Set slug - * - * @param string $slug - * @return ForumTopicGroup - */ - public function setSlug($slug) - { - $this->slug = $slug; - return $this; - } + /** + * Set slug + * + * @param string $slug + * @return ForumTopicGroup + */ + public function setSlug($slug) + { + // TODO: Check if empty or null! + $this->slug = $slug; + return $this; + } - /** - * Get slug - * - * @return string - */ - public function getSlug() - { - return $this->slug; - } + /** + * Get slug + * + * @return string + */ + public function getSlug() + { + return $this->slug; + } - /** - * @var string $title - * @ORM\Column(type="string", length=100, nullable=false, unique=true) - */ - protected $title; + /** + * The title of this ForumTopicGroup + * + * @var string $title + * + * @ORM\Column(type="string", length=100, nullable=false, unique=true) + */ + protected $title; - /** - * Set title - * - * @param string $title - * @return ForumTopicGroup - */ - public function setTitle($title) - { - $this->title = $title; - return $this; - } + /** + * Set title + * + * @param string $title + * @return ForumTopicGroup + */ + public function setTitle($title) + { + $this->title = $title; + return $this; + } - /** - * Get title - * - * @return string - */ - public function getTitle() - { - return $this->title; - } + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } - /** - * @var ArrayCollection $topics - * @ORM\OneToMany(targetEntity="ForumTopic", mappedBy="topicGroup") - */ - protected $topics; + /** + * The ArrayCollection of ForumTopics that belong to this ForumTopicGroup + * + * @var ArrayCollection $topics + * + * @ORM\OneToMany(targetEntity="ForumTopic", mappedBy="topicGroup") + */ + protected $topics; - /** - * Add topic - * - * @param ForumTopic $topic - * @return ForumTopicGroup - */ - public function addTopic(ForumTopic $topic) - { - $this->topics[] = $topic; - return $this; - } + /** + * Add topic + * + * @param ForumTopic $topic + * @return ForumTopicGroup + */ + public function addTopic(ForumTopic $topic) + { + // TODO: Check if null! + $this->topics[] = $topic; + return $this; + } - /** - * Get topics - * - * @return ArrayCollection - */ - public function getTopics() - { - return $this->topics; - } + /** + * Get topics + * + * @return ArrayCollection + */ + public function getTopics() + { + return $this->topics; + } } - diff --git a/src/KekRozsak/FrontBundle/Entity/Group.php b/src/KekRozsak/FrontBundle/Entity/Group.php index a850086..bb4f2dd 100644 --- a/src/KekRozsak/FrontBundle/Entity/Group.php +++ b/src/KekRozsak/FrontBundle/Entity/Group.php @@ -19,325 +19,357 @@ use KekRozsak\FrontBundle\Entity\Document; */ class Group { - public function __construct() - { - $this->members = new ArrayCollection(); - $this->documents = new ArrayCollection(); - } + public function __construct() + { + $this->members = new ArrayCollection(); + $this->documents = new ArrayCollection(); + } - /** - * @var integer $id - * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") - * @ORM\Column(type="integer") - */ - protected $id; + /** + * The ID of this Group + * + * @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 $leader - * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") - */ - protected $leader; + /** + * @var KekRozsak\SecurityBundle\Entity\User $leader + * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") + */ + protected $leader; - /** - * Set leader - * - * @param KekRozsak\SecurityBundle\Entity\User $leader - * @return Group - */ - public function setLeader(\KekRozsak\SecurityBundle\Entity\User $leader = null) - { - $this->leader = $leader; - return $this; - } + /** + * Set leader + * + * @param KekRozsak\SecurityBundle\Entity\User $leader + * @return Group + */ + public function setLeader(User $leader = null) + { + $this->leader = $leader; + return $this; + } - /** - * Get leader - * - * @return KekRozsak\SecurityBundle\Entity\User - */ - public function getLeader() - { - return $this->leader; - } + /** + * Get leader + * + * @return KekRozsak\SecurityBundle\Entity\User + */ + public function getLeader() + { + return $this->leader; + } - /** - * @var string $name - * @ORM\Column(type="string", length=50, nullable=false, unique=true) - * @Assert\NotBlank() - */ - protected $name; + /** + * The name of this Group + * + * @var string $name + * + * @ORM\Column(type="string", length=50, nullable=false, unique=true) + * + * @Assert\NotBlank() + */ + protected $name; - /** - * Set name - * - * @param string $name - * @return Group - */ - public function setName($name) - { - $this->name = $name; - return $this; - } + /** + * Set name + * + * @param string $name + * @return Group + */ + public function setName($name) + { + // TODO: Check if empty or null! + $this->name = $name; + return $this; + } - /** - * Get name - * - * @return string - */ - public function getName() - { - return $this->name; - } + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } - /** - * @var string $slug - * @ORM\Column(type="string", length=50, nullable=false, unique=true) - */ - protected $slug; + /** + * The slugified name of this Group + * + * @var string $slug + * + * @ORM\Column(type="string", length=50, nullable=false, unique=true) + */ + protected $slug; - /** - * Set slug - * - * @param string $slug - * @return Group - */ - public function setSlug($slug) - { - $this->slug = $slug; - return $this; - } + /** + * Set slug + * + * @param string $slug + * @return Group + */ + public function setSlug($slug) + { + // TODO: Check if empty or null! + $this->slug = $slug; + return $this; + } - /** - * Get slug - * - * @return string - */ - public function getSlug() - { - return $this->slug; - } + /** + * Get slug + * + * @return string + */ + public function getSlug() + { + return $this->slug; + } - /** - * @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 this Group + * + * @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 Group - */ - public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy) - { - $this->createdBy = $createdBy; - return $this; - } + /** + * Set createdBy + * + * @param KekRozsak\SecurityBundle\Entity\User $createdBy + * @return Group + */ + public function setCreatedBy(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; + } - /** - * @var DateTime $createdAt - * @ORM\Column(type="datetime", name="created_at", nullable=false) - */ - protected $createdAt; + /** + * The timestamp when this Group was created + * + * @var DateTime $createdAt + * + * @ORM\Column(type="datetime", name="created_at", nullable=false) + */ + protected $createdAt; - /** - * Set createdAt - * - * @param DateTime $createdAt - * @return Group - */ - public function setCreatedAt(\DateTime $createdAt) - { - $this->createdAt = $createdAt; - return $this; - } + /** + * Set createdAt + * + * @param DateTime $createdAt + * @return Group + */ + public function setCreatedAt(\DateTime $createdAt) + { + // TODO: Check if null! + $this->createdAt = $createdAt; + return $this; + } - /** - * Get createdAt - * - * @return DateTime - */ - public function getCreatedAt() - { - return $this->createdAt; - } + /** + * Get createdAt + * + * @return DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } - /** - * @var Doctrine\Common\Collections\ArrayCollection $members - * @ORM\OneToMany(targetEntity="UserGroupMembership", mappedBy="group") - */ - protected $members; + /** + * An ArrayCollection of UserGroupMemberships representing the Group's + * members + * + * @var Doctrine\Common\Collections\ArrayCollection $members + * + * @ORM\OneToMany(targetEntity="UserGroupMembership", mappedBy="group") + */ + protected $members; - /** - * Add member - * - * @param KekRozsak\FrontBundle\Entity\UserGroupMembership $member - * @return Group - */ - public function addMember(\KekRozsak\FrontBundle\Entity\UserGroupMembership $member) - { - $this->members[] = $member; - return $this; - } + /** + * Add member + * + * @param KekRozsak\FrontBundle\Entity\UserGroupMembership $member + * @return Group + */ + public function addMember(UserGroupMembership $member) + { + // TODO: Check if null! + $this->members[] = $member; + return $this; + } - /** - * Get all members - * - * @return Doctrine\Common\Collections\ArrayCollection - */ - public function getMembers() - { - return $this->members; - } + /** + * Get all members + * + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getMembers() + { + return $this->members; + } - /** - * Check if user is a member of this Group - * - * @param KekRozsak\SecurityBundle\Entity\User $user - * @return boolean - */ - public function isMember(\KekRozsak\SecurityBundle\Entity\User $user) - { - return ($this->members->filter( - function ($groupMembership) use ($user) { - return ( - ($groupMembership->getUser() == $user) - && ( - $groupMembership->getGroup()->isOpen() - || ($groupMembership->getMembershipAcceptedAt() !== null) - ) - ); - } - )->count() > 0); - } + /** + * Check if user is a member of this Group + * + * @param KekRozsak\SecurityBundle\Entity\User $user + * @return boolean + */ + public function isMember(User $user) + { + return ($this->members->filter(function ($groupMembership) use ($user) + { + return ( + ($groupMembership->getUser() == $user) + && ( + $groupMembership->getGroup()->isOpen() + || ($groupMembership->getMembershipAcceptedAt() !== null) + ) + ); + })->count() > 0); + } - /** - * Check if user already requested a membership in this Group - * - * @param KekRozsak\SecurityBundle\Entity\User $user - * @return boolean - */ - public function isRequested(\KekRozsak\SecurityBundle\Entity\User $user) - { - return ($this->members->filter( - function ($groupMembership) use ($user) { - return ( - ($groupMembership->getUser() == $user) - && ($groupMembership->getMembershipRequestedAt() !== null) - ); - } - )->count() > 0); - } + /** + * Check if user already requested a membership in this Group + * + * @param KekRozsak\SecurityBundle\Entity\User $user + * @return boolean + */ + public function isRequested(User $user) + { + return ($this->members->filter(function ($groupMembership) use ($user) + { + return ( + ($groupMembership->getUser() == $user) + && ($groupMembership->getMembershipRequestedAt() !== null) + ); + })->count() > 0); + } - /** - * @var string description - * @ORM\Column(type="text", nullable=true) - */ - protected $description; + /** + * The description of the Group + * + * @var string description + * + * @ORM\Column(type="text", nullable=true) + */ + protected $description; - /** - * Set description - * - * @param string $description - * @return Group - */ - public function setDescription($description = null) - { - $this->description = $description; - return $this; - } + /** + * Set description + * + * @param string $description + * @return Group + */ + public function setDescription($description = null) + { + $this->description = $description; + return $this; + } - /** - * Get description - * - * @return string - */ - public function getDescription() - { - return $this->description; - } + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } - /** - * @var boolean open - * @ORM\Column(type="boolean", nullable=false) - */ - protected $open; + /** + * TRUE if this Group is open, and anyone can join + * + * @var boolean open + * + * @ORM\Column(type="boolean", nullable=false) + */ + protected $open; - /** - * Set open - * - * @param boolean $open - * @ return Group - */ - public function setOpen($open = false) - { - $this->open = $open; - return $this; - } + /** + * Set open + * + * @param boolean $open + * @ return Group + */ + public function setOpen($open = false) + { + $this->open = $open; + return $this; + } - /** - * Get open - * - * @return boolean - */ - public function isOpen() - { - return $this->open; - } + /** + * Get open + * + * @return boolean + */ + public function isOpen() + { + return $this->open; + } - /** - * @var Doctrine\Common\Collections\ArrayCollection $documents - * @ORM\ManyToMany(targetEntity="Document", inversedBy="groups") - * @ORM\JoinTable(name="group_document", inverseJoinColumns={ - * @ORM\JoinColumn(name="document_id", referencedColumnName="id"), - * }, joinColumns={ - * @ORM\JoinColumn(name="group_id", referencedColumnName="id") - * }) - */ - protected $documents; + /** + * An ArrayCollection of Documents that belong to this Group + * + * @var Doctrine\Common\Collections\ArrayCollection $documents + * + * @ORM\ManyToMany(targetEntity="Document", inversedBy="groups", fetch="LAZY") + * @ORM\JoinTable(name="group_document", inverseJoinColumns={ + * @ORM\JoinColumn(name="document_id", referencedColumnName="id"), + * }, joinColumns={ + * @ORM\JoinColumn(name="group_id", referencedColumnName="id") + * }) + */ + protected $documents; - /** - * Add document - * - * @param KekRozsak\FrontBundle\Entity\Document $document - * @return Group - */ - public function addDocument(\KekRozsak\FrontBundle\Entity\Document $document) - { - $this->documents[] = $document; - return $this; - } + /** + * Add document + * + * @param KekRozsak\FrontBundle\Entity\Document $document + * @return Group + */ + public function addDocument(Document $document) + { + // TODO: Check if null! + $this->documents[] = $document; + return $this; + } - /** - * Get all documents - * - * @return Doctrine\Common\Collections\ArrayCollection - */ - public function getDocuments() - { - return $this->documents; - } + /** + * Get all documents + * + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getDocuments() + { + return $this->documents; + } } diff --git a/src/KekRozsak/FrontBundle/Entity/News.php b/src/KekRozsak/FrontBundle/Entity/News.php index f0ae6aa..921c5bc 100644 --- a/src/KekRozsak/FrontBundle/Entity/News.php +++ b/src/KekRozsak/FrontBundle/Entity/News.php @@ -4,169 +4,192 @@ namespace KekRozsak\FrontBundle\Entity; use Doctrine\ORM\Mapping as ORM; +use KekRozsak\SecurityBundle\Entity\User; + /** * @ORM\Entity * @ORM\Table(name="news") */ class News { - /** - * @var integer $id - * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") - * @ORM\Column(type="integer") - */ - protected $id; + /** + * The ID of this News + * + * @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 string $title - * @ORM\Column(type="string", length=100) - */ - protected $title; + /** + * The title of this News + * + * @var string $title + * + * @ORM\Column(type="string", length=100) + */ + protected $title; - /** - * Set title - * - * @param string $title - * @return News - */ - public function setTitle($title) - { - $this->title = $title; - return $this; - } + /** + * Set title + * + * @param string $title + * @return News + */ + public function setTitle($title) + { + // TODO: Check if empty or null! + $this->title = $title; + return $this; + } - /** - * Get title - * - * @return string - */ - public function getTitle() - { - return $this->title; - } + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } - /** - * @var string $text - * @ORM\Column(type="text", nullable=false) - */ - protected $text; + /** + * The contents of this News + * + * @var string $text + * + * @ORM\Column(type="text", nullable=false) + */ + protected $text; - /** - * Set text - * - * @param string $text - * @return News - */ - public function setText($text) - { - $this->text = $text; - return $this; - } + /** + * Set text + * + * @param string $text + * @return News + */ + public function setText($text) + { + $this->text = $text; + return $this; + } - /** - * Get text - * - * @return string - */ - public function getText() - { - return $this->text; - } + /** + * Get text + * + * @return string + */ + public function getText() + { + return $this->text; + } - /** - * @var DateTime $createdAt - * @ORM\Column(type="datetime", name="created_at", nullable=false) - */ - protected $createdAt; + /** + * The timestamp when this News was created + * + * @var DateTime $createdAt + * + * @ORM\Column(type="datetime", name="created_at", nullable=false) + */ + protected $createdAt; - /** - * Set createdAt - * - * @param DateTime $createdAt - * @return News - */ - public function setCreatedAt(\DateTime $createdAt) - { - $this->createdAt = $createdAt; - return $this; - } + /** + * Set createdAt + * + * @param DateTime $createdAt + * @return News + */ + public function setCreatedAt(\DateTime $createdAt) + { + // TODO: Check if null! + $this->createdAt = $createdAt; + return $this; + } - /** - * Get createdAt - * - * @return DateTime - */ - public function getCreatedAt() - { - return $this->createdAt; - } + /** + * Get createdAt + * + * @return DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } - /** - * @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 this News item + * + * @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 News - */ - public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy) - { - $this->createdBy = $createdBy; - return $this; - } + /** + * Set createdBy + * + * @param \KekRozsak\SecurityBundle\Entity\User $createdBy + * @return News + */ + public function setCreatedBy(User $createdBy) + { + // TODO: Check if null! + $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; + } - /** - * @var boolean $public - * - * @ORM\Column(type="boolean", nullable=false) - */ - protected $public; + /** + * TRUE if this News item is public + * + * @var boolean $public + * + * @ORM\Column(type="boolean", nullable=false) + */ + protected $public; - /** - * Set public - * - * @param boolean $public - * @return News - */ - public function setPublic($public) - { - $this->public = $public; - return $this; - } + /** + * Set public + * + * @param boolean $public + * @return News + */ + public function setPublic($public) + { + // TODO: Check if parameter is boolean! + $this->public = $public; + return $this; + } - /** - * Get public - * - * @return boolean - */ - public function getPublic() - { - return $this->public; - } + /** + * Get public + * + * @return boolean + */ + public function isPublic() + { + return $this->public; + } } diff --git a/src/KekRozsak/FrontBundle/Entity/UserData.php b/src/KekRozsak/FrontBundle/Entity/UserData.php index fa77424..e18701d 100644 --- a/src/KekRozsak/FrontBundle/Entity/UserData.php +++ b/src/KekRozsak/FrontBundle/Entity/UserData.php @@ -13,380 +13,430 @@ use \KekRozsak\SecurityBundle\Entity\User; */ class UserData { - public function __construct() - { - $this->emailPublic = false; - $this->realNamePublic = false; - $this->msnAddressPublic = false; - $this->googleTalkPublic = false; - $this->skypePublic = false; - $this->phoneNumberPublic = false; - } + public function __construct() + { + $this->emailPublic = false; + $this->realNamePublic = false; + $this->msnAddressPublic = false; + $this->googleTalkPublic = false; + $this->skypePublic = false; + $this->phoneNumberPublic = false; + } - /** - * @var KekRozsak\SecurityBundle\Entity\User $user - * @ORM\Id - * @ORM\GeneratedValue(strategy="NONE") - * @ORM\OneToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User", inversedBy="userData") - * @ORM\JoinColumn(name="user_id") - */ - protected $user; + /** + * The User object this UserData belongs to + * + * @var KekRozsak\SecurityBundle\Entity\User $user + * + * @ORM\Id + * @ORM\GeneratedValue(strategy="NONE") + * @ORM\OneToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User", inversedBy="userData") + * @ORM\JoinColumn(name="user_id") + */ + protected $user; - /** - * Set user - * - * @param KekRozsak\SecurityBundle\Entity\User $user - * @return UserData - */ - public function setUser(\KekRozsak\SecurityBundle\Entity\User $user) - { - $this->user = $user; - return $this; - } + /** + * Set user + * + * @param KekRozsak\SecurityBundle\Entity\User $user + * @return UserData + */ + public function setUser(\KekRozsak\SecurityBundle\Entity\User $user) + { + $this->user = $user; + return $this; + } - /** - * Get user - * - * @return KekRozsak\SecurityBundle\Entity\User - */ - public function getUser() - { - return $this->user; - } + /** + * Get user + * + * @return KekRozsak\SecurityBundle\Entity\User + */ + public function getUser() + { + return $this->user; + } - /** - * @var boolean $emailPublic - * @ORM\Column(type="boolean", name="email_public") - */ - protected $emailPublic; + /** + * TRUE if $user's e-mail address is public + * + * @var boolean $emailPublic + * + * @ORM\Column(type="boolean", name="email_public") + */ + protected $emailPublic; - /** - * Set emailPublic - * - * @param boolean $emailPublic - * @return UserData - */ - public function setEmailPublic($emailPublic) - { - $this->emailPublic = $emailPublic; - return $this; - } + /** + * Set emailPublic + * + * @param boolean $emailPublic + * @return UserData + */ + public function setEmailPublic($emailPublic) + { + // TODO: Check if parameter is boolean! + $this->emailPublic = $emailPublic; + return $this; + } - /** - * Get emailPublic - * - * @return boolean - */ - public function getEmailPublic() - { - return $this->emailPublic; - } + /** + * Get emailPublic + * + * @return boolean + */ + public function isEmailPublic() + { + return $this->emailPublic; + } - /** - * @var string $realName - * @ORM\Column(type="string", length=100, nullable=true, name="real_name") - */ - protected $realName; + /** + * The real name of $user + * + * @var string $realName + * + * @ORM\Column(type="string", length=100, nullable=true, name="real_name") + */ + protected $realName; - /** - * Set realName - * - * @param string $realName - * @return UserData - */ - public function setRealName($realName = null) - { - $this->realName = $realName; - return $this; - } + /** + * Set realName + * + * @param string $realName + * @return UserData + */ + public function setRealName($realName = null) + { + // TODO: Check if empty! + $this->realName = $realName; + return $this; + } - /** - * Get realName - * - * @return string - */ - public function getRealName() - { - return $this->realName; - } + /** + * Get realName + * + * @return string + */ + public function getRealName() + { + return $this->realName; + } - /** - * @var boolean $realNamePublic - * @ORM\Column(type="boolean", name="real_name_public") - */ - protected $realNamePublic; + /** + * TRUE is $user's real name is public + * + * @var boolean $realNamePublic + * + * @ORM\Column(type="boolean", name="real_name_public") + */ + protected $realNamePublic; - /** - * Set realNamePublic - * - * @param boolean $realNamePublic - * @return UserData - */ - public function setRealNamePublic($realNamePublic = false) - { - $this->realNamePublic = $realNamePublic; - return $this; - } + /** + * Set realNamePublic + * + * @param boolean $realNamePublic + * @return UserData + */ + public function setRealNamePublic($realNamePublic = false) + { + // TODO: Check if parameter is boolean! + $this->realNamePublic = $realNamePublic; + return $this; + } - /** - * Get realNamePublic - * - * @return boolean - */ - public function getRealNamePublic() - { - return $this->realNamePublic; - } + /** + * Get realNamePublic + * + * @return boolean + */ + public function isRealNamePublic() + { + return $this->realNamePublic; + } - /** - * @var string $selfDescription - * @ORM\Column(type="text", nullable=true, name="self_description") - */ - protected $selfDescription; + /** + * The self description of $user + * + * @var string $selfDescription + * + * @ORM\Column(type="text", nullable=true, name="self_description") + */ + protected $selfDescription; - /** - * Set selfDescription - * - * @param string $selfDescription - * @return UserData - */ - public function setSelfDescription($selfDescription = null) - { - $this->selfDescription = $selfDescription; - return $this; - } + /** + * Set selfDescription + * + * @param string $selfDescription + * @return UserData + */ + public function setSelfDescription($selfDescription = null) + { + $this->selfDescription = $selfDescription; + return $this; + } - /** - * Get selfDescription - * - * @return string - */ - public function getSelfDescription() - { - return $this->selfDescription; - } + /** + * Get selfDescription + * + * @return string + */ + public function getSelfDescription() + { + return $this->selfDescription; + } - /** - * @var string $msnAddress - * @ORM\Column(type="string", length=100, nullable=true, name="msn_address") - */ - protected $msnAddress; + /** + * The MSN address of $user + * + * @var string $msnAddress + * + * @ORM\Column(type="string", length=100, nullable=true, name="msn_address") + */ + protected $msnAddress; - /** - * Set msnAddress - * - * @param string $msnAddress - * @return UserData - */ - public function setMsnAddress($msnAddress = null) - { - $this->msnAddress = $msnAddress; - return $this; - } + /** + * Set msnAddress + * + * @param string $msnAddress + * @return UserData + */ + public function setMsnAddress($msnAddress = null) + { + // TODO: Check if empty! + $this->msnAddress = $msnAddress; + return $this; + } - /** - * Get msnAddress - * - * @return string - */ - public function getMsnAddress() - { - return $this->msnAddress; - } + /** + * Get msnAddress + * + * @return string + */ + public function getMsnAddress() + { + return $this->msnAddress; + } - /** - * @var boolean $msnAddressPublic - * @ORM\Column(type="boolean", name="msn_address_public") - */ - protected $msnAddressPublic; + /** + * TRUE if $user's MSN address is public + * + * @var boolean $msnAddressPublic + * + * @ORM\Column(type="boolean", name="msn_address_public") + */ + protected $msnAddressPublic; - /** - * Set msnAddressPublic - * - * @param boolean $msnAddressPublic - * @return UserData - */ - public function setMsnAddressPublic($msnAddressPublic) - { - $this->msnAddressPublic = $msnAddressPublic; - return $this; - } + /** + * Set msnAddressPublic + * + * @param boolean $msnAddressPublic + * @return UserData + */ + public function setMsnAddressPublic($msnAddressPublic) + { + // TODO: Check if parameter is boolean! + $this->msnAddressPublic = $msnAddressPublic; + return $this; + } - /** - * Get msnAddressPublic - * - * @return boolean - */ - public function getMsnAddressPublic() - { - return $this->msnAddressPublic; - } + /** + * Get msnAddressPublic + * + * @return boolean + */ + public function isMsnAddressPublic() + { + return $this->msnAddressPublic; + } - /** - * @var string $googleTalk - * @ORM\Column(type="string", length=100, nullable=true, name="google_talk") - */ - protected $googleTalk; + /** + * Google Talk address of $user + * + * @var string $googleTalk + * + * @ORM\Column(type="string", length=100, nullable=true, name="google_talk") + */ + protected $googleTalk; - /** - * Set googleTalk - * - * @param string $googleTalk - * @return UserData - */ - public function setGoogleTalk($googleTalk = null) - { - $this->googleTalk = $googleTalk; - return $this; - } + /** + * Set googleTalk + * + * @param string $googleTalk + * @return UserData + */ + public function setGoogleTalk($googleTalk = null) + { + // TODO: Check if empty! + $this->googleTalk = $googleTalk; + return $this; + } - /** - * Get googleTalk - * - * @return string - */ - public function getGoogleTalk() - { - return $this->googleTalk; - } + /** + * Get googleTalk + * + * @return string + */ + public function getGoogleTalk() + { + return $this->googleTalk; + } - /** - * @var boolean $googleTalkPublic - * @ORM\Column(type="boolean", name="google_talk_public") - */ - protected $googleTalkPublic; + /** + * TRUE if $user's Google Talk address is public + * + * @var boolean $googleTalkPublic + * + * @ORM\Column(type="boolean", name="google_talk_public") + */ + protected $googleTalkPublic; - /** - * Set googleTalkPublic - * - * @param boolean $googleTalkPublic - * @return UserData - */ - public function setGoogleTalkPublic($googleTalkPublic) - { - $this->googleTalkPublic = $googleTalkPublic; - return $this; - } + /** + * Set googleTalkPublic + * + * @param boolean $googleTalkPublic + * @return UserData + */ + public function setGoogleTalkPublic($googleTalkPublic) + { + // TODO: Check if parameter is boolean! + $this->googleTalkPublic = $googleTalkPublic; + return $this; + } - /** - * Get googleTalkPublic - * - * @return boolean - */ - public function getGoogleTalkPublic() - { - return $this->googleTalkPublic; - } + /** + * Get googleTalkPublic + * + * @return boolean + */ + public function isGoogleTalkPublic() + { + return $this->googleTalkPublic; + } - /** - * @var string $skype - * @ORM\Column(type="string", length=100, nullable=true, name="skype") - */ - protected $skype; + /** + * Skype name of $user + * + * @var string $skype + * + * @ORM\Column(type="string", length=100, nullable=true, name="skype") + */ + protected $skype; - /** - * Set skype - * - * @param string $skype - * @return UserData - */ - public function setSkype($skype = null) - { - $this->skype = $skype; - return $this; - } + /** + * Set skype + * + * @param string $skype + * @return UserData + */ + public function setSkype($skype = null) + { + // TODO: Check if empty! + $this->skype = $skype; + return $this; + } - /** - * Get skype - * - * @return string - */ - public function getSkype() - { - return $this->skype; - } + /** + * Get skype + * + * @return string + */ + public function getSkype() + { + return $this->skype; + } - /** - * @var boolean $skypePublic - * @ORM\Column(type="boolean", name="skype_public") - */ - protected $skypePublic; + /** + * TRUE if $user's Skype name is public + * + * @var boolean $skypePublic + * + * @ORM\Column(type="boolean", name="skype_public") + */ + protected $skypePublic; - /** - * Set skypePublic - * - * @param boolean $skypePublic - * @return UserData - */ - public function setSkypePublic($skypePublic) - { - $this->skypePublic = $skypePublic; - return $this; - } + /** + * Set skypePublic + * + * @param boolean $skypePublic + * @return UserData + */ + public function setSkypePublic($skypePublic) + { + // TODO: Check if parameter is boolean! + $this->skypePublic = $skypePublic; + return $this; + } - /** - * Get skypePublic - * - * @return boolean - */ - public function getSkypePublic() - { - return $this->skypePublic; - } + /** + * Get skypePublic + * + * @return boolean + */ + public function isSkypePublic() + { + return $this->skypePublic; + } - /** - * @var string $phoneNumber - * @ORM\Column(type="string", length=30, nullable=true, name="phone_number") - */ - protected $phoneNumber; + /** + * Phone number of $user + * + * @var string $phoneNumber + * + * @ORM\Column(type="string", length=30, nullable=true, name="phone_number") + */ + protected $phoneNumber; - /** - * Set phoneNumber - * - * @param string $phoneNumber - * @return UserData - */ - public function setPhoneNumber($phoneNumber = null) - { - $this->phoneNumber = $phoneNumber; - return $this; - } + /** + * Set phoneNumber + * + * @param string $phoneNumber + * @return UserData + */ + public function setPhoneNumber($phoneNumber = null) + { + // TODO: Check if empty! + $this->phoneNumber = $phoneNumber; + return $this; + } - /** - * Get phoneNumber - * - * @return string - */ - public function getPhoneNumber() - { - return $this->phoneNumber; - } + /** + * Get phoneNumber + * + * @return string + */ + public function getPhoneNumber() + { + return $this->phoneNumber; + } - /** - * @var boolean $phoneNumberPublic - * @ORM\Column(type="boolean", name="phone_number_public") - */ - protected $phoneNumberPublic; + /** + * TRUE if $user's phone number is public + * + * @var boolean $phoneNumberPublic + * + * @ORM\Column(type="boolean", name="phone_number_public") + */ + protected $phoneNumberPublic; - /** - * Set phoneNumberPublic - * - * @param boolean $phoneNumberPublic - * @return UserData - */ - public function setPhoneNumberPublic($phoneNumberPublic) - { - $this->phoneNumberPublic = $phoneNumberPublic; - return $this; - } + /** + * Set phoneNumberPublic + * + * @param boolean $phoneNumberPublic + * @return UserData + */ + public function setPhoneNumberPublic($phoneNumberPublic) + { + // TODO: Check if parameter is boolean! + $this->phoneNumberPublic = $phoneNumberPublic; + return $this; + } - /** - * Get phoneNumberPublic - * - * @return boolean - */ - public function getPhoneNumberPublic() - { - return $this->phoneNumberPublic; - } + /** + * Get phoneNumberPublic + * + * @return boolean + */ + public function isPhoneNumberPublic() + { + return $this->phoneNumberPublic; + } } diff --git a/src/KekRozsak/FrontBundle/Entity/UserGroupMembership.php b/src/KekRozsak/FrontBundle/Entity/UserGroupMembership.php index 55ecb97..036952e 100644 --- a/src/KekRozsak/FrontBundle/Entity/UserGroupMembership.php +++ b/src/KekRozsak/FrontBundle/Entity/UserGroupMembership.php @@ -5,6 +5,7 @@ namespace KekRozsak\FrontBundle\Entity; use Doctrine\ORM\Mapping as ORM; use KekRozsak\SecurityBundle\Entity\User; +use KekRozsak\FrontBundle\Entity\Group; /** * KekRozsak\FrontBundle\Entity\UserGroupMembership @@ -15,171 +16,191 @@ use KekRozsak\SecurityBundle\Entity\User; */ class UserGroupMembership { - public function __construct(\KekRozsak\SecurityBundle\Entity\User $user, \KekRozsak\FrontBundle\Entity\Group $group) - { - $this->setUser($user); - $this->setGroup($group); - $this->setMembershipRequestedAt(new \DateTime('now')); - } + public function __construct(\KekRozsak\SecurityBundle\Entity\User $user, \KekRozsak\FrontBundle\Entity\Group $group) + { + $this->setUser($user); + $this->setGroup($group); + $this->setMembershipRequestedAt(new \DateTime('now')); + } - /** - * @var integer $id - * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") - * @ORM\Column(type="integer") - */ - protected $id; + /** + * The ID of the UserGroupMembership + * + * @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 $user - * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User", inversedBy="groups") - * @ORM\JoinColumn(name="user_id") - */ - protected $user; + /** + * The User this membership is applied to + * + * @var KekRozsak\SecurityBundle\Entity\User $user + * + * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User", inversedBy="groups") + * @ORM\JoinColumn(name="user_id") + */ + protected $user; - /** - * Set user - * - * @param KekRozsak\SecurityBundle\Entity\User $user - * @return UserGroupMembership - */ - public function setUser(\KekRozsak\SecurityBundle\Entity\User $user) - { - $this->user = $user; - return $this; - } + /** + * Set user + * + * @param KekRozsak\SecurityBundle\Entity\User $user + * @return UserGroupMembership + */ + public function setUser(User $user) + { + // TODO: Check if not null! + $this->user = $user; + return $this; + } - /** - * Get user - * - * @return KekRozsak\SecurityBundle\Entity\User - */ - public function getUser() - { - return $this->user; - } + /** + * Get user + * + * @return KekRozsak\SecurityBundle\Entity\User + */ + public function getUser() + { + return $this->user; + } - /** - * @var KekRozsak\FrontBundle\Entity\Group - * @ORM\ManyToOne(targetEntity="Group", inversedBy="members") - * @ORM\JoinColumn(name="group_id") - */ - protected $group; + /** + * The Group this membership is applied to + * + * @var KekRozsak\FrontBundle\Entity\Group + * + * @ORM\ManyToOne(targetEntity="Group", inversedBy="members") + * @ORM\JoinColumn(name="group_id") + */ + protected $group; - /** - * Set group - * - * @param KekRozsak\FrontBundle\Entity\Group - * @return UserGroupMembership - */ - public function setGroup(\KekRozsak\FrontBundle\Entity\Group $group) - { - $this->group = $group; - return $this; - } + /** + * Set group + * + * @param KekRozsak\FrontBundle\Entity\Group + * @return UserGroupMembership + */ + public function setGroup(Group $group) + { + $this->group = $group; + return $this; + } - /** - * Get group - * - * @return KekRozsak\FrontBundle\Entity\Group - */ - public function getGroup() - { - return $this->group; - } + /** + * Get group + * + * @return KekRozsak\FrontBundle\Entity\Group + */ + public function getGroup() + { + return $this->group; + } - /** - * @var DateTime $membershipRequestedAt - * @ORM\Column(type="datetime", name="membership_requested_at") - */ - protected $membershipRequestedAt; + /** + * The timestamp when $user requested membership in $group + * + * @var DateTime $membershipRequestedAt + * + * @ORM\Column(type="datetime", name="membership_requested_at") + */ + protected $membershipRequestedAt; - /** - * Set membershipRequestedAt - * - * @param DateTime $membershipRequestedAt - * @return UserGroupMembership - */ - public function setMembershipRequestedAt(\DateTime $membershipRequestedAt) - { - $this->membershipRequestedAt = $membershipRequestedAt; - return $this; - } + /** + * Set membershipRequestedAt + * + * @param DateTime $membershipRequestedAt + * @return UserGroupMembership + */ + public function setMembershipRequestedAt(\DateTime $membershipRequestedAt) + { + // TODO: Check if null! + $this->membershipRequestedAt = $membershipRequestedAt; + return $this; + } - /** - * Get membershipRequestedAt - * - * @return DateTime - */ - public function getMembershipRequestedAt() - { - return $this->membershipRequestedAt; - } + /** + * Get membershipRequestedAt + * + * @return DateTime + */ + public function getMembershipRequestedAt() + { + return $this->membershipRequestedAt; + } - /** - * @var DateTime membershipAcceptedAt - * @ORM\Column(type="datetime", nullable=true, name="membership_accepted_at") - */ - protected $membershipAcceptedAt; + /** + * The timestamp when $user's membership was accepted + * + * @var DateTime membershipAcceptedAt + * + * @ORM\Column(type="datetime", nullable=true, name="membership_accepted_at") + */ + protected $membershipAcceptedAt; - /** - * Set membershipAcceptedAt - * - * @param DateTime $membershipAcceptedAt - * @return UserGroupMembership - */ - public function setMembershipAcceptedAt(\DateTime $membershipAcceptedAt = null) - { - $this->membershipAcceptedAt = $membershipAcceptedAt; - return $this; - } + /** + * Set membershipAcceptedAt + * + * @param DateTime $membershipAcceptedAt + * @return UserGroupMembership + */ + public function setMembershipAcceptedAt(\DateTime $membershipAcceptedAt = null) + { + $this->membershipAcceptedAt = $membershipAcceptedAt; + return $this; + } - /** - * Get membershipAcceptedAt - * - * @return DateTime - */ - public function getMembershipAcceptedAt() - { - return $this->membershipAcceptedAt; - } + /** + * Get membershipAcceptedAt + * + * @return DateTime + */ + public function getMembershipAcceptedAt() + { + return $this->membershipAcceptedAt; + } - /** - * @var KekRozsak\SecurityBundle\Entity\User $membershipAcceptedBy - * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") - * @ORM\JoinColumn(name="membership_accepted_by_id") - */ - protected $membershipAcceptedBy; - - /** - * Set membershipAcceptedBy - * - * @param KekRozsak\SecurityBundle\Entity\User - * @return UserGroupMembership - */ - public function setMembershipAcceptedBy(\KekRozsak\SecurityBundle\Entity\User $membershipAcceptedBy = null) - { - $this->membershipAcceptedBy = $membershipAcceptedBy; - return $this; - } + /** + * The User who accepted $user's membership + * + * @var KekRozsak\SecurityBundle\Entity\User $membershipAcceptedBy + * + * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") + * @ORM\JoinColumn(name="membership_accepted_by_id") + */ + protected $membershipAcceptedBy; - /** - * Get membershipAcceptedBy - * - * @return KekRozsak\SecurityBundle\Entity\User - */ - public function getMembershipAcceptedBy() - { - return $this->membershipAcceptedBy; - } + /** + * Set membershipAcceptedBy + * + * @param KekRozsak\SecurityBundle\Entity\User + * @return UserGroupMembership + */ + public function setMembershipAcceptedBy(\KekRozsak\SecurityBundle\Entity\User $membershipAcceptedBy = null) + { + $this->membershipAcceptedBy = $membershipAcceptedBy; + return $this; + } + + /** + * Get membershipAcceptedBy + * + * @return KekRozsak\SecurityBundle\Entity\User + */ + public function getMembershipAcceptedBy() + { + return $this->membershipAcceptedBy; + } } diff --git a/src/KekRozsak/FrontBundle/Extensions/Slugifier.php b/src/KekRozsak/FrontBundle/Extensions/Slugifier.php index 8dbdafc..b6b48b3 100644 --- a/src/KekRozsak/FrontBundle/Extensions/Slugifier.php +++ b/src/KekRozsak/FrontBundle/Extensions/Slugifier.php @@ -4,30 +4,40 @@ namespace KekRozsak\FrontBundle\Extensions; class Slugifier { - /** - * Slugify string - * - * @param string $text - * @return string - */ - public function slugify($text) - { - $text = trim(preg_replace('~[^\\pL\d]+~u', '-', $text)); + /** + * Slugify string + * + * @param string $text + * @return string + */ + public function slugify($text) + { + $text = preg_replace( + '~[^-\w]+~', + '', + str_replace( + array('"', "'", ':'), + '', + strtolower( + iconv( + 'utf-8', + 'us-ascii//TRANSLIT', + trim( + preg_replace( + '~[^\\pL\d]+~u', + '-', + $text + ) + ) + ) + ) + ) + ); - if (function_exists('iconv')) - { - $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); - } + if (empty($text)) { + $text = 'n-a'; + } - $text = strtolower($text); - - $text = preg_replace('~[^-\w]+~', '', $text); - - if (empty($text)) - { - $text = 'n-a'; - } - - return $text; - } + return $text; + } } diff --git a/src/KekRozsak/FrontBundle/Form/Extension/HelpMessageTypeExtension.php b/src/KekRozsak/FrontBundle/Form/Extension/HelpMessageTypeExtension.php index d28f4d9..e0dc2ce 100644 --- a/src/KekRozsak/FrontBundle/Form/Extension/HelpMessageTypeExtension.php +++ b/src/KekRozsak/FrontBundle/Form/Extension/HelpMessageTypeExtension.php @@ -8,26 +8,25 @@ use Symfony\Component\Form\FormBuilderInterface; class HelpMessageTypeExtension extends AbstractTypeExtension { - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->setAttribute('help', $options['help']); - } + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder->setAttribute('help', $options['help']); + } - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->set('help', $form->getAttribute('help')); - } + public function buildView(FormView $view, FormInterface $form, array $options) + { + $view->set('help', $form->getAttribute('help')); + } - public function getDefaultOptions() - { - return array( - 'help' => null, - ); - } + public function getDefaultOptions() + { + return array( + 'help' => null, + ); + } - public function getExtendedType() - { - return 'field'; - } + public function getExtendedType() + { + return 'field'; + } } - diff --git a/src/KekRozsak/FrontBundle/Form/Type/DocumentType.php b/src/KekRozsak/FrontBundle/Form/Type/DocumentType.php index d7c3068..fa60527 100644 --- a/src/KekRozsak/FrontBundle/Form/Type/DocumentType.php +++ b/src/KekRozsak/FrontBundle/Form/Type/DocumentType.php @@ -7,21 +7,23 @@ use Symfony\Component\Form\FormBuilderInterface; class DocumentType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add('title', null, array( - 'label' => 'A dokumentum címe', - )); + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder->add('title', null, array( + 'label' => 'A dokumentum címe', + ) + ); - $builder->add('content', 'ckeditor', array( - 'label' => ' ', - )); + $builder->add('content', 'ckeditor', array( + 'label' => ' ', + ) + ); - /* TODO: possibility to add to other groups! */ - } + // TODO: possibility to add to other groups! + } - public function getName() - { - return 'document'; - } + public function getName() + { + return 'document'; + } } diff --git a/src/KekRozsak/FrontBundle/Form/Type/ForumPostType.php b/src/KekRozsak/FrontBundle/Form/Type/ForumPostType.php index a2cdc12..87bfedc 100644 --- a/src/KekRozsak/FrontBundle/Form/Type/ForumPostType.php +++ b/src/KekRozsak/FrontBundle/Form/Type/ForumPostType.php @@ -7,36 +7,38 @@ use Symfony\Component\OptionsResolver\OptionsResolverInterface; class ForumPostType extends AbstractType { - private $topicGroup; - private $topic; + private $topicGroup; + private $topic; - public function __construct($topicGroup = null, $topic = null) - { - $this->topicGroup = $topicGroup; - $this->topic = $topic; - } + public function __construct($topicGroup = null, $topic = null) + { + $this->topicGroup = $topicGroup; + $this->topic = $topic; + } - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add('text', null, array( - 'label' => ' ', - )); - $builder->add('topic', 'hidden', array( - 'property_path' => false, - 'data' => $this->topic, - )); - } + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder->add('text', null, array( + 'label' => ' ', + ) + ); - public function getName() - { - return 'forum_post'; - } + $builder->add('topic', 'hidden', array( + 'property_path' => false, + 'data' => $this->topic, + ) + ); + } - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - 'data_class' => 'KekRozsak\FrontBundle\Entity\ForumPost', - )); - } + public function getName() + { + return 'forum_post'; + } + + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'KekRozsak\FrontBundle\Entity\ForumPost', + )); + } } - diff --git a/src/KekRozsak/FrontBundle/Form/Type/GroupType.php b/src/KekRozsak/FrontBundle/Form/Type/GroupType.php index bac7a9e..ef6b6f7 100644 --- a/src/KekRozsak/FrontBundle/Form/Type/GroupType.php +++ b/src/KekRozsak/FrontBundle/Form/Type/GroupType.php @@ -7,19 +7,21 @@ use Symfony\Component\Form\FormBuilderInterface; class GroupType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add('name', null, array( - 'label' => 'A csoport neve', - )); + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder->add('name', null, array( + 'label' => 'A csoport neve', + ) + ); - $builder->add('description', 'ckeditor', array( - 'label' => 'A csoport leírása', - )); - } + $builder->add('description', 'ckeditor', array( + 'label' => 'A csoport leírása', + ) + ); + } - public function getName() - { - return 'group'; - } + public function getName() + { + return 'group'; + } } diff --git a/src/KekRozsak/FrontBundle/Form/Type/UserDataType.php b/src/KekRozsak/FrontBundle/Form/Type/UserDataType.php index 763c346..2d402e7 100644 --- a/src/KekRozsak/FrontBundle/Form/Type/UserDataType.php +++ b/src/KekRozsak/FrontBundle/Form/Type/UserDataType.php @@ -7,74 +7,96 @@ use Symfony\Component\OptionsResolver\OptionsResolverInterface; class UserDataType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add('emailPublic', null, array( - 'label' => 'Publikus legyen az e-mail címed?', - 'help' => 'Ha bejelölöd, a kör többi tagja láthatja az e-mail címedet.', - 'required' => false, - )); - $builder->add('realName', null, array( - 'label' => 'Valódi neved', - 'help' => 'A valódi, polgári neved. Nem kötelező mező, akkor érdemes megadni, ha szeretnéd, hogy a többi tag megtalálhasson különféle közösségi oldalakon.', - )); - $builder->add('realNamePublic', null, array( - 'label' => 'Publikus legyen a valódi neved?', - 'help' => 'Ha bejelölöd, a kör többi tagja láthatja a valódi neved.', - 'required' => false, - )); - $builder->add('selfDescription', null, array( - 'label' => 'Rövid leírás Magadról', - 'help' => 'Írj ide egy rövid leírást saját magadról. Ez mindenképpen megjelenik majd a profilodon, így a többiek tudhatják, hogy mivel is foglalkozol.', - )); - $builder->add('msnAddress', null, array( - 'label' => 'MSN címed', - 'help' => 'Egy MSN cím, amin elérhető vagy.' - )); - $builder->add('msnAddressPublic', null, array( - 'label' => 'Publikus legyen az MSN címed?', - 'help' => 'Ha bejelölöd, a kör többi tagja láthatja az MSN címedet.', - 'required' => false, - )); - $builder->add('googleTalk', null, array( - 'label' => 'Google Talk címed', - 'help' => 'Itt egy olyan GMail-es e-mail címet adhatsz meg, amin elérhető vagy a GMail csevegőben.', - )); - $builder->add('googleTalkPublic', null, array( - 'label' => 'Publikus legyen a Google Talk címed?', - 'help' => 'Ha bejelölöd, a kör többi tagja láthatja a Google Talk címedet.', - 'required' => false, - )); - $builder->add('skype', null, array( - 'label' => 'Skype neved', - 'help' => 'Egy Skype név, amin elérhető vagy.', - )); - $builder->add('skypePublic', null, array( - 'label' => 'Publikus legyen a Skype neved?', - 'help' => 'Ha bejelölöd, a kör többi tagja láthatja a Skype nevedet.', - 'required' => false, - )); - $builder->add('phoneNumber', null, array( - 'label' => 'Telefonszámod', - 'help' => 'Egy telefonszám, amin elérhető vagy. Programszervezéseknél jól jöhet.', - )); - $builder->add('phoneNumberPublic', null, array( - 'label' => 'Publikus legyen a telefonszámod?', - 'help' => 'Ha bejelölöd, a kör többi tagja láthatja a telefonszámodat.', - 'required' => false, - )); - } + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder->add('emailPublic', null, array( + 'label' => 'Publikus legyen az e-mail címed?', + 'help' => 'Ha bejelölöd, a kör többi tagja láthatja az e-mail címedet.', + 'required' => false, + ) + ); - public function getName() - { - return 'user_data'; - } + $builder->add('realName', null, array( + 'label' => 'Valódi neved', + 'help' => 'A valódi, polgári neved. Nem kötelező mező, akkor érdemes megadni, ha szeretnéd, hogy a többi tag megtalálhasson különféle közösségi oldalakon.', + ) + ); - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - 'data_class' => 'KekRozsak\FrontBundle\Entity\UserData' - )); - } + $builder->add('realNamePublic', null, array( + 'label' => 'Publikus legyen a valódi neved?', + 'help' => 'Ha bejelölöd, a kör többi tagja láthatja a valódi neved.', + 'required' => false, + ) + ); + + $builder->add('selfDescription', null, array( + 'label' => 'Rövid leírás Magadról', + 'help' => 'Írj ide egy rövid leírást saját magadról. Ez mindenképpen megjelenik majd a profilodon, így a többiek tudhatják, hogy mivel is foglalkozol.', + ) + ); + + $builder->add('msnAddress', null, array( + 'label' => 'MSN címed', + 'help' => 'Egy MSN cím, amin elérhető vagy.' + ) + ); + + $builder->add('msnAddressPublic', null, array( + 'label' => 'Publikus legyen az MSN címed?', + 'help' => 'Ha bejelölöd, a kör többi tagja láthatja az MSN címedet.', + 'required' => false, + ) + ); + + $builder->add('googleTalk', null, array( + 'label' => 'Google Talk címed', + 'help' => 'Itt egy olyan GMail-es e-mail címet adhatsz meg, amin elérhető vagy a GMail csevegőben.', + ) + ); + + $builder->add('googleTalkPublic', null, array( + 'label' => 'Publikus legyen a Google Talk címed?', + 'help' => 'Ha bejelölöd, a kör többi tagja láthatja a Google Talk címedet.', + 'required' => false, + ) + ); + + $builder->add('skype', null, array( + 'label' => 'Skype neved', + 'help' => 'Egy Skype név, amin elérhető vagy.', + ) + ); + + $builder->add('skypePublic', null, array( + 'label' => 'Publikus legyen a Skype neved?', + 'help' => 'Ha bejelölöd, a kör többi tagja láthatja a Skype nevedet.', + 'required' => false, + ) + ); + + $builder->add('phoneNumber', null, array( + 'label' => 'Telefonszámod', + 'help' => 'Egy telefonszám, amin elérhető vagy. Programszervezéseknél jól jöhet.', + ) + ); + + $builder->add('phoneNumberPublic', null, array( + 'label' => 'Publikus legyen a telefonszámod?', + 'help' => 'Ha bejelölöd, a kör többi tagja láthatja a telefonszámodat.', + 'required' => false, + ) + ); + } + + public function getName() + { + return 'user_data'; + } + + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'KekRozsak\FrontBundle\Entity\UserData' + )); + } } - diff --git a/src/KekRozsak/FrontBundle/Resources/config/services.xml b/src/KekRozsak/FrontBundle/Resources/config/services.xml index 0318904..693930e 100644 --- a/src/KekRozsak/FrontBundle/Resources/config/services.xml +++ b/src/KekRozsak/FrontBundle/Resources/config/services.xml @@ -1,18 +1,20 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/src/KekRozsak/FrontBundle/Resources/public/css/forum.css b/src/KekRozsak/FrontBundle/Resources/public/css/forum.css index fddc8f0..4d9eda6 100644 --- a/src/KekRozsak/FrontBundle/Resources/public/css/forum.css +++ b/src/KekRozsak/FrontBundle/Resources/public/css/forum.css @@ -21,78 +21,78 @@ } .forum-lista thead td a { - color: #3366ff; - text-decoration: none; + color: #3366ff; + text-decoration: none; } .forum-lista tbody td { - padding: 5px; - border-bottom: 1px solid #3366ff; + padding: 5px; + border-bottom: 1px solid #3366ff; } .forum-lista tbody tr.odd td { - background-color: #060c16; + background-color: #060c16; } .forum-lista tbody tr.even td { - background-color: #000000; + background-color: #000000; } .forum-lista tbody td a { - color: #3366ff; - text-decoration: underline; + color: #3366ff; + text-decoration: underline; } .post-lista { - border: 1px solid #3366ff; - border-collapse: collapse; + border: 1px solid #3366ff; + border-collapse: collapse; } .post-lista td { - border-style: solid; - border-color: #3366ff; - border-width: 3px 1px; - vertical-align: top; - padding: 5px; + border-style: solid; + border-color: #3366ff; + border-width: 3px 1px; + vertical-align: top; + padding: 5px; } .post-lista td.felado { - width: 150px !important; - font-size: 80%; + width: 150px !important; + font-size: 80%; } .post-lista td.szoveg { - width: 510px; + width: 510px; } .post-lista td.szoveg div { - width: 510px; - overflow: auto; + width: 510px; + overflow: auto; } td.uj-post { } td.uj-post textarea { - width: 500px; - background-color: #000000; - color: #3366ff; - border-style: solid; - border-color: #3366ff; - border-width: 0 0 2px 0; - height: 15em; + width: 500px; + background-color: #000000; + color: #3366ff; + border-style: solid; + border-color: #3366ff; + border-width: 0 0 2px 0; + height: 15em; } td.uj-post p { - clear: both; - float: none; - margin: 0; + clear: both; + float: none; + margin: 0; } td.uj-post p .eszkoztar { - float: left; + float: left; } td.uj-post p .kuldes-gomb { - float: right; + float: right; } diff --git a/src/KekRozsak/FrontBundle/Resources/public/css/group.css b/src/KekRozsak/FrontBundle/Resources/public/css/group.css index bcc4d50..c76b3c8 100644 --- a/src/KekRozsak/FrontBundle/Resources/public/css/group.css +++ b/src/KekRozsak/FrontBundle/Resources/public/css/group.css @@ -1,11 +1,11 @@ ul#submenu { - margin: 0; - padding: 0; + margin: 0; + padding: 0; } ul#submenu li { - margin: 0; - padding: 3px; - display: inline; + margin: 0; + padding: 3px; + display: inline; } diff --git a/src/KekRozsak/FrontBundle/Resources/public/css/popup.css b/src/KekRozsak/FrontBundle/Resources/public/css/popup.css index 94f3933..f58cc3b 100644 --- a/src/KekRozsak/FrontBundle/Resources/public/css/popup.css +++ b/src/KekRozsak/FrontBundle/Resources/public/css/popup.css @@ -7,94 +7,94 @@ */ #popup-container { - display: none; - position: fixed; - height: 300px; - width: 200px; - background: #ffffff; - z-index: 80; + display: none; + position: fixed; + height: 300px; + width: 200px; + background: #ffffff; + z-index: 80; } #popup-close { - position: absolute; - width: 16px; - height: 16px; - top: -5px; - right: -5px; - background-image: url('../images/no.png'); + position: absolute; + width: 16px; + height: 16px; + top: -5px; + right: -5px; + background-image: url('../images/no.png'); } #popup-inside { - border: 1px solid black; - height: 292px; - width: 192px; - margin-left: auto; - margin-right: auto; - margin-top: 3px; + border: 1px solid black; + height: 292px; + width: 192px; + margin-left: auto; + margin-right: auto; + margin-top: 3px; } #popup-title { - font-weight: bold; - padding: 5px; + font-weight: bold; + padding: 5px; } #popup-content { - padding: 3px; + padding: 3px; } #popup-scrollable { - width: 192px; - clear: both; - margin: 20px 0 10px; + width: 192px; + clear: both; + margin: 20px 0 10px; } #popup-scrollable .viewport { - width: 172px; - height: 246px; - overflow: hidden; - position: relative; + width: 172px; + height: 246px; + overflow: hidden; + position: relative; } #popup-scrollable .overview { - list-style: none; - position: absolute; - left: 0; - top: 0; + list-style: none; + position: absolute; + left: 0; + top: 0; } #popup-scrollable .thumb .end, #popup-scrollable .thumb { - background-color: #003D5D; + background-color: #003D5D; } #popup-scrollable .scrollbar { - position: relative; - float: right; - width: 15px; + position: relative; + float: right; + width: 15px; } #popup-scrollable .track { - background-color: #D8EEFD; - height: 100%; - width: 13px; - position: relative; - padding: 0 1px; + background-color: #D8EEFD; + height: 100%; + width: 13px; + position: relative; + padding: 0 1px; } #popup-scrollable .thumb { - height: 20px; - width: 13px; - cursor: pointer; - overflow: hidden; - position: absolute; - top: 0; + height: 20px; + width: 13px; + cursor: pointer; + overflow: hidden; + position: absolute; + top: 0; } #popup-scrollable .thumb .end { - overflow: hidden; - height: 5px; - width: 13px; + overflow: hidden; + height: 5px; + width: 13px; } #popup-scrollable .disable { - display: none; + display: none; } diff --git a/src/KekRozsak/FrontBundle/Resources/views/Book/ajaxData.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Book/ajaxData.html.twig index 56ffafd..b6469a4 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Book/ajaxData.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Book/ajaxData.html.twig @@ -1,63 +1,63 @@ {# vim: ft=htmljinja #}

- Szerző: {{ book.author }}
- Cím: {{ book.title }}
- Kiadás éve: {{ book.year }}
+ Szerző: {{ book.author }}
+ Cím: {{ book.title }}
+ Kiadás éve: {{ book.year }}

- Nekem van {{ book.usersCopies(app.user)|length }}, ebből kölcsön van adva X.
- A teljes közösségnek összesen {{ book.copies|length }} példánya van.
- Kölcsönkérhető {{ book.copiesBorrowable|length }} példány, ebből {{ book.copiesBorrowedByUser(app.user)|length }} nálam van.
+ Nekem van {{ book.usersCopies(app.user)|length }}, ebből kölcsön van adva X.
+ A teljes közösségnek összesen {{ book.copies|length }} példánya van.
+ Kölcsönkérhető {{ book.copiesBorrowable|length }} példány, ebből {{ book.copiesBorrowedByUser(app.user)|length }} nálam van.

{% if book.usersCopies(app.user)|length == 0 %} - [Nekem is van egy] + [Nekem is van egy] {% else %} - [Nincs már] + [Nincs már] {# TODO - [Eladtam valakinek a körben] + [Eladtam valakinek a körben] #} {% if book.usersCopiesBorrowable(app.user)|length == 0 %} - [Az enyém is kölcsönkérhető] + [Az enyém is kölcsönkérhető] {% else %} - [Nem szeretném kölcsönadni] + [Nem szeretném kölcsönadni] {% endif %} {% endif %} {% if book.usersCopies(app.user)|length > 0 %} {% if book.usersCopiesBuyable(app.user)|length == 0 %} - [Az enyém eladó] + [Az enyém eladó] {% else %} - [Nem szeretném eladni] + [Nem szeretném eladni] {% endif %} {% endif %} {% if book.copiesBorrowedByUser(app.user)|length == 0 and book.usersCopies(app.user)|length == 0 and not book.userWouldBorrow(app.user) %} - [Kérek egyet kölcsön] + [Kérek egyet kölcsön] {% endif %} {% if book.usersCopies(app.user)|length == 0 and not book.userWouldBuy(app.user) %} - [Vennék egyet] + [Vennék egyet] {% endif %}

{% if book.wouldBuy|length > 0 %}

- Ők szeretnének egyet kölcsönkérni:
-

    + Ők szeretnének egyet kölcsönkérni:
    +
      {% for user in book.wouldBorrow %} -
    • {{ user|userdataspan }}
    • +
    • {{ user|userdataspan }}
    • {% endfor %} -
    +

{% endif %} {% if book.wouldBuy|length > 0 %}

- Ők szeretnének venni egyet:
-

    + Ők szeretnének venni egyet:
    +
      {% for user in book.wouldBuy %} -
    • {{ user|userdataspan }}
    • +
    • {{ user|userdataspan }}
    • {% endfor %} -
    +

{% endif %} diff --git a/src/KekRozsak/FrontBundle/Resources/views/Book/list.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Book/list.html.twig index 7874195..16f5f3f 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Book/list.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Book/list.html.twig @@ -7,127 +7,155 @@ [Saját könyveim] [Nálam lévő kölcsönzött könyvek] {% if books|length > 0 %} - - - - - - - - - - - - + + + + + + + + + + + + {% for book in books %} - - - - - - - - - + + + + + + + + + {% endfor %} - +
SzerzőCímÉvÖsszesKölcsönözhetőSajátNálam (Vissza)
SzerzőCímÉvÖsszesKölcsönözhetőSajátNálam (Vissza)
{% endif %} {% endblock %} {% block bottomscripts %} {% endblock bottomscripts %} diff --git a/src/KekRozsak/FrontBundle/Resources/views/Box/Events.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Box/Events.html.twig index 0658b8a..d3bb8c9 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Box/Events.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Box/Events.html.twig @@ -1,31 +1,31 @@ {# vim: ft=htmljinja #} -
- [események gomb] -
-
-

{{ firstDay|date('Y-m') }}

- - - - - - - - - - - - - - - - +
+ [események gomb] +
+
+

{{ firstDay|date('Y-m') }}

+
HKSzeCsPSzoV
{{ firstDay|date('W') }}
+ + + + + + + + + + + + + + + {% set curDow = 0 %} {% if firstDayWeekday != 1 %} {% for i in 1..(firstDayWeekday - 1) %} {% set curDow = curDow + 1 %}{% if curDow == 8 %}{% set curDow = 1 %}{% endif %} - + {% endfor %} {% endif %} {% set cur = firstDayWeekday - 1 %} @@ -33,30 +33,26 @@ {% set cur = cur + 1 %} {% set curDow = curDow + 1 %}{% if curDow == 8 %}{% set curDow = 1 %}{% endif %} {% set eventCount = 0 %} -{# TODO Check if an event occurs on this date: -(event.startDate = this day AND event.endDate is NULL) -OR (event.startDate <= this day AND evend.endDate >= this day) -#} - + {% if cur is divisibleby(7) %} - + {% if cur != numDays %} - - + + {% endif %} {% endif %} {% endfor %} {% if curDow != 7 %} {% for i in (curDow + 1)..7 %} - + {% endfor %} {% endif %} - - -
HKSzeCsPSzoV
{{ firstDay|date('W') }} 0 %} class="program" rel="{{ path('KekRozsakFrontBundle_eventAjaxList', {date: eventList[i].date|date('Y-m-d'), _format: 'html'}) }}"{% endif %}> - {{ eventList[i].date|date('d') }} - 0 %} class="program" rel="{{ path('KekRozsakFrontBundle_eventAjaxList', {date: eventList[i].date|date('Y-m-d'), _format: 'html'}) }}"{% endif %}> + {{ eventList[i].date|date('d') }} +
{{ eventList[i + 1].date|date('W') }}
{{ eventList[i + 1].date|date('W') }}
- További események -
-
-
+ + + + További események + + + diff --git a/src/KekRozsak/FrontBundle/Resources/views/Box/Login.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Box/Login.html.twig index 349fb58..c75cf33 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Box/Login.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Box/Login.html.twig @@ -1,14 +1,14 @@ {# vim: ft=htmljinja #} -
- Bejelentkezés -
-
-
- Felhasználónév:
- Jelszó:
- -
-
-
-
+
+ Bejelentkezés +
+
+
+ Felhasználónév:
+ Jelszó:
+ +
+
+
+
diff --git a/src/KekRozsak/FrontBundle/Resources/views/Box/UserProfile.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Box/UserProfile.html.twig index 75a858c..a8bdba9 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Box/UserProfile.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Box/UserProfile.html.twig @@ -1,28 +1,27 @@ {# vim: ft=htmljinja #} -
- [avatar] {{ app.user.displayName }} -
-
- [avatar] - {{ app.user.displayName }}
- Jogosultság{% if app.user.roles|length > 1 %}ok{% endif %}
-
-
Csoportjaim
+
+ [avatar] {{ app.user.displayName }} +
+
+ [avatar] + {{ app.user.displayName }}
+ Jogosultság{% if app.user.roles|length > 1 %}ok{% endif %}
+
+
Csoportjaim
{% for group in app.user.groups %} {% if group.group.open or group.membershipAcceptedAt %} -
{{ group.group.name }}
+
{{ group.group.name }}
{% endif %} {% endfor %} -
További csoportok
+
További csoportok
-
Kedvenc Fórum-témáim
+
Kedvenc Fórum-témáim
+
Fórum
-
Fórum
- -
Üzenetek
-
-
- -
-
+
Üzenetek
+
+
+ +
+
diff --git a/src/KekRozsak/FrontBundle/Resources/views/Default/userprofile.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Default/userprofile.html.twig index 24af558..96906fc 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Default/userprofile.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Default/userprofile.html.twig @@ -8,9 +8,9 @@

Az itt megadott adataidat szigorúan kezeljük, azt más számára kizárólag hatósági felszólításra adjuk ki.

A publikusnak megjelölt adataidat csak a kör tagjai láthatják, míg a nem publikusnak megjelölteket kizárólag az oldal adminisztrátorai.

- +
{{ form_widget(form) }} -
- + +
{% endblock content %} diff --git a/src/KekRozsak/FrontBundle/Resources/views/Document/create.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Document/create.html.twig index ad586c0..0a1a3b4 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Document/create.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Document/create.html.twig @@ -5,7 +5,7 @@ {% block content %}

Új dokumentum létrehozása

- {{ form_widget(form) }} - + {{ form_widget(form) }} +
{% endblock content %} diff --git a/src/KekRozsak/FrontBundle/Resources/views/Document/edit.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Document/edit.html.twig index e8aaa90..642779b 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Document/edit.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Document/edit.html.twig @@ -5,7 +5,7 @@ {% block content %}

Dokumentum szerkesztése - {{ document.title }}

- {{ form_widget(form) }} - + {{ form_widget(form) }} +
{% endblock content %} diff --git a/src/KekRozsak/FrontBundle/Resources/views/Document/view.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Document/view.html.twig index b51d14a..98d2ea1 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Document/view.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Document/view.html.twig @@ -4,7 +4,7 @@ {% block title %} - Dokumentum - {{ document.title }}{% endblock %} {% block content %}

- {{ document.title }}{% if document.createdBy == app.user %} [ Szerkesztés ] {% endif %} + {{ document.title }}{% if document.createdBy == app.user %} [ Szerkesztés ] {% endif %}

{{ document.content|raw }}
{{ document.createdBy|userdataspan }}
diff --git a/src/KekRozsak/FrontBundle/Resources/views/Event/ajaxList.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Event/ajaxList.html.twig index d27f8f5..f1d8b1b 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Event/ajaxList.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Event/ajaxList.html.twig @@ -1,16 +1,16 @@ {# vim: ft=htmljinja #} - - Események - - + + Események + + {% if events|length > 0 %} -
    +
      {% for event in events %} -
    • {{ event.title }}
    • +
    • {{ event.title }}
    • {% endfor %} -
    +
{% endif %} - + diff --git a/src/KekRozsak/FrontBundle/Resources/views/Event/list.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Event/list.html.twig index 2a1e30d..da38d19 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Event/list.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Event/list.html.twig @@ -7,7 +7,7 @@ {% if events %} {% else %} diff --git a/src/KekRozsak/FrontBundle/Resources/views/Event/view.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Event/view.html.twig index 104bc4d..e130876 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Event/view.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Event/view.html.twig @@ -7,12 +7,12 @@

{{ event.startDate|date('Y-m-d') }} {{ event.startTime|date('H:i') }}{% if event.endDate or event.endTime %} - {% endif %}{% if event.endDate is not null %} {{ event.endDate|date('Y-m-d') }}{% endif %}{% if event.endTime is not null %} {{ event.endTime|date('H:i') }}{% endif %}

Az eseményt szervezi: {{ event.createdBy|userdataspan }}

- {{ event.description }} + {{ event.description }}

Eddigi résztvevők

    {% for attendee in event.attendees %} -
  • {{ attendee|userdataspan }}
  • +
  • {{ attendee|userdataspan }}
  • {% endfor %}
{% if not event.isAttending(app.user) and not event.isPast %} diff --git a/src/KekRozsak/FrontBundle/Resources/views/Form/user_form.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Form/user_form.html.twig index 43fd1a6..b3cf523 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Form/user_form.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Form/user_form.html.twig @@ -2,11 +2,11 @@ #} {% block field_row %} - {{ form_label(form) }} - {{ form_widget(form) }} - - {{ help }} - - {{ form_errors(form) }} + {{ form_label(form) }} + {{ form_widget(form) }} + + {{ help }} + + {{ form_errors(form) }} {% endblock %} diff --git a/src/KekRozsak/FrontBundle/Resources/views/Forum/postList.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Forum/postList.html.twig index dce4e3b..147c188 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Forum/postList.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Forum/postList.html.twig @@ -5,42 +5,42 @@ {% block content %}

Fórum - {{ topicGroup.title }} - {{ topic.title }}

- - - - - + + + + + {% for post in posts %} - - - - + + + + {% endfor %} - +
-
- {{ form_widget(form) }} -

- Súgó -

-
-
-
-
- [avatar]
- {{ app.user.displayName }}
- Saját szint
-
- Tagság kezdete:
- {{ app.user.registeredAt|date('Y-m-d') }} -
+
+ {{ form_widget(form) }} +

+ Súgó +

+
+
+
+
+ [avatar]
+ {{ app.user.displayName }}
+ Saját szint
+
+ Tagság kezdete:
+ {{ app.user.registeredAt|date('Y-m-d') }} +
{{ post.text|bbdecode }}
- {{ post.createdAt|date('Y-m-d') }}
- {{ post.createdAt|date('H:i') }}
- [avatar]
- {{ post.createdBy|userdataspan }}
- Szint
-
- Tagság kezdete:
- {{ post.createdBy.RegisteredAt|date('Y-m-d') }} -
{{ post.text|bbdecode }}
+ {{ post.createdAt|date('Y-m-d') }}
+ {{ post.createdAt|date('H:i') }}
+ [avatar]
+ {{ post.createdBy|userdataspan }}
+ Szint
+
+ Tagság kezdete:
+ {{ post.createdBy.RegisteredAt|date('Y-m-d') }} +
{% endblock %} diff --git a/src/KekRozsak/FrontBundle/Resources/views/Forum/topicGroupList.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Forum/topicGroupList.html.twig index 8fd0bc2..e8b0c04 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Forum/topicGroupList.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Forum/topicGroupList.html.twig @@ -6,36 +6,36 @@

Fórum

{% for topicGroup in topicGroups %} - - - - - - - - + + + + + + + + {% if topicGroup.topics|length > 0 %} {% for topic in topicGroup.topics %} - - - - - + + + + - + + {% endfor %} {% else %} - - - + + + {% endif %} - +
{{ topicGroup.title }}Hozzászólások számaUtolsó hozzászólás
{{ topicGroup.title }}Hozzászólások számaUtolsó hozzászólás
[ikon]{{ topic.title }} +
[ikon]{{ topic.title }} {% if topic.lastPost %} - {{ topic.lastPost.createdBy|userdataspan }}
- {{ topic.lastPost.createdAt|date('Y-m-d H:i') }} + {{ topic.lastPost.createdBy|userdataspan }}
+ {{ topic.lastPost.createdAt|date('Y-m-d H:i') }} {% else %} -  
  +  
  {% endif %} -
Ebben a kategóriában nincsenek témák
Ebben a kategóriában nincsenek témák
{% endfor %} {% endblock content %} diff --git a/src/KekRozsak/FrontBundle/Resources/views/Forum/topicList.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Forum/topicList.html.twig index e658969..be3bc51 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Forum/topicList.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Forum/topicList.html.twig @@ -6,29 +6,29 @@

Fórum - {{ topicGroup.title }}

{% if topicGroup.topics|length > 0 %} - - - - - - - - + + + + + + + + {% for topic in topicGroup.topics %} - - - - + + + - + + {% endfor %} - +
Hozzászólások számaUtolsó hozzászólás
Hozzászólások számaUtolsó hozzászólás
{{ topic.title }} +
{{ topic.title }} {% if topic.lastPost %} - {{ topic.lastPost.createdBy|userdataspan }}
- {{ topic.lastPost.createdAt|date('Y-m-d H:i') }} + {{ topic.lastPost.createdBy|userdataspan }}
+ {{ topic.lastPost.createdAt|date('Y-m-d H:i') }} {% else %} -  
  +  
  {% endif %} -
{% else %} Ebben a témakörben nincsenek témák. diff --git a/src/KekRozsak/FrontBundle/Resources/views/Group/create.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Group/create.html.twig index df6ef18..128aa6c 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Group/create.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Group/create.html.twig @@ -4,7 +4,8 @@ {% block title %} - Csoport létrehozása{% endblock %} {% block content %}

Csoport létrehozása

-

Warning

+{# TODO: Leírást készíteni ide, hogy mivel jár a csoportok létrehozása #} +

{{ form_widget(form) }} diff --git a/src/KekRozsak/FrontBundle/Resources/views/Group/documents.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Group/documents.html.twig index ede8d36..0886491 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Group/documents.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Group/documents.html.twig @@ -2,34 +2,31 @@ #} {% extends 'KekRozsakFrontBundle:Default:main_template.html.twig' %} {% block title %} - {{ group.name }}{% endblock %} -{% block additional_css %} - -{% endblock additional_css %} {% block content %}

{{ group.name }} - Dokumentumok

- - - - - - - + + + + + + + {% for document in group.documents %} - - - - - + + + + + {% endfor %} - +
CímKészítette
CímKészítette
[ikon]{{ document.title }} - {{ document.createdBy|userdataspan }}
- {{ document.createdAt|date('Y-m-d H:i') }} -
[ikon]{{ document.title }} + {{ document.createdBy|userdataspan }}
+ {{ document.createdAt|date('Y-m-d H:i') }} +
Új dokumentum {% endblock %} diff --git a/src/KekRozsak/FrontBundle/Resources/views/Group/list.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Group/list.html.twig index 48c8af2..d521fad 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Group/list.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Group/list.html.twig @@ -9,53 +9,47 @@

Szintén fontos, hogy egy új csoport létrehozása nem tesz azonnal annak vezetőjévé, azt a csoport tagjainak meg kell szavazniuk, vagy a Véneknek jóváhagyniuk, hiszen a Kék Rózsák, ezáltal annak csoportjai is az egyenlőség elvén működnek.

Amennyiben látni szeretnéd egy csoport leírását, kattints a csoport nevére!

- - - - - - - - + + + + + + + + {% for group in groups %} - - - - - - + + + + + + {% endfor %} - +
Csoport neveStátuszVezető
Csoport neveStátuszVezető
[ikon]{{ group.name }} - {% if group.isMember(app.user) %} - [tag ikon] - {% elseif group.isRequested(app.user) %} - [jelentkeztél ikon] - {% else %} - {% if group.isOpen %} - [nyílt ikon] - {% else %} - [zárt ikon] - {% endif %} - {% endif %} - {% if group.leader %}{{ group.leader|userdataspan }}{% else %}Nincs{% endif %}
[ikon]{{ group.name }} +{% if group.isMember(app.user) %} + [tag ikon] +{% elseif group.isRequested(app.user) %} + [jelentkeztél ikon] +{% else %} +{% if group.isOpen %} + [nyílt ikon] +{% else %} + [zárt ikon] +{% endif %} +{% endif %} + {% if group.leader %}{{ group.leader|userdataspan }}{% else %}Nincs{% endif %}
Új csoport létrehozása {% endblock content %} {% block bottomscripts %} - + {% endblock bottomscripts %} - - - - - - diff --git a/src/KekRozsak/FrontBundle/Resources/views/Group/members.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Group/members.html.twig index 77d2520..79b0b82 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Group/members.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Group/members.html.twig @@ -2,13 +2,10 @@ #} {% extends 'KekRozsakFrontBundle:Default:main_template.html.twig' %} {% block title %} - {{ group.name }}{% endblock %} -{% block additional_css %} - -{% endblock additional_css %} {% block content %}

{{ group.name }} - Tagok

    @@ -18,4 +15,4 @@ {% endif %} {% endfor %}
-{% endblock %} +{% endblock content %} diff --git a/src/KekRozsak/FrontBundle/Resources/views/Group/view.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Group/view.html.twig index f68ac5e..552b05b 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Group/view.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Group/view.html.twig @@ -3,12 +3,12 @@ {% extends 'KekRozsakFrontBundle:Default:main_template.html.twig' %} {% block title %} - {{ group.name }}{% endblock %} {% block additional_css %} - + {% endblock additional_css %} {% block content %}

{{ group.name }}

{{ group.description|raw }} diff --git a/src/KekRozsak/FrontBundle/Twig/TwigBBExtension.php b/src/KekRozsak/FrontBundle/Twig/TwigBBExtension.php index cc54b25..2af7871 100644 --- a/src/KekRozsak/FrontBundle/Twig/TwigBBExtension.php +++ b/src/KekRozsak/FrontBundle/Twig/TwigBBExtension.php @@ -5,77 +5,118 @@ use Symfony\Component\DependencyInjection\ContainerInterface; class TwigBBExtension extends \Twig_Extension { - private $container; - private $assets; + private $container; + private $assets; - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } + public function __construct(ContainerInterface $container) + { + $this->container = $container; + } - public function getFilters() - { - return array( - 'bbdecode' => new \Twig_Filter_Method($this, 'bbdecode', array( - 'is_safe' => array('html'), - )), - ); - } + public function getFilters() + { + return array( + 'bbdecode' => new \Twig_Filter_Method($this, 'bbdecode', array( + 'is_safe' => array('html'), + )), + ); + } - public function bbdecode($sentence) - { - $sentence = htmlspecialchars($sentence, ENT_NOQUOTES); - $sentence = str_replace(array("\r\n", "\n", "\r"), "
", $sentence); - $sentence = preg_replace('/\\[u\\](.*?)\\[\\/u\\]/im', '\\1', $sentence); - $sentence = preg_replace('/\\[b\\](.*?)\\[\\/b\\]/im', '\\1', $sentence); - $sentence = preg_replace('/\\[i\\](.*?)\\[\\/i\\]/im', '\\1', $sentence); - while (preg_match('/\\[img( (ns|name)="[^"]+"){1,}\\]/i', $sentence, $m, PREG_OFFSET_CAPTURE)) - { - $start = $m[0][1]; - $len = strlen($m[0][0]); - $full_tag = $m[0][0]; + public function bbdecode($sentence) + { + $sentence = preg_replace( + '/\\[i\\](.*?)\\[\\/i\\]/im', + '\\1', + preg_replace( + '/\\[b\\](.*?)\\[\\/b\\]/im', + '\\1', + preg_replace( + '/\\[u\\](.*?)\\[\\/u\\]/im', + '\\1', + str_replace( + array("\r\n", "\n", "\r"), + "
", + htmlspecialchars($sentence, ENT_NOQUOTES) + ) + ) + ) + ); - $ns = (preg_match('/ ns="([^"]+)"/', $full_tag, $ns)) ? trim($ns[1]) : ''; - $name = (preg_match('/ name="([^"]+)"/', $full_tag, $name)) ? trim($name[1]) : ''; + $m = array(); - if ($name == '') - { - $sentence = substr_replace($sentence, 'Hibás kép', $start, $len); - } - else - { - // TODO: Thumbnailing! - $sentence = substr_replace($sentence, '', $start, $len); - } - } - while (preg_match('/\\[link( (url)="[^"]+"){1,}\\](?P.*?)\\[\\/link\\]/i', $sentence, $m, PREG_OFFSET_CAPTURE)) - { - $start = $m[0][1]; - $len = strlen($m[0][0]); - $full_tag = $m[0][0]; + while ( + preg_match( + '/\\[img( (ns|name)="[^"]+"){1,}\\]/i', + $sentence, + $m, + PREG_OFFSET_CAPTURE + ) + ) { + $start = $m[0][1]; + $len = strlen($m[0][0]); + $full_tag = $m[0][0]; - $url = (preg_match('/ url="([^"]+)"/', $full_tag, $url)) ? trim($url[1]) : ''; - $content = ''; - if (array_key_exists('content', $m)) - { - $content = trim($m['content'][0]); - } + $ns = (preg_match('/ ns="([^"]+)"/', $full_tag, $ns)) ? trim($ns[1]) : ''; + $name = (preg_match('/ name="([^"]+)"/', $full_tag, $name)) ? trim($name[1]) : ''; - if (($url == '') || ($content == '')) - { - $sentence = substr_replace($sentence, 'Hibás link', $start, $len); - } - else - { - $sentence = substr_replace($sentence, '' . $content . '', $start, $len); - } - } - return $sentence; - } + if ($name == '') { + $sentence = substr_replace($sentence, 'Hibás kép', $start, $len); + } else { + // TODO: Thumbnailing! + $sentence = substr_replace( + $sentence, + '', + $start, + $len + ); + } + } - public function getName() - { - return 'twig_bb'; - } + while ( + preg_match( + '/\\[link( (url)="[^"]+"){1,}\\](?P.*?)\\[\\/link\\]/i', + $sentence, $m, PREG_OFFSET_CAPTURE) + ) { + $start = $m[0][1]; + $len = strlen($m[0][0]); + $full_tag = $m[0][0]; + + $url = (preg_match('/ url="([^"]+)"/', $full_tag, $url)) ? trim($url[1]) : ''; + $content = ''; + if (array_key_exists('content', $m)) { + $content = trim($m['content'][0]); + } + + if (($url == '') || ($content == '')) { + $sentence = substr_replace($sentence, 'Hibás link', $start, $len); + } else { + $sentence = substr_replace( + $sentence, + '' + . $content + . '', + $start, + $len + ); + } + } + + return $sentence; + } + + public function getName() + { + return 'twig_bb'; + } } - diff --git a/src/KekRozsak/SecurityBundle/Controller/DefaultController.php b/src/KekRozsak/SecurityBundle/Controller/DefaultController.php index f33b098..5d97e4f 100644 --- a/src/KekRozsak/SecurityBundle/Controller/DefaultController.php +++ b/src/KekRozsak/SecurityBundle/Controller/DefaultController.php @@ -16,124 +16,138 @@ use KekRozsak\FrontBundle\Entity\UserData; class DefaultController extends Controller { - /** - * @Route("/login", name="KekRozsakSecurityBundle_login") - * @Template() - */ - public function loginAction() - { - $request = $this->getRequest(); - $session = $request->getSession(); + /** + * @Route("/login", name="KekRozsakSecurityBundle_login") + * @Template() + */ + public function loginAction() + { + $request = $this->getRequest(); + $session = $request->getSession(); - if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) - { - $error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR); - } - else - { - $error = $session->get(SecurityContext::AUTHENTICATION_ERROR); - $session->remove(SecurityContext::AUTHENTICATION_ERROR); - } + if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) { + $error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR); + } else { + $error = $session->get(SecurityContext::AUTHENTICATION_ERROR); + $session->remove(SecurityContext::AUTHENTICATION_ERROR); + } - return array( - 'last_username' => $session->get(SecurityContext::LAST_USERNAME), - 'error' => $error, - ); - } + return array( + 'last_username' => $session->get(SecurityContext::LAST_USERNAME), + 'error' => $error, + ); + } - /** - * @Route("/login_check", name="KekRozsakSecurityBundle_login_check") - */ - public function loginCheckAction() - { - // The security layer will intercept this request. This method will never be called. - } + /** + * @Route("/login_check", name="KekRozsakSecurityBundle_login_check") + */ + public function loginCheckAction() + { + // The security layer will intercept this request. This method will never be called. + } - /** - * @Route("/logout", name="KekRozsakSecurityBundle_logout") - */ - public function logoutAction() - { - // The security layer will intercept this request. This method will never be called. - } + /** + * @Route("/logout", name="KekRozsakSecurityBundle_logout") + */ + public function logoutAction() + { + // The security layer will intercept this request. This method will never be called. + } - /** - * @Route("/jelentkezes", name="KekRozsakSecurityBundle_registration") - * @Template() - */ - public function registrationAction() - { - $user = $this->get('security.context')->getToken()->getUser(); - if ($user instanceof UserInterface) - { - return $this->redirect($this->generateUrl('KekRozsakFrontBundle_homepage')); - } + /** + * @Route("/jelentkezes", name="KekRozsakSecurityBundle_registration") + * @Template() + */ + public function registrationAction() + { + $user = $this->get('security.context')->getToken()->getUser(); + if ($user instanceof UserInterface) { + return $this->redirect($this->generateUrl('KekRozsakFrontBundle_homepage')); + } - $user = new User(); - $form = $this->createForm(new UserType(true), $user); - $request = $this->getRequest(); + $user = new User(); + $form = $this->createForm(new UserType(true), $user); + $request = $this->getRequest(); - if ($request->getMethod() == 'POST') - { - $form->bind($request); + if ($request->getMethod() == 'POST') { + $form->bind($request); - if ($form->isValid(array('registration'))) - { - $roleRepo = $this->getDoctrine()->getRepository('KekRozsakSecurityBundle:Role'); - $defaultRoles = $roleRepo->findByDefault(true); + if ($form->isValid(array('registration'))) { + $roleRepo = $this->getDoctrine()->getRepository('KekRozsakSecurityBundle:Role'); + $defaultRoles = $roleRepo->findByDefault(true); - $user->setRegisteredAt(new \DateTime('now')); - $user->setPassword($this->get('security.encoder_factory')->getEncoder($user)->encodePassword($user->getPassword(), $user->getSalt())); - foreach ($defaultRoles as $role) - $user->addRole($role); - $em = $this->getDoctrine()->getEntityManager(); - $em->persist($user); - $em->flush(); + $user->setRegisteredAt(new \DateTime('now')); + $user->setPassword( + $this + ->get('security.encoder_factory') + ->getEncoder($user) + ->encodePassword( + $user->getPassword(), + $user->getSalt() + ) + ); - $userData = new UserData(); - $user->setUserData($userData); - $em->persist($user); - $em->persist($userData); - $em->flush(); + /* Add default Roles */ + foreach ($defaultRoles as $role) { + $user->addRole($role); + } - $message = \Swift_Message::newInstance() - ->setSubject('Új jelentkező') - // TODO: Make this a config parameter! - ->setFrom('info@blueroses.hu') - // TODO: Make this a config parameter! - ->setTo('jelentkezes@blueroses.hu') - ->setBody($this->renderView('KekRozsakSecurityBundle:Email:new_registration.txt.twig', array('user' => $user))); - $this->get('mailer')->send($message); + $em = $this->getDoctrine()->getEntityManager(); + $em->persist($user); + $em->flush(); - return $this->redirect($this->generateUrl('KekRozsakSecurityBundle_reg_success')); - } - } + $userData = new UserData(); + $user->setUserData($userData); + $em->persist($user); + $em->persist($userData); + $em->flush(); - return array( - 'form' => $form->createView(), - ); - } + $message = \Swift_Message::newInstance() + ->setSubject('Új jelentkező') + // TODO: Make the next two config parameters! + ->setFrom('info@blueroses.hu') + ->setTo('jelentkezes@blueroses.hu') + ->setBody( + $this->renderView( + 'KekRozsakSecurityBundle:Email:new_registration.txt.twig', + array('user' => $user) + ) + ); + $this->get('mailer')->send($message); - /** - * @Route("/most_varj", name="KekRozsakSecurityBundle_reg_success") - * @Template() - */ - public function regSuccessAction() - { - return array( - ); - } + return $this->redirect( + $this->generateUrl( + 'KekRozsakSecurityBundle_reg_success' + ) + ); + } + } - /** - * @Route("/profil/{id}/ajax-felhasznalo-info.{_format}", name="KekRozsakSecurityBundle_ajaxUserdata", requirements={"_format": "html"}) - * @Method({"GET"}) - * @Template() - * @ParamConverter("user") - */ - public function ajaxUserdataAction(User $user) - { - return array( - 'user' => $user, - ); - } + return array( + 'form' => $form->createView(), + ); + } + + /** + * @Route("/most_varj", name="KekRozsakSecurityBundle_reg_success") + * @Template() + */ + public function regSuccessAction() + { + return array( + ); + } + + /** + * @Route("/profil/{id}/ajax-felhasznalo-info.{_format}", name="KekRozsakSecurityBundle_ajaxUserdata", requirements={"_format": "html"}) + * @Method({"GET"}) + * @Template() + * @ParamConverter("user") + */ + public function ajaxUserdataAction(User $user) + { + return array( + 'user' => $user, + ); + } } diff --git a/src/KekRozsak/SecurityBundle/DependencyInjection/Compiler/OverrideServiceCompilerPass.php b/src/KekRozsak/SecurityBundle/DependencyInjection/Compiler/OverrideServiceCompilerPass.php index 59947ae..215b0b9 100644 --- a/src/KekRozsak/SecurityBundle/DependencyInjection/Compiler/OverrideServiceCompilerPass.php +++ b/src/KekRozsak/SecurityBundle/DependencyInjection/Compiler/OverrideServiceCompilerPass.php @@ -7,10 +7,10 @@ use Symfony\Component\DependencyInjection\Reference; class OverrideServiceCompilerPass implements CompilerPassInterface { - public function process(ContainerBuilder $container) - { - $definition = $container->getDefinition('security.role_hierarchy'); - $definition->setClass('KekRozsak\SecurityBundle\Service\RoleHierarchy'); - $definition->setArguments(array(new Reference('doctrine'))); - } + public function process(ContainerBuilder $container) + { + $definition = $container->getDefinition('security.role_hierarchy'); + $definition->setClass('KekRozsak\SecurityBundle\Service\RoleHierarchy'); + $definition->setArguments(array(new Reference('doctrine'))); + } } diff --git a/src/KekRozsak/SecurityBundle/Entity/Role.php b/src/KekRozsak/SecurityBundle/Entity/Role.php index e92f31d..6584ebf 100644 --- a/src/KekRozsak/SecurityBundle/Entity/Role.php +++ b/src/KekRozsak/SecurityBundle/Entity/Role.php @@ -15,155 +15,171 @@ use KekRozsak\SecurityBundle\Entity\User; */ class Role implements RoleInterface { - /** - * @var integer $id - * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") - * @ORM\Column(type="integer") - */ - protected $id; + /** + * The ID of the Role + * + * @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 string name - * @ORM\Column(type="string", length=50, unique=true, nullable=false) - */ - protected $name; + /** + * The role name of the Role + * + * @var string name + * + * @ORM\Column(type="string", length=50, unique=true, nullable=false) + */ + protected $name; - /** - * Set name - * - * @param string $name - * @return Role - */ - public function setName($name) - { - $this->name = $name; - return $this; - } + /** + * Set name + * + * @param string $name + * @return Role + */ + public function setName($name) + { + // TODO: Check if null or empty! + $this->name = $name; + return $this; + } - /** - * Get name - * - * @return string - */ - public function getName() - { - return $this->name; - } + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } - /** - * @var boolean $default - * @ORM\Column(type="boolean", nullable=false) - */ - protected $default; + /** + * TRUE if this Role is automatically added to newly registered Users + * + * @var boolean $default + * + * @ORM\Column(type="boolean", nullable=false) + */ + protected $default; - /** - * Set default - * - * @param boolean $default - */ - public function setDefault($default) - { - $this->default = $default; - return $this; - } + /** + * Set default + * + * @param boolean $default + */ + public function setDefault($default) + { + // TODO: Check if parameter is boolean! + $this->default = $default; + return $this; + } - /** - * @var text description - * @ORM\Column(type="string", length=150, nullable=true) - */ - protected $description; + /** + * The description of this Role + * + * @var text description + * + * @ORM\Column(type="string", length=150, nullable=true) + */ + protected $description; - /** - * Set description - * - * @param string $description - * @return Role - */ - public function setDescription($description = null) - { - $this->description = $description; - return $this; - } + /** + * Set description + * + * @param string $description + * @return Role + */ + public function setDescription($description = null) + { + $this->description = $description; + return $this; + } - /** - * Get description - * - * @return string - */ - public function getDescription() - { - return $this->description; - } + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } - /* Here comes the rest of RoleInterface's implementation */ + /* Here comes the rest of RoleInterface's implementation */ - public function getRole() - { - return $this->name; - } + public function getRole() + { + return $this->name; + } - /** - * Short description - * - * @var string shortDescription - * - * @ORM\Column(type="string", length=50, nullable=false, unique=true, name="short_description") - */ - protected $shortDescription; + /** + * Short description of the Role (e.g readable name) + * + * @var string shortDescription + * + * @ORM\Column(type="string", length=50, nullable=false, unique=true, name="short_description") + */ + protected $shortDescription; - /** - * Set shortDescription - * - * @param string $shortDescription - * @return Role - */ - public function setShortDescription($shortDescription) - { - $this->shortDescription = $shortDescription; - return $this; - } + /** + * Set shortDescription + * + * @param string $shortDescription + * @return Role + */ + public function setShortDescription($shortDescription) + { + // TODO: Check if empty or null! + $this->shortDescription = $shortDescription; + return $this; + } - /** - * Get shortDescription - * - * @return string - */ - public function getShortDescription() - { - return $this->shortDescription; - } + /** + * Get shortDescription + * + * @return string + */ + public function getShortDescription() + { + return $this->shortDescription; + } - /** - * List of inherited Roles - * - * @ORM\ManyToMany(targetEntity="Role", fetch="LAZY") - * @ORM\JoinTable(name="role_hierarchy", joinColumns={ - * @ORM\JoinColumn(name="parent_role_id", referencedColumnName="id") - * }, inverseJoinColumns={ - * @ORM\JoinColumn(name="child_role_id", referencedColumnName="id") - * }) - */ - protected $inheritedRoles; + /** + * List of inherited Roles. Required for RoleHierarchy + * + * @var Doctrine\Common\Collections\ArrayCollection $inheritedRoles + * + * @ORM\ManyToMany(targetEntity="Role", fetch="LAZY") + * @ORM\JoinTable(name="role_hierarchy", joinColumns={ + * @ORM\JoinColumn(name="parent_role_id", referencedColumnName="id") + * }, inverseJoinColumns={ + * @ORM\JoinColumn(name="child_role_id", referencedColumnName="id") + * }) + */ + protected $inheritedRoles; - /** - * Get all inherited roles - * - * @return Doctrine\Common\Collections\ArrayCollection - */ - public function getInheritedRoles() - { - return $this->inheritedRoles; - } + /** + * Get all inherited roles + * + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getInheritedRoles() + { + return $this->inheritedRoles; + } } - diff --git a/src/KekRozsak/SecurityBundle/Entity/User.php b/src/KekRozsak/SecurityBundle/Entity/User.php index f5f50ec..5995025 100644 --- a/src/KekRozsak/SecurityBundle/Entity/User.php +++ b/src/KekRozsak/SecurityBundle/Entity/User.php @@ -11,6 +11,7 @@ use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert; use KekRozsak\FrontBundle\Entity\UserData; use KekRozsak\FrontBundle\Entity\UserGroupMembership; +use KekRozsak\SecurityBundle\Entity\Role; /** * KekRozsak\SecurityBundle\Entity\User @@ -22,364 +23,403 @@ use KekRozsak\FrontBundle\Entity\UserGroupMembership; */ class User implements UserInterface, AdvancedUserInterface { - public function __construct() - { - $this->groups = new ArrayCollection(); - $this->roles = new ArrayCollection(); - } + public function __construct() + { + $this->groups = new ArrayCollection(); + $this->roles = new ArrayCollection(); + } - /** - * @var integer $id - * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") - * @ORM\Column(type="integer") - */ - protected $id; + /** + * The ID of the User + * + * @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 string $username - * @ORM\Column(type="string", length=50, nullable=false, unique=true) - * @Assert\NotBlank(groups="registration") - */ - protected $username; + /** + * The login name of the User + * + * @var string $username + * + * @ORM\Column(type="string", length=50, nullable=false, unique=true) + * @Assert\NotBlank(groups="registration") + */ + protected $username; - /** - * Set username - * - * @param string $username - * @return User - */ - public function setUsername($username) - { - $this->username = $username; - return $this; - } + /** + * Set username + * + * @param string $username + * @return User + */ + public function setUsername($username) + { + // TODO: check if null or empty! + $this->username = $username; + return $this; + } - /** - * Get username - * - * @return string - */ - public function getUsername() - { - return $this->username; - } + /** + * Get username + * + * @return string + */ + public function getUsername() + { + return $this->username; + } - /** - * @var string $password - * @ORM\Column(type="string", length=50, nullable=false) - * @Assert\NotBlank(groups="registration") - */ - protected $password; + /** + * The encrypted password of the User + * + * @var string $password + * + * @ORM\Column(type="string", length=50, nullable=false) + * @Assert\NotBlank(groups="registration") + */ + protected $password; - /** - * Set password - * - * @param string $password - * @return User - */ - public function setPassword($password) - { - $this->password = $password; - return $this; - } + /** + * Set password + * + * @param string $password + * @return User + */ + public function setPassword($password) + { + $this->password = $password; + return $this; + } - /** - * Get password - * - * @return string - */ - public function getPassword() - { - return $this->password; - } + /** + * Get password + * + * @return string + */ + public function getPassword() + { + return $this->password; + } - /** - * @var string $displayName - * @ORM\Column(type="string", length=50, unique=true, name="display_name") - */ - protected $displayName; + /** + * The display name of the User + * + * @var string $displayName + * + * @ORM\Column(type="string", length=50, unique=true, name="display_name") + */ + protected $displayName; - /** - * Set displayName - * - * @param string $displayName - * @return User - */ - public function setDisplayName($displayName) - { - $this->displayName = $displayName; - return $this; - } + /** + * Set displayName + * + * @param string $displayName + * @return User + */ + public function setDisplayName($displayName) + { + // TODO: Check if empty or null! + $this->displayName = $displayName; + return $this; + } - /** - * Get displayName - * - * @return string - */ - public function getDisplayName() - { - return $this->displayName; - } + /** + * Get displayName + * + * @return string + */ + public function getDisplayName() + { + return $this->displayName; + } - /** - * @var string $email - * @ORM\Column(type="string", length=100, nullable=false, unique=true) - */ - protected $email; + /** + * The e-mail address of the User + * + * @var string $email + * + * @ORM\Column(type="string", length=100, nullable=false, unique=true) + */ + protected $email; - /** - * Set email - * - * @param string $email - * @return User - */ - public function setEmail($email) - { - $this->email = $email; - return $this; - } + /** + * Set email + * + * @param string $email + * @return User + */ + public function setEmail($email) + { + // TODO: Check if empty or null! + $this->email = $email; + return $this; + } - /** - * Get email - * - * @return string - */ - public function getEmail() - { - return $this->email; - } + /** + * Get email + * + * @return string + */ + public function getEmail() + { + return $this->email; + } - /** - * @var DateTime $registeredAt - * @ORM\Column(type="datetime", nullable=false, name="registered_at") - */ - protected $registeredAt; + /** + * The timestamp when the user registered + * + * @var DateTime $registeredAt + * + * @ORM\Column(type="datetime", nullable=false, name="registered_at") + */ + protected $registeredAt; - /** - * Set registeredAt - * - * @param DateTime $registeredAt - * @return User - */ - public function setRegisteredAt(\DateTime $registeredAt) - { - $this->registeredAt = $registeredAt; - return $this; - } + /** + * Set registeredAt + * + * @param DateTime $registeredAt + * @return User + */ + public function setRegisteredAt(\DateTime $registeredAt) + { + $this->registeredAt = $registeredAt; + return $this; + } - /** - * Get registeredAt - * - * @return DateTime - */ - public function getRegisteredAt() - { - return $this->registeredAt; - } + /** + * Get registeredAt + * + * @return DateTime + */ + public function getRegisteredAt() + { + return $this->registeredAt; + } - /** - * @var User acceptedBy - * @ORM\ManyToOne(targetEntity="User") - * @ORM\JoinColumn(name="accepted_by_id") - */ - protected $acceptedBy; + /** + * The User who accepted this User's registration + * + * @var User acceptedBy + * + * @ORM\ManyToOne(targetEntity="User") + * @ORM\JoinColumn(name="accepted_by_id") + */ + protected $acceptedBy; - /** - * Set acceptedBy - * - * @param User $acceptedBy - * @return User - */ - public function setAcceptedBy(User $acceptedBy = null) - { - $this->acceptedBy = $acceptedBy; - return $this; - } + /** + * Set acceptedBy + * + * @param User $acceptedBy + * @return User + */ + public function setAcceptedBy(User $acceptedBy = null) + { + $this->acceptedBy = $acceptedBy; + return $this; + } - /** - * Get acceptedBy - * - * @return User - */ - public function getAcceptedBy() - { - return $this->acceptedBy; - } + /** + * Get acceptedBy + * + * @return User + */ + public function getAcceptedBy() + { + return $this->acceptedBy; + } - /** - * @var DateTime $lastLoginAt - * @ORM\Column(type="datetime", nullable=true, name="last_login_at") - */ - protected $lastLoginAt; + /** + * The timestamp when the User logged in last time + * + * @var DateTime $lastLoginAt + * + * @ORM\Column(type="datetime", nullable=true, name="last_login_at") + */ + protected $lastLoginAt; - /** - * Set lastLoginAt; - * - * @param DateTime $lastLoginAt - * @return User - */ - public function setLastLoginAt(\DateTime $lastLoginAt = null) - { - $this->lastLoginAt = $lastLoginAt; - return $this; - } + /** + * Set lastLoginAt; + * + * @param DateTime $lastLoginAt + * @return User + */ + public function setLastLoginAt(\DateTime $lastLoginAt = null) + { + $this->lastLoginAt = $lastLoginAt; + return $this; + } - /** - * Get lastLoginAt - * - * @return DateTime - */ - public function getLastLoginAt() - { - return $this->lastLoginAt; - } + /** + * Get lastLoginAt + * + * @return DateTime + */ + public function getLastLoginAt() + { + return $this->lastLoginAt; + } - /** - * @var \KekRozsak\FrontBundle\Entity\UserData $userData - * @ORM\OneToOne(targetEntity="KekRozsak\FrontBundle\Entity\UserData", fetch="LAZY", cascade={"persist"}, mappedBy="user") - */ - protected $userData; + /** + * The UserData object for this User + * + * @var \KekRozsak\FrontBundle\Entity\UserData $userData + * + * @ORM\OneToOne(targetEntity="KekRozsak\FrontBundle\Entity\UserData", fetch="LAZY", cascade={"persist"}, mappedBy="user") + */ + protected $userData; + /** + * Set userData + * + * @param \KekRozsak\FrontBundle\Entity\UserData $userData + * @return User + */ + public function setUserData(\KekRozsak\FrontBundle\Entity\UserData $userData = null) + { + $this->userData = $userData; + $userData->setUser($this); + return $this; + } - /** - * Set userData - * - * @param \KekRozsak\FrontBundle\Entity\UserData $userData - * @return User - */ - public function setUserData(\KekRozsak\FrontBundle\Entity\UserData $userData = null) - { - $this->userData = $userData; - $userData->setUser($this); - return $this; - } + /** + * Get userData + * + * @return \KekRozsak\FrontBundle\Entity\UserData + */ + public function getUserData() + { + return $this->userData; + } - /** - * Get userData - * - * @return \KekRozsak\FrontBundle\Entity\UserData - */ - public function getUserData() - { - return $this->userData; - } + /** + * The Group memberships of this User represented by UserGroupMembership + * objects + * + * @var Doctrine\Common\Collections\ArrayCollection $groups + * + * @ORM\OneToMany(targetEntity="KekRozsak\FrontBundle\Entity\UserGroupMembership", mappedBy="user") + * @ORM\JoinColumn(referencedColumnName="user_id") + */ + protected $groups; - /** - * @var Doctrine\Common\Collections\ArrayCollection $groups - * @ORM\OneToMany(targetEntity="KekRozsak\FrontBundle\Entity\UserGroupMembership", mappedBy="user") - * @ORM\JoinColumn(referencedColumnName="user_id") - */ - protected $groups; + /** + * Add group + * + * @param KekRozsak\FrontBundle\Entity\UserGroupMembership $group + * @return User + */ + public function addGroup(UserGroupMembership $group) + { + // TODO: Check if null! + $this->groups[] = $group; + return $this; + } - /** - * Add group - * - * @param KekRozsak\FrontBundle\Entity\UserGroupMembership $group - * @return User - */ - public function addGroup(\KekRozsak\FrontBundle\Entity\UserGroupMembership $group) - { - $this->groups[] = $group; - return $this; - } + /** + * Get all groups + * + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getGroups() + { + return $this->groups; + } - /** - * Get all groups - * - * @return Doctrine\Common\Collections\ArrayCollection - */ - public function getGroups() - { - return $this->groups; - } + /** + * The Roles belonging to this User + * + * @var Doctrine\Common\Collections\ArrayCollection $roles + * + * @ORM\ManyToMany(targetEntity="Role") + */ + protected $roles; - /** - * @var Doctrine\Common\Collections\ArrayCollection $roles - * @ORM\ManyToMany(targetEntity="Role") - */ - protected $roles; + /** + * Add a role + * + * @param KekRozsak\SecurityBundle\Entity\Role $role + * @return User + */ + public function addRole(Role $role) + { + // TODO: Check if null! + $this->roles[] = $role; + return $this; + } - /** - * Add a role - * - * @param KekRozsak\SecurityBundle\Entity\Role $role - * @return User - */ - public function addRole(\KekRozsak\SecurityBundle\Entity\Role $role) - { - $this->roles[] = $role; - return $this; - } + /** + * Get all roles as an ArrayCollection + * + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getRolesCollection() + { + return $this->roles; + } - /** - * Get all roles as an ArrayCollection - * - * @return Doctrine\Common\Collections\ArrayCollection - */ - public function getRolesCollection() - { - return $this->roles; - } + /** + * Get all roles, for UserInterface implementation. To get the + * ArrayCollection, use getRolesCollection() instead + * + * @return array + */ + public function getRoles() + { + return $this->roles->toArray(); + } - /** - * Get all roles, for UserInterface implementation. To get the - * collection, use getRolesCollection() instead - * - * @return array - */ - public function getRoles() - { - return $this->roles->toArray(); - } + /* Here comes the remaining part of UserInterface implementation */ - /* Here comes the remaining part of UserInterface implementation */ + public function getSalt() + { + /* + * As we use crypt() to encode passwords, salt is always the same as the + * password + */ + return $this->password; + } - public function getSalt() - { - /* As we use crypt() to encode passwords, salt is always the - * same as password - */ - return $this->password; - } + public function eraseCredentials() + { + } - public function eraseCredentials() - { - } + /* Here comes the AdvancedUserInterface implementation */ - /* Here comes the AdvancedUserInterface implementation */ + public function isAccountNonExpired() + { + /* Currently, accounts never expire */ + return true; + } - public function isAccountNonExpired() - { - /* Currently, accounts never expire */ - return true; - } + public function isAccountNonLocked() + { + /* Currently, accounts cannot be locked */ + return true; + } - public function isAccountNonLocked() - { - /* Currently, accounts cannot be locked */ - return true; - } + public function isCredentialsNonExpired() + { + /* Currently, credentials never expire */ + return true; + } - public function isCredentialsNonExpired() - { - /* Currently, credentials never expire */ - return true; - } - - public function isEnabled() - { - /* Account is enabled if it is accepted by someone */ - return ($this->acceptedBy !== null); - } + public function isEnabled() + { + /* Account is enabled if it is accepted by someone */ + return ($this->acceptedBy !== null); + } } diff --git a/src/KekRozsak/SecurityBundle/Form/Type/UserType.php b/src/KekRozsak/SecurityBundle/Form/Type/UserType.php index f2cf812..8b3f5f4 100644 --- a/src/KekRozsak/SecurityBundle/Form/Type/UserType.php +++ b/src/KekRozsak/SecurityBundle/Form/Type/UserType.php @@ -9,68 +9,76 @@ use KekRozsak\FrontBundle\Form\Type\UserDataType; class UserType extends AbstractType { - protected $_registration; + protected $_registration; - public function __construct($registration = false) - { - $this->_registration = $registration; - } + public function __construct($registration = false) + { + $this->_registration = $registration; + } - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add('username', null, array( - 'label' => 'Felhasználónév', - 'read_only' => (!$this->_registration), - 'help' => 'Ezt fogod használni az oldalra való bejelentkezéshez. Jelszavadhoz hasonlóan kezeld bizalmasan! Jelentkezés után nem lehet megváltoztatni!', - )); - $builder->add('password', 'repeated', array( - 'type' => 'password', - 'second_name' => 'confirm', - 'invalid_message' => 'A két jelszó nem egyezik meg!', - 'required' => ($this->_registration), - 'options' => array( - 'label' => 'Jelszó', - 'help' => 'Ezt fogod használni az oldalra való bejelentkezéshez. Soha ne add meg senkinek!', - ), - )); - $builder->add('email', null, array( - 'label' => 'E-mail cím', - 'help' => 'Ezen az e-mail címen értesítünk majd, ha felvételt nyersz a körbe.', - )); - $builder->add('displayName', null, array( - 'label' => 'Név', - 'help' => 'Ezen a néven fog szólítani a közösség. Bármikor megváltoztathatod, de az egyértelműség kedvéért ezt mindig jelezd a többiek felé!', - )); - if (!$this->_registration) - { - $builder->add('userData', new UserDataType(), array( - 'label' => 'Egyéb adatok', - )); - } - else - { - $builder->add('agree', 'checkbox', array( - 'property_path' => false, - 'label' => ' ', - 'help' => 'A Jelentkezés gomb megnyomásával kijelentem, hogy a Kék Rózsa okkultista kör Házirendjét elolvastam, és azt felvételem esetén magamra nézve teljes mértékben elfogadom.', - )); - } - } + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder->add('username', null, array( + 'label' => 'Felhasználónév', + 'read_only' => (!$this->_registration), + 'help' => 'Ezt fogod használni az oldalra való bejelentkezéshez. Jelszavadhoz hasonlóan kezeld bizalmasan! Jelentkezés után nem lehet megváltoztatni!', + ) + ); - public function getName() - { - return 'user'; - } + $builder->add('password', 'repeated', array( + 'type' => 'password', + 'second_name' => 'confirm', + 'invalid_message' => 'A két jelszó nem egyezik meg!', + 'required' => ($this->_registration), + 'options' => array( + 'label' => 'Jelszó', + 'help' => 'Ezt fogod használni az oldalra való bejelentkezéshez. Soha ne add meg senkinek!', + ), + ) + ); - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $opts = array( - 'data_class' => 'KekRozsak\SecurityBundle\Entity\User', - ); - if ($this->_registration) - $opts['validation_groups'] = array('registration'); + $builder->add('email', null, array( + 'label' => 'E-mail cím', + 'help' => 'Ezen az e-mail címen értesítünk majd, ha felvételt nyersz a körbe.', + ) + ); - $resolver->setDefaults($opts); - } + $builder->add('displayName', null, array( + 'label' => 'Név', + 'help' => 'Ezen a néven fog szólítani a közösség. Bármikor megváltoztathatod, de az egyértelműség kedvéért ezt mindig jelezd a többiek felé!', + ) + ); + + if (!$this->_registration) { + $builder->add('userData', new UserDataType(), array( + 'label' => 'Egyéb adatok', + ) + ); + } else { + $builder->add('agree', 'checkbox', array( + 'property_path' => false, + 'label' => ' ', + 'help' => 'A Jelentkezés gomb megnyomásával kijelentem, hogy a Kék Rózsa okkultista kör Házirendjét elolvastam, és azt felvételem esetén magamra nézve teljes mértékben elfogadom.', + ) + ); + } + } + + public function getName() + { + return 'user'; + } + + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $opts = array( + 'data_class' => 'KekRozsak\SecurityBundle\Entity\User', + ); + + if ($this->_registration) { + $opts['validation_groups'] = array('registration'); + } + + $resolver->setDefaults($opts); + } } - diff --git a/src/KekRozsak/SecurityBundle/KekRozsakSecurityBundle.php b/src/KekRozsak/SecurityBundle/KekRozsakSecurityBundle.php index e8d27b7..7a650b4 100644 --- a/src/KekRozsak/SecurityBundle/KekRozsakSecurityBundle.php +++ b/src/KekRozsak/SecurityBundle/KekRozsakSecurityBundle.php @@ -9,9 +9,9 @@ use KekRozsak\SecurityBundle\DependencyInjection\Compiler\OverrideServiceCompile class KekRozsakSecurityBundle extends Bundle { - public function build(ContainerBuilder $container) - { - parent::build($container); - $container->addCompilerPass(new OverrideServiceCompilerPass()); - } + public function build(ContainerBuilder $container) + { + parent::build($container); + $container->addCompilerPass(new OverrideServiceCompilerPass()); + } } diff --git a/src/KekRozsak/SecurityBundle/Resources/config/services.xml b/src/KekRozsak/SecurityBundle/Resources/config/services.xml index 9b64013..cb21e55 100644 --- a/src/KekRozsak/SecurityBundle/Resources/config/services.xml +++ b/src/KekRozsak/SecurityBundle/Resources/config/services.xml @@ -1,17 +1,19 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/src/KekRozsak/SecurityBundle/Resources/views/Default/ajaxUserdata.html.twig b/src/KekRozsak/SecurityBundle/Resources/views/Default/ajaxUserdata.html.twig index 4b96787..ed39943 100644 --- a/src/KekRozsak/SecurityBundle/Resources/views/Default/ajaxUserdata.html.twig +++ b/src/KekRozsak/SecurityBundle/Resources/views/Default/ajaxUserdata.html.twig @@ -1,10 +1,10 @@ {# vim: ft=htmljinja #} - - {{ user.displayName }} - - - Tagság kezdete: {{ user.registeredAt|date('Y-m-d') }} - + + {{ user.displayName }} + + + Tagság kezdete: {{ user.registeredAt|date('Y-m-d') }} + diff --git a/src/KekRozsak/SecurityBundle/Resources/views/Default/login.html.twig b/src/KekRozsak/SecurityBundle/Resources/views/Default/login.html.twig index 986bb65..cd9d952 100644 --- a/src/KekRozsak/SecurityBundle/Resources/views/Default/login.html.twig +++ b/src/KekRozsak/SecurityBundle/Resources/views/Default/login.html.twig @@ -7,8 +7,8 @@
{{ error.message }}
{% endif %} - - - + + + {% endblock content %} diff --git a/src/KekRozsak/SecurityBundle/Resources/views/Default/regSuccess.html.twig b/src/KekRozsak/SecurityBundle/Resources/views/Default/regSuccess.html.twig index dba36a0..1d03135 100644 --- a/src/KekRozsak/SecurityBundle/Resources/views/Default/regSuccess.html.twig +++ b/src/KekRozsak/SecurityBundle/Resources/views/Default/regSuccess.html.twig @@ -3,5 +3,5 @@ {% extends 'KekRozsakFrontBundle:Default:main_template.html.twig' %} {% block title %} - Sikeres regisztráció{% endblock %} {% block content %} - A regisztrációd sikeres volt. A Vének hamarosan kapcsolatba lépnek Veled, és elbírálják jelentkezésedet. Kérünk, addig légy türelemmel! + A regisztrációd sikeres volt. A Vének hamarosan kapcsolatba lépnek Veled, és elbírálják jelentkezésedet. Kérünk, addig légy türelemmel! {% endblock %} diff --git a/src/KekRozsak/SecurityBundle/Resources/views/Default/registration.html.twig b/src/KekRozsak/SecurityBundle/Resources/views/Default/registration.html.twig index 6b151a6..d36124d 100644 --- a/src/KekRozsak/SecurityBundle/Resources/views/Default/registration.html.twig +++ b/src/KekRozsak/SecurityBundle/Resources/views/Default/registration.html.twig @@ -8,10 +8,10 @@

Amennyiben már tagja vagy a körnek, itt bejelentkezhetsz.

Az alábbi űrlap kitöltésével jelentkezhetsz a Kék Rózsa okkultista kör tagjai közé. Kérünk, hogy jelentkezés előtt figyelmesen olvasd el a Rólunk menüpont szövegét, különös tekintettel a Házirendre.

A jelentkezés NEM jár automatikus tagsággal. A Házirend szerint a Vének jogot formálhatnak arra, hogy a jelentkezésedet elutasítsák, vagy próbáknak vessenek alá, mielőtt a tagok közé fogadnak.

-

FONTOS! Aki a régi fórumon írt bármilyen bejegyzést, az már regisztrálva van ezen az oldalon is! Ez esetben kérlek lépjetek kapcsolatba velem Facebookon vagy e-mailben a jelentkezes@blueroses.hu címen!

+

FONTOS! Aki a régi fórumon írt bármilyen bejegyzést, az már regisztrálva van ezen az oldalon is! Ez esetben kérlek lépjetek kapcsolatba velem Facebookon vagy e-mailben a jelentkezes@blueroses.hu címen!

- +
{{ form_widget(form) }} -
- + + {% endblock content %} diff --git a/src/KekRozsak/SecurityBundle/Security/AuthSuccess.php b/src/KekRozsak/SecurityBundle/Security/AuthSuccess.php index b2e6f81..d0f1a16 100644 --- a/src/KekRozsak/SecurityBundle/Security/AuthSuccess.php +++ b/src/KekRozsak/SecurityBundle/Security/AuthSuccess.php @@ -2,7 +2,6 @@ namespace KekRozsak\SecurityBundle\Security; use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface; -use Doctrine\ORM\EntityManager; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Bridge\Doctrine\RegistryInterface; @@ -10,29 +9,29 @@ use Symfony\Component\Security\Core\Event\AuthenticationEvent; class AuthSuccess implements AuthenticationSuccessHandlerInterface { - private $doctrine; + private $doctrine; - public function __construct(RegistryInterface $doctrine) - { - $this->doctrine = $doctrine; - } + public function __construct(RegistryInterface $doctrine) + { + $this->doctrine = $doctrine; + } - public function onSecurityAuthenticationSuccess(AuthenticationEvent $event) - { - $user = $event->getAuthenticationToken()->getUser(); - $em = $this->doctrine->getEntityManager(); - $user->setLastLoginAt(new \DateTime('now')); - $em->persist($user); - $em->flush(); - } + public function onSecurityAuthenticationSuccess(AuthenticationEvent $event) + { + $user = $event->getAuthenticationToken()->getUser(); + $em = $this->doctrine->getEntityManager(); + $user->setLastLoginAt(new \DateTime('now')); + $em->persist($user); + $em->flush(); + } - public function onAuthenticationSuccess(Request $request, TokenInterface $token) - { - $user = $token->getUser(); - $em = $this->doctrine->getEntityManager(); - $user->setLastLoginAt(new \DateTime('now')); - $em->persist($user); - $em->flush(); - } + public function onAuthenticationSuccess(Request $request, TokenInterface $token) + { + $user = $token->getUser(); + $em = $this->doctrine->getEntityManager(); + $user->setLastLoginAt(new \DateTime('now')); + $em->persist($user); + $em->flush(); + } } diff --git a/src/KekRozsak/SecurityBundle/Service/CryptEncoder.php b/src/KekRozsak/SecurityBundle/Service/CryptEncoder.php index e2b5f7a..f1d40bb 100644 --- a/src/KekRozsak/SecurityBundle/Service/CryptEncoder.php +++ b/src/KekRozsak/SecurityBundle/Service/CryptEncoder.php @@ -5,14 +5,14 @@ use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface; class CryptEncoder implements PasswordEncoderInterface { - function encodePassword($raw, $salt) - { - return crypt($raw); - } + function encodePassword($raw, $salt) + { + return crypt($raw); + } - function isPasswordValid($encoded, $raw, $salt) - { - return (crypt($raw, $salt) == $encoded); - } + function isPasswordValid($encoded, $raw, $salt) + { + return (crypt($raw, $salt) == $encoded); + } } diff --git a/src/KekRozsak/SecurityBundle/Twig/UserDataSpanExtension.php b/src/KekRozsak/SecurityBundle/Twig/UserDataSpanExtension.php index 2d1998c..51c660c 100644 --- a/src/KekRozsak/SecurityBundle/Twig/UserDataSpanExtension.php +++ b/src/KekRozsak/SecurityBundle/Twig/UserDataSpanExtension.php @@ -9,33 +9,40 @@ use KekRozsak\SecurityBundle\Entity\User; class UserDataSpanExtension extends \Twig_Extension { - protected $_securityContext; - protected $_router; + protected $_securityContext; + protected $_router; - public function __construct(Router $router, SecurityContextInterface $security) - { - $this->_router = $router; - $this->_securityContext = $security; - } + public function __construct(Router $router, SecurityContextInterface $security) + { + $this->_router = $router; + $this->_securityContext = $security; + } - public function getFilters() - { - return array( - 'userdataspan' => new \Twig_Filter_Method($this, 'getUserDataSpan', array('is_safe' => array('html'))), - ); - } + public function getFilters() + { + return array( + 'userdataspan' => new \Twig_Filter_Method( + $this, + 'getUserDataSpan', + array('is_safe' => array('html')) + ), + ); + } - public function getUserDataSpan(User $user) - { - if (!is_object($this->_securityContext->getToken()) || !is_object($this->_securityContext->getToken()->getUser())) - return '[nem jelenhet meg]'; + public function getUserDataSpan(User $user) + { + if ( + !is_object($this->_securityContext->getToken()) + || !is_object($this->_securityContext->getToken()->getUser()) + ) { + return '[nem jelenhet meg]'; + } - return '' . $user->getDisplayName() . ''; - } + return '' . $user->getDisplayName() . ''; + } - public function getName() - { - return 'twig_userdataspan'; - } + public function getName() + { + return 'twig_userdataspan'; + } } -