Refactored code to comply with PSR-*
Signed-off-by: Gergely POLONKAI <polesz@w00d5t0ck.info>
This commit is contained in:
parent
de00a6ad21
commit
fab08cad6f
@ -35,19 +35,15 @@ class DefaultController extends Controller
|
||||
$myGroups = $groupRepo->findByLeader($user);
|
||||
|
||||
$request = $this->getRequest();
|
||||
if ($request->getMethod() == 'POST')
|
||||
{
|
||||
if ($request->request->has('group') && $request->request->has('user'))
|
||||
{
|
||||
if ($request->getMethod() == 'POST') {
|
||||
if ($request->request->has('group') && $request->request->has('user')) {
|
||||
$userRepo = $this->getDoctrine()->getRepository('KekRozsakSecurityBundle:User');
|
||||
$aUser = $userRepo->findOneById($request->request->get('user'));
|
||||
$aGroup = $groupRepo->findOneById($request->request->get('group'));
|
||||
if ($aUser && $aGroup)
|
||||
{
|
||||
if ($aUser && $aGroup) {
|
||||
$membershipRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:UserGroupMembership');
|
||||
$membershipObject = $membershipRepo->findOneBy(array('user' => $aUser, 'group' => $aGroup));
|
||||
if ($membershipObject)
|
||||
{
|
||||
if ($membershipObject) {
|
||||
$membershipObject->setMembershipAcceptedAt(new \DateTime('now'));
|
||||
$membershipObject->setMembershipAcceptedBy($user);
|
||||
|
||||
@ -72,6 +68,8 @@ class DefaultController extends Controller
|
||||
*/
|
||||
public function groupJoinDeclineAction()
|
||||
{
|
||||
// TODO: A reason must be written to decline a join request!
|
||||
|
||||
return array(
|
||||
);
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
</container>
|
||||
|
@ -22,8 +22,15 @@ class ArticleController extends Controller
|
||||
public function viewAction(Article $article)
|
||||
{
|
||||
$scontext = $this->get('security.context');
|
||||
if ((!is_object($scontext->getToken()) || !is_object($scontext->getToken()->getUser())) && !$article->isPublic())
|
||||
if (
|
||||
(
|
||||
!is_object($scontext->getToken())
|
||||
|| !is_object($scontext->getToken()->getUser())
|
||||
)
|
||||
&& !$article->isPublic()
|
||||
) {
|
||||
throw new AccessDeniedException('A cikk megtekintéséhez be kell jelentkezned!');
|
||||
}
|
||||
|
||||
return array(
|
||||
'article' => $article,
|
||||
|
@ -48,7 +48,8 @@ class BookController extends Controller
|
||||
{
|
||||
$copies = $book->getUsersCopies($this->get('security.context')->getToken()->getUser());
|
||||
$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);
|
||||
});
|
||||
@ -62,12 +63,11 @@ class BookController extends Controller
|
||||
* @Route("/konyv/ujpeldany/{id}", name="KekRozsakFrontBundle_bookAddCopy", requirements={"id": "\d+"}, options={"expose": true})
|
||||
* @ParamConverter("book")
|
||||
*/
|
||||
public function ajaxAddBookAction(Book $book)
|
||||
public function ajaxAddCopyAction(Book $book)
|
||||
{
|
||||
$user = $this->get('security.context')->getToken()->getUser();
|
||||
$copies = $book->getUsersCopies($user);
|
||||
if ($copies->count() == 0)
|
||||
{
|
||||
if ($copies->count() == 0) {
|
||||
$copy = new BookCopy($book, $user);
|
||||
$em = $this->getDoctrine()->getEntityManager();
|
||||
$em->persist($copy);
|
||||
@ -86,11 +86,13 @@ class BookController extends Controller
|
||||
$user = $this->get('security.context')->getToken()->getUser();
|
||||
$copies = $book->getUsersCopies($user);
|
||||
$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);
|
||||
});
|
||||
$em->flush();
|
||||
|
||||
return new Response();
|
||||
}
|
||||
|
||||
@ -103,11 +105,13 @@ class BookController extends Controller
|
||||
$user = $this->get('security.context')->getToken()->getUser();
|
||||
$copies = $book->getUsersCopies($user);
|
||||
$em = $this->getDoctrine()->getEntityManager();
|
||||
$copies->forAll(function($key, $copy) use ($em, $newValue) {
|
||||
$copies->forAll(function($key, $copy) use ($em, $newValue)
|
||||
{
|
||||
$copy->setBuyable($newValue);
|
||||
$em->persist($copy);
|
||||
});
|
||||
$em->flush();
|
||||
|
||||
return new Response();
|
||||
}
|
||||
|
||||
@ -118,18 +122,17 @@ class BookController extends Controller
|
||||
public function ajaxWantABookAction(Book $book, $wantToBuy)
|
||||
{
|
||||
$user = $this->get('security.context')->getToken()->getUser();
|
||||
if ($wantToBuy)
|
||||
{
|
||||
|
||||
if ($wantToBuy) {
|
||||
$book->addWouldBuy($user);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$book->addWouldBorrow($user);
|
||||
}
|
||||
|
||||
$em = $this->getDoctrine()->getEntityManager();
|
||||
$em->persist($book);
|
||||
$em->flush();
|
||||
|
||||
return new Response();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,9 +20,18 @@ class DefaultController extends Controller
|
||||
*/
|
||||
public function homepageAction()
|
||||
{
|
||||
$mainPageArticle = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Article')->findOneBy(array('mainPage' => true), true, array('createdAt', 'DESC'), 1);
|
||||
if (!$mainPageArticle)
|
||||
$mainPageArticle = $this
|
||||
->getDoctrine()
|
||||
->getRepository('KekRozsakFrontBundle:Article')
|
||||
->findOneBy(
|
||||
array('mainPage' => true),
|
||||
true,
|
||||
array('createdAt', 'DESC'),
|
||||
1
|
||||
);
|
||||
if (!$mainPageArticle) {
|
||||
throw $this->createNotFoundException('A keresett cikk nem létezik!');
|
||||
}
|
||||
|
||||
return $this->forward('KekRozsakFrontBundle:Article:view', array('slug' => $mainPageArticle->getSlug()));
|
||||
}
|
||||
@ -40,15 +49,14 @@ class DefaultController extends Controller
|
||||
$saveSuccess = false;
|
||||
$request = $this->getRequest();
|
||||
|
||||
if ($request->getMethod() == 'POST')
|
||||
{
|
||||
if ($request->getMethod() == 'POST') {
|
||||
$form->bind($request);
|
||||
if ($form->isValid())
|
||||
{
|
||||
if ($user->getPassword() == '')
|
||||
if ($form->isValid()) {
|
||||
if ($user->getPassword() == '') {
|
||||
$user->setPassword($oldPassword);
|
||||
else
|
||||
} else {
|
||||
$user->setPassword($this->get('security.encoder_factory')->getEncoder($user)->encodePassword($user->getPassword(), $user->getSalt()));
|
||||
}
|
||||
|
||||
$em = $this->getDoctrine()->getEntityManager();
|
||||
$em->persist($user);
|
||||
|
@ -24,9 +24,11 @@ class DocumentController extends Controller
|
||||
'document' => $document,
|
||||
);
|
||||
|
||||
if ($_format == 'pdf')
|
||||
{
|
||||
$html = $this->renderView('KekRozsakFrontBundle:Document:pdfView.html.twig', $templateParams);
|
||||
if ($_format == 'pdf') {
|
||||
$html = $this->renderView(
|
||||
'KekRozsakFrontBundle:Document:pdfView.html.twig',
|
||||
$templateParams
|
||||
);
|
||||
return $this->get('io_tcpdf')->quick_pdf($html);
|
||||
}
|
||||
|
||||
@ -44,13 +46,11 @@ class DocumentController extends Controller
|
||||
$form = $this->createForm(new DocumentType(), $document);
|
||||
$request = $this->getRequest();
|
||||
|
||||
if ($request->getMethod() == 'POST')
|
||||
{
|
||||
if ($request->getMethod() == 'POST') {
|
||||
$form->bind($request);
|
||||
|
||||
if ($form->isValid())
|
||||
{
|
||||
/* TODO: move these lines into life cycle events */
|
||||
if ($form->isValid()) {
|
||||
// TODO: move these lines into life cycle events
|
||||
$slugifier = new Slugifier();
|
||||
$document->setSlug($slugifier->slugify($document->getTitle()));
|
||||
$document->setCreatedAt(new \DateTime('now'));
|
||||
@ -60,7 +60,12 @@ class DocumentController extends Controller
|
||||
$em->persist($document);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_documentView', array('slug' => $document->getSlug())));
|
||||
return $this->redirect(
|
||||
$this->generateUrl(
|
||||
'KekRozsakFrontBundle_documentView',
|
||||
array('slug' => $document->getSlug())
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,12 +84,10 @@ class DocumentController extends Controller
|
||||
$form = $this->createForm(new DocumentType(), $document);
|
||||
$request = $this->getRequest();
|
||||
|
||||
if ($request->getMethod() == 'POST')
|
||||
{
|
||||
if ($request->getMethod() == 'POST') {
|
||||
$form->bind($request);
|
||||
if ($form->isValid())
|
||||
{
|
||||
/* TODO: move these lines into life cycle events */
|
||||
if ($form->isValid()) {
|
||||
// TODO: move these lines into life cycle events
|
||||
$slugifier = new Slugifier();
|
||||
$document->setSlug($slugifier->slugify($document->getTitle()));
|
||||
// TODO: add updatedAt, updatedBy, updateReason, etc.
|
||||
@ -93,7 +96,12 @@ class DocumentController extends Controller
|
||||
$em->persist($document);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_documentView', array('slug' => $document->getSlug())));
|
||||
return $this->redirect(
|
||||
$this->generateUrl(
|
||||
'KekRozsakFrontBundle_documentView',
|
||||
array('slug' => $document->getSlug())
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,11 +20,11 @@ class EventController extends Controller
|
||||
*/
|
||||
public function viewAction(\DateTime $startDate, Event $event)
|
||||
{
|
||||
if ($event->getGroup() !== null)
|
||||
{
|
||||
if (!$event->getGroup()->isMember($this->get('security.context')->getToken()->getUser()))
|
||||
if ($event->getGroup() !== null) {
|
||||
if (!$event->getGroup()->isMember($this->get('security.context')->getToken()->getUser())) {
|
||||
throw new AccessDeniedException('Ehhez az eseményhez nem csatlakozhatsz, mivel a csoportjának nem vagy tagja.');
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'event' => $event,
|
||||
@ -39,13 +39,15 @@ class EventController extends Controller
|
||||
*/
|
||||
public function joinAction(\DateTime $startDate, Event $event)
|
||||
{
|
||||
if ($event->getGroup() !== null)
|
||||
{
|
||||
if (!$event->getGroup()->isMember($this->get('security.context')->getToken()->getUser()))
|
||||
$user = $this->get('security.context')->getToken()->getUser();
|
||||
|
||||
if ($event->getGroup() !== null) {
|
||||
if (!$event->getGroup()->isMember($user)) {
|
||||
throw new AccessDeniedException('Ehhez az eseményhez nem csatlakozhatsz, mivel a csoportjának nem vagy tagja.');
|
||||
}
|
||||
}
|
||||
|
||||
$event->addAttendee($this->get('security.context')->getToken()->getUser());
|
||||
$event->addAttendee($user);
|
||||
|
||||
$em = $this->getDoctrine()->getEntityManager();
|
||||
$em->persist($event);
|
||||
|
@ -55,18 +55,26 @@ class ForumController extends Controller
|
||||
{
|
||||
// Get the list of posts in the requested topic
|
||||
$postRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumPost');
|
||||
$posts = $postRepo->findBy(array('topic' => $topic), array('createdAt' => 'DESC') /* TODO: , limit, offset */);
|
||||
$posts = $postRepo->findBy(
|
||||
array('topic' => $topic),
|
||||
array('createdAt' => 'DESC')
|
||||
/* TODO: , limit, offset */
|
||||
);
|
||||
|
||||
// Create an empty post object for posting
|
||||
$post = new ForumPost();
|
||||
$form = $this->createForm(new ForumPostType($topicGroup->getId(), $topic->getId()), $post);
|
||||
$form = $this->createForm(
|
||||
new ForumPostType(
|
||||
$topicGroup->getId(),
|
||||
$topic->getId()
|
||||
),
|
||||
$post
|
||||
);
|
||||
|
||||
$request = $this->getRequest();
|
||||
if ($request->getMethod() == 'POST')
|
||||
{
|
||||
if ($request->getMethod() == 'POST') {
|
||||
$form->bind($request);
|
||||
if ($form->isValid())
|
||||
{
|
||||
if ($form->isValid()) {
|
||||
$post->setCreatedAt(new \DateTime('now'));
|
||||
$post->setCreatedBy($this->get('security.context')->getToken()->getUser());
|
||||
$post->setTopic($topic);
|
||||
@ -76,10 +84,15 @@ class ForumController extends Controller
|
||||
$em->persist($topic);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_forumPostList', array(
|
||||
return $this->redirect(
|
||||
$this->generateUrl(
|
||||
'KekRozsakFrontBundle_forumPostList',
|
||||
array(
|
||||
'topicGroupSlug' => $topicGroup->getSlug(),
|
||||
'topicSlug' => $topic->getSlug(),
|
||||
)));
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,9 @@ class GroupController extends Controller
|
||||
*/
|
||||
public function listAction()
|
||||
{
|
||||
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Group');
|
||||
$groupRepo = $this
|
||||
->getDoctrine()
|
||||
->getRepository('KekRozsakFrontBundle:Group');
|
||||
$groups = $groupRepo->findAll(array('name' => 'ASC'));
|
||||
|
||||
return array(
|
||||
@ -75,13 +77,11 @@ class GroupController extends Controller
|
||||
{
|
||||
$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())));
|
||||
}
|
||||
|
||||
if ($group->isRequested($user))
|
||||
{
|
||||
if ($group->isRequested($user)) {
|
||||
return array(
|
||||
'isRequested' => true,
|
||||
'needApproval' => false,
|
||||
@ -93,8 +93,7 @@ class GroupController extends Controller
|
||||
$membership->setUser($user);
|
||||
$membership->setGroup($group);
|
||||
$membership->setMembershipRequestedAt(new \DateTime('now'));
|
||||
if ($group->isOpen())
|
||||
{
|
||||
if ($group->isOpen()) {
|
||||
$membership->setMembershipAcceptedAt(new \DateTime('now'));
|
||||
}
|
||||
|
||||
@ -102,12 +101,9 @@ class GroupController extends Controller
|
||||
$em->persist($membership);
|
||||
$em->flush();
|
||||
|
||||
if ($group->isOpen())
|
||||
{
|
||||
if ($group->isOpen()) {
|
||||
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_groupView', array('slug' => $group->getSlug())));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$message = \Swift_Message::newInstance()
|
||||
->setSubject('Új jelentkező a csoportodban (' . $group->getName() . '): ' . $user->getDisplayName())
|
||||
// TODO: Make this a config parameter!
|
||||
@ -134,11 +130,9 @@ class GroupController extends Controller
|
||||
$form = $this->createForm(new GroupType(), $group);
|
||||
$request = $this->getRequest();
|
||||
|
||||
if ($request->getMethod() == 'POST')
|
||||
{
|
||||
if ($request->getMethod() == 'POST') {
|
||||
$form->bind($request);
|
||||
if ($form->isValid())
|
||||
{
|
||||
if ($form->isValid()) {
|
||||
$slugifier = new Slugifier();
|
||||
$user = $this->get('security.context')->getToken()->getUser();
|
||||
|
||||
@ -155,7 +149,9 @@ class GroupController extends Controller
|
||||
$em->persist($membership);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_groupList'));
|
||||
return $this->redirect(
|
||||
$this->generateUrl('KekRozsakFrontBundle_groupList')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,10 @@ use KekRozsak\SecurityBundle\Entity\User;
|
||||
class Article
|
||||
{
|
||||
/**
|
||||
* The ID of the Article
|
||||
*
|
||||
* @var integer $id
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @ORM\Column(type="integer")
|
||||
@ -31,7 +34,10 @@ class Article
|
||||
}
|
||||
|
||||
/**
|
||||
* The User who created the Article
|
||||
*
|
||||
* @var KekRozsak\SecurityBundle\Entity\User $createdBy
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
|
||||
* @ORM\JoinColumn(name="created_by_id")
|
||||
*/
|
||||
@ -60,7 +66,10 @@ class Article
|
||||
}
|
||||
|
||||
/**
|
||||
* The timestamp when the Article was created
|
||||
*
|
||||
* @var DateTime $createdAt
|
||||
*
|
||||
* @ORM\Column(type="datetime", name="created_at", nullable=false)
|
||||
*/
|
||||
protected $createdAt;
|
||||
@ -88,7 +97,10 @@ class Article
|
||||
}
|
||||
|
||||
/**
|
||||
* The title of the Article
|
||||
*
|
||||
* @var string $title
|
||||
*
|
||||
* @ORM\Column(type="string", length=100, nullable=false, unique=true)
|
||||
*/
|
||||
protected $title;
|
||||
@ -116,7 +128,10 @@ class Article
|
||||
}
|
||||
|
||||
/**
|
||||
* The slugified title of the Article
|
||||
*
|
||||
* @var string $slug
|
||||
*
|
||||
* @ORM\Column(type="string", length=100, nullable=false, unique=true)
|
||||
*/
|
||||
protected $slug;
|
||||
@ -144,7 +159,10 @@ class Article
|
||||
}
|
||||
|
||||
/**
|
||||
* The content of the Article
|
||||
*
|
||||
* @var string $text
|
||||
*
|
||||
* @ORM\Column(type="text", nullable=false)
|
||||
*/
|
||||
protected $text;
|
||||
@ -172,7 +190,10 @@ class Article
|
||||
}
|
||||
|
||||
/**
|
||||
* TRUE if the article should display on the main mage
|
||||
*
|
||||
* @var boolean $mainPage
|
||||
*
|
||||
* @ORM\Column(type="boolean", name="main_page")
|
||||
*/
|
||||
protected $mainPage;
|
||||
@ -200,7 +221,10 @@ class Article
|
||||
}
|
||||
|
||||
/**
|
||||
* TRUE if the article is viewable by anyone
|
||||
*
|
||||
* @var boolean public
|
||||
*
|
||||
* @ORM\Column(type="boolean", nullable=false)
|
||||
*/
|
||||
protected $public;
|
||||
@ -228,7 +252,10 @@ class Article
|
||||
}
|
||||
|
||||
/**
|
||||
* The source of the Article, if any
|
||||
*
|
||||
* @var string $source
|
||||
*
|
||||
* @ORM\Column(type="string", nullable=true)
|
||||
*/
|
||||
protected $source;
|
||||
@ -255,4 +282,3 @@ class Article
|
||||
return $this->source;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,8 @@ class Book
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the Book
|
||||
*
|
||||
* @var integer $id
|
||||
*
|
||||
* @ORM\Id
|
||||
@ -45,6 +47,8 @@ class Book
|
||||
}
|
||||
|
||||
/**
|
||||
* The copies available for this Book
|
||||
*
|
||||
* @var Doctrine\Common\Collections\ArrayCollection $copies
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity="BookCopy", mappedBy="book")
|
||||
@ -72,27 +76,53 @@ class Book
|
||||
return $this->copies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the copies of this Book those are borrowed by someone
|
||||
*
|
||||
* @return Doctrine\Common\Collections\ArrayCollection
|
||||
*/
|
||||
public function getCopiesBorrowed()
|
||||
{
|
||||
return $this->copies->filter(function($copy) {
|
||||
return $this->copies->filter(function($copy)
|
||||
{
|
||||
return ($copy->getBorrower() !== null);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the copies of this Book those are borrowed by $user
|
||||
*
|
||||
* @param \KekRozsak\SecurityBundle\Entity\User $user
|
||||
* @return Doctrine\Common\Collections\ArrayCollection
|
||||
*/
|
||||
public function getCopiesBorrowedByUser(User $user)
|
||||
{
|
||||
return $this->copies->filter(function($copy) use ($user) {
|
||||
return $this->copies->filter(function($copy) use ($user)
|
||||
{
|
||||
return ($copy->getBorrower() == $user);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the copies of this Book those are borrowed by $user, but marked as
|
||||
* returned
|
||||
*
|
||||
* @param \KekRozsak\SecurityBundle\Entity\User $user
|
||||
* @return Doctrine\Common\Collections\ArrayCollection
|
||||
*/
|
||||
public function getCopiesBorrowedReturnedByUser(User $user)
|
||||
{
|
||||
return $this->copies->filter(function($copy) use ($user) {
|
||||
return $this->copies->filter(function($copy) use ($user)
|
||||
{
|
||||
return ($copy->getBorrower() == $user) && ($copy->isBorrowerReturned());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the borrowable copies of this Book
|
||||
*
|
||||
* @return Doctrine\Common\Collections\ArrayCollection
|
||||
*/
|
||||
public function getCopiesBorrowable()
|
||||
{
|
||||
return $this->copies->filter(function($copy) {
|
||||
@ -100,28 +130,51 @@ class Book
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get $user's copies of this Book
|
||||
*
|
||||
* @param \KekRozsak\SecurityBundle\Entity\User $user
|
||||
* @return Doctrine\Common\Collections\ArrayCollection
|
||||
*/
|
||||
public function getUsersCopies(User $user)
|
||||
{
|
||||
return $this->copies->filter(function ($copy) use ($user) {
|
||||
return $this->copies->filter(function ($copy) use ($user)
|
||||
{
|
||||
return ($copy->getOwner() == $user);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get $user's borrowable copies of this Book
|
||||
*
|
||||
* @param \KekRozsak\SecurityBundle\Entity\User $user
|
||||
* @return Doctrine\Common\Collections\ArrayCollection
|
||||
*/
|
||||
public function getUsersCopiesBorrowable(User $user)
|
||||
{
|
||||
return $this->copies->filter(function($copy) use ($user) {
|
||||
return $this->copies->filter(function($copy) use ($user)
|
||||
{
|
||||
return (($copy->getOwner() == $user) && $copy->isBorrowable());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get $user's buyable copies of this Book
|
||||
*
|
||||
* @param \KekRozsak\SecurityBundle\Entity\User $user
|
||||
* @return Doctrine\Common\Collections\ArrayCollection
|
||||
*/
|
||||
public function getUsersCopiesBuyable(User $user)
|
||||
{
|
||||
return $this->copies->filter(function($copy) use ($user) {
|
||||
return $this->copies->filter(function($copy) use ($user)
|
||||
{
|
||||
return (($copy->getOwner() == $user) && $copy->isBuyable());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The author of the Book
|
||||
*
|
||||
* @var string $author
|
||||
*
|
||||
* @ORM\Column(type="string", length=100, nullable=false)
|
||||
@ -136,6 +189,7 @@ class Book
|
||||
*/
|
||||
public function setAuthor($author)
|
||||
{
|
||||
// TODO: Check if null!
|
||||
$this->author = $author;
|
||||
return $this;
|
||||
}
|
||||
@ -151,6 +205,8 @@ class Book
|
||||
}
|
||||
|
||||
/**
|
||||
* The title of the Book
|
||||
*
|
||||
* @var string $title
|
||||
*
|
||||
* @ORM\Column(type="string", length=100, nullable=false)
|
||||
@ -165,6 +221,7 @@ class Book
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
// TODO: Check if null!
|
||||
$this->title = $title;
|
||||
return $this;
|
||||
}
|
||||
@ -180,6 +237,8 @@ class Book
|
||||
}
|
||||
|
||||
/**
|
||||
* The Book's year of publication
|
||||
*
|
||||
* @var integer $year
|
||||
*
|
||||
* @ORM\Column(type="integer", nullable=false)
|
||||
@ -194,6 +253,7 @@ class Book
|
||||
*/
|
||||
public function setYear($year)
|
||||
{
|
||||
// TODO: Check if null!
|
||||
$this->year = $year;
|
||||
return $this;
|
||||
}
|
||||
@ -209,6 +269,7 @@ class Book
|
||||
}
|
||||
|
||||
/**
|
||||
* TRUE if comments can be written about the Book
|
||||
* @var boolean $commentable
|
||||
*
|
||||
* @ORM\Column(type="boolean", nullable=false)
|
||||
@ -216,6 +277,8 @@ class Book
|
||||
protected $commentable;
|
||||
|
||||
/**
|
||||
* Collection of Users who would like to borrow a copy
|
||||
*
|
||||
* @var Doctrine\Common\Collections\ArrayCollection $wouldBorrow
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity="KekRozsak\SecurityBundle\Entity\User")
|
||||
@ -231,6 +294,7 @@ class Book
|
||||
*/
|
||||
public function addWouldBorrow(User $user)
|
||||
{
|
||||
// TODO: Check if null!
|
||||
$this->wouldBorrow->add($user);
|
||||
return $this;
|
||||
}
|
||||
@ -246,7 +310,7 @@ class Book
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if specified user would borrow this book
|
||||
* Check if $user would like to borrow this book
|
||||
*
|
||||
* @param KekRozsak\SecurityBundle\Entity\User $user
|
||||
* @return boolean
|
||||
@ -257,6 +321,8 @@ class Book
|
||||
}
|
||||
|
||||
/**
|
||||
* Collection of Users who would like to buy a copy of this book
|
||||
*
|
||||
* @var Doctrine\Common\Collections\ArrayCollection $wouldBuy
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity="KekRozsak\SecurityBundle\Entity\User")
|
||||
|
@ -30,6 +30,8 @@ class BookCopy
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the BookCopy
|
||||
*
|
||||
* @var integer $id
|
||||
*
|
||||
* @ORM\Id
|
||||
@ -39,6 +41,7 @@ class BookCopy
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* The Book this BookCopy belongs to
|
||||
* @var KekRozsak\FrontBundle\Entity\Book $book
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Book", inversedBy="copies")
|
||||
@ -47,6 +50,8 @@ class BookCopy
|
||||
protected $book;
|
||||
|
||||
/**
|
||||
* The User this BookCopy belongs to
|
||||
*
|
||||
* @var KekRozsak\SecurityBundle\Entity\User $owner
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
|
||||
@ -65,6 +70,8 @@ class BookCopy
|
||||
}
|
||||
|
||||
/**
|
||||
* The owner's comment about this BookCopy's Book
|
||||
*
|
||||
* @var string $ownerComment
|
||||
*
|
||||
* @ORM\Column(type="text", name="owner_comment", nullable=true)
|
||||
@ -72,6 +79,8 @@ class BookCopy
|
||||
protected $ownerComment;
|
||||
|
||||
/**
|
||||
* TRUE if this BookCopy is borrowable
|
||||
*
|
||||
* @var boolean $borrowable
|
||||
*
|
||||
* @ORM\Column(type="boolean", nullable=false)
|
||||
@ -86,6 +95,7 @@ class BookCopy
|
||||
*/
|
||||
public function setBorrowable($borrowable)
|
||||
{
|
||||
// TODO: Check if parameter is boolean!
|
||||
$this->borrowable = $borrowable;
|
||||
return $this;
|
||||
}
|
||||
@ -101,6 +111,8 @@ class BookCopy
|
||||
}
|
||||
|
||||
/**
|
||||
* TRUE if this BookCopy is for sale
|
||||
*
|
||||
* @var boolean $buyable
|
||||
*
|
||||
* @ORM\Column(type="boolean", nullable=false)
|
||||
@ -115,12 +127,13 @@ class BookCopy
|
||||
*/
|
||||
public function setBuyable($buyable)
|
||||
{
|
||||
// Check if parameter is boolean!
|
||||
$this->buyable = $buyable;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get borrowable
|
||||
* Get buyable
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
@ -130,6 +143,8 @@ class BookCopy
|
||||
}
|
||||
|
||||
/**
|
||||
* The User who is currently borrowing this BookCopy, or null
|
||||
*
|
||||
* @var KekRozsak\SecurityBundle\Entity\User $borrower
|
||||
*
|
||||
* @ORM\OneToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
|
||||
@ -147,6 +162,7 @@ class BookCopy
|
||||
}
|
||||
|
||||
/**
|
||||
* TRUE if borrower says he/she returned this Copy to the owner
|
||||
* @var boolean $borrowerReturned
|
||||
*
|
||||
* @ORM\Column(type="boolean", nullable=false, name="borrower_returned")
|
||||
|
@ -25,7 +25,10 @@ class Document
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the Document
|
||||
*
|
||||
* @var integer $id
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @ORM\Column(type="integer")
|
||||
@ -43,7 +46,10 @@ class Document
|
||||
}
|
||||
|
||||
/**
|
||||
* The title of the Document
|
||||
*
|
||||
* @var string $title
|
||||
*
|
||||
* @ORM\Column(type="string", length=150, unique=true, nullable=false)
|
||||
* @Assert\NotBlank()
|
||||
*/
|
||||
@ -72,7 +78,10 @@ class Document
|
||||
}
|
||||
|
||||
/**
|
||||
* The slugified title of this Document
|
||||
*
|
||||
* @var string $slug
|
||||
*
|
||||
* @ORM\Column(type="string", length=150, unique=true, nullable=false)
|
||||
* @Assert\NotBlank()
|
||||
*/
|
||||
@ -101,7 +110,10 @@ class Document
|
||||
}
|
||||
|
||||
/**
|
||||
* The User who created this Document
|
||||
*
|
||||
* @var KekRozsak\SecurityBundle\Entity\User $createdBy
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
|
||||
* @ORM\JoinColumn(name="created_by_id")
|
||||
*/
|
||||
@ -113,13 +125,12 @@ class Document
|
||||
* @param KekRozsak\SecurityBundle\Entity\User $createdBy
|
||||
* @return Document
|
||||
*/
|
||||
public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy)
|
||||
public function setCreatedBy(User $createdBy)
|
||||
{
|
||||
$this->createdBy = $createdBy;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get createdBy
|
||||
*
|
||||
@ -131,7 +142,10 @@ class Document
|
||||
}
|
||||
|
||||
/**
|
||||
* The timestamp when the Document was created
|
||||
*
|
||||
* @var DateTime $createdat
|
||||
*
|
||||
* @ORM\Column(type="datetime", nullable=false, name="created_at")
|
||||
*/
|
||||
protected $createdAt;
|
||||
@ -159,7 +173,10 @@ class Document
|
||||
}
|
||||
|
||||
/**
|
||||
* The content of the Document
|
||||
*
|
||||
* @var string $content
|
||||
*
|
||||
* @ORM\Column(type="text", nullable=false)
|
||||
*/
|
||||
protected $content;
|
||||
@ -198,7 +215,7 @@ class Document
|
||||
* @param KekRozsak\FrontBundle\Entity\Group $group
|
||||
* @return Document
|
||||
*/
|
||||
public function addGroup(\KekRozsak\FrontBundle\Entity\Group $group)
|
||||
public function addGroup(Group $group)
|
||||
{
|
||||
$this->groups[] = $group;
|
||||
return $this;
|
||||
@ -215,7 +232,10 @@ class Document
|
||||
}
|
||||
|
||||
/**
|
||||
* The User who last updated the Document
|
||||
*
|
||||
* @var KekRozsak\SecurityBundle\Entity\User $updatedBy
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
|
||||
*/
|
||||
protected $updatedBy;
|
||||
@ -226,7 +246,7 @@ class Document
|
||||
* @param KekRozsak\SecurityBundle\Entity\User $updatedBy
|
||||
* @return Document
|
||||
*/
|
||||
public function setUpdatedBy(\KekRozsak\SecurityBundle\Entity\User $updatedBy = null)
|
||||
public function setUpdatedBy(User $updatedBy = null)
|
||||
{
|
||||
$this->updatedBy = $updatedBy;
|
||||
return $this;
|
||||
@ -243,7 +263,10 @@ class Document
|
||||
}
|
||||
|
||||
/**
|
||||
* The timestamp the Document was last updated
|
||||
*
|
||||
* @var DateTime $updatedAt
|
||||
*
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
protected $updatedAt;
|
||||
|
@ -7,6 +7,9 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert;
|
||||
|
||||
use KekRozsak\SecurityBundle\Entity\User;
|
||||
use KekRozsak\FrontBundle\Entity\Group;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="events")
|
||||
@ -17,6 +20,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert;
|
||||
class Event
|
||||
{
|
||||
/**
|
||||
* The ID of the Event
|
||||
*
|
||||
* @var integer $id
|
||||
*
|
||||
* @ORM\Id
|
||||
@ -36,6 +41,8 @@ class Event
|
||||
}
|
||||
|
||||
/**
|
||||
* The User who created the Event
|
||||
*
|
||||
* @var KekRozsak\SecurityBundle\Entity\User $createdBy
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
|
||||
@ -49,7 +56,7 @@ class Event
|
||||
* @param KekRozsak\SecurityBundle\Entity\User $createdBy
|
||||
* @return Event
|
||||
*/
|
||||
public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy)
|
||||
public function setCreatedBy(User $createdBy)
|
||||
{
|
||||
$this->createdBy = $createdBy;
|
||||
return $this;
|
||||
@ -66,6 +73,8 @@ class Event
|
||||
}
|
||||
|
||||
/**
|
||||
* The date on which the Event starts
|
||||
*
|
||||
* @var DateTime $startDate
|
||||
*
|
||||
* @ORM\Column(type="date", nullable=true, name="start_date", nullable=false)
|
||||
@ -95,6 +104,8 @@ class Event
|
||||
}
|
||||
|
||||
/**
|
||||
* The date on which the Event ends. May be null if same as $startDate
|
||||
*
|
||||
* @var DateTime $endDate
|
||||
*
|
||||
* @ORM\Column(type="date", nullable=true, name="end_date")
|
||||
@ -107,8 +118,9 @@ class Event
|
||||
* @param DateTime $endDate
|
||||
* @return Event
|
||||
*/
|
||||
public function setEndDate(\DateTime $endDate)
|
||||
public function setEndDate(\DateTime $endDate = null)
|
||||
{
|
||||
// TODO: Check if endDate is later than startDate
|
||||
$this->endDate = $endDate;
|
||||
return $this;
|
||||
}
|
||||
@ -124,6 +136,8 @@ class Event
|
||||
}
|
||||
|
||||
/**
|
||||
* An ArrayCollection of Users who wish to attend on this Event
|
||||
*
|
||||
* @var Doctrine\Common\Collections\ArrayCollection $attendees
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity="KekRozsak\SecurityBundle\Entity\User")
|
||||
@ -137,7 +151,7 @@ class Event
|
||||
* @param KekRozsak\SecurityBundle\Entity\User $attendee
|
||||
* @return Event
|
||||
*/
|
||||
public function addAttendee(\KekRozsak\SecurityBundle\Entity\User $attendee)
|
||||
public function addAttendee(User $attendee)
|
||||
{
|
||||
$this->attendees[] = $attendee;
|
||||
return $this;
|
||||
@ -159,17 +173,21 @@ class Event
|
||||
* @param KekRozsak\SecurityBundle\Entity\User $user
|
||||
* @return boolean
|
||||
*/
|
||||
public function isAttending(\KekRozsak\SecurityBundle\Entity\User $user)
|
||||
public function isAttending(User $user)
|
||||
{
|
||||
$users = $this->attendees->filter(function ($attendee) use ($user) {
|
||||
if ($attendee == $user)
|
||||
$users = $this->attendees->filter(function ($attendee) use ($user)
|
||||
{
|
||||
if ($attendee == $user) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
return ($users->count() != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* The title of the Event
|
||||
*
|
||||
* @var string $title
|
||||
*
|
||||
* @ORM\Column(type="string", length=150)
|
||||
@ -186,6 +204,7 @@ class Event
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
// TODO: Check if empty or null!
|
||||
$this->title = $title;
|
||||
return $this;
|
||||
}
|
||||
@ -201,6 +220,8 @@ class Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Slugified title of the event
|
||||
*
|
||||
* @var string $slug
|
||||
*
|
||||
* @ORM\Column(type="string", length=150)
|
||||
@ -217,6 +238,7 @@ class Event
|
||||
*/
|
||||
public function setSlug($slug)
|
||||
{
|
||||
// TODO: Check if empty or null!
|
||||
$this->slug = $slug;
|
||||
return $this;
|
||||
}
|
||||
@ -232,6 +254,8 @@ class Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Description of the Event
|
||||
*
|
||||
* @var string $description
|
||||
*
|
||||
* @ORM\Column(type="text")
|
||||
@ -248,6 +272,7 @@ class Event
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
// TODO: Check if empty!
|
||||
$this->description = $description;
|
||||
return $this;
|
||||
}
|
||||
@ -275,7 +300,7 @@ class Event
|
||||
* @param KekRozsak\FrontBundle\Entity\Group $group
|
||||
* @return Event
|
||||
*/
|
||||
public function setGroup(\KekRozsak\FrontBundle\Entity\Group $group = null)
|
||||
public function setGroup(Group $group = null)
|
||||
{
|
||||
$this->group = $group;
|
||||
return $this;
|
||||
@ -292,6 +317,8 @@ class Event
|
||||
}
|
||||
|
||||
/**
|
||||
* TRUE if the Event is cancelled
|
||||
*
|
||||
* @var boolean $cancelled
|
||||
*
|
||||
* @ORM\Column(type="boolean", nullable=false)
|
||||
@ -306,6 +333,7 @@ class Event
|
||||
*/
|
||||
public function setCancelled($cancelled = false)
|
||||
{
|
||||
// TODO: Check if parameter is boolean
|
||||
$this->cancelled = $cancelled;
|
||||
return $this;
|
||||
}
|
||||
@ -321,6 +349,8 @@ class Event
|
||||
}
|
||||
|
||||
/**
|
||||
* The time when the Event starts
|
||||
*
|
||||
* @var DateTime $startTime
|
||||
*
|
||||
* @ORM\Column(type="time", nullable=false, name="start_time")
|
||||
@ -350,6 +380,8 @@ class Event
|
||||
}
|
||||
|
||||
/**
|
||||
* The time when the Event ends
|
||||
*
|
||||
* @var DateTime $endTime
|
||||
*
|
||||
* @ORM\Column(type="time", nullable=true, name="end_time")
|
||||
@ -362,8 +394,9 @@ class Event
|
||||
* @param DateTime $endTime
|
||||
* @return Event
|
||||
*/
|
||||
public function setEndTime(\DateTime $endTime)
|
||||
public function setEndTime(\DateTime $endTime = null)
|
||||
{
|
||||
// TODO: Check if endTime is later than startDate + startTime
|
||||
$this->endTime = $endTime;
|
||||
return $this;
|
||||
}
|
||||
@ -408,8 +441,7 @@ class Event
|
||||
*/
|
||||
public function isPast(\DateTime $date = null)
|
||||
{
|
||||
if ($date === null)
|
||||
{
|
||||
if ($date === null) {
|
||||
$date = new \DateTime('now');
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ namespace KekRozsak\FrontBundle\Entity;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
use KekRozsak\FrontBundle\Entity\ForumTopic;
|
||||
use KekRozsak\SecurityBundle\Entity\User;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
@ -14,7 +15,10 @@ use KekRozsak\FrontBundle\Entity\ForumTopic;
|
||||
class ForumPost
|
||||
{
|
||||
/**
|
||||
* The ID of the ForumPost
|
||||
*
|
||||
* @var integer $id
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @ORM\Column(type="integer")
|
||||
@ -32,6 +36,10 @@ class ForumPost
|
||||
}
|
||||
|
||||
/**
|
||||
* The User who created this ForumPost
|
||||
*
|
||||
* @var KekRozsak\SecurityBundle\Entity\User $createBy
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="\KekRozsak\SecurityBundle\Entity\User")
|
||||
* @ORM\JoinColumn(name="created_by_id")
|
||||
*/
|
||||
@ -43,8 +51,9 @@ class ForumPost
|
||||
* @param \KekRozsak\SecurityBundle\Entity\User $createdBy
|
||||
* @return ForumPost
|
||||
*/
|
||||
public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy)
|
||||
public function setCreatedBy(User $createdBy)
|
||||
{
|
||||
// TODO: Check if null!
|
||||
$this->createdBy = $createdBy;
|
||||
return $this;
|
||||
}
|
||||
@ -60,7 +69,10 @@ class ForumPost
|
||||
}
|
||||
|
||||
/**
|
||||
* The timestamp when the ForumPost was created
|
||||
*
|
||||
* @var DateTime $createdAt
|
||||
*
|
||||
* @ORM\Column(type="datetime", name="created_at")
|
||||
*/
|
||||
protected $createdAt;
|
||||
@ -73,6 +85,7 @@ class ForumPost
|
||||
*/
|
||||
public function setCreatedAt(\DateTime $createdAt)
|
||||
{
|
||||
// TODO: Check if null!
|
||||
$this->createdAt = $createdAt;
|
||||
}
|
||||
|
||||
@ -87,7 +100,10 @@ class ForumPost
|
||||
}
|
||||
|
||||
/**
|
||||
* The content of the ForumPost
|
||||
*
|
||||
* @var string $text
|
||||
*
|
||||
* @ORM\Column(type="text", nullable=false)
|
||||
*/
|
||||
protected $text;
|
||||
@ -100,6 +116,7 @@ class ForumPost
|
||||
*/
|
||||
public function setText($text)
|
||||
{
|
||||
// TODO: Check if empty or null!
|
||||
$this->text = $text;
|
||||
return $this;
|
||||
}
|
||||
@ -115,7 +132,10 @@ class ForumPost
|
||||
}
|
||||
|
||||
/**
|
||||
* The ForumTopic in which this ForumPost is
|
||||
*
|
||||
* @var ForumTopic $topic
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="ForumTopic", inversedBy="posts")
|
||||
*/
|
||||
protected $topic;
|
||||
@ -128,9 +148,16 @@ class ForumPost
|
||||
*/
|
||||
public function setTopic(ForumTopic $topic)
|
||||
{
|
||||
// Set this as the last post of $topic, if later than $topic's current
|
||||
// last post
|
||||
$this->topic = $topic;
|
||||
if (!$topic->getLastPost() || ($topic->getLastPost()->getCreatedAt() < $this->createdAt))
|
||||
if (
|
||||
!$topic->getLastPost()
|
||||
|| ($topic->getLastPost()->getCreatedAt() < $this->createdAt)
|
||||
) {
|
||||
$topic->setLastPost($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -151,8 +178,8 @@ class ForumPost
|
||||
*/
|
||||
public function setCreationTime()
|
||||
{
|
||||
if ($this->createdAt === null)
|
||||
if ($this->createdAt === null) {
|
||||
$this->createdAt = new \DateTime('now');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,10 @@ class ForumTopic
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the ForumTopic
|
||||
*
|
||||
* @var integer $id
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @ORM\Column(type="integer")
|
||||
@ -37,7 +40,10 @@ class ForumTopic
|
||||
}
|
||||
|
||||
/**
|
||||
* The User who created this ForumTopic
|
||||
*
|
||||
* @var KekRozsak\SecurityBundle\Entity\User $createdBy
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
|
||||
* @ORM\JoinColumn(name="created_by_id")
|
||||
*/
|
||||
@ -49,8 +55,9 @@ class ForumTopic
|
||||
* @param KekRozsak\SecurityBundle\Entity\User
|
||||
* @return ForumTopic
|
||||
*/
|
||||
public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy)
|
||||
public function setCreatedBy(User $createdBy)
|
||||
{
|
||||
// TODO: Check if null!
|
||||
$this->createdBy = $createdBy;
|
||||
return $this;
|
||||
}
|
||||
@ -65,9 +72,11 @@ class ForumTopic
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The timestamp when the ForumTopic was created
|
||||
*
|
||||
* @var DateTime $createdAt
|
||||
*
|
||||
* @ORM\Column(type="datetime", nullable=false, name="created_at")
|
||||
*/
|
||||
protected $createdAt;
|
||||
@ -80,6 +89,7 @@ class ForumTopic
|
||||
*/
|
||||
public function setCreatedAt(\DateTime $createdAt)
|
||||
{
|
||||
// TODO: Check if not null!
|
||||
$this->createdAt = $createdAt;
|
||||
return $this;
|
||||
}
|
||||
@ -95,7 +105,10 @@ class ForumTopic
|
||||
}
|
||||
|
||||
/**
|
||||
* The ForumTopicGroup to which this ForumTopic belongs
|
||||
*
|
||||
* @var ForumTopicGroup $topicGroup
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="ForumTopicGroup", inversedBy="topics")
|
||||
* @ORM\JoinColumn(name="topic_group_id")
|
||||
*/
|
||||
@ -109,6 +122,7 @@ class ForumTopic
|
||||
*/
|
||||
public function setTopicGroup(ForumTopicGroup $topicGroup)
|
||||
{
|
||||
// TODO: Check if not null!
|
||||
$this->topicGroup = $topicGroup;
|
||||
return $this;
|
||||
}
|
||||
@ -124,7 +138,10 @@ class ForumTopic
|
||||
}
|
||||
|
||||
/**
|
||||
* The slugified title of the ForumTopic
|
||||
*
|
||||
* @var string $slug
|
||||
*
|
||||
* @ORM\Column(type="string", length=100, nullable=false)
|
||||
*/
|
||||
protected $slug;
|
||||
@ -137,6 +154,7 @@ class ForumTopic
|
||||
*/
|
||||
public function setSlug($slug)
|
||||
{
|
||||
// TODO: Check if empty or null!
|
||||
$this->slug = $slug;
|
||||
return $this;
|
||||
}
|
||||
@ -152,7 +170,10 @@ class ForumTopic
|
||||
}
|
||||
|
||||
/**
|
||||
* The title of the ForumTopic
|
||||
*
|
||||
* @var string $title
|
||||
*
|
||||
* @ORM\Column(type="string", length=100, nullable=false)
|
||||
*/
|
||||
protected $title;
|
||||
@ -165,6 +186,7 @@ class ForumTopic
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
// TODO: Check if empty or null!
|
||||
$this->title = $title;
|
||||
return $this;
|
||||
}
|
||||
@ -180,7 +202,10 @@ class ForumTopic
|
||||
}
|
||||
|
||||
/**
|
||||
* The last Post of this ForumTopic, is any
|
||||
*
|
||||
* @var ForumPost $lastPost
|
||||
*
|
||||
* @ORM\OneToOne(targetEntity="ForumPost", cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="last_post_id")
|
||||
*/
|
||||
@ -208,8 +233,11 @@ class ForumTopic
|
||||
}
|
||||
|
||||
/**
|
||||
* The list of all the ForumPosts in this topic
|
||||
*
|
||||
* @var ArrayCollection $topics;
|
||||
* @ORM\OneToMany(targetEntity="ForumPost", mappedBy="topic")
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity="ForumPost", mappedBy="topic", fetch="LAZY")
|
||||
*/
|
||||
protected $posts;
|
||||
|
||||
@ -221,6 +249,7 @@ class ForumTopic
|
||||
*/
|
||||
public function addPost(ForumPost $post)
|
||||
{
|
||||
// TODO: Check if null!
|
||||
$this->posts[] = $post;
|
||||
return $this;
|
||||
}
|
||||
@ -235,4 +264,3 @@ class ForumTopic
|
||||
return $this->posts;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,10 @@ class ForumTopicGroup
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the ForumTopicGroup
|
||||
*
|
||||
* @var integer $id
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @ORM\Column(type="integer")
|
||||
@ -38,7 +41,10 @@ class ForumTopicGroup
|
||||
}
|
||||
|
||||
/**
|
||||
* The User who created this ForumTopicGroup
|
||||
*
|
||||
* @var KekRozsak\SecurityBundle\Entity\User $createdBy
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
|
||||
* @ORM\JoinColumn(name="created_by_id")
|
||||
*/
|
||||
@ -50,8 +56,9 @@ class ForumTopicGroup
|
||||
* @param KekRozsak\SecurityBundle\Entity\User $createdBy
|
||||
* @return ForumTopicGroup
|
||||
*/
|
||||
public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy)
|
||||
public function setCreatedBy(User $createdBy)
|
||||
{
|
||||
// TODO: Check if null!
|
||||
$this->createdBy = $createdBy;
|
||||
return $this;
|
||||
}
|
||||
@ -67,7 +74,10 @@ class ForumTopicGroup
|
||||
}
|
||||
|
||||
/**
|
||||
* The timestamp when this ForumTopicGroup was created
|
||||
*
|
||||
* @var DateTime $createdAt
|
||||
*
|
||||
* @ORM\Column(type="datetime", nullable=false)
|
||||
*/
|
||||
protected $createdAt;
|
||||
@ -80,6 +90,7 @@ class ForumTopicGroup
|
||||
*/
|
||||
public function setCreatedAt(\DateTime $createdAt)
|
||||
{
|
||||
// TODO: Check if null!
|
||||
$this->createdAt = $createdAt;
|
||||
return $this;
|
||||
}
|
||||
@ -95,7 +106,10 @@ class ForumTopicGroup
|
||||
}
|
||||
|
||||
/**
|
||||
* The slugified title of this ForumTopicGroup
|
||||
*
|
||||
* @var string $slug
|
||||
*
|
||||
* @ORM\Column(type="string", length=100, nullable=false, unique=true)
|
||||
*/
|
||||
protected $slug;
|
||||
@ -108,6 +122,7 @@ class ForumTopicGroup
|
||||
*/
|
||||
public function setSlug($slug)
|
||||
{
|
||||
// TODO: Check if empty or null!
|
||||
$this->slug = $slug;
|
||||
return $this;
|
||||
}
|
||||
@ -123,7 +138,10 @@ class ForumTopicGroup
|
||||
}
|
||||
|
||||
/**
|
||||
* The title of this ForumTopicGroup
|
||||
*
|
||||
* @var string $title
|
||||
*
|
||||
* @ORM\Column(type="string", length=100, nullable=false, unique=true)
|
||||
*/
|
||||
protected $title;
|
||||
@ -151,7 +169,10 @@ class ForumTopicGroup
|
||||
}
|
||||
|
||||
/**
|
||||
* The ArrayCollection of ForumTopics that belong to this ForumTopicGroup
|
||||
*
|
||||
* @var ArrayCollection $topics
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity="ForumTopic", mappedBy="topicGroup")
|
||||
*/
|
||||
protected $topics;
|
||||
@ -164,6 +185,7 @@ class ForumTopicGroup
|
||||
*/
|
||||
public function addTopic(ForumTopic $topic)
|
||||
{
|
||||
// TODO: Check if null!
|
||||
$this->topics[] = $topic;
|
||||
return $this;
|
||||
}
|
||||
@ -178,4 +200,3 @@ class ForumTopicGroup
|
||||
return $this->topics;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,10 @@ class Group
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of this Group
|
||||
*
|
||||
* @var integer $id
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @ORM\Column(type="integer")
|
||||
@ -55,7 +58,7 @@ class Group
|
||||
* @param KekRozsak\SecurityBundle\Entity\User $leader
|
||||
* @return Group
|
||||
*/
|
||||
public function setLeader(\KekRozsak\SecurityBundle\Entity\User $leader = null)
|
||||
public function setLeader(User $leader = null)
|
||||
{
|
||||
$this->leader = $leader;
|
||||
return $this;
|
||||
@ -72,8 +75,12 @@ class Group
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of this Group
|
||||
*
|
||||
* @var string $name
|
||||
*
|
||||
* @ORM\Column(type="string", length=50, nullable=false, unique=true)
|
||||
*
|
||||
* @Assert\NotBlank()
|
||||
*/
|
||||
protected $name;
|
||||
@ -86,6 +93,7 @@ class Group
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
// TODO: Check if empty or null!
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
@ -101,7 +109,10 @@ class Group
|
||||
}
|
||||
|
||||
/**
|
||||
* The slugified name of this Group
|
||||
*
|
||||
* @var string $slug
|
||||
*
|
||||
* @ORM\Column(type="string", length=50, nullable=false, unique=true)
|
||||
*/
|
||||
protected $slug;
|
||||
@ -114,6 +125,7 @@ class Group
|
||||
*/
|
||||
public function setSlug($slug)
|
||||
{
|
||||
// TODO: Check if empty or null!
|
||||
$this->slug = $slug;
|
||||
return $this;
|
||||
}
|
||||
@ -129,7 +141,10 @@ class Group
|
||||
}
|
||||
|
||||
/**
|
||||
* The User who created this Group
|
||||
*
|
||||
* @var KekRozsak\SecurityBundle\Entity\User $createdBy
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
|
||||
* @ORM\JoinColumn(name="created_by_id")
|
||||
*/
|
||||
@ -141,7 +156,7 @@ class Group
|
||||
* @param KekRozsak\SecurityBundle\Entity\User $createdBy
|
||||
* @return Group
|
||||
*/
|
||||
public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy)
|
||||
public function setCreatedBy(User $createdBy)
|
||||
{
|
||||
$this->createdBy = $createdBy;
|
||||
return $this;
|
||||
@ -158,7 +173,10 @@ class Group
|
||||
}
|
||||
|
||||
/**
|
||||
* The timestamp when this Group was created
|
||||
*
|
||||
* @var DateTime $createdAt
|
||||
*
|
||||
* @ORM\Column(type="datetime", name="created_at", nullable=false)
|
||||
*/
|
||||
protected $createdAt;
|
||||
@ -171,6 +189,7 @@ class Group
|
||||
*/
|
||||
public function setCreatedAt(\DateTime $createdAt)
|
||||
{
|
||||
// TODO: Check if null!
|
||||
$this->createdAt = $createdAt;
|
||||
return $this;
|
||||
}
|
||||
@ -186,7 +205,11 @@ class Group
|
||||
}
|
||||
|
||||
/**
|
||||
* An ArrayCollection of UserGroupMemberships representing the Group's
|
||||
* members
|
||||
*
|
||||
* @var Doctrine\Common\Collections\ArrayCollection $members
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity="UserGroupMembership", mappedBy="group")
|
||||
*/
|
||||
protected $members;
|
||||
@ -197,8 +220,9 @@ class Group
|
||||
* @param KekRozsak\FrontBundle\Entity\UserGroupMembership $member
|
||||
* @return Group
|
||||
*/
|
||||
public function addMember(\KekRozsak\FrontBundle\Entity\UserGroupMembership $member)
|
||||
public function addMember(UserGroupMembership $member)
|
||||
{
|
||||
// TODO: Check if null!
|
||||
$this->members[] = $member;
|
||||
return $this;
|
||||
}
|
||||
@ -219,10 +243,10 @@ class Group
|
||||
* @param KekRozsak\SecurityBundle\Entity\User $user
|
||||
* @return boolean
|
||||
*/
|
||||
public function isMember(\KekRozsak\SecurityBundle\Entity\User $user)
|
||||
public function isMember(User $user)
|
||||
{
|
||||
return ($this->members->filter(function ($groupMembership) use ($user)
|
||||
{
|
||||
return ($this->members->filter(
|
||||
function ($groupMembership) use ($user) {
|
||||
return (
|
||||
($groupMembership->getUser() == $user)
|
||||
&& (
|
||||
@ -230,8 +254,7 @@ class Group
|
||||
|| ($groupMembership->getMembershipAcceptedAt() !== null)
|
||||
)
|
||||
);
|
||||
}
|
||||
)->count() > 0);
|
||||
})->count() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -240,20 +263,22 @@ class Group
|
||||
* @param KekRozsak\SecurityBundle\Entity\User $user
|
||||
* @return boolean
|
||||
*/
|
||||
public function isRequested(\KekRozsak\SecurityBundle\Entity\User $user)
|
||||
public function isRequested(User $user)
|
||||
{
|
||||
return ($this->members->filter(function ($groupMembership) use ($user)
|
||||
{
|
||||
return ($this->members->filter(
|
||||
function ($groupMembership) use ($user) {
|
||||
return (
|
||||
($groupMembership->getUser() == $user)
|
||||
&& ($groupMembership->getMembershipRequestedAt() !== null)
|
||||
);
|
||||
}
|
||||
)->count() > 0);
|
||||
})->count() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* The description of the Group
|
||||
*
|
||||
* @var string description
|
||||
*
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*/
|
||||
protected $description;
|
||||
@ -281,7 +306,10 @@ class Group
|
||||
}
|
||||
|
||||
/**
|
||||
* TRUE if this Group is open, and anyone can join
|
||||
*
|
||||
* @var boolean open
|
||||
*
|
||||
* @ORM\Column(type="boolean", nullable=false)
|
||||
*/
|
||||
protected $open;
|
||||
@ -309,8 +337,11 @@ class Group
|
||||
}
|
||||
|
||||
/**
|
||||
* An ArrayCollection of Documents that belong to this Group
|
||||
*
|
||||
* @var Doctrine\Common\Collections\ArrayCollection $documents
|
||||
* @ORM\ManyToMany(targetEntity="Document", inversedBy="groups")
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity="Document", inversedBy="groups", fetch="LAZY")
|
||||
* @ORM\JoinTable(name="group_document", inverseJoinColumns={
|
||||
* @ORM\JoinColumn(name="document_id", referencedColumnName="id"),
|
||||
* }, joinColumns={
|
||||
@ -325,8 +356,9 @@ class Group
|
||||
* @param KekRozsak\FrontBundle\Entity\Document $document
|
||||
* @return Group
|
||||
*/
|
||||
public function addDocument(\KekRozsak\FrontBundle\Entity\Document $document)
|
||||
public function addDocument(Document $document)
|
||||
{
|
||||
// TODO: Check if null!
|
||||
$this->documents[] = $document;
|
||||
return $this;
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ namespace KekRozsak\FrontBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
use KekRozsak\SecurityBundle\Entity\User;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="news")
|
||||
@ -11,7 +13,10 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
class News
|
||||
{
|
||||
/**
|
||||
* The ID of this News
|
||||
*
|
||||
* @var integer $id
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @ORM\Column(type="integer")
|
||||
@ -29,7 +34,10 @@ class News
|
||||
}
|
||||
|
||||
/**
|
||||
* The title of this News
|
||||
*
|
||||
* @var string $title
|
||||
*
|
||||
* @ORM\Column(type="string", length=100)
|
||||
*/
|
||||
protected $title;
|
||||
@ -42,6 +50,7 @@ class News
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
// TODO: Check if empty or null!
|
||||
$this->title = $title;
|
||||
return $this;
|
||||
}
|
||||
@ -57,7 +66,10 @@ class News
|
||||
}
|
||||
|
||||
/**
|
||||
* The contents of this News
|
||||
*
|
||||
* @var string $text
|
||||
*
|
||||
* @ORM\Column(type="text", nullable=false)
|
||||
*/
|
||||
protected $text;
|
||||
@ -85,7 +97,10 @@ class News
|
||||
}
|
||||
|
||||
/**
|
||||
* The timestamp when this News was created
|
||||
*
|
||||
* @var DateTime $createdAt
|
||||
*
|
||||
* @ORM\Column(type="datetime", name="created_at", nullable=false)
|
||||
*/
|
||||
protected $createdAt;
|
||||
@ -98,6 +113,7 @@ class News
|
||||
*/
|
||||
public function setCreatedAt(\DateTime $createdAt)
|
||||
{
|
||||
// TODO: Check if null!
|
||||
$this->createdAt = $createdAt;
|
||||
return $this;
|
||||
}
|
||||
@ -113,7 +129,10 @@ class News
|
||||
}
|
||||
|
||||
/**
|
||||
* The User who created this News item
|
||||
*
|
||||
* @var \KekRozsak\SecurityBundle\Entity\User $createdBy
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="\KekRozsak\SecurityBundle\Entity\User")
|
||||
* @ORM\JoinColumn(name="created_by_id")
|
||||
*/
|
||||
@ -125,8 +144,9 @@ class News
|
||||
* @param \KekRozsak\SecurityBundle\Entity\User $createdBy
|
||||
* @return News
|
||||
*/
|
||||
public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy)
|
||||
public function setCreatedBy(User $createdBy)
|
||||
{
|
||||
// TODO: Check if null!
|
||||
$this->createdBy = $createdBy;
|
||||
return $this;
|
||||
}
|
||||
@ -142,6 +162,8 @@ class News
|
||||
}
|
||||
|
||||
/**
|
||||
* TRUE if this News item is public
|
||||
*
|
||||
* @var boolean $public
|
||||
*
|
||||
* @ORM\Column(type="boolean", nullable=false)
|
||||
@ -156,6 +178,7 @@ class News
|
||||
*/
|
||||
public function setPublic($public)
|
||||
{
|
||||
// TODO: Check if parameter is boolean!
|
||||
$this->public = $public;
|
||||
return $this;
|
||||
}
|
||||
@ -165,7 +188,7 @@ class News
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getPublic()
|
||||
public function isPublic()
|
||||
{
|
||||
return $this->public;
|
||||
}
|
||||
|
@ -24,7 +24,10 @@ class UserData
|
||||
}
|
||||
|
||||
/**
|
||||
* The User object this UserData belongs to
|
||||
*
|
||||
* @var KekRozsak\SecurityBundle\Entity\User $user
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="NONE")
|
||||
* @ORM\OneToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User", inversedBy="userData")
|
||||
@ -55,7 +58,10 @@ class UserData
|
||||
}
|
||||
|
||||
/**
|
||||
* TRUE if $user's e-mail address is public
|
||||
*
|
||||
* @var boolean $emailPublic
|
||||
*
|
||||
* @ORM\Column(type="boolean", name="email_public")
|
||||
*/
|
||||
protected $emailPublic;
|
||||
@ -68,6 +74,7 @@ class UserData
|
||||
*/
|
||||
public function setEmailPublic($emailPublic)
|
||||
{
|
||||
// TODO: Check if parameter is boolean!
|
||||
$this->emailPublic = $emailPublic;
|
||||
return $this;
|
||||
}
|
||||
@ -77,13 +84,16 @@ class UserData
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getEmailPublic()
|
||||
public function isEmailPublic()
|
||||
{
|
||||
return $this->emailPublic;
|
||||
}
|
||||
|
||||
/**
|
||||
* The real name of $user
|
||||
*
|
||||
* @var string $realName
|
||||
*
|
||||
* @ORM\Column(type="string", length=100, nullable=true, name="real_name")
|
||||
*/
|
||||
protected $realName;
|
||||
@ -96,6 +106,7 @@ class UserData
|
||||
*/
|
||||
public function setRealName($realName = null)
|
||||
{
|
||||
// TODO: Check if empty!
|
||||
$this->realName = $realName;
|
||||
return $this;
|
||||
}
|
||||
@ -111,7 +122,10 @@ class UserData
|
||||
}
|
||||
|
||||
/**
|
||||
* TRUE is $user's real name is public
|
||||
*
|
||||
* @var boolean $realNamePublic
|
||||
*
|
||||
* @ORM\Column(type="boolean", name="real_name_public")
|
||||
*/
|
||||
protected $realNamePublic;
|
||||
@ -124,6 +138,7 @@ class UserData
|
||||
*/
|
||||
public function setRealNamePublic($realNamePublic = false)
|
||||
{
|
||||
// TODO: Check if parameter is boolean!
|
||||
$this->realNamePublic = $realNamePublic;
|
||||
return $this;
|
||||
}
|
||||
@ -133,13 +148,16 @@ class UserData
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getRealNamePublic()
|
||||
public function isRealNamePublic()
|
||||
{
|
||||
return $this->realNamePublic;
|
||||
}
|
||||
|
||||
/**
|
||||
* The self description of $user
|
||||
*
|
||||
* @var string $selfDescription
|
||||
*
|
||||
* @ORM\Column(type="text", nullable=true, name="self_description")
|
||||
*/
|
||||
protected $selfDescription;
|
||||
@ -167,7 +185,10 @@ class UserData
|
||||
}
|
||||
|
||||
/**
|
||||
* The MSN address of $user
|
||||
*
|
||||
* @var string $msnAddress
|
||||
*
|
||||
* @ORM\Column(type="string", length=100, nullable=true, name="msn_address")
|
||||
*/
|
||||
protected $msnAddress;
|
||||
@ -180,6 +201,7 @@ class UserData
|
||||
*/
|
||||
public function setMsnAddress($msnAddress = null)
|
||||
{
|
||||
// TODO: Check if empty!
|
||||
$this->msnAddress = $msnAddress;
|
||||
return $this;
|
||||
}
|
||||
@ -195,7 +217,10 @@ class UserData
|
||||
}
|
||||
|
||||
/**
|
||||
* TRUE if $user's MSN address is public
|
||||
*
|
||||
* @var boolean $msnAddressPublic
|
||||
*
|
||||
* @ORM\Column(type="boolean", name="msn_address_public")
|
||||
*/
|
||||
protected $msnAddressPublic;
|
||||
@ -208,6 +233,7 @@ class UserData
|
||||
*/
|
||||
public function setMsnAddressPublic($msnAddressPublic)
|
||||
{
|
||||
// TODO: Check if parameter is boolean!
|
||||
$this->msnAddressPublic = $msnAddressPublic;
|
||||
return $this;
|
||||
}
|
||||
@ -217,13 +243,16 @@ class UserData
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getMsnAddressPublic()
|
||||
public function isMsnAddressPublic()
|
||||
{
|
||||
return $this->msnAddressPublic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Google Talk address of $user
|
||||
*
|
||||
* @var string $googleTalk
|
||||
*
|
||||
* @ORM\Column(type="string", length=100, nullable=true, name="google_talk")
|
||||
*/
|
||||
protected $googleTalk;
|
||||
@ -236,6 +265,7 @@ class UserData
|
||||
*/
|
||||
public function setGoogleTalk($googleTalk = null)
|
||||
{
|
||||
// TODO: Check if empty!
|
||||
$this->googleTalk = $googleTalk;
|
||||
return $this;
|
||||
}
|
||||
@ -251,7 +281,10 @@ class UserData
|
||||
}
|
||||
|
||||
/**
|
||||
* TRUE if $user's Google Talk address is public
|
||||
*
|
||||
* @var boolean $googleTalkPublic
|
||||
*
|
||||
* @ORM\Column(type="boolean", name="google_talk_public")
|
||||
*/
|
||||
protected $googleTalkPublic;
|
||||
@ -264,6 +297,7 @@ class UserData
|
||||
*/
|
||||
public function setGoogleTalkPublic($googleTalkPublic)
|
||||
{
|
||||
// TODO: Check if parameter is boolean!
|
||||
$this->googleTalkPublic = $googleTalkPublic;
|
||||
return $this;
|
||||
}
|
||||
@ -273,13 +307,16 @@ class UserData
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getGoogleTalkPublic()
|
||||
public function isGoogleTalkPublic()
|
||||
{
|
||||
return $this->googleTalkPublic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Skype name of $user
|
||||
*
|
||||
* @var string $skype
|
||||
*
|
||||
* @ORM\Column(type="string", length=100, nullable=true, name="skype")
|
||||
*/
|
||||
protected $skype;
|
||||
@ -292,6 +329,7 @@ class UserData
|
||||
*/
|
||||
public function setSkype($skype = null)
|
||||
{
|
||||
// TODO: Check if empty!
|
||||
$this->skype = $skype;
|
||||
return $this;
|
||||
}
|
||||
@ -307,7 +345,10 @@ class UserData
|
||||
}
|
||||
|
||||
/**
|
||||
* TRUE if $user's Skype name is public
|
||||
*
|
||||
* @var boolean $skypePublic
|
||||
*
|
||||
* @ORM\Column(type="boolean", name="skype_public")
|
||||
*/
|
||||
protected $skypePublic;
|
||||
@ -320,6 +361,7 @@ class UserData
|
||||
*/
|
||||
public function setSkypePublic($skypePublic)
|
||||
{
|
||||
// TODO: Check if parameter is boolean!
|
||||
$this->skypePublic = $skypePublic;
|
||||
return $this;
|
||||
}
|
||||
@ -329,13 +371,16 @@ class UserData
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getSkypePublic()
|
||||
public function isSkypePublic()
|
||||
{
|
||||
return $this->skypePublic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Phone number of $user
|
||||
*
|
||||
* @var string $phoneNumber
|
||||
*
|
||||
* @ORM\Column(type="string", length=30, nullable=true, name="phone_number")
|
||||
*/
|
||||
protected $phoneNumber;
|
||||
@ -348,6 +393,7 @@ class UserData
|
||||
*/
|
||||
public function setPhoneNumber($phoneNumber = null)
|
||||
{
|
||||
// TODO: Check if empty!
|
||||
$this->phoneNumber = $phoneNumber;
|
||||
return $this;
|
||||
}
|
||||
@ -363,7 +409,10 @@ class UserData
|
||||
}
|
||||
|
||||
/**
|
||||
* TRUE if $user's phone number is public
|
||||
*
|
||||
* @var boolean $phoneNumberPublic
|
||||
*
|
||||
* @ORM\Column(type="boolean", name="phone_number_public")
|
||||
*/
|
||||
protected $phoneNumberPublic;
|
||||
@ -376,6 +425,7 @@ class UserData
|
||||
*/
|
||||
public function setPhoneNumberPublic($phoneNumberPublic)
|
||||
{
|
||||
// TODO: Check if parameter is boolean!
|
||||
$this->phoneNumberPublic = $phoneNumberPublic;
|
||||
return $this;
|
||||
}
|
||||
@ -385,7 +435,7 @@ class UserData
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getPhoneNumberPublic()
|
||||
public function isPhoneNumberPublic()
|
||||
{
|
||||
return $this->phoneNumberPublic;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ namespace KekRozsak\FrontBundle\Entity;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
use KekRozsak\SecurityBundle\Entity\User;
|
||||
use KekRozsak\FrontBundle\Entity\Group;
|
||||
|
||||
/**
|
||||
* KekRozsak\FrontBundle\Entity\UserGroupMembership
|
||||
@ -23,7 +24,10 @@ class UserGroupMembership
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the UserGroupMembership
|
||||
*
|
||||
* @var integer $id
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @ORM\Column(type="integer")
|
||||
@ -41,7 +45,10 @@ class UserGroupMembership
|
||||
}
|
||||
|
||||
/**
|
||||
* The User this membership is applied to
|
||||
*
|
||||
* @var KekRozsak\SecurityBundle\Entity\User $user
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User", inversedBy="groups")
|
||||
* @ORM\JoinColumn(name="user_id")
|
||||
*/
|
||||
@ -53,8 +60,9 @@ class UserGroupMembership
|
||||
* @param KekRozsak\SecurityBundle\Entity\User $user
|
||||
* @return UserGroupMembership
|
||||
*/
|
||||
public function setUser(\KekRozsak\SecurityBundle\Entity\User $user)
|
||||
public function setUser(User $user)
|
||||
{
|
||||
// TODO: Check if not null!
|
||||
$this->user = $user;
|
||||
return $this;
|
||||
}
|
||||
@ -70,7 +78,10 @@ class UserGroupMembership
|
||||
}
|
||||
|
||||
/**
|
||||
* The Group this membership is applied to
|
||||
*
|
||||
* @var KekRozsak\FrontBundle\Entity\Group
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Group", inversedBy="members")
|
||||
* @ORM\JoinColumn(name="group_id")
|
||||
*/
|
||||
@ -82,7 +93,7 @@ class UserGroupMembership
|
||||
* @param KekRozsak\FrontBundle\Entity\Group
|
||||
* @return UserGroupMembership
|
||||
*/
|
||||
public function setGroup(\KekRozsak\FrontBundle\Entity\Group $group)
|
||||
public function setGroup(Group $group)
|
||||
{
|
||||
$this->group = $group;
|
||||
return $this;
|
||||
@ -99,7 +110,10 @@ class UserGroupMembership
|
||||
}
|
||||
|
||||
/**
|
||||
* The timestamp when $user requested membership in $group
|
||||
*
|
||||
* @var DateTime $membershipRequestedAt
|
||||
*
|
||||
* @ORM\Column(type="datetime", name="membership_requested_at")
|
||||
*/
|
||||
protected $membershipRequestedAt;
|
||||
@ -112,6 +126,7 @@ class UserGroupMembership
|
||||
*/
|
||||
public function setMembershipRequestedAt(\DateTime $membershipRequestedAt)
|
||||
{
|
||||
// TODO: Check if null!
|
||||
$this->membershipRequestedAt = $membershipRequestedAt;
|
||||
return $this;
|
||||
}
|
||||
@ -127,7 +142,10 @@ class UserGroupMembership
|
||||
}
|
||||
|
||||
/**
|
||||
* The timestamp when $user's membership was accepted
|
||||
*
|
||||
* @var DateTime membershipAcceptedAt
|
||||
*
|
||||
* @ORM\Column(type="datetime", nullable=true, name="membership_accepted_at")
|
||||
*/
|
||||
protected $membershipAcceptedAt;
|
||||
@ -155,7 +173,10 @@ class UserGroupMembership
|
||||
}
|
||||
|
||||
/**
|
||||
* The User who accepted $user's membership
|
||||
*
|
||||
* @var KekRozsak\SecurityBundle\Entity\User $membershipAcceptedBy
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
|
||||
* @ORM\JoinColumn(name="membership_accepted_by_id")
|
||||
*/
|
||||
|
@ -12,19 +12,29 @@ class Slugifier
|
||||
*/
|
||||
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'))
|
||||
{
|
||||
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
|
||||
}
|
||||
|
||||
$text = strtolower($text);
|
||||
|
||||
$text = preg_replace('~[^-\w]+~', '', $text);
|
||||
|
||||
if (empty($text))
|
||||
{
|
||||
if (empty($text)) {
|
||||
$text = 'n-a';
|
||||
}
|
||||
|
||||
|
@ -30,4 +30,3 @@ class HelpMessageTypeExtension extends AbstractTypeExtension
|
||||
return 'field';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,13 +11,15 @@ class DocumentType extends AbstractType
|
||||
{
|
||||
$builder->add('title', null, array(
|
||||
'label' => 'A dokumentum címe',
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$builder->add('content', 'ckeditor', array(
|
||||
'label' => ' ',
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
/* TODO: possibility to add to other groups! */
|
||||
// TODO: possibility to add to other groups!
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
@ -20,11 +20,14 @@ class ForumPostType extends AbstractType
|
||||
{
|
||||
$builder->add('text', null, array(
|
||||
'label' => ' ',
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$builder->add('topic', 'hidden', array(
|
||||
'property_path' => false,
|
||||
'data' => $this->topic,
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
@ -39,4 +42,3 @@ class ForumPostType extends AbstractType
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,11 +11,13 @@ class GroupType extends AbstractType
|
||||
{
|
||||
$builder->add('name', null, array(
|
||||
'label' => 'A csoport neve',
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$builder->add('description', 'ckeditor', array(
|
||||
'label' => 'A csoport leírása',
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
@ -13,56 +13,79 @@ class UserDataType extends AbstractType
|
||||
'label' => 'Publikus legyen az e-mail címed?',
|
||||
'help' => 'Ha bejelölöd, a kör többi tagja láthatja az e-mail címedet.',
|
||||
'required' => false,
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$builder->add('realName', null, array(
|
||||
'label' => 'Valódi neved',
|
||||
'help' => 'A valódi, polgári neved. Nem kötelező mező, akkor érdemes megadni, ha szeretnéd, hogy a többi tag megtalálhasson különféle közösségi oldalakon.',
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$builder->add('realNamePublic', null, array(
|
||||
'label' => 'Publikus legyen a valódi neved?',
|
||||
'help' => 'Ha bejelölöd, a kör többi tagja láthatja a valódi neved.',
|
||||
'required' => false,
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$builder->add('selfDescription', null, array(
|
||||
'label' => 'Rövid leírás Magadról',
|
||||
'help' => 'Írj ide egy rövid leírást saját magadról. Ez mindenképpen megjelenik majd a profilodon, így a többiek tudhatják, hogy mivel is foglalkozol.',
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$builder->add('msnAddress', null, array(
|
||||
'label' => 'MSN címed',
|
||||
'help' => 'Egy MSN cím, amin elérhető vagy.'
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$builder->add('msnAddressPublic', null, array(
|
||||
'label' => 'Publikus legyen az MSN címed?',
|
||||
'help' => 'Ha bejelölöd, a kör többi tagja láthatja az MSN címedet.',
|
||||
'required' => false,
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$builder->add('googleTalk', null, array(
|
||||
'label' => 'Google Talk címed',
|
||||
'help' => 'Itt egy olyan GMail-es e-mail címet adhatsz meg, amin elérhető vagy a GMail csevegőben.',
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$builder->add('googleTalkPublic', null, array(
|
||||
'label' => 'Publikus legyen a Google Talk címed?',
|
||||
'help' => 'Ha bejelölöd, a kör többi tagja láthatja a Google Talk címedet.',
|
||||
'required' => false,
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$builder->add('skype', null, array(
|
||||
'label' => 'Skype neved',
|
||||
'help' => 'Egy Skype név, amin elérhető vagy.',
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$builder->add('skypePublic', null, array(
|
||||
'label' => 'Publikus legyen a Skype neved?',
|
||||
'help' => 'Ha bejelölöd, a kör többi tagja láthatja a Skype nevedet.',
|
||||
'required' => false,
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$builder->add('phoneNumber', null, array(
|
||||
'label' => 'Telefonszámod',
|
||||
'help' => 'Egy telefonszám, amin elérhető vagy. Programszervezéseknél jól jöhet.',
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$builder->add('phoneNumberPublic', null, array(
|
||||
'label' => 'Publikus legyen a telefonszámod?',
|
||||
'help' => 'Ha bejelölöd, a kör többi tagja láthatja a telefonszámodat.',
|
||||
'required' => false,
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
@ -77,4 +100,3 @@ class UserDataType extends AbstractType
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?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">
|
||||
<services>
|
||||
<service id="kek_rozsak_front.twig_extension.events" class="KekRozsak\FrontBundle\Twig\EventsExtension">
|
||||
<argument type="service" id="doctrine" />
|
||||
|
@ -38,95 +38,123 @@
|
||||
<script type="text/javascript">
|
||||
$('.book-row').click(function() {
|
||||
bookid = 0;
|
||||
if (!$(this).attr('id').match(/^book-\d+$/))
|
||||
if (!$(this).attr('id').match(/^book-\d+$/)) {
|
||||
return false;
|
||||
}
|
||||
bookid = $(this).attr('id').replace(/^book-/, '');
|
||||
bookUrl = Routing.generate('KekRozsakFrontBundle_bookAjaxData', { id: bookid, _format: 'html' });
|
||||
bookCallback = function() {
|
||||
bookCallback = function()
|
||||
{
|
||||
// TODO: Change alert() calls to HTML flashes
|
||||
$('.delete-copy-button').click(function() {
|
||||
$('.delete-copy-button').click(function()
|
||||
{
|
||||
bookid = 0;
|
||||
if (!$(this).attr('id').match(/^delete-copy-button-\d+$/))
|
||||
if (!$(this).attr('id').match(/^delete-copy-button-\d+$/)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bookid = $(this).attr('id').replace(/^delete-copy-button-/, '');
|
||||
url = Routing.generate('KekRozsakFrontBundle_bookDeleteCopy', { id: bookid });
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: url
|
||||
}).done(function() {
|
||||
}).done(function()
|
||||
{
|
||||
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback);
|
||||
}).error(function() {
|
||||
}).error(function()
|
||||
{
|
||||
// TODO: Make this a flash!
|
||||
alert('Nem sikerült törölni');
|
||||
});
|
||||
});
|
||||
|
||||
$('.add-copy-button').click(function() {
|
||||
$('.add-copy-button').click(function()
|
||||
{
|
||||
bookid = 0;
|
||||
if (!$(this).attr('id').match(/^add-copy-button-\d+$/))
|
||||
if (!$(this).attr('id').match(/^add-copy-button-\d+$/)) {
|
||||
return false;
|
||||
}
|
||||
bookid = $(this).attr('id').replace(/^add-copy-button-/, '');
|
||||
url = Routing.generate('KekRozsakFrontBundle_bookAddCopy', { id: bookid });
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: url
|
||||
}).done(function() {
|
||||
}).done(function()
|
||||
{
|
||||
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback);
|
||||
}).error(function() {
|
||||
}).error(function()
|
||||
{
|
||||
// TODO: Make this a flash!
|
||||
alert('Nem sikerült bejegyezni ezt a példányt');
|
||||
});
|
||||
});
|
||||
|
||||
$('.mine-is-borrowable-button, .mine-is-not-borrowable-button').click(function() {
|
||||
$('.mine-is-borrowable-button, .mine-is-not-borrowable-button').click(function()
|
||||
{
|
||||
bookid = 0;
|
||||
if (!$(this).attr('id').match(/^mine-is-(not-)?borrowable-button-\d+$/))
|
||||
if (!$(this).attr('id').match(/^mine-is-(not-)?borrowable-button-\d+$/)) {
|
||||
return false;
|
||||
}
|
||||
isBorrowable = ($(this).attr('id').match(/^mine-is-not-borrowable-button-\d+$/)) ? 0 : 1;
|
||||
bookid = $(this).attr('id').replace(/^mine-is-(not-)?borrowable-button-/, '');
|
||||
url = Routing.generate('KekRozsakFrontBundle_bookSetCopyBorrowable', { id: bookid, newValue: isBorrowable });
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: url
|
||||
}).done(function() {
|
||||
}).done(function()
|
||||
{
|
||||
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback);
|
||||
}).error(function() {
|
||||
}).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-for-sale-button, .mine-is-not-for-sale-button').click(function()
|
||||
{
|
||||
bookid = 0;
|
||||
if (!$(this).attr('id').match(/^mine-is-(not-)?for-sale-button-\d+$/))
|
||||
if (!$(this).attr('id').match(/^mine-is-(not-)?for-sale-button-\d+$/)) {
|
||||
return false;
|
||||
}
|
||||
isForSale = ($(this).attr('id').match(/^mine-is-not-for-sale-button-\d+$/)) ? 0 : 1;
|
||||
bookid = $(this).attr('id').replace(/^mine-is-(not-)?for-sale-button-/, '');
|
||||
url = Routing.generate('KekRozsakFrontBundle_bookSetCopyForSale', { id: bookid, newValue: isForSale });
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: url
|
||||
}).done(function() {
|
||||
}).done(function()
|
||||
{
|
||||
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback);
|
||||
}).error(function() {
|
||||
}).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() {
|
||||
$('.want-to-buy-button, .want-to-borrow-button').click(function()
|
||||
{
|
||||
bookid = 0;
|
||||
if (!$(this).attr('id').match(/^want-to-(buy|borrow)-button-\d+$/))
|
||||
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() {
|
||||
}).done(function()
|
||||
{
|
||||
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback);
|
||||
}).error(function() {
|
||||
}).error(function()
|
||||
{
|
||||
alert('Nem sikerült bejegyezni a kérést');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback);
|
||||
});
|
||||
</script>
|
||||
|
@ -33,10 +33,6 @@
|
||||
{% set cur = cur + 1 %}
|
||||
{% set curDow = curDow + 1 %}{% if curDow == 8 %}{% set curDow = 1 %}{% endif %}
|
||||
{% set eventCount = 0 %}
|
||||
{# TODO Check if an event occurs on this date:
|
||||
(event.startDate = this day AND event.endDate is NULL)
|
||||
OR (event.startDate <= this day AND evend.endDate >= this day)
|
||||
#}
|
||||
<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>
|
||||
|
@ -4,21 +4,20 @@
|
||||
<span id="profil-mutato" class="gomb">[avatar] {{ app.user.displayName }}</span>
|
||||
<div id="profil-box">
|
||||
<div id="profil-belso">
|
||||
[avatar]
|
||||
<span class="avatar">[avatar]</span>
|
||||
{{ 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 />
|
||||
<dl>
|
||||
<dt>Csoportjaim</dt>
|
||||
{% for group in app.user.groups %}
|
||||
{% 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 %}
|
||||
{% 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>
|
||||
|
||||
<dl><a href="{{ path('KekRozsakFrontBundle_forumTopicGroupList') }}">Fórum</a></dl>
|
||||
<dd><a href="{{ path('KekRozsakFrontBundle_forumTopicGroupList') }}">Fórum</a></dd>
|
||||
|
||||
<dt>Üzenetek</dt>
|
||||
</dl>
|
||||
|
@ -4,7 +4,8 @@
|
||||
{% block title %} - Csoport létrehozása{% endblock %}
|
||||
{% block content %}
|
||||
<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_widget(form) }}
|
||||
<button type="submit">Létrehozás</button>
|
||||
|
@ -2,9 +2,6 @@
|
||||
#}
|
||||
{% extends 'KekRozsakFrontBundle:Default:main_template.html.twig' %}
|
||||
{% block title %} - {{ group.name }}{% endblock %}
|
||||
{% block additional_css %}
|
||||
<link rel="stylesheet" href="{{ asset('css/group.css') }}" type="text/css" />
|
||||
{% endblock additional_css %}
|
||||
{% block content %}
|
||||
<ul id="submenu">
|
||||
<li><a href="{{ path('KekRozsakFrontBundle_groupMembers', {slug: group.slug}) }}">Tagok</a></li>
|
||||
|
@ -53,9 +53,3 @@
|
||||
});
|
||||
</script>
|
||||
{% endblock bottomscripts %}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -2,9 +2,6 @@
|
||||
#}
|
||||
{% extends 'KekRozsakFrontBundle:Default:main_template.html.twig' %}
|
||||
{% block title %} - {{ group.name }}{% endblock %}
|
||||
{% block additional_css %}
|
||||
<link rel="stylesheet" href="{{ asset('css/group.css') }}" type="text/css" />
|
||||
{% endblock additional_css %}
|
||||
{% block content %}
|
||||
<ul id="submenu">
|
||||
<li><a href="{{ path('KekRozsakFrontBundle_groupView', {slug: group.slug}) }}">Leírás</a></li>
|
||||
@ -18,4 +15,4 @@
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
{% endblock content %}
|
||||
|
@ -24,13 +24,34 @@ class TwigBBExtension extends \Twig_Extension
|
||||
|
||||
public function bbdecode($sentence)
|
||||
{
|
||||
$sentence = htmlspecialchars($sentence, ENT_NOQUOTES);
|
||||
$sentence = str_replace(array("\r\n", "\n", "\r"), "<br />", $sentence);
|
||||
$sentence = preg_replace('/\\[u\\](.*?)\\[\\/u\\]/im', '<span class="u">\\1</span>', $sentence);
|
||||
$sentence = preg_replace('/\\[b\\](.*?)\\[\\/b\\]/im', '<span class="b">\\1</span>', $sentence);
|
||||
$sentence = preg_replace('/\\[i\\](.*?)\\[\\/i\\]/im', '<span class="i">\\1</span>', $sentence);
|
||||
while (preg_match('/\\[img( (ns|name)="[^"]+"){1,}\\]/i', $sentence, $m, PREG_OFFSET_CAPTURE))
|
||||
{
|
||||
$sentence = preg_replace(
|
||||
'/\\[i\\](.*?)\\[\\/i\\]/im',
|
||||
'<span class="i">\\1</span>',
|
||||
preg_replace(
|
||||
'/\\[b\\](.*?)\\[\\/b\\]/im',
|
||||
'<span class="b">\\1</span>',
|
||||
preg_replace(
|
||||
'/\\[u\\](.*?)\\[\\/u\\]/im',
|
||||
'<span class="u">\\1</span>',
|
||||
str_replace(
|
||||
array("\r\n", "\n", "\r"),
|
||||
"<br />",
|
||||
htmlspecialchars($sentence, ENT_NOQUOTES)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$m = array();
|
||||
|
||||
while (
|
||||
preg_match(
|
||||
'/\\[img( (ns|name)="[^"]+"){1,}\\]/i',
|
||||
$sentence,
|
||||
$m,
|
||||
PREG_OFFSET_CAPTURE
|
||||
)
|
||||
) {
|
||||
$start = $m[0][1];
|
||||
$len = strlen($m[0][0]);
|
||||
$full_tag = $m[0][0];
|
||||
@ -38,38 +59,59 @@ class TwigBBExtension extends \Twig_Extension
|
||||
$ns = (preg_match('/ ns="([^"]+)"/', $full_tag, $ns)) ? trim($ns[1]) : '';
|
||||
$name = (preg_match('/ name="([^"]+)"/', $full_tag, $name)) ? trim($name[1]) : '';
|
||||
|
||||
if ($name == '')
|
||||
{
|
||||
if ($name == '') {
|
||||
$sentence = substr_replace($sentence, 'Hibás kép', $start, $len);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// TODO: Thumbnailing!
|
||||
$sentence = substr_replace($sentence, '<img src="' . $this->container->get('templating.helper.assets')->getUrl('upload/images/' . (($ns == '') ? '' : $ns . '/') . $name) . '" alt="" />', $start, $len);
|
||||
$sentence = substr_replace(
|
||||
$sentence,
|
||||
'<img src="'
|
||||
. $this
|
||||
->container
|
||||
->get('templating.helper.assets')
|
||||
->getUrl(
|
||||
'upload/images/'
|
||||
. (($ns == '') ? '' : $ns . '/')
|
||||
. $name
|
||||
)
|
||||
. '" alt="" />',
|
||||
$start,
|
||||
$len
|
||||
);
|
||||
}
|
||||
}
|
||||
while (preg_match('/\\[link( (url)="[^"]+"){1,}\\](?P<content>.*?)\\[\\/link\\]/i', $sentence, $m, PREG_OFFSET_CAPTURE))
|
||||
{
|
||||
|
||||
while (
|
||||
preg_match(
|
||||
'/\\[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))
|
||||
{
|
||||
if (array_key_exists('content', $m)) {
|
||||
$content = trim($m['content'][0]);
|
||||
}
|
||||
|
||||
if (($url == '') || ($content == ''))
|
||||
{
|
||||
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);
|
||||
} else {
|
||||
$sentence = substr_replace(
|
||||
$sentence,
|
||||
'<a href="'
|
||||
. $url
|
||||
. '" target="_blank">'
|
||||
. $content
|
||||
. '</a>',
|
||||
$start,
|
||||
$len
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $sentence;
|
||||
}
|
||||
|
||||
@ -78,4 +120,3 @@ class TwigBBExtension extends \Twig_Extension
|
||||
return 'twig_bb';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,12 +25,9 @@ class DefaultController extends Controller
|
||||
$request = $this->getRequest();
|
||||
$session = $request->getSession();
|
||||
|
||||
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR))
|
||||
{
|
||||
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
|
||||
$error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
|
||||
$session->remove(SecurityContext::AUTHENTICATION_ERROR);
|
||||
}
|
||||
@ -64,8 +61,7 @@ class DefaultController extends Controller
|
||||
public function registrationAction()
|
||||
{
|
||||
$user = $this->get('security.context')->getToken()->getUser();
|
||||
if ($user instanceof UserInterface)
|
||||
{
|
||||
if ($user instanceof UserInterface) {
|
||||
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_homepage'));
|
||||
}
|
||||
|
||||
@ -73,19 +69,29 @@ class DefaultController extends Controller
|
||||
$form = $this->createForm(new UserType(true), $user);
|
||||
$request = $this->getRequest();
|
||||
|
||||
if ($request->getMethod() == 'POST')
|
||||
{
|
||||
if ($request->getMethod() == 'POST') {
|
||||
$form->bind($request);
|
||||
|
||||
if ($form->isValid(array('registration')))
|
||||
{
|
||||
if ($form->isValid(array('registration'))) {
|
||||
$roleRepo = $this->getDoctrine()->getRepository('KekRozsakSecurityBundle:Role');
|
||||
$defaultRoles = $roleRepo->findByDefault(true);
|
||||
|
||||
$user->setRegisteredAt(new \DateTime('now'));
|
||||
$user->setPassword($this->get('security.encoder_factory')->getEncoder($user)->encodePassword($user->getPassword(), $user->getSalt()));
|
||||
foreach ($defaultRoles as $role)
|
||||
$user->setPassword(
|
||||
$this
|
||||
->get('security.encoder_factory')
|
||||
->getEncoder($user)
|
||||
->encodePassword(
|
||||
$user->getPassword(),
|
||||
$user->getSalt()
|
||||
)
|
||||
);
|
||||
|
||||
/* Add default Roles */
|
||||
foreach ($defaultRoles as $role) {
|
||||
$user->addRole($role);
|
||||
}
|
||||
|
||||
$em = $this->getDoctrine()->getEntityManager();
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
@ -98,14 +104,22 @@ class DefaultController extends Controller
|
||||
|
||||
$message = \Swift_Message::newInstance()
|
||||
->setSubject('Új jelentkező')
|
||||
// TODO: Make this a config parameter!
|
||||
// TODO: Make the next two config parameters!
|
||||
->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)));
|
||||
->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'));
|
||||
return $this->redirect(
|
||||
$this->generateUrl(
|
||||
'KekRozsakSecurityBundle_reg_success'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,10 @@ use KekRozsak\SecurityBundle\Entity\User;
|
||||
class Role implements RoleInterface
|
||||
{
|
||||
/**
|
||||
* The ID of the Role
|
||||
*
|
||||
* @var integer $id
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @ORM\Column(type="integer")
|
||||
@ -34,7 +37,10 @@ class Role implements RoleInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* The role name of the Role
|
||||
*
|
||||
* @var string name
|
||||
*
|
||||
* @ORM\Column(type="string", length=50, unique=true, nullable=false)
|
||||
*/
|
||||
protected $name;
|
||||
@ -47,6 +53,7 @@ class Role implements RoleInterface
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
// TODO: Check if null or empty!
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
@ -62,7 +69,10 @@ class Role implements RoleInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* TRUE if this Role is automatically added to newly registered Users
|
||||
*
|
||||
* @var boolean $default
|
||||
*
|
||||
* @ORM\Column(type="boolean", nullable=false)
|
||||
*/
|
||||
protected $default;
|
||||
@ -74,12 +84,16 @@ class Role implements RoleInterface
|
||||
*/
|
||||
public function setDefault($default)
|
||||
{
|
||||
// TODO: Check if parameter is boolean!
|
||||
$this->default = $default;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The description of this Role
|
||||
*
|
||||
* @var text description
|
||||
*
|
||||
* @ORM\Column(type="string", length=150, nullable=true)
|
||||
*/
|
||||
protected $description;
|
||||
@ -114,7 +128,7 @@ class Role implements RoleInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Short description
|
||||
* Short description of the Role (e.g readable name)
|
||||
*
|
||||
* @var string shortDescription
|
||||
*
|
||||
@ -130,6 +144,7 @@ class Role implements RoleInterface
|
||||
*/
|
||||
public function setShortDescription($shortDescription)
|
||||
{
|
||||
// TODO: Check if empty or null!
|
||||
$this->shortDescription = $shortDescription;
|
||||
return $this;
|
||||
}
|
||||
@ -145,7 +160,9 @@ class Role implements RoleInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* List of inherited Roles
|
||||
* List of inherited Roles. Required for RoleHierarchy
|
||||
*
|
||||
* @var Doctrine\Common\Collections\ArrayCollection $inheritedRoles
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity="Role", fetch="LAZY")
|
||||
* @ORM\JoinTable(name="role_hierarchy", joinColumns={
|
||||
@ -166,4 +183,3 @@ class Role implements RoleInterface
|
||||
return $this->inheritedRoles;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert;
|
||||
|
||||
use KekRozsak\FrontBundle\Entity\UserData;
|
||||
use KekRozsak\FrontBundle\Entity\UserGroupMembership;
|
||||
use KekRozsak\SecurityBundle\Entity\Role;
|
||||
|
||||
/**
|
||||
* KekRozsak\SecurityBundle\Entity\User
|
||||
@ -29,7 +30,10 @@ class User implements UserInterface, AdvancedUserInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the User
|
||||
*
|
||||
* @var integer $id
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @ORM\Column(type="integer")
|
||||
@ -47,7 +51,10 @@ class User implements UserInterface, AdvancedUserInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* The login name of the User
|
||||
*
|
||||
* @var string $username
|
||||
*
|
||||
* @ORM\Column(type="string", length=50, nullable=false, unique=true)
|
||||
* @Assert\NotBlank(groups="registration")
|
||||
*/
|
||||
@ -61,6 +68,7 @@ class User implements UserInterface, AdvancedUserInterface
|
||||
*/
|
||||
public function setUsername($username)
|
||||
{
|
||||
// TODO: check if null or empty!
|
||||
$this->username = $username;
|
||||
return $this;
|
||||
}
|
||||
@ -76,7 +84,10 @@ class User implements UserInterface, AdvancedUserInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* The encrypted password of the User
|
||||
*
|
||||
* @var string $password
|
||||
*
|
||||
* @ORM\Column(type="string", length=50, nullable=false)
|
||||
* @Assert\NotBlank(groups="registration")
|
||||
*/
|
||||
@ -105,7 +116,10 @@ class User implements UserInterface, AdvancedUserInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* The display name of the User
|
||||
*
|
||||
* @var string $displayName
|
||||
*
|
||||
* @ORM\Column(type="string", length=50, unique=true, name="display_name")
|
||||
*/
|
||||
protected $displayName;
|
||||
@ -118,6 +132,7 @@ class User implements UserInterface, AdvancedUserInterface
|
||||
*/
|
||||
public function setDisplayName($displayName)
|
||||
{
|
||||
// TODO: Check if empty or null!
|
||||
$this->displayName = $displayName;
|
||||
return $this;
|
||||
}
|
||||
@ -133,7 +148,10 @@ class User implements UserInterface, AdvancedUserInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* The e-mail address of the User
|
||||
*
|
||||
* @var string $email
|
||||
*
|
||||
* @ORM\Column(type="string", length=100, nullable=false, unique=true)
|
||||
*/
|
||||
protected $email;
|
||||
@ -146,6 +164,7 @@ class User implements UserInterface, AdvancedUserInterface
|
||||
*/
|
||||
public function setEmail($email)
|
||||
{
|
||||
// TODO: Check if empty or null!
|
||||
$this->email = $email;
|
||||
return $this;
|
||||
}
|
||||
@ -161,7 +180,10 @@ class User implements UserInterface, AdvancedUserInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* The timestamp when the user registered
|
||||
*
|
||||
* @var DateTime $registeredAt
|
||||
*
|
||||
* @ORM\Column(type="datetime", nullable=false, name="registered_at")
|
||||
*/
|
||||
protected $registeredAt;
|
||||
@ -189,7 +211,10 @@ class User implements UserInterface, AdvancedUserInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* The User who accepted this User's registration
|
||||
*
|
||||
* @var User acceptedBy
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="User")
|
||||
* @ORM\JoinColumn(name="accepted_by_id")
|
||||
*/
|
||||
@ -218,7 +243,10 @@ class User implements UserInterface, AdvancedUserInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* The timestamp when the User logged in last time
|
||||
*
|
||||
* @var DateTime $lastLoginAt
|
||||
*
|
||||
* @ORM\Column(type="datetime", nullable=true, name="last_login_at")
|
||||
*/
|
||||
protected $lastLoginAt;
|
||||
@ -246,12 +274,14 @@ class User implements UserInterface, AdvancedUserInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* The UserData object for this User
|
||||
*
|
||||
* @var \KekRozsak\FrontBundle\Entity\UserData $userData
|
||||
*
|
||||
* @ORM\OneToOne(targetEntity="KekRozsak\FrontBundle\Entity\UserData", fetch="LAZY", cascade={"persist"}, mappedBy="user")
|
||||
*/
|
||||
protected $userData;
|
||||
|
||||
|
||||
/**
|
||||
* Set userData
|
||||
*
|
||||
@ -276,7 +306,11 @@ class User implements UserInterface, AdvancedUserInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* The Group memberships of this User represented by UserGroupMembership
|
||||
* objects
|
||||
*
|
||||
* @var Doctrine\Common\Collections\ArrayCollection $groups
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity="KekRozsak\FrontBundle\Entity\UserGroupMembership", mappedBy="user")
|
||||
* @ORM\JoinColumn(referencedColumnName="user_id")
|
||||
*/
|
||||
@ -288,8 +322,9 @@ class User implements UserInterface, AdvancedUserInterface
|
||||
* @param KekRozsak\FrontBundle\Entity\UserGroupMembership $group
|
||||
* @return User
|
||||
*/
|
||||
public function addGroup(\KekRozsak\FrontBundle\Entity\UserGroupMembership $group)
|
||||
public function addGroup(UserGroupMembership $group)
|
||||
{
|
||||
// TODO: Check if null!
|
||||
$this->groups[] = $group;
|
||||
return $this;
|
||||
}
|
||||
@ -305,7 +340,10 @@ class User implements UserInterface, AdvancedUserInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* The Roles belonging to this User
|
||||
*
|
||||
* @var Doctrine\Common\Collections\ArrayCollection $roles
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity="Role")
|
||||
*/
|
||||
protected $roles;
|
||||
@ -316,8 +354,9 @@ class User implements UserInterface, AdvancedUserInterface
|
||||
* @param KekRozsak\SecurityBundle\Entity\Role $role
|
||||
* @return User
|
||||
*/
|
||||
public function addRole(\KekRozsak\SecurityBundle\Entity\Role $role)
|
||||
public function addRole(Role $role)
|
||||
{
|
||||
// TODO: Check if null!
|
||||
$this->roles[] = $role;
|
||||
return $this;
|
||||
}
|
||||
@ -334,7 +373,7 @@ class User implements UserInterface, AdvancedUserInterface
|
||||
|
||||
/**
|
||||
* Get all roles, for UserInterface implementation. To get the
|
||||
* collection, use getRolesCollection() instead
|
||||
* ArrayCollection, use getRolesCollection() instead
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -347,8 +386,9 @@ class User implements UserInterface, AdvancedUserInterface
|
||||
|
||||
public function getSalt()
|
||||
{
|
||||
/* As we use crypt() to encode passwords, salt is always the
|
||||
* same as password
|
||||
/*
|
||||
* As we use crypt() to encode passwords, salt is always the same as the
|
||||
* password
|
||||
*/
|
||||
return $this->password;
|
||||
}
|
||||
|
@ -22,7 +22,9 @@ class UserType extends AbstractType
|
||||
'label' => 'Felhasználónév',
|
||||
'read_only' => (!$this->_registration),
|
||||
'help' => 'Ezt fogod használni az oldalra való bejelentkezéshez. Jelszavadhoz hasonlóan kezeld bizalmasan! Jelentkezés után nem lehet megváltoztatni!',
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$builder->add('password', 'repeated', array(
|
||||
'type' => 'password',
|
||||
'second_name' => 'confirm',
|
||||
@ -32,28 +34,33 @@ class UserType extends AbstractType
|
||||
'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)
|
||||
{
|
||||
)
|
||||
);
|
||||
|
||||
if (!$this->_registration) {
|
||||
$builder->add('userData', new UserDataType(), array(
|
||||
'label' => 'Egyéb adatok',
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
)
|
||||
);
|
||||
} 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.',
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,10 +74,11 @@ class UserType extends AbstractType
|
||||
$opts = array(
|
||||
'data_class' => 'KekRozsak\SecurityBundle\Entity\User',
|
||||
);
|
||||
if ($this->_registration)
|
||||
|
||||
if ($this->_registration) {
|
||||
$opts['validation_groups'] = array('registration');
|
||||
}
|
||||
|
||||
$resolver->setDefaults($opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?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">
|
||||
<services>
|
||||
<service id="kek_rozsak_security.encoder.crypt" class="KekRozsak\SecurityBundle\Service\CryptEncoder">
|
||||
</service>
|
||||
|
@ -2,7 +2,6 @@
|
||||
namespace KekRozsak\SecurityBundle\Security;
|
||||
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Bridge\Doctrine\RegistryInterface;
|
||||
|
@ -21,14 +21,22 @@ class UserDataSpanExtension extends \Twig_Extension
|
||||
public function getFilters()
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (!is_object($this->_securityContext->getToken()) || !is_object($this->_securityContext->getToken()->getUser()))
|
||||
if (
|
||||
!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>';
|
||||
}
|
||||
@ -38,4 +46,3 @@ class UserDataSpanExtension extends \Twig_Extension
|
||||
return 'twig_userdataspan';
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user