Refactored code to comply with PSR-*

Signed-off-by: Gergely POLONKAI <polesz@w00d5t0ck.info>
This commit is contained in:
Gergely POLONKAI 2012-08-16 15:52:41 +02:00
parent de00a6ad21
commit fab08cad6f
69 changed files with 5253 additions and 4673 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,89 +12,91 @@ use KekRozsak\FrontBundle\Entity\Event;
class EventController extends Controller class EventController extends Controller
{ {
/** /**
* @Route("/esesmeny/{startDate}/{eventSlug}", name="KekRozsakFrontBundle_eventView") * @Route("/esesmeny/{startDate}/{eventSlug}", name="KekRozsakFrontBundle_eventView")
* @Template() * @Template()
* @ParamConverter("event", class="KekRozsakFrontBundle:Event", options={"mapping"={"eventSlug" = "slug", "startDate"="startDate"}}) * @ParamConverter("event", class="KekRozsakFrontBundle:Event", options={"mapping"={"eventSlug" = "slug", "startDate"="startDate"}})
* @ParamConverter("startDate", class="DateTime", options={"format"="Y-m-d"}) * @ParamConverter("startDate", class="DateTime", options={"format"="Y-m-d"})
*/ */
public function viewAction(\DateTime $startDate, Event $event) public function viewAction(\DateTime $startDate, Event $event)
{ {
if ($event->getGroup() !== null) if ($event->getGroup() !== null) {
{ if (!$event->getGroup()->isMember($this->get('security.context')->getToken()->getUser())) {
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.');
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);
} }
$events = $query->getResult(); }
return array( return array(
'day' => $realDate, 'event' => $event,
'events' => $events, );
); }
}
/** /**
* @Route("/esemenyek/{date}/ajax-lista.{_format}", name="KekRozsakFrontBundle_eventAjaxList", requirements={"_format": "html"}) * @Route("/esemeny/{startDate}/{eventSlug}/csatlakozas", name="KekRozsakFrontBundle_eventJoin")
* @Template() * @Template()
* @ParamConverter("date", options={"format": "Y-m-d"}) * @ParamConverter("event", class="KekRozsakFrontBundle:Event", options={"mapping"={"eventSlug": "slug", "startDate": "startDate"}})
*/ * @ParamConverter("startDate", class="DateTime", options={"format"="Y-m-d"})
public function ajaxListAction(\DateTime $date) */
{ public function joinAction(\DateTime $startDate, Event $event)
$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); $user = $this->get('security.context')->getToken()->getUser();
$events = $query->getResult();
return array( if ($event->getGroup() !== null) {
'day' => $date, if (!$event->getGroup()->isMember($user)) {
'events' => $events, 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,
);
}
} }

View File

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

View File

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

View File

@ -12,247 +12,273 @@ use KekRozsak\SecurityBundle\Entity\User;
*/ */
class Article class Article
{ {
/** /**
* @var integer $id * The ID of the Article
* @ORM\Id *
* @ORM\GeneratedValue(strategy="AUTO") * @var integer $id
* @ORM\Column(type="integer") *
*/ * @ORM\Id
protected $id; * @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
protected $id;
/** /**
* Get id * Get id
* *
* @return integer * @return integer
*/ */
public function getId() public function getId()
{ {
return $this->id; return $this->id;
} }
/** /**
* @var KekRozsak\SecurityBundle\Entity\User $createdBy * The User who created the Article
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") *
* @ORM\JoinColumn(name="created_by_id") * @var KekRozsak\SecurityBundle\Entity\User $createdBy
*/ *
protected $createdBy; * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
* @ORM\JoinColumn(name="created_by_id")
*/
protected $createdBy;
/** /**
* Set createdBy * Set createdBy
* *
* @param KekRozsak\SecurityBundle\Entity\User $createdBy * @param KekRozsak\SecurityBundle\Entity\User $createdBy
* @return Article * @return Article
*/ */
public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy) public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy)
{ {
$this->createdBy = $createdBy; $this->createdBy = $createdBy;
return $this; return $this;
} }
/** /**
* Get createdBy * Get createdBy
* *
* @return KekRozsak\SecurityBundle\Entity\User * @return KekRozsak\SecurityBundle\Entity\User
*/ */
public function getCreatedBy() public function getCreatedBy()
{ {
return $this->createdBy; return $this->createdBy;
} }
/** /**
* @var DateTime $createdAt * The timestamp when the Article was created
* @ORM\Column(type="datetime", name="created_at", nullable=false) *
*/ * @var DateTime $createdAt
protected $createdAt; *
* @ORM\Column(type="datetime", name="created_at", nullable=false)
*/
protected $createdAt;
/** /**
* Set createdAt * Set createdAt
* *
* @param DateTime $createdAt * @param DateTime $createdAt
* @return Article * @return Article
*/ */
public function setCreatedAt(\DateTime $createdAt) public function setCreatedAt(\DateTime $createdAt)
{ {
$this->createdAt = $createdAt; $this->createdAt = $createdAt;
return $this; return $this;
} }
/** /**
* Get createdAt * Get createdAt
* *
* @return DateTime * @return DateTime
*/ */
public function getCreatedAt() public function getCreatedAt()
{ {
return $this->createdAt; return $this->createdAt;
} }
/** /**
* @var string $title * The title of the Article
* @ORM\Column(type="string", length=100, nullable=false, unique=true) *
*/ * @var string $title
protected $title; *
* @ORM\Column(type="string", length=100, nullable=false, unique=true)
*/
protected $title;
/** /**
* Set title * Set title
* *
* @param string $title * @param string $title
* @return Article * @return Article
*/ */
public function setTitle($title) public function setTitle($title)
{ {
$this->title = $title; $this->title = $title;
return $this; return $this;
} }
/** /**
* Get title * Get title
* *
* @return string * @return string
*/ */
public function getTitle() public function getTitle()
{ {
return $this->title; return $this->title;
} }
/** /**
* @var string $slug * The slugified title of the Article
* @ORM\Column(type="string", length=100, nullable=false, unique=true) *
*/ * @var string $slug
protected $slug; *
* @ORM\Column(type="string", length=100, nullable=false, unique=true)
*/
protected $slug;
/** /**
* Set slug * Set slug
* *
* @param string $slug * @param string $slug
* @return Article * @return Article
*/ */
public function setSlug($slug) public function setSlug($slug)
{ {
$this->slug = $slug; $this->slug = $slug;
return $this; return $this;
} }
/** /**
* Get slug * Get slug
* *
* @return string * @return string
*/ */
public function getSlug() public function getSlug()
{ {
return $this->slug; return $this->slug;
} }
/** /**
* @var string $text * The content of the Article
* @ORM\Column(type="text", nullable=false) *
*/ * @var string $text
protected $text; *
* @ORM\Column(type="text", nullable=false)
*/
protected $text;
/** /**
* Set text * Set text
* *
* @param string $text * @param string $text
* @return Article * @return Article
*/ */
public function setText($text) public function setText($text)
{ {
$this->text = $text; $this->text = $text;
return $this; return $this;
} }
/** /**
* Get text * Get text
* *
* return string * return string
*/ */
public function getText() public function getText()
{ {
return $this->text; return $this->text;
} }
/** /**
* @var boolean $mainPage * TRUE if the article should display on the main mage
* @ORM\Column(type="boolean", name="main_page") *
*/ * @var boolean $mainPage
protected $mainPage; *
* @ORM\Column(type="boolean", name="main_page")
*/
protected $mainPage;
/** /**
* Set mainPage * Set mainPage
* *
* @param boolean $mainPage * @param boolean $mainPage
* @return Article * @return Article
*/ */
public function setMainPage($mainPage) public function setMainPage($mainPage)
{ {
$this->mainPage = $mainPage; $this->mainPage = $mainPage;
return $this; return $this;
} }
/** /**
* Get mainPage * Get mainPage
* *
* @return boolean * @return boolean
*/ */
public function getMainPage() public function getMainPage()
{ {
return $this->mainPage; return $this->mainPage;
} }
/** /**
* @var boolean public * TRUE if the article is viewable by anyone
* @ORM\Column(type="boolean", nullable=false) *
*/ * @var boolean public
protected $public; *
* @ORM\Column(type="boolean", nullable=false)
*/
protected $public;
/** /**
* Set public * Set public
* *
* @param boolean $public * @param boolean $public
* @return Article * @return Article
*/ */
public function setPublic($public = false) public function setPublic($public = false)
{ {
$this->public = $public; $this->public = $public;
return $this; return $this;
} }
/** /**
* Get public * Get public
* *
* @return boolean * @return boolean
*/ */
public function isPublic() public function isPublic()
{ {
return $this->public; return $this->public;
} }
/** /**
* @var string $source * The source of the Article, if any
* @ORM\Column(type="string", nullable=true) *
*/ * @var string $source
protected $source; *
* @ORM\Column(type="string", nullable=true)
*/
protected $source;
/** /**
* Set source * Set source
* *
* @param string $source * @param string $source
* @return Article * @return Article
*/ */
public function setSource($source = null) public function setSource($source = null)
{ {
$this->source = $source; $this->source = $source;
return $this; return $this;
} }
/** /**
* Get source * Get source
* *
* @return string * @return string
*/ */
public function getSource() public function getSource()
{ {
return $this->source; return $this->source;
} }
} }

View File

@ -18,282 +18,348 @@ use KekRozsak\SecurityBundle\Entity\User;
*/ */
class Book class Book
{ {
public function __construct() public function __construct()
{ {
$this->copies = new ArrayCollection(); $this->copies = new ArrayCollection();
$this->wouldBorrow = new ArrayCollection(); $this->wouldBorrow = new ArrayCollection();
$this->wouldBuy = new ArrayCollection(); $this->wouldBuy = new ArrayCollection();
} }
/** /**
* @var integer $id * The ID of the Book
* *
* @ORM\Id * @var integer $id
* @ORM\GeneratedValue(strategy="AUTO") *
* @ORM\Column(type="integer") * @ORM\Id
*/ * @ORM\GeneratedValue(strategy="AUTO")
protected $id; * @ORM\Column(type="integer")
*/
protected $id;
/** /**
* Get id * Get id
* *
* @return integer * @return integer
*/ */
public function getId() public function getId()
{ {
return $this->id; return $this->id;
} }
/** /**
* @var Doctrine\Common\Collections\ArrayCollection $copies * The copies available for this Book
* *
* @ORM\OneToMany(targetEntity="BookCopy", mappedBy="book") * @var Doctrine\Common\Collections\ArrayCollection $copies
*/ *
protected $copies; * @ORM\OneToMany(targetEntity="BookCopy", mappedBy="book")
*/
protected $copies;
/** /**
* Remove a copy * Remove a copy
* *
* @param KekRozsak\FrontBundle\Entity\BookCopy $copy * @param KekRozsak\FrontBundle\Entity\BookCopy $copy
* @return Book * @return Book
*/ */
public function removeCopy(BookCopy $copy) public function removeCopy(BookCopy $copy)
{ {
$this->copies->removeElement($copy); $this->copies->removeElement($copy);
} }
/** /**
* Get copies * Get copies
* *
* @return Doctrine\Common\Collections\ArrayCollection * @return Doctrine\Common\Collections\ArrayCollection
*/ */
public function getCopies() public function getCopies()
{ {
return $this->copies; return $this->copies;
} }
public function getCopiesBorrowed() /**
{ * Get the copies of this Book those are borrowed by someone
return $this->copies->filter(function($copy) { *
return ($copy->getBorrower() !== null); * @return Doctrine\Common\Collections\ArrayCollection
}); */
} public function getCopiesBorrowed()
{
return $this->copies->filter(function($copy)
{
return ($copy->getBorrower() !== null);
});
}
public function getCopiesBorrowedByUser(User $user) /**
{ * Get the copies of this Book those are borrowed by $user
return $this->copies->filter(function($copy) use ($user) { *
return ($copy->getBorrower() == $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) /**
{ * Get the copies of this Book those are borrowed by $user, but marked as
return $this->copies->filter(function($copy) use ($user) { * returned
return ($copy->getBorrower() == $user) && ($copy->isBorrowerReturned()); *
}); * @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() /**
{ * Get all the borrowable copies of this Book
return $this->copies->filter(function($copy) { *
return $copy->isBorrowable(); * @return Doctrine\Common\Collections\ArrayCollection
}); */
} public function getCopiesBorrowable()
{
return $this->copies->filter(function($copy) {
return $copy->isBorrowable();
});
}
public function getUsersCopies(User $user) /**
{ * Get $user's copies of this Book
return $this->copies->filter(function ($copy) use ($user) { *
return ($copy->getOwner() == $user); * @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) /**
{ * Get $user's borrowable copies of this Book
return $this->copies->filter(function($copy) use ($user) { *
return (($copy->getOwner() == $user) && $copy->isBorrowable()); * @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) /**
{ * Get $user's buyable copies of this Book
return $this->copies->filter(function($copy) use ($user) { *
return (($copy->getOwner() == $user) && $copy->isBuyable()); * @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 * The author of the Book
* *
* @ORM\Column(type="string", length=100, nullable=false) * @var string $author
*/ *
protected $author; * @ORM\Column(type="string", length=100, nullable=false)
*/
protected $author;
/** /**
* Set author * Set author
* *
* @param string $author * @param string $author
* @return Book * @return Book
*/ */
public function setAuthor($author) public function setAuthor($author)
{ {
$this->author = $author; // TODO: Check if null!
return $this; $this->author = $author;
} return $this;
}
/** /**
* Get author * Get author
* *
* @return string * @return string
*/ */
public function getAuthor() public function getAuthor()
{ {
return $this->author; return $this->author;
} }
/** /**
* @var string $title * The title of the Book
* *
* @ORM\Column(type="string", length=100, nullable=false) * @var string $title
*/ *
protected $title; * @ORM\Column(type="string", length=100, nullable=false)
*/
protected $title;
/** /**
* Set title * Set title
* *
* @param string $title * @param string $title
* @return Book * @return Book
*/ */
public function setTitle($title) public function setTitle($title)
{ {
$this->title = $title; // TODO: Check if null!
return $this; $this->title = $title;
} return $this;
}
/** /**
* Get title * Get title
* *
* @return string * @return string
*/ */
public function getTitle() public function getTitle()
{ {
return $this->title; return $this->title;
} }
/** /**
* @var integer $year * The Book's year of publication
* *
* @ORM\Column(type="integer", nullable=false) * @var integer $year
*/ *
protected $year; * @ORM\Column(type="integer", nullable=false)
*/
protected $year;
/** /**
* Set year * Set year
* *
* @param integer $year * @param integer $year
* @return Book * @return Book
*/ */
public function setYear($year) public function setYear($year)
{ {
$this->year = $year; // TODO: Check if null!
return $this; $this->year = $year;
} return $this;
}
/** /**
* Get year * Get year
* *
* @return integer * @return integer
*/ */
public function getYear() public function getYear()
{ {
return $this->year; return $this->year;
} }
/** /**
* @var boolean $commentable * TRUE if comments can be written about the Book
* * @var boolean $commentable
* @ORM\Column(type="boolean", nullable=false) *
*/ * @ORM\Column(type="boolean", nullable=false)
protected $commentable; */
protected $commentable;
/** /**
* @var Doctrine\Common\Collections\ArrayCollection $wouldBorrow * Collection of Users who would like to borrow a copy
* *
* @ORM\ManyToMany(targetEntity="KekRozsak\SecurityBundle\Entity\User") * @var Doctrine\Common\Collections\ArrayCollection $wouldBorrow
* @ORM\JoinTable(name="book_would_borrow") *
*/ * @ORM\ManyToMany(targetEntity="KekRozsak\SecurityBundle\Entity\User")
protected $wouldBorrow; * @ORM\JoinTable(name="book_would_borrow")
*/
protected $wouldBorrow;
/** /**
* Add a user for want-to-borrowers * Add a user for want-to-borrowers
* *
* @param KekRozsak\SecurityBundle\Entity\User $user * @param KekRozsak\SecurityBundle\Entity\User $user
* @return Book * @return Book
*/ */
public function addWouldBorrow(User $user) public function addWouldBorrow(User $user)
{ {
$this->wouldBorrow->add($user); // TODO: Check if null!
return $this; $this->wouldBorrow->add($user);
} return $this;
}
/** /**
* Get wouldBorrow list * Get wouldBorrow list
* *
* @return Doctrine\Common\Collections\ArrayCollection * @return Doctrine\Common\Collections\ArrayCollection
*/ */
public function getWouldBorrow() public function getWouldBorrow()
{ {
return $this->wouldBorrow; return $this->wouldBorrow;
} }
/** /**
* Check if specified user would borrow this book * Check if $user would like to borrow this book
* *
* @param KekRozsak\SecurityBundle\Entity\User $user * @param KekRozsak\SecurityBundle\Entity\User $user
* @return boolean * @return boolean
*/ */
public function userWouldBorrow(User $user) public function userWouldBorrow(User $user)
{ {
return $this->wouldBorrow->contains($user); return $this->wouldBorrow->contains($user);
} }
/** /**
* @var Doctrine\Common\Collections\ArrayCollection $wouldBuy * Collection of Users who would like to buy a copy of this book
* *
* @ORM\ManyToMany(targetEntity="KekRozsak\SecurityBundle\Entity\User") * @var Doctrine\Common\Collections\ArrayCollection $wouldBuy
* @ORM\JoinTable(name="book_would_buy") *
*/ * @ORM\ManyToMany(targetEntity="KekRozsak\SecurityBundle\Entity\User")
protected $wouldBuy; * @ORM\JoinTable(name="book_would_buy")
*/
protected $wouldBuy;
/** /**
* Add a user for want-to-buyers * Add a user for want-to-buyers
* *
* @param KekRozsak\SecurityBundle\Entity\User $user * @param KekRozsak\SecurityBundle\Entity\User $user
* @return Book * @return Book
*/ */
public function addWouldBuy(User $user) public function addWouldBuy(User $user)
{ {
$this->wouldBuy->add($user); $this->wouldBuy->add($user);
return $this; return $this;
} }
/** /**
* Get wouldBuy list * Get wouldBuy list
* *
* @return Doctrine\Common\Collections\ArrayCollection * @return Doctrine\Common\Collections\ArrayCollection
*/ */
public function getWouldBuy() public function getWouldBuy()
{ {
return $this->wouldBuy; return $this->wouldBuy;
} }
/** /**
* Check if specified user would buy this book * Check if specified user would buy this book
* *
* @param KekRozsak\SecurityBundle\Entity\User $user * @param KekRozsak\SecurityBundle\Entity\User $user
* @return boolean * @return boolean
*/ */
public function userWouldBuy(User $user) public function userWouldBuy(User $user)
{ {
return $this->wouldBuy->contains($user); return $this->wouldBuy->contains($user);
} }
} }

View File

@ -19,147 +19,163 @@ use KekRozsak\SecurityBundle\Entity\User;
*/ */
class BookCopy class BookCopy
{ {
public function __construct(Book $book, User $owner) public function __construct(Book $book, User $owner)
{ {
$this->book = $book; $this->book = $book;
$this->owner = $owner; $this->owner = $owner;
$this->borrowable = false; $this->borrowable = false;
$this->buyable = false; $this->buyable = false;
$this->borrower = null; $this->borrower = null;
$this->borrowerReturned = true; $this->borrowerReturned = true;
} }
/** /**
* @var integer $id * The ID of the BookCopy
* *
* @ORM\Id * @var integer $id
* @ORM\GeneratedValue(strategy="AUTO") *
* @ORM\Column(type="integer") * @ORM\Id
*/ * @ORM\GeneratedValue(strategy="AUTO")
protected $id; * @ORM\Column(type="integer")
*/
protected $id;
/** /**
* @var KekRozsak\FrontBundle\Entity\Book $book * The Book this BookCopy belongs to
* * @var KekRozsak\FrontBundle\Entity\Book $book
* @ORM\ManyToOne(targetEntity="Book", inversedBy="copies") *
* @ORM\JoinColumn(nullable=false) * @ORM\ManyToOne(targetEntity="Book", inversedBy="copies")
*/ * @ORM\JoinColumn(nullable=false)
protected $book; */
protected $book;
/** /**
* @var KekRozsak\SecurityBundle\Entity\User $owner * The User this BookCopy belongs to
* *
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") * @var KekRozsak\SecurityBundle\Entity\User $owner
* @ORM\JoinColumn(nullable=false) *
*/ * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
protected $owner; * @ORM\JoinColumn(nullable=false)
*/
protected $owner;
/** /**
* Get owner * Get owner
* *
* @return KekRozsak\SecurityBundle\Entity\User * @return KekRozsak\SecurityBundle\Entity\User
*/ */
public function getOwner() public function getOwner()
{ {
return $this->owner; return $this->owner;
} }
/** /**
* @var string $ownerComment * The owner's comment about this BookCopy's Book
* *
* @ORM\Column(type="text", name="owner_comment", nullable=true) * @var string $ownerComment
*/ *
protected $ownerComment; * @ORM\Column(type="text", name="owner_comment", nullable=true)
*/
protected $ownerComment;
/** /**
* @var boolean $borrowable * TRUE if this BookCopy is borrowable
* *
* @ORM\Column(type="boolean", nullable=false) * @var boolean $borrowable
*/ *
protected $borrowable; * @ORM\Column(type="boolean", nullable=false)
*/
protected $borrowable;
/** /**
* Set borrowable * Set borrowable
* *
* @param boolean $borrowable * @param boolean $borrowable
* @return BookCopy * @return BookCopy
*/ */
public function setBorrowable($borrowable) public function setBorrowable($borrowable)
{ {
$this->borrowable = $borrowable; // TODO: Check if parameter is boolean!
return $this; $this->borrowable = $borrowable;
} return $this;
}
/** /**
* Get borrowable * Get borrowable
* *
* @return boolean * @return boolean
*/ */
public function isBorrowable() public function isBorrowable()
{ {
return $this->borrowable; return $this->borrowable;
} }
/** /**
* @var boolean $buyable * TRUE if this BookCopy is for sale
* *
* @ORM\Column(type="boolean", nullable=false) * @var boolean $buyable
*/ *
protected $buyable; * @ORM\Column(type="boolean", nullable=false)
*/
protected $buyable;
/** /**
* Set buyable * Set buyable
* *
* @param boolean $buyable * @param boolean $buyable
* @return BookCopy * @return BookCopy
*/ */
public function setBuyable($buyable) public function setBuyable($buyable)
{ {
$this->buyable = $buyable; // Check if parameter is boolean!
return $this; $this->buyable = $buyable;
} return $this;
}
/** /**
* Get borrowable * Get buyable
* *
* @return boolean * @return boolean
*/ */
public function isBuyable() public function isBuyable()
{ {
return $this->buyable; return $this->buyable;
} }
/** /**
* @var KekRozsak\SecurityBundle\Entity\User $borrower * The User who is currently borrowing this BookCopy, or null
* *
* @ORM\OneToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") * @var KekRozsak\SecurityBundle\Entity\User $borrower
*/ *
protected $borrower; * @ORM\OneToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
*/
protected $borrower;
/** /**
* Get borrower * Get borrower
* *
* @return KekRozsak\SecurityBundle\Entity\User * @return KekRozsak\SecurityBundle\Entity\User
*/ */
public function getBorrower() public function getBorrower()
{ {
return $this->borrower; return $this->borrower;
} }
/** /**
* @var boolean $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") *
*/ * @ORM\Column(type="boolean", nullable=false, name="borrower_returned")
protected $borrowerReturned; */
protected $borrowerReturned;
/** /**
* Get borrowerReturned * Get borrowerReturned
* *
* @return boolean * @return boolean
*/ */
public function isBorrowerReturned() public function isBorrowerReturned()
{ {
return $this->borrowerReturned(); return $this->borrowerReturned();
} }
} }

View File

@ -19,282 +19,305 @@ use KekRozsak\FrontBundle\Entity\Group;
*/ */
class Document class Document
{ {
public function __construct() public function __construct()
{ {
$this->groups = new ArrayCollection(); $this->groups = new ArrayCollection();
} }
/** /**
* @var integer $id * The ID of the Document
* @ORM\Id *
* @ORM\GeneratedValue(strategy="AUTO") * @var integer $id
* @ORM\Column(type="integer") *
*/ * @ORM\Id
protected $id; * @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
protected $id;
/** /**
* Get id * Get id
* *
* @return integer * @return integer
*/ */
public function getId() public function getId()
{ {
return $this->id; return $this->id;
} }
/** /**
* @var string $title * The title of the Document
* @ORM\Column(type="string", length=150, unique=true, nullable=false) *
* @Assert\NotBlank() * @var string $title
*/ *
protected $title; * @ORM\Column(type="string", length=150, unique=true, nullable=false)
* @Assert\NotBlank()
*/
protected $title;
/** /**
* Set title * Set title
* *
* @param string $title * @param string $title
* @return Document * @return Document
*/ */
public function setTitle($title) public function setTitle($title)
{ {
$this->title = $title; $this->title = $title;
return $this; return $this;
} }
/** /**
* Get title * Get title
* *
* @return string * @return string
*/ */
public function getTitle() public function getTitle()
{ {
return $this->title; return $this->title;
} }
/** /**
* @var string $slug * The slugified title of this Document
* @ORM\Column(type="string", length=150, unique=true, nullable=false) *
* @Assert\NotBlank() * @var string $slug
*/ *
protected $slug; * @ORM\Column(type="string", length=150, unique=true, nullable=false)
* @Assert\NotBlank()
*/
protected $slug;
/** /**
* Set slug * Set slug
* *
* @param string $slug * @param string $slug
* @return Document * @return Document
*/ */
public function setSlug($slug) public function setSlug($slug)
{ {
$this->slug = $slug; $this->slug = $slug;
return $this; return $this;
} }
/** /**
* Get slug * Get slug
* *
* @return string * @return string
*/ */
public function getSlug() public function getSlug()
{ {
return $this->slug; return $this->slug;
} }
/** /**
* @var KekRozsak\SecurityBundle\Entity\User $createdBy * The User who created this Document
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") *
* @ORM\JoinColumn(name="created_by_id") * @var KekRozsak\SecurityBundle\Entity\User $createdBy
*/ *
protected $createdBy; * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
* @ORM\JoinColumn(name="created_by_id")
*/
protected $createdBy;
/** /**
* Set createdBy * Set createdBy
* *
* @param KekRozsak\SecurityBundle\Entity\User $createdBy * @param KekRozsak\SecurityBundle\Entity\User $createdBy
* @return Document * @return Document
*/ */
public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy) public function setCreatedBy(User $createdBy)
{ {
$this->createdBy = $createdBy; $this->createdBy = $createdBy;
return $this; return $this;
} }
/**
* Get createdBy
*
* @return KekRozsak\SecurityBundle\Entity\User
*/
public function getCreatedBy()
{
return $this->createdBy;
}
/** /**
* Get createdBy * The timestamp when the Document was created
* *
* @return KekRozsak\SecurityBundle\Entity\User * @var DateTime $createdat
*/ *
public function getCreatedBy() * @ORM\Column(type="datetime", nullable=false, name="created_at")
{ */
return $this->createdBy; protected $createdAt;
}
/** /**
* @var DateTime $createdat * Set createdAt
* @ORM\Column(type="datetime", nullable=false, name="created_at") *
*/ * @param DateTime $createdAt
protected $createdAt; * @return Document
*/
public function setCreatedAt(\DateTime $createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/** /**
* Set createdAt * Get createdAt
* *
* @param DateTime $createdAt * @return DateTime
* @return Document */
*/ public function getCreatedAt()
public function setCreatedAt(\DateTime $createdAt) {
{ return $this->createdAt;
$this->createdAt = $createdAt; }
return $this;
}
/** /**
* Get createdAt * The content of the Document
* *
* @return DateTime * @var string $content
*/ *
public function getCreatedAt() * @ORM\Column(type="text", nullable=false)
{ */
return $this->createdAt; protected $content;
}
/** /**
* @var string $content * Set content
* @ORM\Column(type="text", nullable=false) *
*/ * @param string $content
protected $content; * @return Document
*/
public function setContent($content)
{
$this->content = $content;
return $this;
}
/** /**
* Set content * Get content
* *
* @param string $content * @return string
* @return Document */
*/ public function getContent()
public function setContent($content) {
{ return $this->content;
$this->content = $content; }
return $this;
}
/** /**
* Get content * @var Doctrine\Common\Collections\ArrayCollection $groups
* * @ORM\ManyToMany(targetEntity="KekRozsak\FrontBundle\Entity\Group", mappedBy="documents")
* @return string */
*/ protected $groups;
public function getContent()
{
return $this->content;
}
/** /**
* @var Doctrine\Common\Collections\ArrayCollection $groups * Add a group
* @ORM\ManyToMany(targetEntity="KekRozsak\FrontBundle\Entity\Group", mappedBy="documents") *
*/ * @param KekRozsak\FrontBundle\Entity\Group $group
protected $groups; * @return Document
*/
public function addGroup(Group $group)
{
$this->groups[] = $group;
return $this;
}
/** /**
* Add a group * Get all groups
* *
* @param KekRozsak\FrontBundle\Entity\Group $group * @return Doctrine\Common\Collections\ArrayCollection
* @return Document */
*/ public function getGroups()
public function addGroup(\KekRozsak\FrontBundle\Entity\Group $group) {
{ return $this->group;
$this->groups[] = $group; }
return $this;
}
/** /**
* Get all groups * The User who last updated the Document
* *
* @return Doctrine\Common\Collections\ArrayCollection * @var KekRozsak\SecurityBundle\Entity\User $updatedBy
*/ *
public function getGroups() * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
{ */
return $this->group; protected $updatedBy;
}
/** /**
* @var KekRozsak\SecurityBundle\Entity\User $updatedBy * Set updatedBy
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") *
*/ * @param KekRozsak\SecurityBundle\Entity\User $updatedBy
protected $updatedBy; * @return Document
*/
public function setUpdatedBy(User $updatedBy = null)
{
$this->updatedBy = $updatedBy;
return $this;
}
/** /**
* Set updatedBy * Get updatedBy
* *
* @param KekRozsak\SecurityBundle\Entity\User $updatedBy * @return KekRozsak\SecurityBundle\Entity\User
* @return Document */
*/ public function getUpdatedBy()
public function setUpdatedBy(\KekRozsak\SecurityBundle\Entity\User $updatedBy = null) {
{ return $this->updatedBy;
$this->updatedBy = $updatedBy; }
return $this;
}
/** /**
* Get updatedBy * The timestamp the Document was last updated
* *
* @return KekRozsak\SecurityBundle\Entity\User * @var DateTime $updatedAt
*/ *
public function getUpdatedBy() * @ORM\Column(type="datetime", nullable=true)
{ */
return $this->updatedBy; protected $updatedAt;
}
/** /**
* @var DateTime $updatedAt * Set updatedAt
* @ORM\Column(type="datetime", nullable=true) *
*/ * @param DateTime $updatedAt
protected $updatedAt; * @return Document
*/
/** public function setUpdatedAt(\DateTime $updatedAt = null)
* Set updatedAt {
* $this->updatedAt = $updatedAt;
* @param DateTime $updatedAt return $this;
* @return Document }
*/
public function setUpdatedAt(\DateTime $updatedAt = null)
{
$this->updatedAt = $updatedAt;
return $this;
}
/** /**
* Get updatedAt * Get updatedAt
* *
* @return DateTime * @return DateTime
*/ */
public function getUpdatedAt() public function getUpdatedAt()
{ {
return $this->updatedAt; return $this->updatedAt;
} }
/** /**
* @var string updateReason * @var string updateReason
* @ORM\Column(type="text", nullable=true) * @ORM\Column(type="text", nullable=true)
*/ */
protected $updateReason; protected $updateReason;
/** /**
* Set updateReason * Set updateReason
* *
* @param string $updateReason * @param string $updateReason
* @return Document * @return Document
*/ */
public function setUpdateReason($updateReason = null) public function setUpdateReason($updateReason = null)
{ {
$this->updateReason = $updateReason; $this->updateReason = $updateReason;
return $this; return $this;
} }
/** /**
* Get updateReason * Get updateReason
* *
* @return string * @return string
*/ */
public function getUpdateReason() public function getUpdateReason()
{ {
return $this->updateReason; return $this->updateReason;
} }
} }

View File

@ -7,6 +7,9 @@ use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert; use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert;
use KekRozsak\SecurityBundle\Entity\User;
use KekRozsak\FrontBundle\Entity\Group;
/** /**
* @ORM\Entity * @ORM\Entity
* @ORM\Table(name="events") * @ORM\Table(name="events")
@ -16,403 +19,432 @@ use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert;
*/ */
class Event class Event
{ {
/** /**
* @var integer $id * The ID of the Event
* *
* @ORM\Id * @var integer $id
* @ORM\GeneratedValue(strategy="AUTO") *
* @ORM\Column(type="integer") * @ORM\Id
*/ * @ORM\GeneratedValue(strategy="AUTO")
protected $id; * @ORM\Column(type="integer")
*/
protected $id;
/** /**
* Get id * Get id
* *
* @return integer * @return integer
*/ */
public function getId() public function getId()
{ {
return $this->id; return $this->id;
} }
/** /**
* @var KekRozsak\SecurityBundle\Entity\User $createdBy * The User who created the Event
* *
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") * @var KekRozsak\SecurityBundle\Entity\User $createdBy
* @ORM\JoinColumn(name="created_by_id") *
*/ * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
protected $createdBy; * @ORM\JoinColumn(name="created_by_id")
*/
protected $createdBy;
/** /**
* Set createdBy * Set createdBy
* *
* @param KekRozsak\SecurityBundle\Entity\User $createdBy * @param KekRozsak\SecurityBundle\Entity\User $createdBy
* @return Event * @return Event
*/ */
public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy) public function setCreatedBy(User $createdBy)
{ {
$this->createdBy = $createdBy; $this->createdBy = $createdBy;
return $this; return $this;
} }
/** /**
* Get createdBy * Get createdBy
* *
* @return KekRozsak\SecurityBundle\Entity\User * @return KekRozsak\SecurityBundle\Entity\User
*/ */
public function getCreatedBy() public function getCreatedBy()
{ {
return $this->createdBy; return $this->createdBy;
} }
/** /**
* @var DateTime $startDate * The date on which the Event starts
* *
* @ORM\Column(type="date", nullable=true, name="start_date", nullable=false) * @var DateTime $startDate
*/ *
protected $startDate; * @ORM\Column(type="date", nullable=true, name="start_date", nullable=false)
*/
protected $startDate;
/** /**
* Set startDate * Set startDate
* *
* @param DateTime $startDate * @param DateTime $startDate
* @return Event * @return Event
*/ */
public function setStartDate(\DateTime $startDate = null) public function setStartDate(\DateTime $startDate = null)
{ {
$this->startDate = $startDate; $this->startDate = $startDate;
return $this; return $this;
} }
/** /**
* Get startDate * Get startDate
* *
* @return DateTime * @return DateTime
*/ */
public function getStartDate() public function getStartDate()
{ {
return $this->startDate; return $this->startDate;
} }
/** /**
* @var DateTime $endDate * The date on which the Event ends. May be null if same as $startDate
* *
* @ORM\Column(type="date", nullable=true, name="end_date") * @var DateTime $endDate
*/ *
protected $endDate; * @ORM\Column(type="date", nullable=true, name="end_date")
*/
protected $endDate;
/** /**
* Set endDate * Set endDate
* *
* @param DateTime $endDate * @param DateTime $endDate
* @return Event * @return Event
*/ */
public function setEndDate(\DateTime $endDate) public function setEndDate(\DateTime $endDate = null)
{ {
$this->endDate = $endDate; // TODO: Check if endDate is later than startDate
return $this; $this->endDate = $endDate;
} return $this;
}
/** /**
* Get endDate * Get endDate
* *
* @return DateTime * @return DateTime
*/ */
public function getEndDate() public function getEndDate()
{ {
return $this->endDate; return $this->endDate;
} }
/** /**
* @var Doctrine\Common\Collections\ArrayCollection $attendees * An ArrayCollection of Users who wish to attend on this Event
* *
* @ORM\ManyToMany(targetEntity="KekRozsak\SecurityBundle\Entity\User") * @var Doctrine\Common\Collections\ArrayCollection $attendees
* @ORM\JoinTable(name="event_attendees") *
*/ * @ORM\ManyToMany(targetEntity="KekRozsak\SecurityBundle\Entity\User")
protected $attendees; * @ORM\JoinTable(name="event_attendees")
*/
protected $attendees;
/** /**
* Add attendee * Add attendee
* *
* @param KekRozsak\SecurityBundle\Entity\User $attendee * @param KekRozsak\SecurityBundle\Entity\User $attendee
* @return Event * @return Event
*/ */
public function addAttendee(\KekRozsak\SecurityBundle\Entity\User $attendee) public function addAttendee(User $attendee)
{ {
$this->attendees[] = $attendee; $this->attendees[] = $attendee;
return $this; return $this;
} }
/** /**
* Get all attendees * Get all attendees
* *
* @return Doctrine\Common\Collections\ArrayCollection * @return Doctrine\Common\Collections\ArrayCollection
*/ */
public function getAttendees() public function getAttendees()
{ {
return $this->attendees; return $this->attendees;
} }
/** /**
* Check if a user is attending * Check if a user is attending
* *
* @param KekRozsak\SecurityBundle\Entity\User $user * @param KekRozsak\SecurityBundle\Entity\User $user
* @return boolean * @return boolean
*/ */
public function isAttending(\KekRozsak\SecurityBundle\Entity\User $user) public function isAttending(User $user)
{ {
$users = $this->attendees->filter(function ($attendee) use ($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)
{ {
if ($date === null) if ($attendee == $user) {
{ return true;
$date = new \DateTime('now');
} }
});
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);
}
} }

View File

@ -5,6 +5,7 @@ namespace KekRozsak\FrontBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use KekRozsak\FrontBundle\Entity\ForumTopic; use KekRozsak\FrontBundle\Entity\ForumTopic;
use KekRozsak\SecurityBundle\Entity\User;
/** /**
* @ORM\Entity * @ORM\Entity
@ -13,146 +14,172 @@ use KekRozsak\FrontBundle\Entity\ForumTopic;
*/ */
class ForumPost class ForumPost
{ {
/** /**
* @var integer $id * The ID of the ForumPost
* @ORM\Id *
* @ORM\GeneratedValue(strategy="AUTO") * @var integer $id
* @ORM\Column(type="integer") *
*/ * @ORM\Id
protected $id; * @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
protected $id;
/** /**
* Get id * Get id
* *
* @return integer * @return integer
*/ */
public function getId() public function getId()
{ {
return $this->id; return $this->id;
} }
/** /**
* @ORM\ManyToOne(targetEntity="\KekRozsak\SecurityBundle\Entity\User") * The User who created this ForumPost
* @ORM\JoinColumn(name="created_by_id") *
*/ * @var KekRozsak\SecurityBundle\Entity\User $createBy
protected $createdBy; *
* @ORM\ManyToOne(targetEntity="\KekRozsak\SecurityBundle\Entity\User")
/** * @ORM\JoinColumn(name="created_by_id")
* Set createdBy */
* protected $createdBy;
* @param \KekRozsak\SecurityBundle\Entity\User $createdBy
* @return ForumPost /**
*/ * Set createdBy
public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy) *
{ * @param \KekRozsak\SecurityBundle\Entity\User $createdBy
$this->createdBy = $createdBy; * @return ForumPost
return $this; */
} public function setCreatedBy(User $createdBy)
{
/** // TODO: Check if null!
* Get createdBy $this->createdBy = $createdBy;
* return $this;
* @return \KekRozsak\SecurityBundle\Entity\User }
*/
public function getCreatedBy() /**
{ * Get createdBy
return $this->createdBy; *
} * @return \KekRozsak\SecurityBundle\Entity\User
*/
/** public function getCreatedBy()
* @var DateTime $createdAt {
* @ORM\Column(type="datetime", name="created_at") return $this->createdBy;
*/ }
protected $createdAt;
/**
/** * The timestamp when the ForumPost was created
* Set createdAt *
* * @var DateTime $createdAt
* @param DateTime $createdAt *
* @return ForumPost * @ORM\Column(type="datetime", name="created_at")
*/ */
public function setCreatedAt(\DateTime $createdAt) protected $createdAt;
{
$this->createdAt = $createdAt; /**
} * Set createdAt
*
/** * @param DateTime $createdAt
* Get createdAt * @return ForumPost
* */
* @return DateTime public function setCreatedAt(\DateTime $createdAt)
*/ {
public function getCreatedAt() // TODO: Check if null!
{ $this->createdAt = $createdAt;
return $this->createdAt; }
}
/**
/** * Get createdAt
* @var string $text *
* @ORM\Column(type="text", nullable=false) * @return DateTime
*/ */
protected $text; public function getCreatedAt()
{
/** return $this->createdAt;
* Set text }
*
* @param string $text /**
* @return ForumPost * The content of the ForumPost
*/ *
public function setText($text) * @var string $text
{ *
$this->text = $text; * @ORM\Column(type="text", nullable=false)
return $this; */
} protected $text;
/** /**
* Get text * Set text
* *
* @return string * @param string $text
*/ * @return ForumPost
public function getText() */
{ public function setText($text)
return $this->text; {
} // TODO: Check if empty or null!
$this->text = $text;
/** return $this;
* @var ForumTopic $topic }
* @ORM\ManyToOne(targetEntity="ForumTopic", inversedBy="posts")
*/ /**
protected $topic; * Get text
*
/** * @return string
* Set topic */
* public function getText()
* @param ForumTopic $topic {
* @return ForumPost return $this->text;
*/ }
public function setTopic(ForumTopic $topic)
{ /**
$this->topic = $topic; * The ForumTopic in which this ForumPost is
if (!$topic->getLastPost() || ($topic->getLastPost()->getCreatedAt() < $this->createdAt)) *
$topic->setLastPost($this); * @var ForumTopic $topic
return $this; *
} * @ORM\ManyToOne(targetEntity="ForumTopic", inversedBy="posts")
*/
/** protected $topic;
* Get topic
* /**
* @return ForumTopic * Set topic
*/ *
public function getTopic() * @param ForumTopic $topic
{ * @return ForumPost
return $this->topic; */
} public function setTopic(ForumTopic $topic)
{
/** // Set this as the last post of $topic, if later than $topic's current
* Set createdAt before persisting // last post
* $this->topic = $topic;
* @ORM\PrePersist if (
*/ !$topic->getLastPost()
public function setCreationTime() || ($topic->getLastPost()->getCreatedAt() < $this->createdAt)
{ ) {
if ($this->createdAt === null) $topic->setLastPost($this);
$this->createdAt = new \DateTime('now'); }
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');
} }
}
} }

View File

@ -13,226 +13,254 @@ use KekRozsak\SecurityBundle\Entity\User;
*/ */
class ForumTopic class ForumTopic
{ {
public function __construct() public function __construct()
{ {
$this->posts = new ArrayCollection(); $this->posts = new ArrayCollection();
} }
/** /**
* @var integer $id * The ID of the ForumTopic
* @ORM\Id *
* @ORM\GeneratedValue(strategy="AUTO") * @var integer $id
* @ORM\Column(type="integer") *
*/ * @ORM\Id
protected $id; * @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
protected $id;
/** /**
* Get id * Get id
* *
* @return integer * @return integer
*/ */
public function getId() public function getId()
{ {
return $this->id; return $this->id;
} }
/** /**
* @var KekRozsak\SecurityBundle\Entity\User $createdBy * The User who created this ForumTopic
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") *
* @ORM\JoinColumn(name="created_by_id") * @var KekRozsak\SecurityBundle\Entity\User $createdBy
*/ *
protected $createdBy; * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
* @ORM\JoinColumn(name="created_by_id")
*/
protected $createdBy;
/** /**
* Set createdBy * Set createdBy
* *
* @param KekRozsak\SecurityBundle\Entity\User * @param KekRozsak\SecurityBundle\Entity\User
* @return ForumTopic * @return ForumTopic
*/ */
public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy) public function setCreatedBy(User $createdBy)
{ {
$this->createdBy = $createdBy; // TODO: Check if null!
return $this; $this->createdBy = $createdBy;
} return $this;
}
/** /**
* Get createdBy * Get createdBy
* *
* @return KekRozsak\SecurityBundle\Entity\User * @return KekRozsak\SecurityBundle\Entity\User
*/ */
public function getCreatedBy() public function getCreatedBy()
{ {
return $this->createdBy; 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 * Set createdAt
* @ORM\Column(type="datetime", nullable=false, name="created_at") *
*/ * @param DateTime $createdAt
protected $createdAt; * @return ForumTopic
*/
public function setCreatedAt(\DateTime $createdAt)
{
// TODO: Check if not null!
$this->createdAt = $createdAt;
return $this;
}
/** /**
* Set createdAt * Get createdAt
* *
* @param DateTime $createdAt * @return DateTime
* @return ForumTopic */
*/ public function getCreatedAt()
public function setCreatedAt(\DateTime $createdAt) {
{ return $this->createdAt;
$this->createdAt = $createdAt; }
return $this;
}
/** /**
* Get createdAt * The ForumTopicGroup to which this ForumTopic belongs
* *
* @return DateTime * @var ForumTopicGroup $topicGroup
*/ *
public function getCreatedAt() * @ORM\ManyToOne(targetEntity="ForumTopicGroup", inversedBy="topics")
{ * @ORM\JoinColumn(name="topic_group_id")
return $this->createdAt; */
} protected $topicGroup;
/** /**
* @var ForumTopicGroup $topicGroup * Set topicGroup
* @ORM\ManyToOne(targetEntity="ForumTopicGroup", inversedBy="topics") *
* @ORM\JoinColumn(name="topic_group_id") * @param ForumTopicGroup $topicGroup
*/ * @return ForumTopic
protected $topicGroup; */
public function setTopicGroup(ForumTopicGroup $topicGroup)
{
// TODO: Check if not null!
$this->topicGroup = $topicGroup;
return $this;
}
/** /**
* Set topicGroup * Get topicGroup
* *
* @param ForumTopicGroup $topicGroup * @return ForumTopicGroup
* @return ForumTopic */
*/ public function getTopicGroup()
public function setTopicGroup(ForumTopicGroup $topicGroup) {
{ return $this->topicGroup;
$this->topicGroup = $topicGroup; }
return $this;
}
/** /**
* Get topicGroup * The slugified title of the ForumTopic
* *
* @return ForumTopicGroup * @var string $slug
*/ *
public function getTopicGroup() * @ORM\Column(type="string", length=100, nullable=false)
{ */
return $this->topicGroup; protected $slug;
}
/** /**
* @var string $slug * Set slug
* @ORM\Column(type="string", length=100, nullable=false) *
*/ * @param string $slug
protected $slug; * @return ForumTopic
*/
public function setSlug($slug)
{
// TODO: Check if empty or null!
$this->slug = $slug;
return $this;
}
/** /**
* Set slug * Get slug
* *
* @param string $slug * @return string
* @return ForumTopic */
*/ public function getSlug()
public function setSlug($slug) {
{ return $this->slug;
$this->slug = $slug; }
return $this;
}
/** /**
* Get slug * The title of the ForumTopic
* *
* @return string * @var string $title
*/ *
public function getSlug() * @ORM\Column(type="string", length=100, nullable=false)
{ */
return $this->slug; protected $title;
}
/** /**
* @var string $title * Set title
* @ORM\Column(type="string", length=100, nullable=false) *
*/ * @param string $title
protected $title; * @return ForumTopic
*/
public function setTitle($title)
{
// TODO: Check if empty or null!
$this->title = $title;
return $this;
}
/** /**
* Set title * Get title
* *
* @param string $title * @return string
* @return ForumTopic */
*/ public function getTitle()
public function setTitle($title) {
{ return $this->title;
$this->title = $title; }
return $this;
}
/** /**
* Get title * The last Post of this ForumTopic, is any
* *
* @return string * @var ForumPost $lastPost
*/ *
public function getTitle() * @ORM\OneToOne(targetEntity="ForumPost", cascade={"persist"})
{ * @ORM\JoinColumn(name="last_post_id")
return $this->title; */
} protected $lastPost;
/** /**
* @var ForumPost $lastPost * Set lastPost
* @ORM\OneToOne(targetEntity="ForumPost", cascade={"persist"}) *
* @ORM\JoinColumn(name="last_post_id") * @param ForumPost $lastPost
*/ * @return ForumTopic
protected $lastPost; */
public function setLastPost($lastPost = null)
{
$this->lastPost = $lastPost;
}
/** /**
* Set lastPost * Get lastPost
* *
* @param ForumPost $lastPost * @return ForumPost
* @return ForumTopic */
*/ public function getLastPost()
public function setLastPost($lastPost = null) {
{ return $this->lastPost;
$this->lastPost = $lastPost; }
}
/** /**
* Get lastPost * The list of all the ForumPosts in this topic
* *
* @return ForumPost * @var ArrayCollection $topics;
*/ *
public function getLastPost() * @ORM\OneToMany(targetEntity="ForumPost", mappedBy="topic", fetch="LAZY")
{ */
return $this->lastPost; protected $posts;
}
/** /**
* @var ArrayCollection $topics; * Add post
* @ORM\OneToMany(targetEntity="ForumPost", mappedBy="topic") *
*/ * @param ForumPost $post
protected $posts; * @return ForumTopic
*/
public function addPost(ForumPost $post)
{
// TODO: Check if null!
$this->posts[] = $post;
return $this;
}
/** /**
* Add post * Get posts
* *
* @param ForumPost $post * @return ArrayCollection
* @return ForumTopic */
*/ public function getPosts()
public function addPost(ForumPost $post) {
{ return $this->posts;
$this->posts[] = $post; }
return $this;
}
/**
* Get posts
*
* @return ArrayCollection
*/
public function getPosts()
{
return $this->posts;
}
} }

View File

@ -14,168 +14,189 @@ use KekRozsak\SecurityBundle\Entity\User;
*/ */
class ForumTopicGroup class ForumTopicGroup
{ {
public function __construct() public function __construct()
{ {
$this->topics = new ArrayCollection(); $this->topics = new ArrayCollection();
} }
/** /**
* @var integer $id * The ID of the ForumTopicGroup
* @ORM\Id *
* @ORM\GeneratedValue(strategy="AUTO") * @var integer $id
* @ORM\Column(type="integer") *
*/ * @ORM\Id
protected $id; * @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
protected $id;
/** /**
* Get id * Get id
* *
* @return integer * @return integer
*/ */
public function getId() public function getId()
{ {
return $this->id; return $this->id;
} }
/** /**
* @var KekRozsak\SecurityBundle\Entity\User $createdBy * The User who created this ForumTopicGroup
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") *
* @ORM\JoinColumn(name="created_by_id") * @var KekRozsak\SecurityBundle\Entity\User $createdBy
*/ *
protected $createdBy; * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
* @ORM\JoinColumn(name="created_by_id")
*/
protected $createdBy;
/** /**
* Set createdBy * Set createdBy
* *
* @param KekRozsak\SecurityBundle\Entity\User $createdBy * @param KekRozsak\SecurityBundle\Entity\User $createdBy
* @return ForumTopicGroup * @return ForumTopicGroup
*/ */
public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy) public function setCreatedBy(User $createdBy)
{ {
$this->createdBy = $createdBy; // TODO: Check if null!
return $this; $this->createdBy = $createdBy;
} return $this;
}
/** /**
* Get createdBy * Get createdBy
* *
* @return KekRozsak\SecurityBundle\Entity\User * @return KekRozsak\SecurityBundle\Entity\User
*/ */
public function getCreatedBy() public function getCreatedBy()
{ {
return $this->createdBy; return $this->createdBy;
} }
/** /**
* @var DateTime $createdAt * The timestamp when this ForumTopicGroup was created
* @ORM\Column(type="datetime", nullable=false) *
*/ * @var DateTime $createdAt
protected $createdAt; *
* @ORM\Column(type="datetime", nullable=false)
*/
protected $createdAt;
/** /**
* Set createdAt * Set createdAt
* *
* @param DateTime $createdAt * @param DateTime $createdAt
* @return ForumTopicGroup * @return ForumTopicGroup
*/ */
public function setCreatedAt(\DateTime $createdAt) public function setCreatedAt(\DateTime $createdAt)
{ {
$this->createdAt = $createdAt; // TODO: Check if null!
return $this; $this->createdAt = $createdAt;
} return $this;
}
/** /**
* Get createdAt * Get createdAt
* *
* @return DateTime * @return DateTime
*/ */
public function getCreatedAt() public function getCreatedAt()
{ {
return $this->createdAt; return $this->createdAt;
} }
/** /**
* @var string $slug * The slugified title of this ForumTopicGroup
* @ORM\Column(type="string", length=100, nullable=false, unique=true) *
*/ * @var string $slug
protected $slug; *
* @ORM\Column(type="string", length=100, nullable=false, unique=true)
*/
protected $slug;
/** /**
* Set slug * Set slug
* *
* @param string $slug * @param string $slug
* @return ForumTopicGroup * @return ForumTopicGroup
*/ */
public function setSlug($slug) public function setSlug($slug)
{ {
$this->slug = $slug; // TODO: Check if empty or null!
return $this; $this->slug = $slug;
} return $this;
}
/** /**
* Get slug * Get slug
* *
* @return string * @return string
*/ */
public function getSlug() public function getSlug()
{ {
return $this->slug; return $this->slug;
} }
/** /**
* @var string $title * The title of this ForumTopicGroup
* @ORM\Column(type="string", length=100, nullable=false, unique=true) *
*/ * @var string $title
protected $title; *
* @ORM\Column(type="string", length=100, nullable=false, unique=true)
*/
protected $title;
/** /**
* Set title * Set title
* *
* @param string $title * @param string $title
* @return ForumTopicGroup * @return ForumTopicGroup
*/ */
public function setTitle($title) public function setTitle($title)
{ {
$this->title = $title; $this->title = $title;
return $this; return $this;
} }
/** /**
* Get title * Get title
* *
* @return string * @return string
*/ */
public function getTitle() public function getTitle()
{ {
return $this->title; return $this->title;
} }
/** /**
* @var ArrayCollection $topics * The ArrayCollection of ForumTopics that belong to this ForumTopicGroup
* @ORM\OneToMany(targetEntity="ForumTopic", mappedBy="topicGroup") *
*/ * @var ArrayCollection $topics
protected $topics; *
* @ORM\OneToMany(targetEntity="ForumTopic", mappedBy="topicGroup")
*/
protected $topics;
/** /**
* Add topic * Add topic
* *
* @param ForumTopic $topic * @param ForumTopic $topic
* @return ForumTopicGroup * @return ForumTopicGroup
*/ */
public function addTopic(ForumTopic $topic) public function addTopic(ForumTopic $topic)
{ {
$this->topics[] = $topic; // TODO: Check if null!
return $this; $this->topics[] = $topic;
} return $this;
}
/** /**
* Get topics * Get topics
* *
* @return ArrayCollection * @return ArrayCollection
*/ */
public function getTopics() public function getTopics()
{ {
return $this->topics; return $this->topics;
} }
} }

View File

@ -19,325 +19,357 @@ use KekRozsak\FrontBundle\Entity\Document;
*/ */
class Group class Group
{ {
public function __construct() public function __construct()
{ {
$this->members = new ArrayCollection(); $this->members = new ArrayCollection();
$this->documents = new ArrayCollection(); $this->documents = new ArrayCollection();
} }
/** /**
* @var integer $id * The ID of this Group
* @ORM\Id *
* @ORM\GeneratedValue(strategy="AUTO") * @var integer $id
* @ORM\Column(type="integer") *
*/ * @ORM\Id
protected $id; * @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
protected $id;
/** /**
* Get id * Get id
* *
* @return integer * @return integer
*/ */
public function getId() public function getId()
{ {
return $this->id; return $this->id;
} }
/** /**
* @var KekRozsak\SecurityBundle\Entity\User $leader * @var KekRozsak\SecurityBundle\Entity\User $leader
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
*/ */
protected $leader; protected $leader;
/** /**
* Set leader * Set leader
* *
* @param KekRozsak\SecurityBundle\Entity\User $leader * @param KekRozsak\SecurityBundle\Entity\User $leader
* @return Group * @return Group
*/ */
public function setLeader(\KekRozsak\SecurityBundle\Entity\User $leader = null) public function setLeader(User $leader = null)
{ {
$this->leader = $leader; $this->leader = $leader;
return $this; return $this;
} }
/** /**
* Get leader * Get leader
* *
* @return KekRozsak\SecurityBundle\Entity\User * @return KekRozsak\SecurityBundle\Entity\User
*/ */
public function getLeader() public function getLeader()
{ {
return $this->leader; return $this->leader;
} }
/** /**
* @var string $name * The name of this Group
* @ORM\Column(type="string", length=50, nullable=false, unique=true) *
* @Assert\NotBlank() * @var string $name
*/ *
protected $name; * @ORM\Column(type="string", length=50, nullable=false, unique=true)
*
* @Assert\NotBlank()
*/
protected $name;
/** /**
* Set name * Set name
* *
* @param string $name * @param string $name
* @return Group * @return Group
*/ */
public function setName($name) public function setName($name)
{ {
$this->name = $name; // TODO: Check if empty or null!
return $this; $this->name = $name;
} return $this;
}
/** /**
* Get name * Get name
* *
* @return string * @return string
*/ */
public function getName() public function getName()
{ {
return $this->name; return $this->name;
} }
/** /**
* @var string $slug * The slugified name of this Group
* @ORM\Column(type="string", length=50, nullable=false, unique=true) *
*/ * @var string $slug
protected $slug; *
* @ORM\Column(type="string", length=50, nullable=false, unique=true)
*/
protected $slug;
/** /**
* Set slug * Set slug
* *
* @param string $slug * @param string $slug
* @return Group * @return Group
*/ */
public function setSlug($slug) public function setSlug($slug)
{ {
$this->slug = $slug; // TODO: Check if empty or null!
return $this; $this->slug = $slug;
} return $this;
}
/** /**
* Get slug * Get slug
* *
* @return string * @return string
*/ */
public function getSlug() public function getSlug()
{ {
return $this->slug; return $this->slug;
} }
/** /**
* @var KekRozsak\SecurityBundle\Entity\User $createdBy * The User who created this Group
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") *
* @ORM\JoinColumn(name="created_by_id") * @var KekRozsak\SecurityBundle\Entity\User $createdBy
*/ *
protected $createdBy; * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
* @ORM\JoinColumn(name="created_by_id")
*/
protected $createdBy;
/** /**
* Set createdBy * Set createdBy
* *
* @param KekRozsak\SecurityBundle\Entity\User $createdBy * @param KekRozsak\SecurityBundle\Entity\User $createdBy
* @return Group * @return Group
*/ */
public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy) public function setCreatedBy(User $createdBy)
{ {
$this->createdBy = $createdBy; $this->createdBy = $createdBy;
return $this; return $this;
} }
/** /**
* Get createdBy * Get createdBy
* *
* @return KekRozsak\SecurityBundle\Entity\User * @return KekRozsak\SecurityBundle\Entity\User
*/ */
public function getCreatedBy() public function getCreatedBy()
{ {
return $this->createdBy; return $this->createdBy;
} }
/** /**
* @var DateTime $createdAt * The timestamp when this Group was created
* @ORM\Column(type="datetime", name="created_at", nullable=false) *
*/ * @var DateTime $createdAt
protected $createdAt; *
* @ORM\Column(type="datetime", name="created_at", nullable=false)
*/
protected $createdAt;
/** /**
* Set createdAt * Set createdAt
* *
* @param DateTime $createdAt * @param DateTime $createdAt
* @return Group * @return Group
*/ */
public function setCreatedAt(\DateTime $createdAt) public function setCreatedAt(\DateTime $createdAt)
{ {
$this->createdAt = $createdAt; // TODO: Check if null!
return $this; $this->createdAt = $createdAt;
} return $this;
}
/** /**
* Get createdAt * Get createdAt
* *
* @return DateTime * @return DateTime
*/ */
public function getCreatedAt() public function getCreatedAt()
{ {
return $this->createdAt; return $this->createdAt;
} }
/** /**
* @var Doctrine\Common\Collections\ArrayCollection $members * An ArrayCollection of UserGroupMemberships representing the Group's
* @ORM\OneToMany(targetEntity="UserGroupMembership", mappedBy="group") * members
*/ *
protected $members; * @var Doctrine\Common\Collections\ArrayCollection $members
*
* @ORM\OneToMany(targetEntity="UserGroupMembership", mappedBy="group")
*/
protected $members;
/** /**
* Add member * Add member
* *
* @param KekRozsak\FrontBundle\Entity\UserGroupMembership $member * @param KekRozsak\FrontBundle\Entity\UserGroupMembership $member
* @return Group * @return Group
*/ */
public function addMember(\KekRozsak\FrontBundle\Entity\UserGroupMembership $member) public function addMember(UserGroupMembership $member)
{ {
$this->members[] = $member; // TODO: Check if null!
return $this; $this->members[] = $member;
} return $this;
}
/** /**
* Get all members * Get all members
* *
* @return Doctrine\Common\Collections\ArrayCollection * @return Doctrine\Common\Collections\ArrayCollection
*/ */
public function getMembers() public function getMembers()
{ {
return $this->members; return $this->members;
} }
/** /**
* Check if user is a member of this Group * Check if user is a member of this Group
* *
* @param KekRozsak\SecurityBundle\Entity\User $user * @param KekRozsak\SecurityBundle\Entity\User $user
* @return boolean * @return boolean
*/ */
public function isMember(\KekRozsak\SecurityBundle\Entity\User $user) public function isMember(User $user)
{ {
return ($this->members->filter( return ($this->members->filter(function ($groupMembership) use ($user)
function ($groupMembership) use ($user) { {
return ( return (
($groupMembership->getUser() == $user) ($groupMembership->getUser() == $user)
&& ( && (
$groupMembership->getGroup()->isOpen() $groupMembership->getGroup()->isOpen()
|| ($groupMembership->getMembershipAcceptedAt() !== null) || ($groupMembership->getMembershipAcceptedAt() !== null)
) )
); );
} })->count() > 0);
)->count() > 0); }
}
/** /**
* Check if user already requested a membership in this Group * Check if user already requested a membership in this Group
* *
* @param KekRozsak\SecurityBundle\Entity\User $user * @param KekRozsak\SecurityBundle\Entity\User $user
* @return boolean * @return boolean
*/ */
public function isRequested(\KekRozsak\SecurityBundle\Entity\User $user) public function isRequested(User $user)
{ {
return ($this->members->filter( return ($this->members->filter(function ($groupMembership) use ($user)
function ($groupMembership) use ($user) { {
return ( return (
($groupMembership->getUser() == $user) ($groupMembership->getUser() == $user)
&& ($groupMembership->getMembershipRequestedAt() !== null) && ($groupMembership->getMembershipRequestedAt() !== null)
); );
} })->count() > 0);
)->count() > 0); }
}
/** /**
* @var string description * The description of the Group
* @ORM\Column(type="text", nullable=true) *
*/ * @var string description
protected $description; *
* @ORM\Column(type="text", nullable=true)
*/
protected $description;
/** /**
* Set description * Set description
* *
* @param string $description * @param string $description
* @return Group * @return Group
*/ */
public function setDescription($description = null) public function setDescription($description = null)
{ {
$this->description = $description; $this->description = $description;
return $this; return $this;
} }
/** /**
* Get description * Get description
* *
* @return string * @return string
*/ */
public function getDescription() public function getDescription()
{ {
return $this->description; return $this->description;
} }
/** /**
* @var boolean open * TRUE if this Group is open, and anyone can join
* @ORM\Column(type="boolean", nullable=false) *
*/ * @var boolean open
protected $open; *
* @ORM\Column(type="boolean", nullable=false)
*/
protected $open;
/** /**
* Set open * Set open
* *
* @param boolean $open * @param boolean $open
* @ return Group * @ return Group
*/ */
public function setOpen($open = false) public function setOpen($open = false)
{ {
$this->open = $open; $this->open = $open;
return $this; return $this;
} }
/** /**
* Get open * Get open
* *
* @return boolean * @return boolean
*/ */
public function isOpen() public function isOpen()
{ {
return $this->open; return $this->open;
} }
/** /**
* @var Doctrine\Common\Collections\ArrayCollection $documents * An ArrayCollection of Documents that belong to this Group
* @ORM\ManyToMany(targetEntity="Document", inversedBy="groups") *
* @ORM\JoinTable(name="group_document", inverseJoinColumns={ * @var Doctrine\Common\Collections\ArrayCollection $documents
* @ORM\JoinColumn(name="document_id", referencedColumnName="id"), *
* }, joinColumns={ * @ORM\ManyToMany(targetEntity="Document", inversedBy="groups", fetch="LAZY")
* @ORM\JoinColumn(name="group_id", referencedColumnName="id") * @ORM\JoinTable(name="group_document", inverseJoinColumns={
* }) * @ORM\JoinColumn(name="document_id", referencedColumnName="id"),
*/ * }, joinColumns={
protected $documents; * @ORM\JoinColumn(name="group_id", referencedColumnName="id")
* })
*/
protected $documents;
/** /**
* Add document * Add document
* *
* @param KekRozsak\FrontBundle\Entity\Document $document * @param KekRozsak\FrontBundle\Entity\Document $document
* @return Group * @return Group
*/ */
public function addDocument(\KekRozsak\FrontBundle\Entity\Document $document) public function addDocument(Document $document)
{ {
$this->documents[] = $document; // TODO: Check if null!
return $this; $this->documents[] = $document;
} return $this;
}
/** /**
* Get all documents * Get all documents
* *
* @return Doctrine\Common\Collections\ArrayCollection * @return Doctrine\Common\Collections\ArrayCollection
*/ */
public function getDocuments() public function getDocuments()
{ {
return $this->documents; return $this->documents;
} }
} }

View File

@ -4,169 +4,192 @@ namespace KekRozsak\FrontBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use KekRozsak\SecurityBundle\Entity\User;
/** /**
* @ORM\Entity * @ORM\Entity
* @ORM\Table(name="news") * @ORM\Table(name="news")
*/ */
class News class News
{ {
/** /**
* @var integer $id * The ID of this News
* @ORM\Id *
* @ORM\GeneratedValue(strategy="AUTO") * @var integer $id
* @ORM\Column(type="integer") *
*/ * @ORM\Id
protected $id; * @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
protected $id;
/** /**
* Get id * Get id
* *
* @return integer * @return integer
*/ */
public function getId() public function getId()
{ {
return $this->id; return $this->id;
} }
/** /**
* @var string $title * The title of this News
* @ORM\Column(type="string", length=100) *
*/ * @var string $title
protected $title; *
* @ORM\Column(type="string", length=100)
*/
protected $title;
/** /**
* Set title * Set title
* *
* @param string $title * @param string $title
* @return News * @return News
*/ */
public function setTitle($title) public function setTitle($title)
{ {
$this->title = $title; // TODO: Check if empty or null!
return $this; $this->title = $title;
} return $this;
}
/** /**
* Get title * Get title
* *
* @return string * @return string
*/ */
public function getTitle() public function getTitle()
{ {
return $this->title; return $this->title;
} }
/** /**
* @var string $text * The contents of this News
* @ORM\Column(type="text", nullable=false) *
*/ * @var string $text
protected $text; *
* @ORM\Column(type="text", nullable=false)
*/
protected $text;
/** /**
* Set text * Set text
* *
* @param string $text * @param string $text
* @return News * @return News
*/ */
public function setText($text) public function setText($text)
{ {
$this->text = $text; $this->text = $text;
return $this; return $this;
} }
/** /**
* Get text * Get text
* *
* @return string * @return string
*/ */
public function getText() public function getText()
{ {
return $this->text; return $this->text;
} }
/** /**
* @var DateTime $createdAt * The timestamp when this News was created
* @ORM\Column(type="datetime", name="created_at", nullable=false) *
*/ * @var DateTime $createdAt
protected $createdAt; *
* @ORM\Column(type="datetime", name="created_at", nullable=false)
*/
protected $createdAt;
/** /**
* Set createdAt * Set createdAt
* *
* @param DateTime $createdAt * @param DateTime $createdAt
* @return News * @return News
*/ */
public function setCreatedAt(\DateTime $createdAt) public function setCreatedAt(\DateTime $createdAt)
{ {
$this->createdAt = $createdAt; // TODO: Check if null!
return $this; $this->createdAt = $createdAt;
} return $this;
}
/** /**
* Get createdAt * Get createdAt
* *
* @return DateTime * @return DateTime
*/ */
public function getCreatedAt() public function getCreatedAt()
{ {
return $this->createdAt; return $this->createdAt;
} }
/** /**
* @var \KekRozsak\SecurityBundle\Entity\User $createdBy * The User who created this News item
* @ORM\ManyToOne(targetEntity="\KekRozsak\SecurityBundle\Entity\User") *
* @ORM\JoinColumn(name="created_by_id") * @var \KekRozsak\SecurityBundle\Entity\User $createdBy
*/ *
protected $createdBy; * @ORM\ManyToOne(targetEntity="\KekRozsak\SecurityBundle\Entity\User")
* @ORM\JoinColumn(name="created_by_id")
*/
protected $createdBy;
/** /**
* Set createdBy * Set createdBy
* *
* @param \KekRozsak\SecurityBundle\Entity\User $createdBy * @param \KekRozsak\SecurityBundle\Entity\User $createdBy
* @return News * @return News
*/ */
public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy) public function setCreatedBy(User $createdBy)
{ {
$this->createdBy = $createdBy; // TODO: Check if null!
return $this; $this->createdBy = $createdBy;
} return $this;
}
/** /**
* Get createdBy * Get createdBy
* *
* @return \KekRozsak\SecurityBundle\Entity\User * @return \KekRozsak\SecurityBundle\Entity\User
*/ */
public function getCreatedBy() public function getCreatedBy()
{ {
return $this->createdBy; return $this->createdBy;
} }
/** /**
* @var boolean $public * TRUE if this News item is public
* *
* @ORM\Column(type="boolean", nullable=false) * @var boolean $public
*/ *
protected $public; * @ORM\Column(type="boolean", nullable=false)
*/
protected $public;
/** /**
* Set public * Set public
* *
* @param boolean $public * @param boolean $public
* @return News * @return News
*/ */
public function setPublic($public) public function setPublic($public)
{ {
$this->public = $public; // TODO: Check if parameter is boolean!
return $this; $this->public = $public;
} return $this;
}
/** /**
* Get public * Get public
* *
* @return boolean * @return boolean
*/ */
public function getPublic() public function isPublic()
{ {
return $this->public; return $this->public;
} }
} }

View File

@ -13,380 +13,430 @@ use \KekRozsak\SecurityBundle\Entity\User;
*/ */
class UserData class UserData
{ {
public function __construct() public function __construct()
{ {
$this->emailPublic = false; $this->emailPublic = false;
$this->realNamePublic = false; $this->realNamePublic = false;
$this->msnAddressPublic = false; $this->msnAddressPublic = false;
$this->googleTalkPublic = false; $this->googleTalkPublic = false;
$this->skypePublic = false; $this->skypePublic = false;
$this->phoneNumberPublic = false; $this->phoneNumberPublic = false;
} }
/** /**
* @var KekRozsak\SecurityBundle\Entity\User $user * The User object this UserData belongs to
* @ORM\Id *
* @ORM\GeneratedValue(strategy="NONE") * @var KekRozsak\SecurityBundle\Entity\User $user
* @ORM\OneToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User", inversedBy="userData") *
* @ORM\JoinColumn(name="user_id") * @ORM\Id
*/ * @ORM\GeneratedValue(strategy="NONE")
protected $user; * @ORM\OneToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User", inversedBy="userData")
* @ORM\JoinColumn(name="user_id")
*/
protected $user;
/** /**
* Set user * Set user
* *
* @param KekRozsak\SecurityBundle\Entity\User $user * @param KekRozsak\SecurityBundle\Entity\User $user
* @return UserData * @return UserData
*/ */
public function setUser(\KekRozsak\SecurityBundle\Entity\User $user) public function setUser(\KekRozsak\SecurityBundle\Entity\User $user)
{ {
$this->user = $user; $this->user = $user;
return $this; return $this;
} }
/** /**
* Get user * Get user
* *
* @return KekRozsak\SecurityBundle\Entity\User * @return KekRozsak\SecurityBundle\Entity\User
*/ */
public function getUser() public function getUser()
{ {
return $this->user; return $this->user;
} }
/** /**
* @var boolean $emailPublic * TRUE if $user's e-mail address is public
* @ORM\Column(type="boolean", name="email_public") *
*/ * @var boolean $emailPublic
protected $emailPublic; *
* @ORM\Column(type="boolean", name="email_public")
*/
protected $emailPublic;
/** /**
* Set emailPublic * Set emailPublic
* *
* @param boolean $emailPublic * @param boolean $emailPublic
* @return UserData * @return UserData
*/ */
public function setEmailPublic($emailPublic) public function setEmailPublic($emailPublic)
{ {
$this->emailPublic = $emailPublic; // TODO: Check if parameter is boolean!
return $this; $this->emailPublic = $emailPublic;
} return $this;
}
/** /**
* Get emailPublic * Get emailPublic
* *
* @return boolean * @return boolean
*/ */
public function getEmailPublic() public function isEmailPublic()
{ {
return $this->emailPublic; return $this->emailPublic;
} }
/** /**
* @var string $realName * The real name of $user
* @ORM\Column(type="string", length=100, nullable=true, name="real_name") *
*/ * @var string $realName
protected $realName; *
* @ORM\Column(type="string", length=100, nullable=true, name="real_name")
*/
protected $realName;
/** /**
* Set realName * Set realName
* *
* @param string $realName * @param string $realName
* @return UserData * @return UserData
*/ */
public function setRealName($realName = null) public function setRealName($realName = null)
{ {
$this->realName = $realName; // TODO: Check if empty!
return $this; $this->realName = $realName;
} return $this;
}
/** /**
* Get realName * Get realName
* *
* @return string * @return string
*/ */
public function getRealName() public function getRealName()
{ {
return $this->realName; return $this->realName;
} }
/** /**
* @var boolean $realNamePublic * TRUE is $user's real name is public
* @ORM\Column(type="boolean", name="real_name_public") *
*/ * @var boolean $realNamePublic
protected $realNamePublic; *
* @ORM\Column(type="boolean", name="real_name_public")
*/
protected $realNamePublic;
/** /**
* Set realNamePublic * Set realNamePublic
* *
* @param boolean $realNamePublic * @param boolean $realNamePublic
* @return UserData * @return UserData
*/ */
public function setRealNamePublic($realNamePublic = false) public function setRealNamePublic($realNamePublic = false)
{ {
$this->realNamePublic = $realNamePublic; // TODO: Check if parameter is boolean!
return $this; $this->realNamePublic = $realNamePublic;
} return $this;
}
/** /**
* Get realNamePublic * Get realNamePublic
* *
* @return boolean * @return boolean
*/ */
public function getRealNamePublic() public function isRealNamePublic()
{ {
return $this->realNamePublic; return $this->realNamePublic;
} }
/** /**
* @var string $selfDescription * The self description of $user
* @ORM\Column(type="text", nullable=true, name="self_description") *
*/ * @var string $selfDescription
protected $selfDescription; *
* @ORM\Column(type="text", nullable=true, name="self_description")
*/
protected $selfDescription;
/** /**
* Set selfDescription * Set selfDescription
* *
* @param string $selfDescription * @param string $selfDescription
* @return UserData * @return UserData
*/ */
public function setSelfDescription($selfDescription = null) public function setSelfDescription($selfDescription = null)
{ {
$this->selfDescription = $selfDescription; $this->selfDescription = $selfDescription;
return $this; return $this;
} }
/** /**
* Get selfDescription * Get selfDescription
* *
* @return string * @return string
*/ */
public function getSelfDescription() public function getSelfDescription()
{ {
return $this->selfDescription; return $this->selfDescription;
} }
/** /**
* @var string $msnAddress * The MSN address of $user
* @ORM\Column(type="string", length=100, nullable=true, name="msn_address") *
*/ * @var string $msnAddress
protected $msnAddress; *
* @ORM\Column(type="string", length=100, nullable=true, name="msn_address")
*/
protected $msnAddress;
/** /**
* Set msnAddress * Set msnAddress
* *
* @param string $msnAddress * @param string $msnAddress
* @return UserData * @return UserData
*/ */
public function setMsnAddress($msnAddress = null) public function setMsnAddress($msnAddress = null)
{ {
$this->msnAddress = $msnAddress; // TODO: Check if empty!
return $this; $this->msnAddress = $msnAddress;
} return $this;
}
/** /**
* Get msnAddress * Get msnAddress
* *
* @return string * @return string
*/ */
public function getMsnAddress() public function getMsnAddress()
{ {
return $this->msnAddress; return $this->msnAddress;
} }
/** /**
* @var boolean $msnAddressPublic * TRUE if $user's MSN address is public
* @ORM\Column(type="boolean", name="msn_address_public") *
*/ * @var boolean $msnAddressPublic
protected $msnAddressPublic; *
* @ORM\Column(type="boolean", name="msn_address_public")
*/
protected $msnAddressPublic;
/** /**
* Set msnAddressPublic * Set msnAddressPublic
* *
* @param boolean $msnAddressPublic * @param boolean $msnAddressPublic
* @return UserData * @return UserData
*/ */
public function setMsnAddressPublic($msnAddressPublic) public function setMsnAddressPublic($msnAddressPublic)
{ {
$this->msnAddressPublic = $msnAddressPublic; // TODO: Check if parameter is boolean!
return $this; $this->msnAddressPublic = $msnAddressPublic;
} return $this;
}
/** /**
* Get msnAddressPublic * Get msnAddressPublic
* *
* @return boolean * @return boolean
*/ */
public function getMsnAddressPublic() public function isMsnAddressPublic()
{ {
return $this->msnAddressPublic; return $this->msnAddressPublic;
} }
/** /**
* @var string $googleTalk * Google Talk address of $user
* @ORM\Column(type="string", length=100, nullable=true, name="google_talk") *
*/ * @var string $googleTalk
protected $googleTalk; *
* @ORM\Column(type="string", length=100, nullable=true, name="google_talk")
*/
protected $googleTalk;
/** /**
* Set googleTalk * Set googleTalk
* *
* @param string $googleTalk * @param string $googleTalk
* @return UserData * @return UserData
*/ */
public function setGoogleTalk($googleTalk = null) public function setGoogleTalk($googleTalk = null)
{ {
$this->googleTalk = $googleTalk; // TODO: Check if empty!
return $this; $this->googleTalk = $googleTalk;
} return $this;
}
/** /**
* Get googleTalk * Get googleTalk
* *
* @return string * @return string
*/ */
public function getGoogleTalk() public function getGoogleTalk()
{ {
return $this->googleTalk; return $this->googleTalk;
} }
/** /**
* @var boolean $googleTalkPublic * TRUE if $user's Google Talk address is public
* @ORM\Column(type="boolean", name="google_talk_public") *
*/ * @var boolean $googleTalkPublic
protected $googleTalkPublic; *
* @ORM\Column(type="boolean", name="google_talk_public")
*/
protected $googleTalkPublic;
/** /**
* Set googleTalkPublic * Set googleTalkPublic
* *
* @param boolean $googleTalkPublic * @param boolean $googleTalkPublic
* @return UserData * @return UserData
*/ */
public function setGoogleTalkPublic($googleTalkPublic) public function setGoogleTalkPublic($googleTalkPublic)
{ {
$this->googleTalkPublic = $googleTalkPublic; // TODO: Check if parameter is boolean!
return $this; $this->googleTalkPublic = $googleTalkPublic;
} return $this;
}
/** /**
* Get googleTalkPublic * Get googleTalkPublic
* *
* @return boolean * @return boolean
*/ */
public function getGoogleTalkPublic() public function isGoogleTalkPublic()
{ {
return $this->googleTalkPublic; return $this->googleTalkPublic;
} }
/** /**
* @var string $skype * Skype name of $user
* @ORM\Column(type="string", length=100, nullable=true, name="skype") *
*/ * @var string $skype
protected $skype; *
* @ORM\Column(type="string", length=100, nullable=true, name="skype")
*/
protected $skype;
/** /**
* Set skype * Set skype
* *
* @param string $skype * @param string $skype
* @return UserData * @return UserData
*/ */
public function setSkype($skype = null) public function setSkype($skype = null)
{ {
$this->skype = $skype; // TODO: Check if empty!
return $this; $this->skype = $skype;
} return $this;
}
/** /**
* Get skype * Get skype
* *
* @return string * @return string
*/ */
public function getSkype() public function getSkype()
{ {
return $this->skype; return $this->skype;
} }
/** /**
* @var boolean $skypePublic * TRUE if $user's Skype name is public
* @ORM\Column(type="boolean", name="skype_public") *
*/ * @var boolean $skypePublic
protected $skypePublic; *
* @ORM\Column(type="boolean", name="skype_public")
*/
protected $skypePublic;
/** /**
* Set skypePublic * Set skypePublic
* *
* @param boolean $skypePublic * @param boolean $skypePublic
* @return UserData * @return UserData
*/ */
public function setSkypePublic($skypePublic) public function setSkypePublic($skypePublic)
{ {
$this->skypePublic = $skypePublic; // TODO: Check if parameter is boolean!
return $this; $this->skypePublic = $skypePublic;
} return $this;
}
/** /**
* Get skypePublic * Get skypePublic
* *
* @return boolean * @return boolean
*/ */
public function getSkypePublic() public function isSkypePublic()
{ {
return $this->skypePublic; return $this->skypePublic;
} }
/** /**
* @var string $phoneNumber * Phone number of $user
* @ORM\Column(type="string", length=30, nullable=true, name="phone_number") *
*/ * @var string $phoneNumber
protected $phoneNumber; *
* @ORM\Column(type="string", length=30, nullable=true, name="phone_number")
*/
protected $phoneNumber;
/** /**
* Set phoneNumber * Set phoneNumber
* *
* @param string $phoneNumber * @param string $phoneNumber
* @return UserData * @return UserData
*/ */
public function setPhoneNumber($phoneNumber = null) public function setPhoneNumber($phoneNumber = null)
{ {
$this->phoneNumber = $phoneNumber; // TODO: Check if empty!
return $this; $this->phoneNumber = $phoneNumber;
} return $this;
}
/** /**
* Get phoneNumber * Get phoneNumber
* *
* @return string * @return string
*/ */
public function getPhoneNumber() public function getPhoneNumber()
{ {
return $this->phoneNumber; return $this->phoneNumber;
} }
/** /**
* @var boolean $phoneNumberPublic * TRUE if $user's phone number is public
* @ORM\Column(type="boolean", name="phone_number_public") *
*/ * @var boolean $phoneNumberPublic
protected $phoneNumberPublic; *
* @ORM\Column(type="boolean", name="phone_number_public")
*/
protected $phoneNumberPublic;
/** /**
* Set phoneNumberPublic * Set phoneNumberPublic
* *
* @param boolean $phoneNumberPublic * @param boolean $phoneNumberPublic
* @return UserData * @return UserData
*/ */
public function setPhoneNumberPublic($phoneNumberPublic) public function setPhoneNumberPublic($phoneNumberPublic)
{ {
$this->phoneNumberPublic = $phoneNumberPublic; // TODO: Check if parameter is boolean!
return $this; $this->phoneNumberPublic = $phoneNumberPublic;
} return $this;
}
/** /**
* Get phoneNumberPublic * Get phoneNumberPublic
* *
* @return boolean * @return boolean
*/ */
public function getPhoneNumberPublic() public function isPhoneNumberPublic()
{ {
return $this->phoneNumberPublic; return $this->phoneNumberPublic;
} }
} }

View File

@ -5,6 +5,7 @@ namespace KekRozsak\FrontBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use KekRozsak\SecurityBundle\Entity\User; use KekRozsak\SecurityBundle\Entity\User;
use KekRozsak\FrontBundle\Entity\Group;
/** /**
* KekRozsak\FrontBundle\Entity\UserGroupMembership * KekRozsak\FrontBundle\Entity\UserGroupMembership
@ -15,171 +16,191 @@ use KekRozsak\SecurityBundle\Entity\User;
*/ */
class UserGroupMembership class UserGroupMembership
{ {
public function __construct(\KekRozsak\SecurityBundle\Entity\User $user, \KekRozsak\FrontBundle\Entity\Group $group) public function __construct(\KekRozsak\SecurityBundle\Entity\User $user, \KekRozsak\FrontBundle\Entity\Group $group)
{ {
$this->setUser($user); $this->setUser($user);
$this->setGroup($group); $this->setGroup($group);
$this->setMembershipRequestedAt(new \DateTime('now')); $this->setMembershipRequestedAt(new \DateTime('now'));
} }
/** /**
* @var integer $id * The ID of the UserGroupMembership
* @ORM\Id *
* @ORM\GeneratedValue(strategy="AUTO") * @var integer $id
* @ORM\Column(type="integer") *
*/ * @ORM\Id
protected $id; * @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
protected $id;
/** /**
* Get id * Get id
* *
* @return integer * @return integer
*/ */
public function getId() public function getId()
{ {
return $this->id; return $this->id;
} }
/** /**
* @var KekRozsak\SecurityBundle\Entity\User $user * The User this membership is applied to
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User", inversedBy="groups") *
* @ORM\JoinColumn(name="user_id") * @var KekRozsak\SecurityBundle\Entity\User $user
*/ *
protected $user; * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User", inversedBy="groups")
* @ORM\JoinColumn(name="user_id")
*/
protected $user;
/** /**
* Set user * Set user
* *
* @param KekRozsak\SecurityBundle\Entity\User $user * @param KekRozsak\SecurityBundle\Entity\User $user
* @return UserGroupMembership * @return UserGroupMembership
*/ */
public function setUser(\KekRozsak\SecurityBundle\Entity\User $user) public function setUser(User $user)
{ {
$this->user = $user; // TODO: Check if not null!
return $this; $this->user = $user;
} return $this;
}
/** /**
* Get user * Get user
* *
* @return KekRozsak\SecurityBundle\Entity\User * @return KekRozsak\SecurityBundle\Entity\User
*/ */
public function getUser() public function getUser()
{ {
return $this->user; return $this->user;
} }
/** /**
* @var KekRozsak\FrontBundle\Entity\Group * The Group this membership is applied to
* @ORM\ManyToOne(targetEntity="Group", inversedBy="members") *
* @ORM\JoinColumn(name="group_id") * @var KekRozsak\FrontBundle\Entity\Group
*/ *
protected $group; * @ORM\ManyToOne(targetEntity="Group", inversedBy="members")
* @ORM\JoinColumn(name="group_id")
*/
protected $group;
/** /**
* Set group * Set group
* *
* @param KekRozsak\FrontBundle\Entity\Group * @param KekRozsak\FrontBundle\Entity\Group
* @return UserGroupMembership * @return UserGroupMembership
*/ */
public function setGroup(\KekRozsak\FrontBundle\Entity\Group $group) public function setGroup(Group $group)
{ {
$this->group = $group; $this->group = $group;
return $this; return $this;
} }
/** /**
* Get group * Get group
* *
* @return KekRozsak\FrontBundle\Entity\Group * @return KekRozsak\FrontBundle\Entity\Group
*/ */
public function getGroup() public function getGroup()
{ {
return $this->group; return $this->group;
} }
/** /**
* @var DateTime $membershipRequestedAt * The timestamp when $user requested membership in $group
* @ORM\Column(type="datetime", name="membership_requested_at") *
*/ * @var DateTime $membershipRequestedAt
protected $membershipRequestedAt; *
* @ORM\Column(type="datetime", name="membership_requested_at")
*/
protected $membershipRequestedAt;
/** /**
* Set membershipRequestedAt * Set membershipRequestedAt
* *
* @param DateTime $membershipRequestedAt * @param DateTime $membershipRequestedAt
* @return UserGroupMembership * @return UserGroupMembership
*/ */
public function setMembershipRequestedAt(\DateTime $membershipRequestedAt) public function setMembershipRequestedAt(\DateTime $membershipRequestedAt)
{ {
$this->membershipRequestedAt = $membershipRequestedAt; // TODO: Check if null!
return $this; $this->membershipRequestedAt = $membershipRequestedAt;
} return $this;
}
/** /**
* Get membershipRequestedAt * Get membershipRequestedAt
* *
* @return DateTime * @return DateTime
*/ */
public function getMembershipRequestedAt() public function getMembershipRequestedAt()
{ {
return $this->membershipRequestedAt; return $this->membershipRequestedAt;
} }
/** /**
* @var DateTime membershipAcceptedAt * The timestamp when $user's membership was accepted
* @ORM\Column(type="datetime", nullable=true, name="membership_accepted_at") *
*/ * @var DateTime membershipAcceptedAt
protected $membershipAcceptedAt; *
* @ORM\Column(type="datetime", nullable=true, name="membership_accepted_at")
*/
protected $membershipAcceptedAt;
/** /**
* Set membershipAcceptedAt * Set membershipAcceptedAt
* *
* @param DateTime $membershipAcceptedAt * @param DateTime $membershipAcceptedAt
* @return UserGroupMembership * @return UserGroupMembership
*/ */
public function setMembershipAcceptedAt(\DateTime $membershipAcceptedAt = null) public function setMembershipAcceptedAt(\DateTime $membershipAcceptedAt = null)
{ {
$this->membershipAcceptedAt = $membershipAcceptedAt; $this->membershipAcceptedAt = $membershipAcceptedAt;
return $this; return $this;
} }
/** /**
* Get membershipAcceptedAt * Get membershipAcceptedAt
* *
* @return DateTime * @return DateTime
*/ */
public function getMembershipAcceptedAt() public function getMembershipAcceptedAt()
{ {
return $this->membershipAcceptedAt; return $this->membershipAcceptedAt;
} }
/** /**
* @var KekRozsak\SecurityBundle\Entity\User $membershipAcceptedBy * The User who accepted $user's membership
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") *
* @ORM\JoinColumn(name="membership_accepted_by_id") * @var KekRozsak\SecurityBundle\Entity\User $membershipAcceptedBy
*/ *
protected $membershipAcceptedBy; * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
* @ORM\JoinColumn(name="membership_accepted_by_id")
/** */
* Set membershipAcceptedBy protected $membershipAcceptedBy;
*
* @param KekRozsak\SecurityBundle\Entity\User
* @return UserGroupMembership
*/
public function setMembershipAcceptedBy(\KekRozsak\SecurityBundle\Entity\User $membershipAcceptedBy = null)
{
$this->membershipAcceptedBy = $membershipAcceptedBy;
return $this;
}
/** /**
* Get membershipAcceptedBy * Set membershipAcceptedBy
* *
* @return KekRozsak\SecurityBundle\Entity\User * @param KekRozsak\SecurityBundle\Entity\User
*/ * @return UserGroupMembership
public function getMembershipAcceptedBy() */
{ public function setMembershipAcceptedBy(\KekRozsak\SecurityBundle\Entity\User $membershipAcceptedBy = null)
return $this->membershipAcceptedBy; {
} $this->membershipAcceptedBy = $membershipAcceptedBy;
return $this;
}
/**
* Get membershipAcceptedBy
*
* @return KekRozsak\SecurityBundle\Entity\User
*/
public function getMembershipAcceptedBy()
{
return $this->membershipAcceptedBy;
}
} }

View File

@ -4,30 +4,40 @@ namespace KekRozsak\FrontBundle\Extensions;
class Slugifier class Slugifier
{ {
/** /**
* Slugify string * Slugify string
* *
* @param string $text * @param string $text
* @return string * @return string
*/ */
public function slugify($text) public function slugify($text)
{ {
$text = trim(preg_replace('~[^\\pL\d]+~u', '-', $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')) if (empty($text)) {
{ $text = 'n-a';
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); }
}
$text = strtolower($text); return $text;
}
$text = preg_replace('~[^-\w]+~', '', $text);
if (empty($text))
{
$text = 'n-a';
}
return $text;
}
} }

View File

@ -8,26 +8,25 @@ use Symfony\Component\Form\FormBuilderInterface;
class HelpMessageTypeExtension extends AbstractTypeExtension class HelpMessageTypeExtension extends AbstractTypeExtension
{ {
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder->setAttribute('help', $options['help']); $builder->setAttribute('help', $options['help']);
} }
public function buildView(FormView $view, FormInterface $form, array $options) public function buildView(FormView $view, FormInterface $form, array $options)
{ {
$view->set('help', $form->getAttribute('help')); $view->set('help', $form->getAttribute('help'));
} }
public function getDefaultOptions() public function getDefaultOptions()
{ {
return array( return array(
'help' => null, 'help' => null,
); );
} }
public function getExtendedType() public function getExtendedType()
{ {
return 'field'; return 'field';
} }
} }

View File

@ -7,21 +7,23 @@ use Symfony\Component\Form\FormBuilderInterface;
class DocumentType extends AbstractType class DocumentType extends AbstractType
{ {
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder->add('title', null, array( $builder->add('title', null, array(
'label' => 'A dokumentum címe', 'label' => 'A dokumentum címe',
)); )
);
$builder->add('content', 'ckeditor', array( $builder->add('content', 'ckeditor', array(
'label' => ' ', 'label' => ' ',
)); )
);
/* TODO: possibility to add to other groups! */ // TODO: possibility to add to other groups!
} }
public function getName() public function getName()
{ {
return 'document'; return 'document';
} }
} }

View File

@ -7,36 +7,38 @@ use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class ForumPostType extends AbstractType class ForumPostType extends AbstractType
{ {
private $topicGroup; private $topicGroup;
private $topic; private $topic;
public function __construct($topicGroup = null, $topic = null) public function __construct($topicGroup = null, $topic = null)
{ {
$this->topicGroup = $topicGroup; $this->topicGroup = $topicGroup;
$this->topic = $topic; $this->topic = $topic;
} }
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder->add('text', null, array( $builder->add('text', null, array(
'label' => ' ', 'label' => ' ',
)); )
$builder->add('topic', 'hidden', array( );
'property_path' => false,
'data' => $this->topic,
));
}
public function getName() $builder->add('topic', 'hidden', array(
{ 'property_path' => false,
return 'forum_post'; 'data' => $this->topic,
} )
);
}
public function setDefaultOptions(OptionsResolverInterface $resolver) public function getName()
{ {
$resolver->setDefaults(array( return 'forum_post';
'data_class' => 'KekRozsak\FrontBundle\Entity\ForumPost', }
));
} public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'KekRozsak\FrontBundle\Entity\ForumPost',
));
}
} }

View File

@ -7,19 +7,21 @@ use Symfony\Component\Form\FormBuilderInterface;
class GroupType extends AbstractType class GroupType extends AbstractType
{ {
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder->add('name', null, array( $builder->add('name', null, array(
'label' => 'A csoport neve', 'label' => 'A csoport neve',
)); )
);
$builder->add('description', 'ckeditor', array( $builder->add('description', 'ckeditor', array(
'label' => 'A csoport leírása', 'label' => 'A csoport leírása',
)); )
} );
}
public function getName() public function getName()
{ {
return 'group'; return 'group';
} }
} }

View File

@ -7,74 +7,96 @@ use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class UserDataType extends AbstractType class UserDataType extends AbstractType
{ {
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder->add('emailPublic', null, array( $builder->add('emailPublic', null, array(
'label' => 'Publikus legyen az e-mail címed?', '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.', 'help' => 'Ha bejelölöd, a kör többi tagja láthatja az e-mail címedet.',
'required' => false, '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 getName() $builder->add('realName', null, array(
{ 'label' => 'Valódi neved',
return 'user_data'; '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) $builder->add('realNamePublic', null, array(
{ 'label' => 'Publikus legyen a valódi neved?',
$resolver->setDefaults(array( 'help' => 'Ha bejelölöd, a kör többi tagja láthatja a valódi neved.',
'data_class' => 'KekRozsak\FrontBundle\Entity\UserData' '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'
));
}
} }

View File

@ -1,18 +1,20 @@
<?xml version="1.0" ?> <?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <container xmlns="http://symfony.com/schema/dic/services"
<services> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<service id="kek_rozsak_front.twig_extension.events" class="KekRozsak\FrontBundle\Twig\EventsExtension"> xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<argument type="service" id="doctrine" /> <services>
<argument type="service" id="security.context" /> <service id="kek_rozsak_front.twig_extension.events" class="KekRozsak\FrontBundle\Twig\EventsExtension">
<tag name="twig.extension" /> <argument type="service" id="doctrine" />
</service> <argument type="service" id="security.context" />
<service id="form.type_extension.help_message" class="KekRozsak\FrontBundle\Form\Extension\HelpMessageTypeExtension"> <tag name="twig.extension" />
<tag name="form.type_extension" alias="field" /> </service>
</service> <service id="form.type_extension.help_message" class="KekRozsak\FrontBundle\Form\Extension\HelpMessageTypeExtension">
<service id="bb.twig.extension" class="KekRozsak\FrontBundle\Twig\TwigBBExtension"> <tag name="form.type_extension" alias="field" />
<argument type="service" id="service_container" /> </service>
<tag name="twig.extension" /> <service id="bb.twig.extension" class="KekRozsak\FrontBundle\Twig\TwigBBExtension">
</service> <argument type="service" id="service_container" />
</services> <tag name="twig.extension" />
</service>
</services>
</container> </container>

View File

@ -21,78 +21,78 @@
} }
.forum-lista thead td a { .forum-lista thead td a {
color: #3366ff; color: #3366ff;
text-decoration: none; text-decoration: none;
} }
.forum-lista tbody td { .forum-lista tbody td {
padding: 5px; padding: 5px;
border-bottom: 1px solid #3366ff; border-bottom: 1px solid #3366ff;
} }
.forum-lista tbody tr.odd td { .forum-lista tbody tr.odd td {
background-color: #060c16; background-color: #060c16;
} }
.forum-lista tbody tr.even td { .forum-lista tbody tr.even td {
background-color: #000000; background-color: #000000;
} }
.forum-lista tbody td a { .forum-lista tbody td a {
color: #3366ff; color: #3366ff;
text-decoration: underline; text-decoration: underline;
} }
.post-lista { .post-lista {
border: 1px solid #3366ff; border: 1px solid #3366ff;
border-collapse: collapse; border-collapse: collapse;
} }
.post-lista td { .post-lista td {
border-style: solid; border-style: solid;
border-color: #3366ff; border-color: #3366ff;
border-width: 3px 1px; border-width: 3px 1px;
vertical-align: top; vertical-align: top;
padding: 5px; padding: 5px;
} }
.post-lista td.felado { .post-lista td.felado {
width: 150px !important; width: 150px !important;
font-size: 80%; font-size: 80%;
} }
.post-lista td.szoveg { .post-lista td.szoveg {
width: 510px; width: 510px;
} }
.post-lista td.szoveg div { .post-lista td.szoveg div {
width: 510px; width: 510px;
overflow: auto; overflow: auto;
} }
td.uj-post { td.uj-post {
} }
td.uj-post textarea { td.uj-post textarea {
width: 500px; width: 500px;
background-color: #000000; background-color: #000000;
color: #3366ff; color: #3366ff;
border-style: solid; border-style: solid;
border-color: #3366ff; border-color: #3366ff;
border-width: 0 0 2px 0; border-width: 0 0 2px 0;
height: 15em; height: 15em;
} }
td.uj-post p { td.uj-post p {
clear: both; clear: both;
float: none; float: none;
margin: 0; margin: 0;
} }
td.uj-post p .eszkoztar { td.uj-post p .eszkoztar {
float: left; float: left;
} }
td.uj-post p .kuldes-gomb { td.uj-post p .kuldes-gomb {
float: right; float: right;
} }

View File

@ -1,11 +1,11 @@
ul#submenu { ul#submenu {
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
ul#submenu li { ul#submenu li {
margin: 0; margin: 0;
padding: 3px; padding: 3px;
display: inline; display: inline;
} }

View File

@ -7,94 +7,94 @@
*/ */
#popup-container { #popup-container {
display: none; display: none;
position: fixed; position: fixed;
height: 300px; height: 300px;
width: 200px; width: 200px;
background: #ffffff; background: #ffffff;
z-index: 80; z-index: 80;
} }
#popup-close { #popup-close {
position: absolute; position: absolute;
width: 16px; width: 16px;
height: 16px; height: 16px;
top: -5px; top: -5px;
right: -5px; right: -5px;
background-image: url('../images/no.png'); background-image: url('../images/no.png');
} }
#popup-inside { #popup-inside {
border: 1px solid black; border: 1px solid black;
height: 292px; height: 292px;
width: 192px; width: 192px;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
margin-top: 3px; margin-top: 3px;
} }
#popup-title { #popup-title {
font-weight: bold; font-weight: bold;
padding: 5px; padding: 5px;
} }
#popup-content { #popup-content {
padding: 3px; padding: 3px;
} }
#popup-scrollable { #popup-scrollable {
width: 192px; width: 192px;
clear: both; clear: both;
margin: 20px 0 10px; margin: 20px 0 10px;
} }
#popup-scrollable .viewport { #popup-scrollable .viewport {
width: 172px; width: 172px;
height: 246px; height: 246px;
overflow: hidden; overflow: hidden;
position: relative; position: relative;
} }
#popup-scrollable .overview { #popup-scrollable .overview {
list-style: none; list-style: none;
position: absolute; position: absolute;
left: 0; left: 0;
top: 0; top: 0;
} }
#popup-scrollable .thumb .end, #popup-scrollable .thumb { #popup-scrollable .thumb .end, #popup-scrollable .thumb {
background-color: #003D5D; background-color: #003D5D;
} }
#popup-scrollable .scrollbar { #popup-scrollable .scrollbar {
position: relative; position: relative;
float: right; float: right;
width: 15px; width: 15px;
} }
#popup-scrollable .track { #popup-scrollable .track {
background-color: #D8EEFD; background-color: #D8EEFD;
height: 100%; height: 100%;
width: 13px; width: 13px;
position: relative; position: relative;
padding: 0 1px; padding: 0 1px;
} }
#popup-scrollable .thumb { #popup-scrollable .thumb {
height: 20px; height: 20px;
width: 13px; width: 13px;
cursor: pointer; cursor: pointer;
overflow: hidden; overflow: hidden;
position: absolute; position: absolute;
top: 0; top: 0;
} }
#popup-scrollable .thumb .end { #popup-scrollable .thumb .end {
overflow: hidden; overflow: hidden;
height: 5px; height: 5px;
width: 13px; width: 13px;
} }
#popup-scrollable .disable { #popup-scrollable .disable {
display: none; display: none;
} }

View File

@ -1,63 +1,63 @@
{# vim: ft=htmljinja {# vim: ft=htmljinja
#} #}
<p> <p>
<strong>Szerző:</strong> {{ book.author }}<br /> <strong>Szerző:</strong> {{ book.author }}<br />
<strong>Cím:</strong> {{ book.title }}<br /> <strong>Cím:</strong> {{ book.title }}<br />
<strong>Kiadás éve:</strong> {{ book.year }}<br /> <strong>Kiadás éve:</strong> {{ book.year }}<br />
</p> </p>
<p> <p>
Nekem van <strong>{{ book.usersCopies(app.user)|length }}</strong>, ebből kölcsön van adva <strong>X</strong>.<br /> Nekem van <strong>{{ book.usersCopies(app.user)|length }}</strong>, ebből kölcsön van adva <strong>X</strong>.<br />
A teljes közösségnek összesen <strong>{{ book.copies|length }}</strong> példánya van.<br /> A teljes közösségnek összesen <strong>{{ book.copies|length }}</strong> példánya van.<br />
Kölcsönkérhető <strong>{{ book.copiesBorrowable|length }}</strong> példány, ebből <strong>{{ book.copiesBorrowedByUser(app.user)|length }}</strong> nálam van.<br /> Kölcsönkérhető <strong>{{ book.copiesBorrowable|length }}</strong> példány, ebből <strong>{{ book.copiesBorrowedByUser(app.user)|length }}</strong> nálam van.<br />
</p> </p>
<p> <p>
{% if book.usersCopies(app.user)|length == 0 %} {% if book.usersCopies(app.user)|length == 0 %}
<span class="gomb add-copy-button" id="add-copy-button-{{ book.id }}">[Nekem is van egy]</span> <span class="gomb add-copy-button" id="add-copy-button-{{ book.id }}">[Nekem is van egy]</span>
{% else %} {% else %}
<span class="gomb delete-copy-button" id="delete-copy-button-{{ book.id }}">[Nincs már]</span> <span class="gomb delete-copy-button" id="delete-copy-button-{{ book.id }}">[Nincs már]</span>
{# TODO {# TODO
<span class="gomb">[Eladtam valakinek a körben]</span> <span class="gomb">[Eladtam valakinek a körben]</span>
#} #}
{% if book.usersCopiesBorrowable(app.user)|length == 0 %} {% if book.usersCopiesBorrowable(app.user)|length == 0 %}
<span class="gomb mine-is-borrowable-button" id="mine-is-borrowable-button-{{ book.id }}">[Az enyém is kölcsönkérhető]</span> <span class="gomb mine-is-borrowable-button" id="mine-is-borrowable-button-{{ book.id }}">[Az enyém is kölcsönkérhető]</span>
{% else %} {% else %}
<span class="gomb mine-is-not-borrowable-button" id="mine-is-not-borrowable-button-{{ book.id }}">[Nem szeretném kölcsönadni]</span> <span class="gomb mine-is-not-borrowable-button" id="mine-is-not-borrowable-button-{{ book.id }}">[Nem szeretném kölcsönadni]</span>
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if book.usersCopies(app.user)|length > 0 %} {% if book.usersCopies(app.user)|length > 0 %}
{% if book.usersCopiesBuyable(app.user)|length == 0 %} {% if book.usersCopiesBuyable(app.user)|length == 0 %}
<span class="gomb mine-is-for-sale-button" id="mine-is-for-sale-button-{{ book.id }}">[Az enyém eladó]</span> <span class="gomb mine-is-for-sale-button" id="mine-is-for-sale-button-{{ book.id }}">[Az enyém eladó]</span>
{% else %} {% else %}
<span class="gomb mine-is-not-for-sale-button" id="mine-is-not-for-sale-button-{{ book.id }}">[Nem szeretném eladni]</span> <span class="gomb mine-is-not-for-sale-button" id="mine-is-not-for-sale-button-{{ book.id }}">[Nem szeretném eladni]</span>
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if book.copiesBorrowedByUser(app.user)|length == 0 and book.usersCopies(app.user)|length == 0 and not book.userWouldBorrow(app.user) %} {% if book.copiesBorrowedByUser(app.user)|length == 0 and book.usersCopies(app.user)|length == 0 and not book.userWouldBorrow(app.user) %}
<span class="gomb want-to-borrow-button" id="want-to-borrow-button-{{ book.id }}">[Kérek egyet kölcsön]</span> <span class="gomb want-to-borrow-button" id="want-to-borrow-button-{{ book.id }}">[Kérek egyet kölcsön]</span>
{% endif %} {% endif %}
{% if book.usersCopies(app.user)|length == 0 and not book.userWouldBuy(app.user) %} {% if book.usersCopies(app.user)|length == 0 and not book.userWouldBuy(app.user) %}
<span class="gomb want-to-buy-button" id="want-to-buy-button-{{ book.id }}">[Vennék egyet]</span> <span class="gomb want-to-buy-button" id="want-to-buy-button-{{ book.id }}">[Vennék egyet]</span>
{% endif %} {% endif %}
</p> </p>
{% if book.wouldBuy|length > 0 %} {% if book.wouldBuy|length > 0 %}
<p> <p>
Ők szeretnének egyet kölcsönkérni:<br /> Ők szeretnének egyet kölcsönkérni:<br />
<ul> <ul>
{% for user in book.wouldBorrow %} {% for user in book.wouldBorrow %}
<li>{{ user|userdataspan }}</li> <li>{{ user|userdataspan }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
</p> </p>
{% endif %} {% endif %}
{% if book.wouldBuy|length > 0 %} {% if book.wouldBuy|length > 0 %}
<p> <p>
Ők szeretnének venni egyet:<br /> Ők szeretnének venni egyet:<br />
<ul> <ul>
{% for user in book.wouldBuy %} {% for user in book.wouldBuy %}
<li>{{ user|userdataspan }}</li> <li>{{ user|userdataspan }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
</p> </p>
{% endif %} {% endif %}

View File

@ -7,127 +7,155 @@
[Saját könyveim] [Nálam lévő kölcsönzött könyvek] [Saját könyveim] [Nálam lévő kölcsönzött könyvek]
{% if books|length > 0 %} {% if books|length > 0 %}
<table> <table>
<thead> <thead>
<tr> <tr>
<td>Szerző</td> <td>Szerző</td>
<td>Cím</td> <td>Cím</td>
<td>Év</td> <td>Év</td>
<td>Összes</td> <td>Összes</td>
<td>Kölcsönözhető</td> <td>Kölcsönözhető</td>
<td>Saját</td> <td>Saját</td>
<td>Nálam (Vissza)</td> <td>Nálam (Vissza)</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for book in books %} {% for book in books %}
<tr class="book-row popup-opener" id="book-{{ book.id }}"> <tr class="book-row popup-opener" id="book-{{ book.id }}">
<td class="popup-opener">{{ book.author }}</td> <td class="popup-opener">{{ book.author }}</td>
<td>{{ book.title }}</td> <td>{{ book.title }}</td>
<td>{{ book.year }}</td> <td>{{ book.year }}</td>
<td>{{ book.copies|length }}</td> <td>{{ book.copies|length }}</td>
<td>{{ book.copiesBorrowable|length }}</td> <td>{{ book.copiesBorrowable|length }}</td>
<td>{{ book.usersCopies(app.user)|length }}</td> <td>{{ book.usersCopies(app.user)|length }}</td>
<td>{{ book.copiesBorrowedByUser(app.user)|length }} ({{ book.copiesBorrowedReturnedByUser(app.user)|length }})</td> <td>{{ book.copiesBorrowedByUser(app.user)|length }} ({{ book.copiesBorrowedReturnedByUser(app.user)|length }})</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block bottomscripts %} {% block bottomscripts %}
<script type="text/javascript"> <script type="text/javascript">
$('.book-row').click(function() { $('.book-row').click(function() {
bookid = 0; bookid = 0;
if (!$(this).attr('id').match(/^book-\d+$/)) if (!$(this).attr('id').match(/^book-\d+$/)) {
return false; return false;
bookid = $(this).attr('id').replace(/^book-/, ''); }
bookUrl = Routing.generate('KekRozsakFrontBundle_bookAjaxData', { id: bookid, _format: 'html' }); bookid = $(this).attr('id').replace(/^book-/, '');
bookCallback = function() { bookUrl = Routing.generate('KekRozsakFrontBundle_bookAjaxData', { id: bookid, _format: 'html' });
// TODO: Change alert() calls to HTML flashes bookCallback = function()
$('.delete-copy-button').click(function() { {
bookid = 0; // TODO: Change alert() calls to HTML flashes
if (!$(this).attr('id').match(/^delete-copy-button-\d+$/)) $('.delete-copy-button').click(function()
return false; {
bookid = $(this).attr('id').replace(/^delete-copy-button-/, ''); bookid = 0;
url = Routing.generate('KekRozsakFrontBundle_bookDeleteCopy', { id: bookid }); if (!$(this).attr('id').match(/^delete-copy-button-\d+$/)) {
$.ajax({ return false;
method: 'GET', }
url: url
}).done(function() {
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback);
}).error(function() {
alert('Nem sikerült törölni');
});
});
$('.add-copy-button').click(function() { bookid = $(this).attr('id').replace(/^delete-copy-button-/, '');
bookid = 0; url = Routing.generate('KekRozsakFrontBundle_bookDeleteCopy', { id: bookid });
if (!$(this).attr('id').match(/^add-copy-button-\d+$/)) $.ajax({
return false; method: 'GET',
bookid = $(this).attr('id').replace(/^add-copy-button-/, ''); url: url
url = Routing.generate('KekRozsakFrontBundle_bookAddCopy', { id: bookid }); }).done(function()
$.ajax({ {
method: 'GET', doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback);
url: url }).error(function()
}).done(function() { {
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback); // TODO: Make this a flash!
}).error(function() { alert('Nem sikerült törölni');
alert('Nem sikerült bejegyezni ezt a példányt'); });
}); });
});
$('.mine-is-borrowable-button, .mine-is-not-borrowable-button').click(function() { $('.add-copy-button').click(function()
bookid = 0; {
if (!$(this).attr('id').match(/^mine-is-(not-)?borrowable-button-\d+$/)) bookid = 0;
return false; if (!$(this).attr('id').match(/^add-copy-button-\d+$/)) {
isBorrowable = ($(this).attr('id').match(/^mine-is-not-borrowable-button-\d+$/)) ? 0 : 1; return false;
bookid = $(this).attr('id').replace(/^mine-is-(not-)?borrowable-button-/, ''); }
url = Routing.generate('KekRozsakFrontBundle_bookSetCopyBorrowable', { id: bookid, newValue: isBorrowable }); bookid = $(this).attr('id').replace(/^add-copy-button-/, '');
$.ajax({ url = Routing.generate('KekRozsakFrontBundle_bookAddCopy', { id: bookid });
method: 'GET', $.ajax({
url: url method: 'GET',
}).done(function() { url: url
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback); }).done(function()
}).error(function() { {
alert('Nem sikerült bejegyezni ezt a példányt'); doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback);
}); }).error(function()
}); {
// TODO: Make this a flash!
alert('Nem sikerült bejegyezni ezt a példányt');
});
});
$('.mine-is-for-sale-button, .mine-is-not-for-sale-button').click(function() { $('.mine-is-borrowable-button, .mine-is-not-borrowable-button').click(function()
bookid = 0; {
if (!$(this).attr('id').match(/^mine-is-(not-)?for-sale-button-\d+$/)) bookid = 0;
return false; if (!$(this).attr('id').match(/^mine-is-(not-)?borrowable-button-\d+$/)) {
isForSale = ($(this).attr('id').match(/^mine-is-not-for-sale-button-\d+$/)) ? 0 : 1; return false;
bookid = $(this).attr('id').replace(/^mine-is-(not-)?for-sale-button-/, ''); }
url = Routing.generate('KekRozsakFrontBundle_bookSetCopyForSale', { id: bookid, newValue: isForSale }); isBorrowable = ($(this).attr('id').match(/^mine-is-not-borrowable-button-\d+$/)) ? 0 : 1;
$.ajax({ bookid = $(this).attr('id').replace(/^mine-is-(not-)?borrowable-button-/, '');
method: 'GET', url = Routing.generate('KekRozsakFrontBundle_bookSetCopyBorrowable', { id: bookid, newValue: isBorrowable });
url: url $.ajax({
}).done(function() { method: 'GET',
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback); url: url
}).error(function() { }).done(function()
alert('Nem sikerült bejegyezni ezt a példányt'); {
}); doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback);
}); }).error(function()
{
// TODO: Make this a flash!
alert('Nem sikerült bejegyezni ezt a példányt');
});
});
$('.want-to-buy-button, .want-to-borrow-button').click(function() { $('.mine-is-for-sale-button, .mine-is-not-for-sale-button').click(function()
bookid = 0; {
if (!$(this).attr('id').match(/^want-to-(buy|borrow)-button-\d+$/)) bookid = 0;
return false; if (!$(this).attr('id').match(/^mine-is-(not-)?for-sale-button-\d+$/)) {
toBuy = ($(this).attr('id').match(/^want-to-buy-button-\d+$/)) ? 1 : 0; return false;
bookid = $(this).attr('id').replace(/^want-to-(buy|borrow)-button-/, ''); }
url = Routing.generate('KekRozsakFrontBundle_bookWantOne', { id: bookid, wantToBuy: toBuy }); isForSale = ($(this).attr('id').match(/^mine-is-not-for-sale-button-\d+$/)) ? 0 : 1;
$.ajax({ bookid = $(this).attr('id').replace(/^mine-is-(not-)?for-sale-button-/, '');
method: 'GET', url = Routing.generate('KekRozsakFrontBundle_bookSetCopyForSale', { id: bookid, newValue: isForSale });
url: url $.ajax({
}).done(function() { method: 'GET',
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback); url: url
}).error(function() { }).done(function()
alert('Nem sikerült bejegyezni a kérést'); {
}); doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback);
}); }).error(function()
}; {
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback); // TODO: Make this a flash!
alert('Nem sikerült bejegyezni ezt a példányt');
});
});
$('.want-to-buy-button, .want-to-borrow-button').click(function()
{
bookid = 0;
if (!$(this).attr('id').match(/^want-to-(buy|borrow)-button-\d+$/)) {
return false;
}
toBuy = ($(this).attr('id').match(/^want-to-buy-button-\d+$/)) ? 1 : 0;
bookid = $(this).attr('id').replace(/^want-to-(buy|borrow)-button-/, '');
url = Routing.generate('KekRozsakFrontBundle_bookWantOne', { id: bookid, wantToBuy: toBuy });
$.ajax({
method: 'GET',
url: url
}).done(function()
{
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback);
}).error(function()
{
alert('Nem sikerült bejegyezni a kérést');
});
});
};
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback);
}); });
</script> </script>
{% endblock bottomscripts %} {% endblock bottomscripts %}

View File

@ -1,31 +1,31 @@
{# vim: ft=htmljinja {# vim: ft=htmljinja
#} #}
<div id="events-button"> <div id="events-button">
<span id="event-shower" class="gomb">[események gomb]</span> <span id="event-shower" class="gomb">[események gomb]</span>
<div id="event-box"> <div id="event-box">
<div id="event-inside"> <div id="event-inside">
<p class="month">{{ firstDay|date('Y-m') }}</p> <p class="month">{{ firstDay|date('Y-m') }}</p>
<table> <table>
<thead> <thead>
<tr> <tr>
<td></td> <td></td>
<td>H</td> <td>H</td>
<td>K</td> <td>K</td>
<td>Sze</td> <td>Sze</td>
<td>Cs</td> <td>Cs</td>
<td>P</td> <td>P</td>
<td>Szo</td> <td>Szo</td>
<td>V</td> <td>V</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td class="woy">{{ firstDay|date('W') }}</td> <td class="woy">{{ firstDay|date('W') }}</td>
{% set curDow = 0 %} {% set curDow = 0 %}
{% if firstDayWeekday != 1 %} {% if firstDayWeekday != 1 %}
{% for i in 1..(firstDayWeekday - 1) %} {% for i in 1..(firstDayWeekday - 1) %}
{% set curDow = curDow + 1 %}{% if curDow == 8 %}{% set curDow = 1 %}{% endif %} {% set curDow = curDow + 1 %}{% if curDow == 8 %}{% set curDow = 1 %}{% endif %}
<td></td> <td></td>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% set cur = firstDayWeekday - 1 %} {% set cur = firstDayWeekday - 1 %}
@ -33,30 +33,26 @@
{% set cur = cur + 1 %} {% set cur = cur + 1 %}
{% set curDow = curDow + 1 %}{% if curDow == 8 %}{% set curDow = 1 %}{% endif %} {% set curDow = curDow + 1 %}{% if curDow == 8 %}{% set curDow = 1 %}{% endif %}
{% set eventCount = 0 %} {% set eventCount = 0 %}
{# TODO Check if an event occurs on this date: <td id="event-calendar-{{ i }}"{% if eventList[i].events|length > 0 %} class="program" rel="{{ path('KekRozsakFrontBundle_eventAjaxList', {date: eventList[i].date|date('Y-m-d'), _format: 'html'}) }}"{% endif %}>
(event.startDate = this day AND event.endDate is NULL) <a href="{{ path('KekRozsakFrontBundle_eventList', { date: eventList[i].date|date('Y-m-d')}) }}">{{ eventList[i].date|date('d') }}</a>
OR (event.startDate <= this day AND evend.endDate >= this day) </td>
#}
<td id="event-calendar-{{ i }}"{% if eventList[i].events|length > 0 %} class="program" rel="{{ path('KekRozsakFrontBundle_eventAjaxList', {date: eventList[i].date|date('Y-m-d'), _format: 'html'}) }}"{% endif %}>
<a href="{{ path('KekRozsakFrontBundle_eventList', { date: eventList[i].date|date('Y-m-d')}) }}">{{ eventList[i].date|date('d') }}</a>
</td>
{% if cur is divisibleby(7) %} {% if cur is divisibleby(7) %}
</tr> </tr>
{% if cur != numDays %} {% if cur != numDays %}
<tr> <tr>
<td class="woy">{{ eventList[i + 1].date|date('W') }}</td> <td class="woy">{{ eventList[i + 1].date|date('W') }}</td>
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% if curDow != 7 %} {% if curDow != 7 %}
{% for i in (curDow + 1)..7 %} {% for i in (curDow + 1)..7 %}
<td></td> <td></td>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
</tr> </tr>
</tbody> </tbody>
</table> </table>
<a href="{{ path('KekRozsakFrontBundle_eventList') }}">További események</a> <a href="{{ path('KekRozsakFrontBundle_eventList') }}">További események</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,14 +1,14 @@
{# vim: ft=htmljinja {# vim: ft=htmljinja
#} #}
<div id="login-gomb"> <div id="login-gomb">
<span id="login-mutato" class="gomb">Bejelentkezés</span> <span id="login-mutato" class="gomb">Bejelentkezés</span>
<div id="login-box"> <div id="login-box">
<div id="login-belso"> <div id="login-belso">
<form method="post" action="{{ path('KekRozsakSecurityBundle_login_check') }}"> <form method="post" action="{{ path('KekRozsakSecurityBundle_login_check') }}">
Felhasználónév: <input type="text" name="_username" /><br /> Felhasználónév: <input type="text" name="_username" /><br />
Jelszó: <input type="password" name="_password" /><br /> Jelszó: <input type="password" name="_password" /><br />
<button type="submit">Bejelentkezés</button> <button type="submit">Bejelentkezés</button>
</form> </form>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,28 +1,27 @@
{# vim: ft=htmljinja {# vim: ft=htmljinja
#} #}
<div id="profil-gomb"> <div id="profil-gomb">
<span id="profil-mutato" class="gomb">[avatar] {{ app.user.displayName }}</span> <span id="profil-mutato" class="gomb">[avatar] {{ app.user.displayName }}</span>
<div id="profil-box"> <div id="profil-box">
<div id="profil-belso"> <div id="profil-belso">
[avatar] <span class="avatar">[avatar]</span>
{{ app.user.displayName }}<br /> {{ app.user.displayName }}<br />
<span id="jog-lista" title="|Jogosultságok|{% for role in app.user.roles %}{{ role.shortDescription }}<br />{% endfor %}">Jogosultság{% if app.user.roles|length > 1 %}ok{% endif %}</span><br /> <span id="jog-lista" title="|Jogosultságok|{% for role in app.user.roles %}{{ role.shortDescription }}<br />{% endfor %}">Jogosultság{% if app.user.roles|length > 1 %}ok{% endif %}</span><br />
<dl> <dl>
<dt>Csoportjaim</dt> <dt>Csoportjaim</dt>
{% for group in app.user.groups %} {% for group in app.user.groups %}
{% if group.group.open or group.membershipAcceptedAt %} {% if group.group.open or group.membershipAcceptedAt %}
<dl><a href="{{ path('KekRozsakFrontBundle_groupView', {slug: group.group.slug}) }}">{{ group.group.name }}</a></dl> <dd><a href="{{ path('KekRozsakFrontBundle_groupView', {slug: group.group.slug}) }}">{{ group.group.name }}</a></dd>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<dl><a href="{{ path('KekRozsakFrontBundle_groupList') }}">További csoportok</a></dl> <dd><a href="{{ path('KekRozsakFrontBundle_groupList') }}">További csoportok</a></dd>
<dt>Kedvenc Fórum-témáim</dt> <dt>Kedvenc Fórum-témáim</dt>
<dd><a href="{{ path('KekRozsakFrontBundle_forumTopicGroupList') }}">Fórum</a></dd>
<dl><a href="{{ path('KekRozsakFrontBundle_forumTopicGroupList') }}">Fórum</a></dl> <dt>Üzenetek</dt>
</dl>
<dt>Üzenetek</dt> </div>
</dl> <div id="profil-szerkesztes"><a href="{{ path('KekRozsakFrontBundle_profile_edit') }}">Profil szerkesztése</a></div>
</div> </div>
<div id="profil-szerkesztes"><a href="{{ path('KekRozsakFrontBundle_profile_edit') }}">Profil szerkesztése</a></div> </div>
</div>
</div>

View File

@ -8,9 +8,9 @@
<p>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.</p> <p>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.</p>
<p>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.</p> <p>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.</p>
<form method="post" action="{{ path('KekRozsakFrontBundle_profile_edit') }}"> <form method="post" action="{{ path('KekRozsakFrontBundle_profile_edit') }}">
<table> <table>
{{ form_widget(form) }} {{ form_widget(form) }}
</table> </table>
<button type="submit">Mentés</button> <button type="submit">Mentés</button>
</form> </form>
{% endblock content %} {% endblock content %}

View File

@ -5,7 +5,7 @@
{% block content %} {% block content %}
<h3>Új dokumentum létrehozása</h3> <h3>Új dokumentum létrehozása</h3>
<form method="post" action="{{ path('KekRozsakFrontBundle_documentCreate') }}"> <form method="post" action="{{ path('KekRozsakFrontBundle_documentCreate') }}">
{{ form_widget(form) }} {{ form_widget(form) }}
<button type="submit">Mentés</button> <button type="submit">Mentés</button>
</form> </form>
{% endblock content %} {% endblock content %}

View File

@ -5,7 +5,7 @@
{% block content %} {% block content %}
<h3>Dokumentum szerkesztése - {{ document.title }}</h3> <h3>Dokumentum szerkesztése - {{ document.title }}</h3>
<form method="post" action="{{ path('KekRozsakFrontBundle_documentEdit', {slug: document.slug}) }}"> <form method="post" action="{{ path('KekRozsakFrontBundle_documentEdit', {slug: document.slug}) }}">
{{ form_widget(form) }} {{ form_widget(form) }}
<button type="submit">Mentés</button> <button type="submit">Mentés</button>
</form> </form>
{% endblock content %} {% endblock content %}

View File

@ -4,7 +4,7 @@
{% block title %} - Dokumentum - {{ document.title }}{% endblock %} {% block title %} - Dokumentum - {{ document.title }}{% endblock %}
{% block content %} {% block content %}
<h3> <h3>
{{ document.title }}{% if document.createdBy == app.user %} [ <a href="{{ path('KekRozsakFrontBundle_documentEdit', {slug: document.slug}) }}">Szerkesztés</a> ] {% endif %} {{ document.title }}{% if document.createdBy == app.user %} [ <a href="{{ path('KekRozsakFrontBundle_documentEdit', {slug: document.slug}) }}">Szerkesztés</a> ] {% endif %}
</h3> </h3>
{{ document.content|raw }} {{ document.content|raw }}
<div class="szerzo">{{ document.createdBy|userdataspan }}</div> <div class="szerzo">{{ document.createdBy|userdataspan }}</div>

View File

@ -1,16 +1,16 @@
{# vim: ft=htmljinja {# vim: ft=htmljinja
#} #}
<html> <html>
<head> <head>
<title>Események</title> <title>Események</title>
</head> </head>
<body> <body>
{% if events|length > 0 %} {% if events|length > 0 %}
<ul> <ul>
{% for event in events %} {% for event in events %}
<li>{{ event.title }}</li> <li>{{ event.title }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}
</body> </body>
</html> </html>

View File

@ -7,7 +7,7 @@
{% if events %} {% if events %}
<ul> <ul>
{% for event in events %} {% for event in events %}
<li><a href="{{ path('KekRozsakFrontBundle_eventView', {startDate: event.startDate|date('Y-m-d'), eventSlug: event.slug}) }}">{{ event.title }}</a></li> <li><a href="{{ path('KekRozsakFrontBundle_eventView', {startDate: event.startDate|date('Y-m-d'), eventSlug: event.slug}) }}">{{ event.title }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
{% else %} {% else %}

View File

@ -7,12 +7,12 @@
<p class="esemeny-idopont">{{ 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 %}</p> <p class="esemeny-idopont">{{ 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 %}</p>
<p class="esemeny-szervezo">Az eseményt szervezi: {{ event.createdBy|userdataspan }}</p> <p class="esemeny-szervezo">Az eseményt szervezi: {{ event.createdBy|userdataspan }}</p>
<p> <p>
{{ event.description }} {{ event.description }}
</p> </p>
<h4>Eddigi résztvevők</h4> <h4>Eddigi résztvevők</h4>
<ul> <ul>
{% for attendee in event.attendees %} {% for attendee in event.attendees %}
<li>{{ attendee|userdataspan }}</li> <li>{{ attendee|userdataspan }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
{% if not event.isAttending(app.user) and not event.isPast %} {% if not event.isAttending(app.user) and not event.isPast %}

View File

@ -2,11 +2,11 @@
#} #}
{% block field_row %} {% block field_row %}
<tr> <tr>
<td>{{ form_label(form) }}</td> <td>{{ form_label(form) }}</td>
<td>{{ form_widget(form) }}</td> <td>{{ form_widget(form) }}</td>
<td> <td>
{{ help }} {{ help }}
</td> </td>
<td>{{ form_errors(form) }}</td> <td>{{ form_errors(form) }}</td>
</td> </td>
{% endblock %} {% endblock %}

View File

@ -5,42 +5,42 @@
{% block content %} {% block content %}
<h3><a href="{{ path('KekRozsakFrontBundle_forumTopicGroupList') }}">Fórum</a> - <a href="{{ path('KekRozsakFrontBundle_forumTopicList', {slug: topicGroup.slug}) }}">{{ topicGroup.title }}</a> - {{ topic.title }}</h3> <h3><a href="{{ path('KekRozsakFrontBundle_forumTopicGroupList') }}">Fórum</a> - <a href="{{ path('KekRozsakFrontBundle_forumTopicList', {slug: topicGroup.slug}) }}">{{ topicGroup.title }}</a> - {{ topic.title }}</h3>
<table class="post-lista"> <table class="post-lista">
<tbody> <tbody>
<tr> <tr>
<td class="uj-post"> <td class="uj-post">
<form method="post" action="{{ path('KekRozsakFrontBundle_forumPostList', { topicGroupSlug: topicGroup.slug, topicSlug: topic.slug } ) }}"> <form method="post" action="{{ path('KekRozsakFrontBundle_forumPostList', { topicGroupSlug: topicGroup.slug, topicSlug: topic.slug } ) }}">
{{ form_widget(form) }} {{ form_widget(form) }}
<p> <p>
<span class="eszkoztar">Súgó</span><span class="kuldes-gomb" /><button type="submit">Küldés</button> <span class="eszkoztar">Súgó</span><span class="kuldes-gomb" /><button type="submit">Küldés</button>
</p> </p>
</form> </form>
</td> </td>
<td class="felado"> <td class="felado">
<br /> <br />
<br /> <br />
[avatar]<br /> [avatar]<br />
{{ app.user.displayName }}<br /> {{ app.user.displayName }}<br />
Saját szint<br /> Saját szint<br />
<br /> <br />
Tagság kezdete:<br /> Tagság kezdete:<br />
{{ app.user.registeredAt|date('Y-m-d') }} {{ app.user.registeredAt|date('Y-m-d') }}
</td> </td>
</tr> </tr>
{% for post in posts %} {% for post in posts %}
<tr> <tr>
<td class="szoveg"><div>{{ post.text|bbdecode }}</div></td> <td class="szoveg"><div>{{ post.text|bbdecode }}</div></td>
<td class="felado"> <td class="felado">
{{ post.createdAt|date('Y-m-d') }}<br /> {{ post.createdAt|date('Y-m-d') }}<br />
{{ post.createdAt|date('H:i') }}<br /> {{ post.createdAt|date('H:i') }}<br />
[avatar]<br /> [avatar]<br />
{{ post.createdBy|userdataspan }}<br /> {{ post.createdBy|userdataspan }}<br />
Szint<br /> Szint<br />
<br /> <br />
Tagság kezdete:<br /> Tagság kezdete:<br />
{{ post.createdBy.RegisteredAt|date('Y-m-d') }} {{ post.createdBy.RegisteredAt|date('Y-m-d') }}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
{% endblock %} {% endblock %}

View File

@ -6,36 +6,36 @@
<h3>Fórum</h3> <h3>Fórum</h3>
{% for topicGroup in topicGroups %} {% for topicGroup in topicGroups %}
<table class="forum-lista"> <table class="forum-lista">
<thead> <thead>
<tr> <tr>
<td colspan="2"><a href="{{ path('KekRozsakFrontBundle_forumTopicList', {slug: topicGroup.slug}) }}">{{ topicGroup.title }}</a></td> <td colspan="2"><a href="{{ path('KekRozsakFrontBundle_forumTopicList', {slug: topicGroup.slug}) }}">{{ topicGroup.title }}</a></td>
<td>Hozzászólások száma</td> <td>Hozzászólások száma</td>
<td>Utolsó hozzászólás</td> <td>Utolsó hozzászólás</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% if topicGroup.topics|length > 0 %} {% if topicGroup.topics|length > 0 %}
{% for topic in topicGroup.topics %} {% for topic in topicGroup.topics %}
<tr class="{{ cycle(['odd', 'even'], loop.index0) }}"> <tr class="{{ cycle(['odd', 'even'], loop.index0) }}">
<td>[ikon]</td> <td>[ikon]</td>
<td><a href="{{ path('KekRozsakFrontBundle_forumPostList', {topicGroupSlug: topicGroup.slug, topicSlug: topic.slug}) }}">{{ topic.title }}</a></td> <td><a href="{{ path('KekRozsakFrontBundle_forumPostList', {topicGroupSlug: topicGroup.slug, topicSlug: topic.slug}) }}">{{ topic.title }}</a></td>
<td></td> <td></td>
<td> <td>
{% if topic.lastPost %} {% if topic.lastPost %}
{{ topic.lastPost.createdBy|userdataspan }}<br /> {{ topic.lastPost.createdBy|userdataspan }}<br />
{{ topic.lastPost.createdAt|date('Y-m-d H:i') }} {{ topic.lastPost.createdAt|date('Y-m-d H:i') }}
{% else %} {% else %}
&nbsp;<br />&nbsp; &nbsp;<br />&nbsp;
{% endif %} {% endif %}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
{% else %} {% else %}
<tr> <tr>
<td colspan="4">Ebben a kategóriában nincsenek témák</td> <td colspan="4">Ebben a kategóriában nincsenek témák</td>
</tr> </tr>
{% endif %} {% endif %}
</tbody> </tbody>
</table> </table>
{% endfor %} {% endfor %}
{% endblock content %} {% endblock content %}

View File

@ -6,29 +6,29 @@
<h3><a href="{{ path('KekRozsakFrontBundle_forumTopicGroupList') }}">Fórum</a> - {{ topicGroup.title }}</h3> <h3><a href="{{ path('KekRozsakFrontBundle_forumTopicGroupList') }}">Fórum</a> - {{ topicGroup.title }}</h3>
{% if topicGroup.topics|length > 0 %} {% if topicGroup.topics|length > 0 %}
<table class="forum-lista"> <table class="forum-lista">
<thead> <thead>
<tr> <tr>
<td></td> <td></td>
<td>Hozzászólások száma</td> <td>Hozzászólások száma</td>
<td>Utolsó hozzászólás</td> <td>Utolsó hozzászólás</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for topic in topicGroup.topics %} {% for topic in topicGroup.topics %}
<tr class="{{ cycle(['odd', 'even'], loop.index0) }}"> <tr class="{{ cycle(['odd', 'even'], loop.index0) }}">
<td><a href="{{ path('KekRozsakFrontBundle_forumPostList', { topicGroupSlug: topicGroup.slug, topicSlug: topic.slug }) }}">{{ topic.title }}</a></td> <td><a href="{{ path('KekRozsakFrontBundle_forumPostList', { topicGroupSlug: topicGroup.slug, topicSlug: topic.slug }) }}">{{ topic.title }}</a></td>
<td></td> <td></td>
<td> <td>
{% if topic.lastPost %} {% if topic.lastPost %}
{{ topic.lastPost.createdBy|userdataspan }}<br /> {{ topic.lastPost.createdBy|userdataspan }}<br />
{{ topic.lastPost.createdAt|date('Y-m-d H:i') }} {{ topic.lastPost.createdAt|date('Y-m-d H:i') }}
{% else %} {% else %}
&nbsp;<br />&nbsp; &nbsp;<br />&nbsp;
{% endif %} {% endif %}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
{% else %} {% else %}
Ebben a témakörben nincsenek témák. Ebben a témakörben nincsenek témák.

View File

@ -4,7 +4,8 @@
{% block title %} - Csoport létrehozása{% endblock %} {% block title %} - Csoport létrehozása{% endblock %}
{% block content %} {% block content %}
<h3>Csoport létrehozása</h3> <h3>Csoport létrehozása</h3>
<p>Warning</p> {# TODO: Leírást készíteni ide, hogy mivel jár a csoportok létrehozása #}
<p></p>
<form method="post" action="{{ path('KekRozsakFrontBundle_groupCreate') }}"> <form method="post" action="{{ path('KekRozsakFrontBundle_groupCreate') }}">
{{ form_widget(form) }} {{ form_widget(form) }}
<button type="submit">Létrehozás</button> <button type="submit">Létrehozás</button>

View File

@ -2,34 +2,31 @@
#} #}
{% extends 'KekRozsakFrontBundle:Default:main_template.html.twig' %} {% extends 'KekRozsakFrontBundle:Default:main_template.html.twig' %}
{% block title %} - {{ group.name }}{% endblock %} {% block title %} - {{ group.name }}{% endblock %}
{% block additional_css %}
<link rel="stylesheet" href="{{ asset('css/group.css') }}" type="text/css" />
{% endblock additional_css %}
{% block content %} {% block content %}
<ul id="submenu"> <ul id="submenu">
<li><a href="{{ path('KekRozsakFrontBundle_groupMembers', {slug: group.slug}) }}">Tagok</a></li> <li><a href="{{ path('KekRozsakFrontBundle_groupMembers', {slug: group.slug}) }}">Tagok</a></li>
<li><a href="{{ path('KekRozsakFrontBundle_groupView', {slug: group.slug}) }}">Leírás</a></li> <li><a href="{{ path('KekRozsakFrontBundle_groupView', {slug: group.slug}) }}">Leírás</a></li>
</ul> </ul>
<h3>{{ group.name }} - Dokumentumok</h3> <h3>{{ group.name }} - Dokumentumok</h3>
<table> <table>
<thead> <thead>
<tr> <tr>
<td colspan="2">Cím</td> <td colspan="2">Cím</td>
<td>Készítette</td> <td>Készítette</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for document in group.documents %} {% for document in group.documents %}
<tr> <tr>
<td>[ikon]</td> <td>[ikon]</td>
<td><a href="{{ path('KekRozsakFrontBundle_documentView', {slug: document.slug}) }}">{{ document.title }}</a></td> <td><a href="{{ path('KekRozsakFrontBundle_documentView', {slug: document.slug}) }}">{{ document.title }}</a></td>
<td> <td>
{{ document.createdBy|userdataspan }}<br /> {{ document.createdBy|userdataspan }}<br />
{{ document.createdAt|date('Y-m-d H:i') }} {{ document.createdAt|date('Y-m-d H:i') }}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<a href="{{ path('KekRozsakFrontBundle_documentCreate', {slug: group.slug}) }}">Új dokumentum</a> <a href="{{ path('KekRozsakFrontBundle_documentCreate', {slug: group.slug}) }}">Új dokumentum</a>
{% endblock %} {% endblock %}

View File

@ -9,53 +9,47 @@
<p>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.</p> <p>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.</p>
<p>Amennyiben látni szeretnéd egy csoport leírását, kattints a csoport nevére!</p> <p>Amennyiben látni szeretnéd egy csoport leírását, kattints a csoport nevére!</p>
<table> <table>
<thead> <thead>
<tr> <tr>
<td colspan="2">Csoport neve</td> <td colspan="2">Csoport neve</td>
<td>Státusz</td> <td>Státusz</td>
<td>Vezető</td> <td>Vezető</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for group in groups %} {% for group in groups %}
<tr> <tr>
<td>[ikon]</td> <td>[ikon]</td>
<td class="csoport" title="|Csoport leírás|{{ group.description }}"><a href="{{ path('KekRozsakFrontBundle_groupView', {slug: group.slug}) }}">{{ group.name }}</a></td> <td class="csoport" title="|Csoport leírás|{{ group.description }}"><a href="{{ path('KekRozsakFrontBundle_groupView', {slug: group.slug}) }}">{{ group.name }}</a></td>
<td> <td>
{% if group.isMember(app.user) %} {% if group.isMember(app.user) %}
<span title="|Állapot|Már tag vagy" class="ikon">[tag ikon]</span> <span title="|Állapot|Már tag vagy" class="ikon">[tag ikon]</span>
{% elseif group.isRequested(app.user) %} {% elseif group.isRequested(app.user) %}
<span title="|Állapot|Már jelentkeztél, de a jelentkezésedet a csoport vezetője még nem fogadta el" class="ikon">[jelentkeztél ikon]</span> <span title="|Állapot|Már jelentkeztél, de a jelentkezésedet a csoport vezetője még nem fogadta el" class="ikon">[jelentkeztél ikon]</span>
{% else %} {% else %}
{% if group.isOpen %} {% if group.isOpen %}
<a href="{{ path('KekRozsakFrontBundle_groupJoin', {slug: group.slug}) }}"><span title="|Állapot|Nyílt csoport, kattints a belépéshez!" class="ikon">[nyílt ikon]</span></a> <a href="{{ path('KekRozsakFrontBundle_groupJoin', {slug: group.slug}) }}"><span title="|Állapot|Nyílt csoport, kattints a belépéshez!" class="ikon">[nyílt ikon]</span></a>
{% else %} {% else %}
<a href="{{ path('KekRozsakFrontBundle_groupJoin', {slug: group.slug}) }}"><span title="|Állapot|Zárt csoport, kattints a jelentkezéshez!" class="ikon">[zárt ikon]</span></a> <a href="{{ path('KekRozsakFrontBundle_groupJoin', {slug: group.slug}) }}"><span title="|Állapot|Zárt csoport, kattints a jelentkezéshez!" class="ikon">[zárt ikon]</span></a>
{% endif %} {% endif %}
{% endif %} {% endif %}
</td> </td>
<td>{% if group.leader %}{{ group.leader|userdataspan }}{% else %}Nincs{% endif %}</td> <td>{% if group.leader %}{{ group.leader|userdataspan }}{% else %}Nincs{% endif %}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<a href="{{ path('KekRozsakFrontBundle_groupCreate') }}">Új csoport létrehozása</a> <a href="{{ path('KekRozsakFrontBundle_groupCreate') }}">Új csoport létrehozása</a>
{% endblock content %} {% endblock content %}
{% block bottomscripts %} {% block bottomscripts %}
<script type="text/javascript"> <script type="text/javascript">
$('.csoport').cluetip({ $('.csoport').cluetip({
splitTitle: '|', splitTitle: '|',
showTitle: false showTitle: false
}); });
$('.ikon').tooltip({ $('.ikon').tooltip({
splitTitle: '|', splitTitle: '|',
showTitle: false showTitle: false
}); });
</script> </script>
{% endblock bottomscripts %} {% endblock bottomscripts %}

View File

@ -2,13 +2,10 @@
#} #}
{% extends 'KekRozsakFrontBundle:Default:main_template.html.twig' %} {% extends 'KekRozsakFrontBundle:Default:main_template.html.twig' %}
{% block title %} - {{ group.name }}{% endblock %} {% block title %} - {{ group.name }}{% endblock %}
{% block additional_css %}
<link rel="stylesheet" href="{{ asset('css/group.css') }}" type="text/css" />
{% endblock additional_css %}
{% block content %} {% block content %}
<ul id="submenu"> <ul id="submenu">
<li><a href="{{ path('KekRozsakFrontBundle_groupView', {slug: group.slug}) }}">Leírás</a></li> <li><a href="{{ path('KekRozsakFrontBundle_groupView', {slug: group.slug}) }}">Leírás</a></li>
<li><a href="{{ path('KekRozsakFrontBundle_groupDocuments', {slug: group.slug}) }}">Dokumentumok</a></li> <li><a href="{{ path('KekRozsakFrontBundle_groupDocuments', {slug: group.slug}) }}">Dokumentumok</a></li>
</ul> </ul>
<h3>{{ group.name }} - Tagok</h3> <h3>{{ group.name }} - Tagok</h3>
<ul> <ul>
@ -18,4 +15,4 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</ul> </ul>
{% endblock %} {% endblock content %}

View File

@ -3,12 +3,12 @@
{% extends 'KekRozsakFrontBundle:Default:main_template.html.twig' %} {% extends 'KekRozsakFrontBundle:Default:main_template.html.twig' %}
{% block title %} - {{ group.name }}{% endblock %} {% block title %} - {{ group.name }}{% endblock %}
{% block additional_css %} {% block additional_css %}
<link rel="stylesheet" href="{{ asset('css/group.css') }}" type="text/css" /> <link rel="stylesheet" href="{{ asset('css/group.css') }}" type="text/css" />
{% endblock additional_css %} {% endblock additional_css %}
{% block content %} {% block content %}
<ul id="submenu"> <ul id="submenu">
<li><a href="{{ path('KekRozsakFrontBundle_groupMembers', {slug: group.slug}) }}">Tagok</a></li> <li><a href="{{ path('KekRozsakFrontBundle_groupMembers', {slug: group.slug}) }}">Tagok</a></li>
<li><a href="{{ path('KekRozsakFrontBundle_groupDocuments', {slug: group.slug}) }}">Dokumentumok</a></li> <li><a href="{{ path('KekRozsakFrontBundle_groupDocuments', {slug: group.slug}) }}">Dokumentumok</a></li>
</ul> </ul>
<h3>{{ group.name }}</h3> <h3>{{ group.name }}</h3>
{{ group.description|raw }} {{ group.description|raw }}

View File

@ -5,77 +5,118 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class TwigBBExtension extends \Twig_Extension class TwigBBExtension extends \Twig_Extension
{ {
private $container; private $container;
private $assets; private $assets;
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
$this->container = $container; $this->container = $container;
} }
public function getFilters() public function getFilters()
{ {
return array( return array(
'bbdecode' => new \Twig_Filter_Method($this, 'bbdecode', array( 'bbdecode' => new \Twig_Filter_Method($this, 'bbdecode', array(
'is_safe' => array('html'), 'is_safe' => array('html'),
)), )),
); );
} }
public function bbdecode($sentence) public function bbdecode($sentence)
{ {
$sentence = htmlspecialchars($sentence, ENT_NOQUOTES); $sentence = preg_replace(
$sentence = str_replace(array("\r\n", "\n", "\r"), "<br />", $sentence); '/\\[i\\](.*?)\\[\\/i\\]/im',
$sentence = preg_replace('/\\[u\\](.*?)\\[\\/u\\]/im', '<span class="u">\\1</span>', $sentence); '<span class="i">\\1</span>',
$sentence = preg_replace('/\\[b\\](.*?)\\[\\/b\\]/im', '<span class="b">\\1</span>', $sentence); preg_replace(
$sentence = preg_replace('/\\[i\\](.*?)\\[\\/i\\]/im', '<span class="i">\\1</span>', $sentence); '/\\[b\\](.*?)\\[\\/b\\]/im',
while (preg_match('/\\[img( (ns|name)="[^"]+"){1,}\\]/i', $sentence, $m, PREG_OFFSET_CAPTURE)) '<span class="b">\\1</span>',
{ preg_replace(
$start = $m[0][1]; '/\\[u\\](.*?)\\[\\/u\\]/im',
$len = strlen($m[0][0]); '<span class="u">\\1</span>',
$full_tag = $m[0][0]; str_replace(
array("\r\n", "\n", "\r"),
"<br />",
htmlspecialchars($sentence, ENT_NOQUOTES)
)
)
)
);
$ns = (preg_match('/ ns="([^"]+)"/', $full_tag, $ns)) ? trim($ns[1]) : ''; $m = array();
$name = (preg_match('/ name="([^"]+)"/', $full_tag, $name)) ? trim($name[1]) : '';
if ($name == '') while (
{ preg_match(
$sentence = substr_replace($sentence, 'Hibás kép', $start, $len); '/\\[img( (ns|name)="[^"]+"){1,}\\]/i',
} $sentence,
else $m,
{ PREG_OFFSET_CAPTURE
// TODO: Thumbnailing! )
$sentence = substr_replace($sentence, '<img src="' . $this->container->get('templating.helper.assets')->getUrl('upload/images/' . (($ns == '') ? '' : $ns . '/') . $name) . '" alt="" />', $start, $len); ) {
} $start = $m[0][1];
} $len = strlen($m[0][0]);
while (preg_match('/\\[link( (url)="[^"]+"){1,}\\](?P<content>.*?)\\[\\/link\\]/i', $sentence, $m, PREG_OFFSET_CAPTURE)) $full_tag = $m[0][0];
{
$start = $m[0][1];
$len = strlen($m[0][0]);
$full_tag = $m[0][0];
$url = (preg_match('/ url="([^"]+)"/', $full_tag, $url)) ? trim($url[1]) : ''; $ns = (preg_match('/ ns="([^"]+)"/', $full_tag, $ns)) ? trim($ns[1]) : '';
$content = ''; $name = (preg_match('/ name="([^"]+)"/', $full_tag, $name)) ? trim($name[1]) : '';
if (array_key_exists('content', $m))
{
$content = trim($m['content'][0]);
}
if (($url == '') || ($content == '')) if ($name == '') {
{ $sentence = substr_replace($sentence, 'Hibás kép', $start, $len);
$sentence = substr_replace($sentence, 'Hibás link', $start, $len); } else {
} // TODO: Thumbnailing!
else $sentence = substr_replace(
{ $sentence,
$sentence = substr_replace($sentence, '<a href="' . $url . '" target="_blank">' . $content . '</a>', $start, $len); '<img src="'
} . $this
} ->container
return $sentence; ->get('templating.helper.assets')
} ->getUrl(
'upload/images/'
. (($ns == '') ? '' : $ns . '/')
. $name
)
. '" alt="" />',
$start,
$len
);
}
}
public function getName() while (
{ preg_match(
return 'twig_bb'; '/\\[link( (url)="[^"]+"){1,}\\](?P<content>.*?)\\[\\/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,
'<a href="'
. $url
. '" target="_blank">'
. $content
. '</a>',
$start,
$len
);
}
}
return $sentence;
}
public function getName()
{
return 'twig_bb';
}
} }

View File

@ -16,124 +16,138 @@ use KekRozsak\FrontBundle\Entity\UserData;
class DefaultController extends Controller class DefaultController extends Controller
{ {
/** /**
* @Route("/login", name="KekRozsakSecurityBundle_login") * @Route("/login", name="KekRozsakSecurityBundle_login")
* @Template() * @Template()
*/ */
public function loginAction() public function loginAction()
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$session = $request->getSession(); $session = $request->getSession();
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
{ $error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
$error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR); } else {
} $error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
else $session->remove(SecurityContext::AUTHENTICATION_ERROR);
{ }
$error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
$session->remove(SecurityContext::AUTHENTICATION_ERROR);
}
return array( return array(
'last_username' => $session->get(SecurityContext::LAST_USERNAME), 'last_username' => $session->get(SecurityContext::LAST_USERNAME),
'error' => $error, 'error' => $error,
); );
} }
/** /**
* @Route("/login_check", name="KekRozsakSecurityBundle_login_check") * @Route("/login_check", name="KekRozsakSecurityBundle_login_check")
*/ */
public function loginCheckAction() public function loginCheckAction()
{ {
// The security layer will intercept this request. This method will never be called. // The security layer will intercept this request. This method will never be called.
} }
/** /**
* @Route("/logout", name="KekRozsakSecurityBundle_logout") * @Route("/logout", name="KekRozsakSecurityBundle_logout")
*/ */
public function logoutAction() public function logoutAction()
{ {
// The security layer will intercept this request. This method will never be called. // The security layer will intercept this request. This method will never be called.
} }
/** /**
* @Route("/jelentkezes", name="KekRozsakSecurityBundle_registration") * @Route("/jelentkezes", name="KekRozsakSecurityBundle_registration")
* @Template() * @Template()
*/ */
public function registrationAction() public function registrationAction()
{ {
$user = $this->get('security.context')->getToken()->getUser(); $user = $this->get('security.context')->getToken()->getUser();
if ($user instanceof UserInterface) if ($user instanceof UserInterface) {
{ return $this->redirect($this->generateUrl('KekRozsakFrontBundle_homepage'));
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_homepage')); }
}
$user = new User(); $user = new User();
$form = $this->createForm(new UserType(true), $user); $form = $this->createForm(new UserType(true), $user);
$request = $this->getRequest(); $request = $this->getRequest();
if ($request->getMethod() == 'POST') if ($request->getMethod() == 'POST') {
{ $form->bind($request);
$form->bind($request);
if ($form->isValid(array('registration'))) if ($form->isValid(array('registration'))) {
{ $roleRepo = $this->getDoctrine()->getRepository('KekRozsakSecurityBundle:Role');
$roleRepo = $this->getDoctrine()->getRepository('KekRozsakSecurityBundle:Role'); $defaultRoles = $roleRepo->findByDefault(true);
$defaultRoles = $roleRepo->findByDefault(true);
$user->setRegisteredAt(new \DateTime('now')); $user->setRegisteredAt(new \DateTime('now'));
$user->setPassword($this->get('security.encoder_factory')->getEncoder($user)->encodePassword($user->getPassword(), $user->getSalt())); $user->setPassword(
foreach ($defaultRoles as $role) $this
$user->addRole($role); ->get('security.encoder_factory')
$em = $this->getDoctrine()->getEntityManager(); ->getEncoder($user)
$em->persist($user); ->encodePassword(
$em->flush(); $user->getPassword(),
$user->getSalt()
)
);
$userData = new UserData(); /* Add default Roles */
$user->setUserData($userData); foreach ($defaultRoles as $role) {
$em->persist($user); $user->addRole($role);
$em->persist($userData); }
$em->flush();
$message = \Swift_Message::newInstance() $em = $this->getDoctrine()->getEntityManager();
->setSubject('Új jelentkező') $em->persist($user);
// TODO: Make this a config parameter! $em->flush();
->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);
return $this->redirect($this->generateUrl('KekRozsakSecurityBundle_reg_success')); $userData = new UserData();
} $user->setUserData($userData);
} $em->persist($user);
$em->persist($userData);
$em->flush();
return array( $message = \Swift_Message::newInstance()
'form' => $form->createView(), ->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);
/** return $this->redirect(
* @Route("/most_varj", name="KekRozsakSecurityBundle_reg_success") $this->generateUrl(
* @Template() 'KekRozsakSecurityBundle_reg_success'
*/ )
public function regSuccessAction() );
{ }
return array( }
);
}
/** return array(
* @Route("/profil/{id}/ajax-felhasznalo-info.{_format}", name="KekRozsakSecurityBundle_ajaxUserdata", requirements={"_format": "html"}) 'form' => $form->createView(),
* @Method({"GET"}) );
* @Template() }
* @ParamConverter("user")
*/ /**
public function ajaxUserdataAction(User $user) * @Route("/most_varj", name="KekRozsakSecurityBundle_reg_success")
{ * @Template()
return array( */
'user' => $user, 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,
);
}
} }

View File

@ -7,10 +7,10 @@ use Symfony\Component\DependencyInjection\Reference;
class OverrideServiceCompilerPass implements CompilerPassInterface class OverrideServiceCompilerPass implements CompilerPassInterface
{ {
public function process(ContainerBuilder $container) public function process(ContainerBuilder $container)
{ {
$definition = $container->getDefinition('security.role_hierarchy'); $definition = $container->getDefinition('security.role_hierarchy');
$definition->setClass('KekRozsak\SecurityBundle\Service\RoleHierarchy'); $definition->setClass('KekRozsak\SecurityBundle\Service\RoleHierarchy');
$definition->setArguments(array(new Reference('doctrine'))); $definition->setArguments(array(new Reference('doctrine')));
} }
} }

View File

@ -15,155 +15,171 @@ use KekRozsak\SecurityBundle\Entity\User;
*/ */
class Role implements RoleInterface class Role implements RoleInterface
{ {
/** /**
* @var integer $id * The ID of the Role
* @ORM\Id *
* @ORM\GeneratedValue(strategy="AUTO") * @var integer $id
* @ORM\Column(type="integer") *
*/ * @ORM\Id
protected $id; * @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
protected $id;
/** /**
* Get id * Get id
* *
* @return integer * @return integer
*/ */
public function getId() public function getId()
{ {
return $this->id; return $this->id;
} }
/** /**
* @var string name * The role name of the Role
* @ORM\Column(type="string", length=50, unique=true, nullable=false) *
*/ * @var string name
protected $name; *
* @ORM\Column(type="string", length=50, unique=true, nullable=false)
*/
protected $name;
/** /**
* Set name * Set name
* *
* @param string $name * @param string $name
* @return Role * @return Role
*/ */
public function setName($name) public function setName($name)
{ {
$this->name = $name; // TODO: Check if null or empty!
return $this; $this->name = $name;
} return $this;
}
/** /**
* Get name * Get name
* *
* @return string * @return string
*/ */
public function getName() public function getName()
{ {
return $this->name; return $this->name;
} }
/** /**
* @var boolean $default * TRUE if this Role is automatically added to newly registered Users
* @ORM\Column(type="boolean", nullable=false) *
*/ * @var boolean $default
protected $default; *
* @ORM\Column(type="boolean", nullable=false)
*/
protected $default;
/** /**
* Set default * Set default
* *
* @param boolean $default * @param boolean $default
*/ */
public function setDefault($default) public function setDefault($default)
{ {
$this->default = $default; // TODO: Check if parameter is boolean!
return $this; $this->default = $default;
} return $this;
}
/** /**
* @var text description * The description of this Role
* @ORM\Column(type="string", length=150, nullable=true) *
*/ * @var text description
protected $description; *
* @ORM\Column(type="string", length=150, nullable=true)
*/
protected $description;
/** /**
* Set description * Set description
* *
* @param string $description * @param string $description
* @return Role * @return Role
*/ */
public function setDescription($description = null) public function setDescription($description = null)
{ {
$this->description = $description; $this->description = $description;
return $this; return $this;
} }
/** /**
* Get description * Get description
* *
* @return string * @return string
*/ */
public function getDescription() public function getDescription()
{ {
return $this->description; return $this->description;
} }
/* Here comes the rest of RoleInterface's implementation */ /* Here comes the rest of RoleInterface's implementation */
public function getRole() public function getRole()
{ {
return $this->name; return $this->name;
} }
/** /**
* Short description * Short description of the Role (e.g readable name)
* *
* @var string shortDescription * @var string shortDescription
* *
* @ORM\Column(type="string", length=50, nullable=false, unique=true, name="short_description") * @ORM\Column(type="string", length=50, nullable=false, unique=true, name="short_description")
*/ */
protected $shortDescription; protected $shortDescription;
/** /**
* Set shortDescription * Set shortDescription
* *
* @param string $shortDescription * @param string $shortDescription
* @return Role * @return Role
*/ */
public function setShortDescription($shortDescription) public function setShortDescription($shortDescription)
{ {
$this->shortDescription = $shortDescription; // TODO: Check if empty or null!
return $this; $this->shortDescription = $shortDescription;
} return $this;
}
/** /**
* Get shortDescription * Get shortDescription
* *
* @return string * @return string
*/ */
public function getShortDescription() public function getShortDescription()
{ {
return $this->shortDescription; return $this->shortDescription;
} }
/** /**
* List of inherited Roles * List of inherited Roles. Required for RoleHierarchy
* *
* @ORM\ManyToMany(targetEntity="Role", fetch="LAZY") * @var Doctrine\Common\Collections\ArrayCollection $inheritedRoles
* @ORM\JoinTable(name="role_hierarchy", joinColumns={ *
* @ORM\JoinColumn(name="parent_role_id", referencedColumnName="id") * @ORM\ManyToMany(targetEntity="Role", fetch="LAZY")
* }, inverseJoinColumns={ * @ORM\JoinTable(name="role_hierarchy", joinColumns={
* @ORM\JoinColumn(name="child_role_id", referencedColumnName="id") * @ORM\JoinColumn(name="parent_role_id", referencedColumnName="id")
* }) * }, inverseJoinColumns={
*/ * @ORM\JoinColumn(name="child_role_id", referencedColumnName="id")
protected $inheritedRoles; * })
*/
protected $inheritedRoles;
/** /**
* Get all inherited roles * Get all inherited roles
* *
* @return Doctrine\Common\Collections\ArrayCollection * @return Doctrine\Common\Collections\ArrayCollection
*/ */
public function getInheritedRoles() public function getInheritedRoles()
{ {
return $this->inheritedRoles; return $this->inheritedRoles;
} }
} }

View File

@ -11,6 +11,7 @@ use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert;
use KekRozsak\FrontBundle\Entity\UserData; use KekRozsak\FrontBundle\Entity\UserData;
use KekRozsak\FrontBundle\Entity\UserGroupMembership; use KekRozsak\FrontBundle\Entity\UserGroupMembership;
use KekRozsak\SecurityBundle\Entity\Role;
/** /**
* KekRozsak\SecurityBundle\Entity\User * KekRozsak\SecurityBundle\Entity\User
@ -22,364 +23,403 @@ use KekRozsak\FrontBundle\Entity\UserGroupMembership;
*/ */
class User implements UserInterface, AdvancedUserInterface class User implements UserInterface, AdvancedUserInterface
{ {
public function __construct() public function __construct()
{ {
$this->groups = new ArrayCollection(); $this->groups = new ArrayCollection();
$this->roles = new ArrayCollection(); $this->roles = new ArrayCollection();
} }
/** /**
* @var integer $id * The ID of the User
* @ORM\Id *
* @ORM\GeneratedValue(strategy="AUTO") * @var integer $id
* @ORM\Column(type="integer") *
*/ * @ORM\Id
protected $id; * @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
protected $id;
/** /**
* Get id * Get id
* *
* @return integer * @return integer
*/ */
public function getId() public function getId()
{ {
return $this->id; return $this->id;
} }
/** /**
* @var string $username * The login name of the User
* @ORM\Column(type="string", length=50, nullable=false, unique=true) *
* @Assert\NotBlank(groups="registration") * @var string $username
*/ *
protected $username; * @ORM\Column(type="string", length=50, nullable=false, unique=true)
* @Assert\NotBlank(groups="registration")
*/
protected $username;
/** /**
* Set username * Set username
* *
* @param string $username * @param string $username
* @return User * @return User
*/ */
public function setUsername($username) public function setUsername($username)
{ {
$this->username = $username; // TODO: check if null or empty!
return $this; $this->username = $username;
} return $this;
}
/** /**
* Get username * Get username
* *
* @return string * @return string
*/ */
public function getUsername() public function getUsername()
{ {
return $this->username; return $this->username;
} }
/** /**
* @var string $password * The encrypted password of the User
* @ORM\Column(type="string", length=50, nullable=false) *
* @Assert\NotBlank(groups="registration") * @var string $password
*/ *
protected $password; * @ORM\Column(type="string", length=50, nullable=false)
* @Assert\NotBlank(groups="registration")
*/
protected $password;
/** /**
* Set password * Set password
* *
* @param string $password * @param string $password
* @return User * @return User
*/ */
public function setPassword($password) public function setPassword($password)
{ {
$this->password = $password; $this->password = $password;
return $this; return $this;
} }
/** /**
* Get password * Get password
* *
* @return string * @return string
*/ */
public function getPassword() public function getPassword()
{ {
return $this->password; return $this->password;
} }
/** /**
* @var string $displayName * The display name of the User
* @ORM\Column(type="string", length=50, unique=true, name="display_name") *
*/ * @var string $displayName
protected $displayName; *
* @ORM\Column(type="string", length=50, unique=true, name="display_name")
*/
protected $displayName;
/** /**
* Set displayName * Set displayName
* *
* @param string $displayName * @param string $displayName
* @return User * @return User
*/ */
public function setDisplayName($displayName) public function setDisplayName($displayName)
{ {
$this->displayName = $displayName; // TODO: Check if empty or null!
return $this; $this->displayName = $displayName;
} return $this;
}
/** /**
* Get displayName * Get displayName
* *
* @return string * @return string
*/ */
public function getDisplayName() public function getDisplayName()
{ {
return $this->displayName; return $this->displayName;
} }
/** /**
* @var string $email * The e-mail address of the User
* @ORM\Column(type="string", length=100, nullable=false, unique=true) *
*/ * @var string $email
protected $email; *
* @ORM\Column(type="string", length=100, nullable=false, unique=true)
*/
protected $email;
/** /**
* Set email * Set email
* *
* @param string $email * @param string $email
* @return User * @return User
*/ */
public function setEmail($email) public function setEmail($email)
{ {
$this->email = $email; // TODO: Check if empty or null!
return $this; $this->email = $email;
} return $this;
}
/** /**
* Get email * Get email
* *
* @return string * @return string
*/ */
public function getEmail() public function getEmail()
{ {
return $this->email; return $this->email;
} }
/** /**
* @var DateTime $registeredAt * The timestamp when the user registered
* @ORM\Column(type="datetime", nullable=false, name="registered_at") *
*/ * @var DateTime $registeredAt
protected $registeredAt; *
* @ORM\Column(type="datetime", nullable=false, name="registered_at")
*/
protected $registeredAt;
/** /**
* Set registeredAt * Set registeredAt
* *
* @param DateTime $registeredAt * @param DateTime $registeredAt
* @return User * @return User
*/ */
public function setRegisteredAt(\DateTime $registeredAt) public function setRegisteredAt(\DateTime $registeredAt)
{ {
$this->registeredAt = $registeredAt; $this->registeredAt = $registeredAt;
return $this; return $this;
} }
/** /**
* Get registeredAt * Get registeredAt
* *
* @return DateTime * @return DateTime
*/ */
public function getRegisteredAt() public function getRegisteredAt()
{ {
return $this->registeredAt; return $this->registeredAt;
} }
/** /**
* @var User acceptedBy * The User who accepted this User's registration
* @ORM\ManyToOne(targetEntity="User") *
* @ORM\JoinColumn(name="accepted_by_id") * @var User acceptedBy
*/ *
protected $acceptedBy; * @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="accepted_by_id")
*/
protected $acceptedBy;
/** /**
* Set acceptedBy * Set acceptedBy
* *
* @param User $acceptedBy * @param User $acceptedBy
* @return User * @return User
*/ */
public function setAcceptedBy(User $acceptedBy = null) public function setAcceptedBy(User $acceptedBy = null)
{ {
$this->acceptedBy = $acceptedBy; $this->acceptedBy = $acceptedBy;
return $this; return $this;
} }
/** /**
* Get acceptedBy * Get acceptedBy
* *
* @return User * @return User
*/ */
public function getAcceptedBy() public function getAcceptedBy()
{ {
return $this->acceptedBy; return $this->acceptedBy;
} }
/** /**
* @var DateTime $lastLoginAt * The timestamp when the User logged in last time
* @ORM\Column(type="datetime", nullable=true, name="last_login_at") *
*/ * @var DateTime $lastLoginAt
protected $lastLoginAt; *
* @ORM\Column(type="datetime", nullable=true, name="last_login_at")
*/
protected $lastLoginAt;
/** /**
* Set lastLoginAt; * Set lastLoginAt;
* *
* @param DateTime $lastLoginAt * @param DateTime $lastLoginAt
* @return User * @return User
*/ */
public function setLastLoginAt(\DateTime $lastLoginAt = null) public function setLastLoginAt(\DateTime $lastLoginAt = null)
{ {
$this->lastLoginAt = $lastLoginAt; $this->lastLoginAt = $lastLoginAt;
return $this; return $this;
} }
/** /**
* Get lastLoginAt * Get lastLoginAt
* *
* @return DateTime * @return DateTime
*/ */
public function getLastLoginAt() public function getLastLoginAt()
{ {
return $this->lastLoginAt; return $this->lastLoginAt;
} }
/** /**
* @var \KekRozsak\FrontBundle\Entity\UserData $userData * The UserData object for this User
* @ORM\OneToOne(targetEntity="KekRozsak\FrontBundle\Entity\UserData", fetch="LAZY", cascade={"persist"}, mappedBy="user") *
*/ * @var \KekRozsak\FrontBundle\Entity\UserData $userData
protected $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 * Get userData
* *
* @param \KekRozsak\FrontBundle\Entity\UserData $userData * @return \KekRozsak\FrontBundle\Entity\UserData
* @return User */
*/ public function getUserData()
public function setUserData(\KekRozsak\FrontBundle\Entity\UserData $userData = null) {
{ return $this->userData;
$this->userData = $userData; }
$userData->setUser($this);
return $this;
}
/** /**
* Get userData * The Group memberships of this User represented by UserGroupMembership
* * objects
* @return \KekRozsak\FrontBundle\Entity\UserData *
*/ * @var Doctrine\Common\Collections\ArrayCollection $groups
public function getUserData() *
{ * @ORM\OneToMany(targetEntity="KekRozsak\FrontBundle\Entity\UserGroupMembership", mappedBy="user")
return $this->userData; * @ORM\JoinColumn(referencedColumnName="user_id")
} */
protected $groups;
/** /**
* @var Doctrine\Common\Collections\ArrayCollection $groups * Add group
* @ORM\OneToMany(targetEntity="KekRozsak\FrontBundle\Entity\UserGroupMembership", mappedBy="user") *
* @ORM\JoinColumn(referencedColumnName="user_id") * @param KekRozsak\FrontBundle\Entity\UserGroupMembership $group
*/ * @return User
protected $groups; */
public function addGroup(UserGroupMembership $group)
{
// TODO: Check if null!
$this->groups[] = $group;
return $this;
}
/** /**
* Add group * Get all groups
* *
* @param KekRozsak\FrontBundle\Entity\UserGroupMembership $group * @return Doctrine\Common\Collections\ArrayCollection
* @return User */
*/ public function getGroups()
public function addGroup(\KekRozsak\FrontBundle\Entity\UserGroupMembership $group) {
{ return $this->groups;
$this->groups[] = $group; }
return $this;
}
/** /**
* Get all groups * The Roles belonging to this User
* *
* @return Doctrine\Common\Collections\ArrayCollection * @var Doctrine\Common\Collections\ArrayCollection $roles
*/ *
public function getGroups() * @ORM\ManyToMany(targetEntity="Role")
{ */
return $this->groups; protected $roles;
}
/** /**
* @var Doctrine\Common\Collections\ArrayCollection $roles * Add a role
* @ORM\ManyToMany(targetEntity="Role") *
*/ * @param KekRozsak\SecurityBundle\Entity\Role $role
protected $roles; * @return User
*/
public function addRole(Role $role)
{
// TODO: Check if null!
$this->roles[] = $role;
return $this;
}
/** /**
* Add a role * Get all roles as an ArrayCollection
* *
* @param KekRozsak\SecurityBundle\Entity\Role $role * @return Doctrine\Common\Collections\ArrayCollection
* @return User */
*/ public function getRolesCollection()
public function addRole(\KekRozsak\SecurityBundle\Entity\Role $role) {
{ return $this->roles;
$this->roles[] = $role; }
return $this;
}
/** /**
* Get all roles as an ArrayCollection * Get all roles, for UserInterface implementation. To get the
* * ArrayCollection, use getRolesCollection() instead
* @return Doctrine\Common\Collections\ArrayCollection *
*/ * @return array
public function getRolesCollection() */
{ public function getRoles()
return $this->roles; {
} return $this->roles->toArray();
}
/** /* Here comes the remaining part of UserInterface implementation */
* 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 */ public function getSalt()
{
/*
* As we use crypt() to encode passwords, salt is always the same as the
* password
*/
return $this->password;
}
public function getSalt() public function eraseCredentials()
{ {
/* As we use crypt() to encode passwords, salt is always the }
* same as password
*/
return $this->password;
}
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() public function isAccountNonLocked()
{ {
/* Currently, accounts never expire */ /* Currently, accounts cannot be locked */
return true; return true;
} }
public function isAccountNonLocked() public function isCredentialsNonExpired()
{ {
/* Currently, accounts cannot be locked */ /* Currently, credentials never expire */
return true; return true;
} }
public function isCredentialsNonExpired() public function isEnabled()
{ {
/* Currently, credentials never expire */ /* Account is enabled if it is accepted by someone */
return true; return ($this->acceptedBy !== null);
} }
public function isEnabled()
{
/* Account is enabled if it is accepted by someone */
return ($this->acceptedBy !== null);
}
} }

View File

@ -9,68 +9,76 @@ use KekRozsak\FrontBundle\Form\Type\UserDataType;
class UserType extends AbstractType class UserType extends AbstractType
{ {
protected $_registration; protected $_registration;
public function __construct($registration = false) public function __construct($registration = false)
{ {
$this->_registration = $registration; $this->_registration = $registration;
} }
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder->add('username', null, array( $builder->add('username', null, array(
'label' => 'Felhasználónév', 'label' => 'Felhasználónév',
'read_only' => (!$this->_registration), '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!', '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 getName() $builder->add('password', 'repeated', array(
{ 'type' => 'password',
return 'user'; '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) $builder->add('email', null, array(
{ 'label' => 'E-mail cím',
$opts = array( 'help' => 'Ezen az e-mail címen értesítünk majd, ha felvételt nyersz a körbe.',
'data_class' => 'KekRozsak\SecurityBundle\Entity\User', )
); );
if ($this->_registration)
$opts['validation_groups'] = array('registration');
$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);
}
} }

View File

@ -9,9 +9,9 @@ use KekRozsak\SecurityBundle\DependencyInjection\Compiler\OverrideServiceCompile
class KekRozsakSecurityBundle extends Bundle class KekRozsakSecurityBundle extends Bundle
{ {
public function build(ContainerBuilder $container) public function build(ContainerBuilder $container)
{ {
parent::build($container); parent::build($container);
$container->addCompilerPass(new OverrideServiceCompilerPass()); $container->addCompilerPass(new OverrideServiceCompilerPass());
} }
} }

View File

@ -1,17 +1,19 @@
<?xml version="1.0" ?> <?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <container xmlns="http://symfony.com/schema/dic/services"
<services> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<service id="kek_rozsak_security.encoder.crypt" class="KekRozsak\SecurityBundle\Service\CryptEncoder"> xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
</service> <services>
<service id="kek_rozsak_security.auth.success" class="KekRozsak\SecurityBundle\Security\AuthSuccess"> <service id="kek_rozsak_security.encoder.crypt" class="KekRozsak\SecurityBundle\Service\CryptEncoder">
<argument type="service" id="doctrine" /> </service>
<tag name="kernel.event_listener" event="security.authentication.success" /> <service id="kek_rozsak_security.auth.success" class="KekRozsak\SecurityBundle\Security\AuthSuccess">
</service> <argument type="service" id="doctrine" />
<service id="kek_rozsak_security.twig_extension.userdataspan" class="KekRozsak\SecurityBundle\Twig\UserDataSpanExtension"> <tag name="kernel.event_listener" event="security.authentication.success" />
<argument type="service" id="router" /> </service>
<argument type="service" id="security.context" /> <service id="kek_rozsak_security.twig_extension.userdataspan" class="KekRozsak\SecurityBundle\Twig\UserDataSpanExtension">
<tag name="twig.extension" /> <argument type="service" id="router" />
</service> <argument type="service" id="security.context" />
</services> <tag name="twig.extension" />
</service>
</services>
</container> </container>

View File

@ -1,10 +1,10 @@
{# vim: ft=htmljinja {# vim: ft=htmljinja
#} #}
<html> <html>
<head> <head>
<title>{{ user.displayName }}</title> <title>{{ user.displayName }}</title>
</head> </head>
<body> <body>
Tagság kezdete: {{ user.registeredAt|date('Y-m-d') }} Tagság kezdete: {{ user.registeredAt|date('Y-m-d') }}
</body> </body>
</html> </html>

View File

@ -7,8 +7,8 @@
<div id="error-message">{{ error.message }}</div> <div id="error-message">{{ error.message }}</div>
{% endif %} {% endif %}
<form action="{{ path('KekRozsakSecurityBundle_login_check') }}" method="post"> <form action="{{ path('KekRozsakSecurityBundle_login_check') }}" method="post">
<input type="text" id="username" name="_username" value="{{ last_username }}" /> <input type="text" id="username" name="_username" value="{{ last_username }}" />
<input type="password" id="password" name="_password" /> <input type="password" id="password" name="_password" />
<button type="submit">Bejelentkezés</button> <button type="submit">Bejelentkezés</button>
</form> </form>
{% endblock content %} {% endblock content %}

View File

@ -3,5 +3,5 @@
{% extends 'KekRozsakFrontBundle:Default:main_template.html.twig' %} {% extends 'KekRozsakFrontBundle:Default:main_template.html.twig' %}
{% block title %} - Sikeres regisztráció{% endblock %} {% block title %} - Sikeres regisztráció{% endblock %}
{% block content %} {% 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 %} {% endblock %}

View File

@ -8,10 +8,10 @@
<p>Amennyiben már tagja vagy a körnek, <a href="{{ path('KekRozsakSecurityBundle_login') }}">itt bejelentkezhetsz</a>. <p>Amennyiben már tagja vagy a körnek, <a href="{{ path('KekRozsakSecurityBundle_login') }}">itt bejelentkezhetsz</a>.
<p>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 <a href="{{ path('KekRozsakFrontBundle_articleView', { slug: 'rolunk' }) }}">Rólunk</a> menüpont szövegét, különös tekintettel a Házirendre.</p> <p>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 <a href="{{ path('KekRozsakFrontBundle_articleView', { slug: 'rolunk' }) }}">Rólunk</a> menüpont szövegét, különös tekintettel a Házirendre.</p>
<p>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.</p> <p>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.</p>
<p><strong>FONTOS!</strong> 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 <a href="http://www.facebook.com/Polesz" target="_blank">Facebookon</a> vagy e-mailben a <a href="jelentkezes@blueroses.hu">jelentkezes@blueroses.hu</a> címen!</p> <p><strong>FONTOS!</strong> 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 <a href="http://www.facebook.com/Polesz" target="_blank">Facebookon</a> vagy e-mailben a <a href="jelentkezes@blueroses.hu">jelentkezes@blueroses.hu</a> címen!</p>
<form method="post" action="{{ path('KekRozsakSecurityBundle_registration') }}"> <form method="post" action="{{ path('KekRozsakSecurityBundle_registration') }}">
<table> <table>
{{ form_widget(form) }} {{ form_widget(form) }}
</table> </table>
<button type="submit">Jelentkezés</button> <button type="submit">Jelentkezés</button>
{% endblock content %} {% endblock content %}

View File

@ -2,7 +2,6 @@
namespace KekRozsak\SecurityBundle\Security; namespace KekRozsak\SecurityBundle\Security;
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface; use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
use Doctrine\ORM\EntityManager;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Bridge\Doctrine\RegistryInterface; use Symfony\Bridge\Doctrine\RegistryInterface;
@ -10,29 +9,29 @@ use Symfony\Component\Security\Core\Event\AuthenticationEvent;
class AuthSuccess implements AuthenticationSuccessHandlerInterface class AuthSuccess implements AuthenticationSuccessHandlerInterface
{ {
private $doctrine; private $doctrine;
public function __construct(RegistryInterface $doctrine) public function __construct(RegistryInterface $doctrine)
{ {
$this->doctrine = $doctrine; $this->doctrine = $doctrine;
} }
public function onSecurityAuthenticationSuccess(AuthenticationEvent $event) public function onSecurityAuthenticationSuccess(AuthenticationEvent $event)
{ {
$user = $event->getAuthenticationToken()->getUser(); $user = $event->getAuthenticationToken()->getUser();
$em = $this->doctrine->getEntityManager(); $em = $this->doctrine->getEntityManager();
$user->setLastLoginAt(new \DateTime('now')); $user->setLastLoginAt(new \DateTime('now'));
$em->persist($user); $em->persist($user);
$em->flush(); $em->flush();
} }
public function onAuthenticationSuccess(Request $request, TokenInterface $token) public function onAuthenticationSuccess(Request $request, TokenInterface $token)
{ {
$user = $token->getUser(); $user = $token->getUser();
$em = $this->doctrine->getEntityManager(); $em = $this->doctrine->getEntityManager();
$user->setLastLoginAt(new \DateTime('now')); $user->setLastLoginAt(new \DateTime('now'));
$em->persist($user); $em->persist($user);
$em->flush(); $em->flush();
} }
} }

View File

@ -5,14 +5,14 @@ use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface;
class CryptEncoder implements PasswordEncoderInterface class CryptEncoder implements PasswordEncoderInterface
{ {
function encodePassword($raw, $salt) function encodePassword($raw, $salt)
{ {
return crypt($raw); return crypt($raw);
} }
function isPasswordValid($encoded, $raw, $salt) function isPasswordValid($encoded, $raw, $salt)
{ {
return (crypt($raw, $salt) == $encoded); return (crypt($raw, $salt) == $encoded);
} }
} }

View File

@ -9,33 +9,40 @@ use KekRozsak\SecurityBundle\Entity\User;
class UserDataSpanExtension extends \Twig_Extension class UserDataSpanExtension extends \Twig_Extension
{ {
protected $_securityContext; protected $_securityContext;
protected $_router; protected $_router;
public function __construct(Router $router, SecurityContextInterface $security) public function __construct(Router $router, SecurityContextInterface $security)
{ {
$this->_router = $router; $this->_router = $router;
$this->_securityContext = $security; $this->_securityContext = $security;
} }
public function getFilters() public function getFilters()
{ {
return array( return array(
'userdataspan' => new \Twig_Filter_Method($this, 'getUserDataSpan', array('is_safe' => array('html'))), 'userdataspan' => new \Twig_Filter_Method(
); $this,
} 'getUserDataSpan',
array('is_safe' => array('html'))
),
);
}
public function getUserDataSpan(User $user) public function getUserDataSpan(User $user)
{ {
if (!is_object($this->_securityContext->getToken()) || !is_object($this->_securityContext->getToken()->getUser())) if (
return '<span class="userdata-secret" title="|Felhasználó|A felhasználóink kiléte szigorúan bizalmas, csak a tagok számára elérhető.">[nem jelenhet meg]</span>'; !is_object($this->_securityContext->getToken())
|| !is_object($this->_securityContext->getToken()->getUser())
) {
return '<span class="userdata-secret" title="|Felhasználó|A felhasználóink kiléte szigorúan bizalmas, csak a tagok számára elérhető.">[nem jelenhet meg]</span>';
}
return '<span class="userdata" rel="' . $this->_router->generate('KekRozsakSecurityBundle_ajaxUserdata', array('id' => $user->getId(), '_format' => 'html')) . '"><a href="">' . $user->getDisplayName() . '</a></span>'; return '<span class="userdata" rel="' . $this->_router->generate('KekRozsakSecurityBundle_ajaxUserdata', array('id' => $user->getId(), '_format' => 'html')) . '"><a href="">' . $user->getDisplayName() . '</a></span>';
} }
public function getName() public function getName()
{ {
return 'twig_userdataspan'; return 'twig_userdataspan';
} }
} }