/**
  * @Route("/new", name="admin_group_new")
  * @Template()
  */
 public function newAction()
 {
     $group = new Group();
     $group->setGroupType('dynamic');
     $res = $this->process($group);
     if ($res instanceof RedirectResponse) {
         return $res;
     }
     return array('form' => $res->createView());
 }
 private function recalcUsers(\Club\UserBundle\Entity\Group $group)
 {
     if ($group->getGroupType() == 'static') {
         return;
     }
     $group->resetUsers();
     $this->em->persist($group);
     $users = $this->em->getRepository('ClubUserBundle:Group')->getDynamicUsers($group);
     $group->setUsers($users);
     $this->em->persist($group);
     $this->em->flush();
 }
Пример #3
0
 public function getDynamicUsers(\Club\UserBundle\Entity\Group $group)
 {
     $filter = new \Club\UserBundle\Entity\Filter();
     if ($group->getGender() != null) {
         $attr = new \Club\UserBundle\Entity\FilterAttribute();
         $attr->setAttribute('gender');
         $attr->setValue($group->getGender());
         $filter->addAttributes($attr);
     }
     if ($group->getMaxAge() != null) {
         $attr = new \Club\UserBundle\Entity\FilterAttribute();
         $attr->setAttribute('max_age');
         $attr->setValue($group->getMaxAge());
         $filter->addAttributes($attr);
     }
     if ($group->getMinAge() != null) {
         $attr = new \Club\UserBundle\Entity\FilterAttribute();
         $attr->setAttribute('min_age');
         $attr->setValue($group->getMinAge());
         $filter->addAttributes($attr);
     }
     if ($group->getActiveMember() != null) {
         $attr = new \Club\UserBundle\Entity\FilterAttribute();
         $attr->setAttribute('active');
         $attr->setValue(1);
         $filter->addAttributes($attr);
     }
     return $this->_em->getRepository('ClubUserBundle:User')->getUsers($filter);
 }
Пример #4
0
 public function inGroup(\Club\UserBundle\Entity\Group $group)
 {
     foreach ($this->getGroups() as $g) {
         if ($group->getId() === $g->getId()) {
             return true;
         }
     }
     return false;
 }
Пример #5
0
 public function getQueryByGroup(\Club\UserBundle\Entity\Group $group)
 {
     $qb = $this->getQueryBuilder();
     if ($group->getGender() != '') {
         $qb = $this->filterGender($qb, $group->getGender());
     }
     if ($group->getMinAge() != '') {
         $qb = $this->filterMinAge($qb, $group->getMinAge());
     }
     if ($group->getMaxAge() != '') {
         $qb = $this->filterMaxAge($qb, $group->getMaxAge());
     }
     if ($group->getActiveMember() != '') {
         $qb = $this->filterActive($qb, $group->getActiveMember());
     }
     if (count($group->getLocation()) > 0) {
         $location_arr = array();
         foreach ($group->getLocation() as $location) {
             $location_arr[] = $location->getId();
         }
         $qb = $this->filterLocation($qb, $location_arr);
     }
     return $qb->getQuery();
 }