Exemplo n.º 1
0
 /**
  * Get a form for adding an admin to a show.
  *
  * @param $identifier
  */
 public function editAdminAction($identifier)
 {
     $show = $this->getEntity($identifier);
     $this->get('camdram.security.acl.helper')->ensureGranted('EDIT', $show);
     $ace = new PendingAccess();
     $ace->setRid($show->getId());
     $ace->setType('show');
     $ace->setIssuer($this->getUser());
     $form = $this->createForm(new PendingAccessType(), $ace, array('action' => $this->generateUrl('post_show_admin', array('identifier' => $identifier))));
     $em = $this->getDoctrine()->getManager();
     $admins = $em->getRepository('ActsCamdramSecurityBundle:User')->getEntityOwners($show);
     $requested_admins = $em->getRepository('ActsCamdramSecurityBundle:User')->getRequestedShowAdmins($show);
     $pending_admins = $em->getRepository('ActsCamdramSecurityBundle:PendingAccess')->findByResource($show);
     return $this->view($form, 200)->setData(array('entity' => $show, 'admins' => $admins, 'requested_admins' => $requested_admins, 'pending_admins' => $pending_admins, 'form' => $form->createView()))->setTemplate('ActsCamdramSecurityBundle:PendingAccess:edit.html.twig');
 }
Exemplo n.º 2
0
 /**
  * Send an email informing someone that they've been granted access to a
  * resource (show, society, or venue).
  */
 public function sendPendingAceEmail(PendingAccess $ace)
 {
     $message = \Swift_Message::newInstance()->setFrom($this->from_address)->setTo($ace->getEmail());
     /* Get the resource and pass it to the template. */
     switch ($ace->getType()) {
         case 'show':
             $entity = $this->em->getRepository('ActsCamdramBundle:Show')->findOneById($ace->getRid());
             break;
         case 'society':
             $entity = $this->em->getRepository('ActsCamdramBundle:Society')->findOneById($ace->getRid());
             break;
         case 'venue':
             $entity = $this->em->getRepository('ActsCamdramBundle:Venue')->findOneById($ace->getRid());
             break;
     }
     $message->setSubject('Access to ' . $ace->getType() . ' ' . $entity->getName() . ' on Camdram granted')->setBody($this->twig->render('ActsCamdramBundle:Email:ace.txt.twig', array('is_pending' => true, 'ace' => $ace, 'entity' => $entity)));
     $this->mailer->send($message);
 }
Exemplo n.º 3
0
 /**
  * Log the he person that they have been granted access to a resource on the
  * site, pending creating an account.
  */
 public function postPersist(PendingAccess $pending_ace, LifecycleEventArgs $event)
 {
     $this->logger->info(sprintf('%s has granted access for %s to edit %s %d.', $pending_ace->getIssuer()->getName(), $pending_ace->getEmail(), $pending_ace->getType(), $pending_ace->getRid()));
 }
Exemplo n.º 4
0
 /**
  * Get a form for adding an admin to an organisation.
  *
  * @param $identifier
  */
 public function editAdminAction($identifier)
 {
     $org = $this->getEntity($identifier);
     $this->get('camdram.security.acl.helper')->ensureGranted('EDIT', $org);
     if ($org->getEntityType() == 'society') {
         $route = 'post_society_admin';
     } else {
         $route = 'post_venue_admin';
     }
     $ace = new PendingAccess();
     $ace->setRid($org->getId());
     $ace->setType($org->getEntityType());
     $ace->setIssuer($this->getUser());
     $form = $this->createForm(new PendingAccessType(), $ace, array('action' => $this->generateUrl($route, array('identifier' => $identifier))));
     $em = $this->getDoctrine()->getManager();
     $admins = $em->getRepository('ActsCamdramSecurityBundle:User')->getEntityOwners($org);
     $pending_admins = $em->getRepository('ActsCamdramSecurityBundle:PendingAccess')->findByResource($org);
     return $this->view($form, 200)->setData(array('entity' => $org, 'admins' => $admins, 'pending_admins' => $pending_admins, 'form' => $form->createView()))->setTemplate('ActsCamdramSecurityBundle:PendingAccess:edit.html.twig');
 }
Exemplo n.º 5
0
 /**
  * Does this match a pre-existing pending access token?
  *
  * This is a lightweight test for equality; is the same email address being
  * granted access to the same resource.
  */
 public function isDuplicate(PendingAccess $ace)
 {
     $qb = $this->createQueryBuilder('p')->where('p.rid = :rid')->andWhere('p.type = :type')->andWhere('p.email = :email')->setParameters(array('rid' => $ace->getRid(), 'type' => $ace->getType(), 'email' => $ace->getEmail()));
     $result = $qb->getQuery()->getOneOrNullResult();
     return $result == null ? false : true;
 }