private function actualForm($registrationSettings, $slug, Request $request)
 {
     $repository = $this->get(self::REPOSITORY_NAME);
     $recaptcha = $this->get('cantiga.security.recaptcha');
     $participant = new EdkParticipant();
     $participant->setPeopleNum(1);
     if (null !== $registrationSettings) {
         $participant->setRegistrationSettings($registrationSettings);
     }
     $terms1Text = $this->getTextRepository()->getText(EdkTexts::REGISTRATION_TERMS1_TEXT, $request, $this->project);
     $terms2Text = $this->getTextRepository()->getText(EdkTexts::REGISTRATION_TERMS2_TEXT, $request, $this->project);
     $terms3Text = $this->getTextRepository()->getText(EdkTexts::REGISTRATION_TERMS3_TEXT, $request, $this->project);
     $form = $this->createForm(new PublicParticipantForm($registrationSettings, strip_tags($terms1Text->getContent()), strip_tags($terms2Text->getContent()), strip_tags($terms3Text->getContent())), $participant, array('action' => $this->generateUrl('public_edk_register', ['slug' => $slug]) . (null !== $registrationSettings ? '?r=' . $registrationSettings->getRoute()->getId() : '')));
     if ($this->getRequest()->getMethod() == 'POST') {
         $form->handleRequest($request);
         if ($form->isValid()) {
             if ($recaptcha->verifyRecaptcha($request)) {
                 $participant->setIpAddress(ip2long($_SERVER['REMOTE_ADDR']));
                 $repository->register($participant, $_SERVER['REMOTE_ADDR'], $slug);
                 return $this->redirect($this->generateUrl('public_edk_registration_completed', ['slug' => $slug, 'accessKey' => $participant->getAccessKey(), 'currentPage' => self::CURRENT_PAGE]));
             } else {
                 return $this->showErrorMessage('You did not solve the CAPTCHA correctly, sorry.');
             }
         }
     }
     $text = $this->getTextRepository()->getText(EdkTexts::REGISTRATION_FORM_TEXT, $request, $this->project);
     $response = $this->render('WioEdkBundle:Public:registration-form.html.twig', array('form' => $form->createView(), 'recaptcha' => $recaptcha, 'route' => null != $registrationSettings ? $registrationSettings->getRoute() : null, 'registrationSettings' => $registrationSettings, 'text' => $text, 'slug' => $this->project->getSlug(), 'currentPage' => self::CURRENT_PAGE));
     return $response;
 }
Exemplo n.º 2
0
 /**
  * @Route("/insert", name="area_edk_participant_insert")
  */
 public function insertAction(Request $request)
 {
     try {
         $area = $this->getMembership()->getItem();
         $project = $area->getProject();
         $settingsRepository = $this->get('wio.edk.repo.registration');
         $settingsRepository->setRootEntity($area);
         $entity = EdkParticipant::newParticipant();
         if ($request->getMethod() == 'POST') {
             $entity->setRegistrationSettings($settingsRepository->getItem($request->get('route', null)));
             $entity->setIpAddress(ip2long($_SERVER['REMOTE_ADDR']));
         }
         $action = new InsertAction($this->crudInfo, $entity);
         $action->slug($this->getSlug());
         $action->form(function ($controller, $item, $formType, $action) use($request, $project, $settingsRepository) {
             $form = new EdkParticipantForm(EdkParticipantForm::ADD, null, $settingsRepository);
             $form->setText(1, $this->getTextRepository()->getText(EdkTexts::REGISTRATION_TERMS1_TEXT, $request, $project));
             $form->setText(2, $this->getTextRepository()->getText(EdkTexts::REGISTRATION_TERMS2_TEXT, $request, $project));
             $form->setText(3, $this->getTextRepository()->getText(EdkTexts::REGISTRATION_TERMS3_TEXT, $request, $project));
             return $controller->createForm($form, $item, array('action' => $action));
         });
         $action->set('ajaxRoutePage', 'area_edk_participant_ajax_routes');
         return $action->run($this, $request);
     } catch (ItemNotFoundException $exception) {
         return $this->showPageWithError($this->trans($exception->getMessage(), [], 'edk'), 'area_edk_participant_index', ['slug' => $this->getSlug()]);
     }
 }
Exemplo n.º 3
0
 /**
  * Fetches the participant by his/her ID and area.
  * 
  * @param Connection $conn
  * @param int $id
  * @param Area $area
  * @param boolean $forUpdate Whether to lock the registration settings for writing
  * @return EdkParticipant
  */
 public static function fetchByArea(Connection $conn, $id, Area $area)
 {
     $data = $conn->fetchAssoc('SELECT * FROM `' . EdkTables::PARTICIPANT_TBL . '` WHERE `id` = :id AND `areaId` = :areaId', [':id' => $id, ':areaId' => $area->getId()]);
     if (false === $data) {
         return false;
     }
     $route = EdkRoute::fetchByRoot($conn, $data['routeId'], $area);
     if (empty($route)) {
         return false;
     }
     $registrationSettings = EdkRegistrationSettings::fetchByRoute($conn, $route);
     if (empty($registrationSettings)) {
         return false;
     }
     $item = EdkParticipant::fromArray($data);
     $item->setRegistrationSettings($registrationSettings);
     return $item;
 }
Exemplo n.º 4
0
 public function removeItemByKey($accessKey, $expectedAreaStatus)
 {
     $this->transaction->requestTransaction();
     try {
         $item = EdkParticipant::fetchByKey($this->conn, $accessKey, $expectedAreaStatus, true);
         if (false === $item) {
             throw new ItemNotFoundException('Participant not found.');
         }
         $item->remove($this->conn);
     } catch (Exception $ex) {
         $this->transaction->requestRollback();
         throw $ex;
     }
 }
Exemplo n.º 5
0
 public function insert(Connection $conn)
 {
     $conn->insert(EdkTables::EDK_REMOVED_PARTICIPANT_TBL, array('participantId' => $this->participantId, 'areaId' => $this->area->getId(), 'reason' => $this->reason, 'email' => $this->email, 'removedAt' => $this->removedAt));
     $this->id = $this->conn->lastInsertId();
     $this->participant->remove($conn);
 }