public function removeUser(\Club\TournamentBundle\Entity\Tournament $tournament, \Club\UserBundle\Entity\User $user) { $attend = $this->em->getRepository('ClubTournamentBundle:Attend')->findOneBy(array('user' => $user->getId(), 'tournament' => $tournament->getId())); $this->em->remove($attend); $this->em->flush(); return $this; }
public function getOpenOrders($limit = 10, \Club\UserBundle\Entity\User $user = null) { $qb = $this->getQueryBuilder()->where('o.paid = false OR o.delivered = false')->andWhere('o.cancelled = false')->setMaxResults($limit)->orderBy('o.updated_at', 'DESC'); if (isset($user)) { $qb->andWhere('o.user = :user')->setParameter('user', $user->getId()); } return $qb->getQuery()->getResult(); }
public function getExpiredSubscriptions(\Club\UserBundle\Entity\User $user = null) { $qb = $this->_em->createQueryBuilder()->select('s')->from('ClubShopBundle:Subscription', 's')->where('s.expire_date <= :expire_date')->andWhere('s.expire_date IS NOT NULL')->setParameter('expire_date', date('Y-m-d H:i:s')); if ($user) { $qb->andWhere('s.user = :user')->setParameter('user', $user->getId()); } return $qb->getQuery()->getResult(); }
public function getUserArray(\Club\UserBundle\Entity\User $user) { $settings = $this->_em->getRepository('ClubUserBundle:UserSetting')->findBy(array('user' => $user->getId())); $res = array(); foreach ($settings as $setting) { $res[$setting->getAttribute()] = $setting->getValue(); } return $res; }
public function getAttended(\Club\UserBundle\Entity\User $user, $limit = 10) { $r = $this->createQueryBuilder('a')->select('a, e')->join('a.event', 'e')->where('a.user = :user')->andWhere('e.start_date < :date')->orderBy('e.start_date', 'DESC')->setMaxResults($limit)->setParameter('user', $user->getId())->setParameter('date', new \DateTime())->getQuery()->getResult(); $events = array(); foreach ($r as $attend) { $events[] = $attend->getEvent(); } return $events; }
public function findActive(\Club\UserBundle\Entity\User $user) { $filter = $this->_em->getRepository('ClubUserBundle:Filter')->findOneBy(array('user' => $user->getId(), 'active' => 1)); if (!$filter) { $filter = $this->createFilter($user); $filter->setActive(1); $this->_em->flush(); } return $filter; }
public function getTeamByUser(\Club\UserBundle\Entity\User $user) { $team = $this->_em->createQueryBuilder()->select('t')->from('ClubMatchBundle:Team', 't')->leftJoin('t.users', 'u')->where('u.id = :user')->setParameter('user', $user->getId())->getQuery()->getOneOrNullResult(); if (!$team) { $team = new \Club\MatchBundle\Entity\Team(); $team->addUser($user); $this->_em->persist($team); } return $team; }
protected function receiveMail(\Club\UserBundle\Entity\User $user) { $s = $this->em->getRepository('ClubUserBundle:UserSetting')->findOneBy(array('user' => $user->getId(), 'attribute' => 'receive_email_on_booking')); if ($s && !$s->getValue()) { return false; } if (!$s && !$this->container->getParameter('club_mail.mail_on_booking')) { return false; } return true; }
public function getAllBetween(\DateTime $start, \DateTime $end = null, \Club\UserBundle\Entity\User $user = null) { $qb = $this->_em->createQueryBuilder()->select('e')->from('ClubEventBundle:Event', 'e')->where('e.start_date >= :start_date')->setParameter('start_date', $start->format('Y-m-d H:i:s')); if ($end != null) { $qb->andWhere('e.start_date <= :stop_date')->setParameter('stop_date', $end->format('Y-m-d H:i:s')); } if ($user != null) { $qb->leftJoin('e.attends', 'a')->andWhere('a.user = :user')->setParameter('user', $user->getId()); } return $qb->getQuery()->getResult(); }
public function banUser(\Club\UserBundle\Entity\User $user) { $ban = new \Club\UserBundle\Entity\Ban(); $ban->setUser($this->security_context->getToken()->getUser()); $ban->setType('user'); $ban->setValue($user->getId()); $ban->setExpireDate(new \DateTime(date('Y-m-d H:i:s', strtotime("+1 month")))); $user->setLocked(1); $this->em->persist($user); $this->em->persist($ban); $this->em->flush(); }
public function getLatest(\Club\UserBundle\Entity\User $user, $limit = 10) { $r = $this->_em->createQueryBuilder()->select('t, mt, m')->from('ClubMatchBundle:Team', 't')->join('t.users', 'u')->join('t.match_teams', 'mt')->join('mt.match', 'm')->where('u.id = :user')->setParameter('user', $user->getId())->setMaxResults($limit)->getQuery()->getResult(); if (!$r) { return false; } $ids = array(); foreach ($r as $team) { foreach ($team->getMatchTeams() as $match_team) { $ids[] = $match_team->getMatch()->getId(); } } return $this->_em->createQueryBuilder()->select('m')->from('ClubMatchBundle:Match', 'm')->where('m.id IN (:ids)')->setParameter('ids', $ids)->getQuery()->getResult(); }
private function addRecipient(\Club\MessageBundle\Entity\Message $message, \Club\UserBundle\Entity\User $user) { if (isset($this->recipients[$user->getId()])) { return; } $this->recipients[$user->getId()] = 1; if (!$user->getProfile()->getProfileEmail()) { return; } $recipient = new \Club\MessageBundle\Entity\MessageRecipient(); $recipient->setMessage($message); $recipient->setUser($user); $recipient->setRecipient($user->getProfile()->getProfileEmail()->getEmailAddress()); $this->em->persist($recipient); }
public function cleanUser(\Club\UserBundle\Entity\User $user) { $profile = $user->getProfile(); foreach ($profile->getProfileEmails() as $email) { if (!strlen($email->getEmailAddress())) { $profile->setProfileEmail(null); $profile->removeProfileEmail($email); $this->em->remove($email); } } if ($profile->getProfilePhone() && $profile->getProfilePhone()->getPhoneNumber() == '') { $this->em->remove($profile->getProfilePhone()); $profile->setProfilePhone(null); } }
public function isAttending(\Club\TournamentBundle\Entity\Tournament $tournament, \Club\UserBundle\Entity\User $user) { return $this->_em->createQueryBuilder()->select('t')->from('ClubTournamentBundle:Tournament', 't')->leftJoin('t.attends', 'a')->where('t.id = :tournament')->andWhere('a.user = :user')->setParameter('tournament', $tournament->getId())->setParameter('user', $user->getId())->getQuery()->getOneOrNullResult(); }
public function getLatest(\Club\UserBundle\Entity\User $user, $limit = 10) { $date = new \DateTime(); return $this->_em->createQueryBuilder()->select('s')->from('ClubTeamBundle:Schedule', 's')->leftJoin('s.users', 'u')->where('u.user = :user')->andWhere('s.first_date < :date')->setParameter('user', $user->getId())->setParameter('date', $date)->setMaxResults($limit)->getQuery()->getResult(); }
public function isAttending(\Club\UserBundle\Entity\User $user) { foreach ($this->getAttends() as $attend) { if ($attend->getUser()->getId() == $user->getId()) { return true; } } return false; }
/** * @Route("/delete/{id}", name="admin_user_delete") * @Template() */ public function deleteAction(\Club\UserBundle\Entity\User $user) { $user->setEnabled(false); $user->setStatus(\Club\UserBundle\Entity\User::TRASHED); $em = $this->getDoctrine()->getManager(); $em->persist($user); $em->flush(); $this->get('club_user.flash')->addNotice(); return $this->redirect($this->generateUrl('admin_user')); }
public function getBoughtByUser(\Club\ShopBundle\Entity\Product $product, \Club\UserBundle\Entity\User $user) { return $this->createQueryBuilder('op')->join('op.order', 'o')->join('o.user', 'u')->join('op.product', 'p')->where('u.id = :user')->andWhere('p.id = :product')->andWhere('o.cancelled = false')->setParameter('user', $user->getId())->setParameter('product', $product->getId())->getQuery()->getResult(); }
public function getGroupsByUser(\Club\UserBundle\Entity\User $user) { $location_str = ''; $used = array(); foreach ($user->getSubscriptions() as $subscription) { foreach ($subscription->getLocation() as $location) { if (!isset($used[$location->getId()])) { $location_str .= 'l.id = ' . $location->getId() . ' OR '; $used[$location->getId()] = 1; } if ($location->getLocation()) { if (!isset($used[$location->getLocation()->getId()])) { $location_str .= 'l.id = ' . $location->getLocation()->getId() . ' OR '; $used[$location->getLocation()->getId()] = 1; } if ($location->getLocation()->getLocation()) { if (!isset($used[$location->getLocation()->getLocation()->getId()])) { $location_str .= 'l.id = ' . $location->getLocation()->getLocation()->getId() . ' OR '; $used[$location->getLocation()->getLocation()->getId()] = 1; } } } } } $subs = $this->_em->getRepository('ClubShopBundle:Subscription')->getActiveSubscriptions($user); $active = !$subs ? false : true; return $this->_em->createQueryBuilder()->select('g')->from('ClubUserBundle:Group', 'g')->leftJoin('g.location', 'l')->andWhere('g.group_type = :type')->andWhere('(g.gender IS NULL OR g.gender=:gender)')->andWhere('(g.min_age IS NULL OR g.min_age <= :min_age)')->andWhere('(g.max_age IS NULL OR g.max_age >= :max_age)')->andWhere('(g.active_member IS NULL OR g.active_member = :active_member)')->andWhere('(' . $location_str . ' l.id IS NULL)')->setParameter('type', 'dynamic')->setParameter('gender', $user->getProfile()->getGender())->setParameter('min_age', $user->getProfile()->getAge())->setParameter('max_age', $user->getProfile()->getAge())->setParameter('active_member', $active)->getQuery()->getResult(); }
private function getAddressByUser(\Club\UserBundle\Entity\User $user) { $addr = $user->getProfile()->getProfileAddress(); $address = new \Club\ShopBundle\Entity\OrderAddress(); $address->setFirstName($user->getProfile()->getFirstName()); $address->setLastName($user->getProfile()->getLastName()); $address->setStreet($addr->getStreet()); $address->setPostalCode($addr->getPostalCode()); $address->setCity($addr->getCity()); $address->setCountry($addr->getCountry()); return $address; }
public function getDistinct(\Club\UserBundle\Entity\User $user) { $q = $this->createQueryBuilder('c')->where('c.user = :user')->groupBy('c.connection')->setParameter('user', $user->getId())->getQuery()->getResult(); return $q; }
private function hasSubscription(\Club\UserBundle\Entity\User $user) { foreach ($user->getSubscriptions() as $subscription) { if ($subscription->hasAttribute('team')) { foreach ($subscription->getLocation() as $location) { if ($location == $this->schedule->getLocation()) { $this->users[] = $user; return true; } foreach ($subscription->getLocation() as $child) { if ($child == $this->schedule->getLocation()) { $this->users[] = $user; return true; } foreach ($child->getChilds() as $child2) { if ($child2 == $this->schedule->getLocation()) { $this->users[] = $user; return true; } } foreach ($child2->getChilds() as $child3) { if ($child3 == $this->schedule->getLocation()) { $this->users[] = $user; return true; } foreach ($child3->getChilds() as $child4) { if ($child4 == $this->schedule->getLocation()) { $this->users[] = $user; return true; } } } } } } } return false; }
public function getByUser(\Club\UserBundle\Entity\User $user) { return $this->_em->createQueryBuilder()->select('r')->from('ClubUserBundle:ResetPassword', 'r')->where('r.user = :user')->andWhere('r.expire_date < :date')->setParameter('user', $user->getId())->setParameter('date', new \DateTime())->getQuery()->getOneOrNullResult(); }
public function getAll(\Club\UserBundle\Entity\User $user) { return $this->createQueryBuilder('b')->leftJoin('b.users', 'u')->andWhere('b.status >= :status')->andWhere('(b.user = :user OR u.id = :user)')->setParameter('user', $user->getId())->setParameter('status', \Club\BookingBundle\Entity\Booking::CONFIRMED)->getQuery()->getResult(); }
/** * @Route("/user/{id}") * @Template() */ public function userAction(\Club\UserBundle\Entity\User $user) { $em = $this->getDoctrine()->getManager(); $orders = $em->getRepository('ClubShopBundle:Order')->findBy(array('user' => $user->getId()), array('id' => 'DESC'), 20); return array('orders' => $orders); }
public function getUserInRange(\Club\UserBundle\Entity\User $user, \DateTime $first, \DateTime $last) { return $this->_em->createQueryBuilder()->select('c')->from('ClubCheckinBundle:Checkin', 'c')->where('c.user = :user')->andWhere('c.created_at >= :first')->andWhere('c.created_at <= :last')->setParameter('user', $user->getId())->setParameter('first', $first)->setParameter('last', $last)->getQuery()->getResult(); }
protected function validateBookingPartnerFuture(\Club\UserBundle\Entity\User $user, \Club\UserBundle\Entity\User $partner) { $date = new \DateTime(); $res = $this->em->createQueryBuilder()->select('COUNT(b)')->from('ClubBookingBundle:Booking', 'b')->leftJoin('b.users', 'u')->where('b.end_date >= :date')->andWhere('b.user = :user')->andWhere('u.id = :partner')->andWhere('b.guest = :is_guest')->setParameter('user', $user->getId())->setParameter('partner', $partner->getId())->setParameter('is_guest', false)->setParameter('date', $date)->getQuery()->getSingleResult(); if ($res[1] >= $this->container->getParameter('club_booking.num_book_same_partner_future')) { return false; } return true; }
public function getByUser(\Club\UserBundle\Entity\User $user) { return $this->_em->createQueryBuilder()->select('l')->from('ClubLogBundle:Log', 'l')->where('l.user = :user')->orderBy('l.id', 'DESC')->setMaxResults(20)->setParameter('user', $user->getId())->getQuery()->getResult(); }