/** * @Route("/remove/{id}", name="civix_front_superuser_group_remove") * @Method({"POST"}) */ public function removeGroupAction(Group $group) { $entityManager = $this->getDoctrine()->getManager(); /** @var $csrfProvider \Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider */ $csrfProvider = $this->get('form.csrf_provider'); if ($csrfProvider->isCsrfTokenValid('remove_group_' . $group->getId(), $this->getRequest()->get('_token'))) { $slugify = new Slugify(); $groupName = $slugify->slugify($group->getOfficialName(), ''); $mailgun = $this->get('civix_core.mailgun')->listremoveAction($groupName); if ($mailgun['http_response_code'] != 200) { $this->get('session')->getFlashBag()->add('error', 'Something went wrong removing the group from mailgun'); return $this->redirect($this->generateUrl('civix_front_superuser_manage_groups')); } try { $this->get('civix_core.customer_manager')->removeCustomer($group); } catch (\Exception $e) { $this->get('session')->getFlashBag()->add('error', $e->getMessage()); return $this->redirect($this->generateUrl('civix_front_superuser_manage_groups')); } $entityManager->getRepository('CivixCoreBundle:Group')->removeGroup($group); $this->get('session')->getFlashBag()->add('notice', 'Group was removed'); } else { $this->get('session')->getFlashBag()->add('error', 'Something went wrong'); } return $this->redirect($this->generateUrl('civix_front_superuser_manage_groups')); }
public function getId() { if ($this->__isInitialized__ === false) { return (int) $this->_identifier["id"]; } $this->__load(); return parent::getId(); }
public function getTotalMembers(Group $group) { $count = $this->getEntityManager()->createQuery(' SELECT COUNT(u) FROM CivixCoreBundle:Group g LEFT JOIN g.users u WHERE g.id = :id ')->setParameter('id', $group->getId())->getSingleScalarResult(); $group->setTotalMembers((int) $count); return $count; }
/** * @Route("/remove/{id}", name="civix_front_superuser_group_remove") * @Method({"POST"}) */ public function removeGroupAction(Group $group) { $entityManager = $this->getDoctrine()->getManager(); /** @var $csrfProvider \Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider */ $csrfProvider = $this->get('form.csrf_provider'); if ($csrfProvider->isCsrfTokenValid('remove_group_' . $group->getId(), $this->getRequest()->get('_token'))) { try { $this->get('civix_core.customer_manager')->removeCustomer($group); } catch (\Exception $e) { $this->get('session')->getFlashBag()->add('error', $e->getMessage()); return $this->redirect($this->generateUrl('civix_front_superuser_manage_groups')); } $entityManager->getRepository('CivixCoreBundle:Group')->removeGroup($group); $this->get('session')->getFlashBag()->add('notice', 'Group was removed'); } else { $this->get('session')->getFlashBag()->add('error', 'Something went wrong'); } return $this->redirect($this->generateUrl('civix_front_superuser_manage_groups')); }
public function noticeGroupsPermissionsChanged(Group $group) { $target = ['id' => $group->getId(), 'type' => 'group']; /** @var User $user */ foreach ($group->getUsers() as $user) { $socialActivity = (new SocialActivity(SocialActivity::TYPE_GROUP_PERMISSIONS_CHANGED, null, $group))->setTarget($target)->setRecipient($user); $this->em->persist($socialActivity); $this->em->flush($socialActivity); $this->pt->addToQueue('sendSocialActivity', [$socialActivity->getId()]); } }
public static function toGroupOwnerData(Group $group) { return ['id' => $group->getId(), 'type' => $group->getType(), 'group_type' => $group->getGroupType(), 'official_title' => $group->getOfficialName(), 'avatar_file_path' => $group->getAvatarFileName()]; }
public function getOpenMicropetition(Group $group) { return $this->getEntityManager()->createQueryBuilder()->select('p, u')->from('CivixCoreBundle:Micropetitions\\Petition', 'p')->leftJoin('p.user', 'u')->where('p.expireAt > :currentDate')->andWhere('p.group = :group')->andWhere('p.publishStatus != 1')->orderBy('p.expireAt', 'DESC')->setParameter('currentDate', new \DateTime())->setParameter('group', $group->getId())->getQuery(); }