/** * @param Group $group * @return \Doctrine\ORM\Query */ public function getUnassignedUsersQueryByGroup(GroupSection $section) { $ids = array(0); foreach ($section->getUsers() as $user) { $ids[] = $user->getId(); } $qb = $this->getEntityManager()->createQueryBuilder(); return $qb->select('u')->from('CivixCoreBundle:User', 'u')->leftJoin('u.groups', 'ug')->where($qb->expr()->notIn('u.id', $ids))->andWhere('ug.group = :group')->setParameter('group', $section->getGroup())->orderBy('u.firstName')->getQuery(); }
public function getUsers() { $this->__load(); return parent::getUsers(); }
/** * @Route("/remove-user/{id}/{user_id}", name="civix_front_group_sections_remove_user") * @ParamConverter("section", class="CivixCoreBundle:GroupSection", options={"id" = "id"}) * @ParamConverter("user", class="CivixCoreBundle:User", options={"id" = "user_id"}) */ public function removeUserAction(Request $request, GroupSection $section, User $user) { if (!$this->checkSubscriptionPackage()) { $this->get('session')->getFlashBag()->add('danger', 'Group sections are not available for this subscription'); return $this->redirect($this->generateUrl('civix_front_group_subscription_index')); } if ($section->getGroup() !== $this->getUser() || $request->get('token') !== $this->getToken()) { throw new AccessDeniedHttpException(); } $manager = $this->getDoctrine()->getManager(); $section->getUsers()->removeElement($user); $manager->flush(); return $this->redirect($this->generateUrl('civix_front_group_sections_view', array('id' => $section->getId()))); }