public function __construct(SessionEvent $sessionEvent, User $user)
 {
     $session = $sessionEvent->getSession();
     $course = $session->getCourse();
     $details = [];
     $details['username'] = $user->getUsername();
     $details['firsName'] = $user->getFirstName();
     $details['lastName'] = $user->getLastName();
     $details['sessionEventId'] = $sessionEvent->getId();
     $details['sessionEventName'] = $sessionEvent->getName();
     $details['sessionId'] = $session->getId();
     $details['sessionName'] = $session->getName();
     $details['courseId'] = $course->getId();
     $details['courseTitle'] = $course->getTitle();
     $details['courseCode'] = $course->getCode();
     parent::__construct(self::ACTION, $details, $user);
 }
 public function __construct(SessionEvent $sessionEvent)
 {
     $session = $sessionEvent->getSession();
     $course = $session->getCourse();
     $details = [];
     $details['id'] = $sessionEvent->getId();
     $details['name'] = $sessionEvent->getName();
     $details['startDate'] = $sessionEvent->getStartDate();
     $details['endDate'] = $sessionEvent->getEndDate();
     $details['sessionId'] = $session->getId();
     $details['sessionName'] = $session->getName();
     $details['courseId'] = $course->getId();
     $details['courseTitle'] = $course->getTitle();
     $details['courseCode'] = $course->getCode();
     foreach ($sessionEvent->getTutors() as $tutor) {
         $details['tutors'][] = ['id' => $tutor->getId(), 'username' => $tutor->getUsername(), 'firstName' => $tutor->getFirstName(), 'lastName' => $tutor->getLastName(), 'guid' => $tutor->getGuid()];
     }
     parent::__construct(self::ACTION, $details);
 }
 /**
  * @EXT\Route(
  *     "/api/session/event/{sessionEvent}/edit",
  *     name="api_put_session_event_edition",
  *     options = {"expose"=true}
  * )
  * @EXT\ParamConverter("user", converter="current_user")
  *
  * Edits a session event
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 public function putSessionEventEditionAction(SessionEvent $sessionEvent)
 {
     $sessionEventDatas = $this->request->request->get('sessionEventDatas', false);
     $trimmedStartDate = trim($sessionEventDatas['startDate'], 'Zz');
     $trimmedEndDate = trim($sessionEventDatas['endDate'], 'Zz');
     $startDate = new \DateTime($trimmedStartDate);
     $endDate = new \DateTime($trimmedEndDate);
     $sessionEvent->setName($sessionEventDatas['name']);
     $sessionEvent->setStartDate($startDate);
     $sessionEvent->setEndDate($endDate);
     $sessionEvent->setDescription($sessionEventDatas['description']);
     $sessionEvent->setLocationExtra($sessionEventDatas['locationExtra']);
     $sessionEvent->setRegistrationType($sessionEventDatas['registrationType']);
     $sessionEvent->setMaxUsers($sessionEventDatas['maxUsers']);
     $sessionEvent->setLocationResource(null);
     $sessionEvent->setLocation(null);
     if ($sessionEventDatas['location']) {
         $location = $this->locationManager->getLocationById($sessionEventDatas['location']);
         if (!is_null($location)) {
             $sessionEvent->setLocation($location);
         }
     }
     if ($sessionEventDatas['locationResource']) {
         $locationResource = $this->cursusManager->getReservationResourceById($sessionEventDatas['locationResource']);
         if (!is_null($locationResource)) {
             $sessionEvent->setLocationResource($locationResource);
         }
     }
     $sessionEvent->emptyTutors();
     $tutorsIds = $sessionEventDatas['tutors'] ? $sessionEventDatas['tutors'] : [];
     $tutors = $this->userManager->getUsersByIds($tutorsIds);
     foreach ($tutors as $tutor) {
         $sessionEvent->addTutor($tutor);
     }
     $this->cursusManager->persistSessionEvent($sessionEvent);
     $event = new LogSessionEventEditEvent($sessionEvent);
     $this->eventDispatcher->dispatch('log', $event);
     $this->cursusManager->checkPendingSessionEventUsers($sessionEvent);
     if ($sessionEvent->getRegistrationType() === CourseSession::REGISTRATION_AUTO) {
         $this->cursusManager->registerSessionUsersToSessionEvent($sessionEvent);
     }
     $serializedSessionEvent = $this->serializer->serialize($sessionEvent, 'json', SerializationContext::create()->setGroups(['api_user_min']));
     return new JsonResponse($serializedSessionEvent, 200);
 }
Exemplo n.º 4
0
 /**
  * @EXT\Route(
  *     "/session/event/{sessionEvent}/comment/create",
  *     name="api_post_session_event_comment",
  *     options={"expose"=true}
  * )
  * @EXT\ParamConverter("user", options={"authenticatedUser" = true})
  */
 public function postSessionEventCommentAction(User $user, SessionEvent $sessionEvent)
 {
     $session = $sessionEvent->getSession();
     $sessionTutor = $this->cursusManager->getOneSessionUserBySessionAndUserAndType($session, $user, CourseSessionUser::TEACHER);
     if (is_null($sessionTutor)) {
         $this->checkToolAccess();
     }
     $comment = $this->request->request->get('comment', false);
     $sessionEventComment = $this->cursusManager->createSessionEventComment($user, $sessionEvent, $comment);
     $serializedSessionEventComment = $this->serializer->serialize($sessionEventComment, 'json', SerializationContext::create()->setGroups(['api_user_min']));
     return new JsonResponse($serializedSessionEventComment, 200);
 }
Exemplo n.º 5
0
 private function sendEventRegistrationConfirmationMessage(User $user, SessionEvent $sessionEvent, $sessionStatus, $sessionEventStatus = null)
 {
     $session = $sessionEvent->getSession();
     $object = '';
     $content = '';
     $successObject = $this->translator->trans('session_event_registration_request', ['%event_name%' => $sessionEvent->getName(), '%event_start_date%' => $sessionEvent->getStartDate()->format('d/m/Y'), '%status%' => $this->translator->trans('registered', [], 'platform')], 'cursus');
     $failedObject = $this->translator->trans('session_event_registration_request', ['%event_name%' => $sessionEvent->getName(), '%event_start_date%' => $sessionEvent->getStartDate()->format('d/m/Y'), '%status%' => $this->translator->trans('failed', [], 'platform')], 'cursus');
     $pendingObject = $this->translator->trans('session_event_registration_request', ['%event_name%' => $sessionEvent->getName(), '%event_start_date%' => $sessionEvent->getStartDate()->format('d/m/Y'), '%status%' => $this->translator->trans('pending', [], 'platform')], 'cursus');
     switch ($sessionStatus) {
         case 'success':
             $object = $sessionEventStatus === 'success' ? $successObject : $pendingObject;
             $content = $sessionEventStatus === 'success' ? $this->translator->trans('session_and_event_registration_success_msg', ['%event_name%' => $sessionEvent->getName(), '%event_start_date%' => $sessionEvent->getStartDate()->format('d/m/Y'), '%session_name%' => $session->getName()], 'cursus') : $this->translator->trans('session_and_event_registration_success_pending_msg', ['%event_name%' => $sessionEvent->getName(), '%event_start_date%' => $sessionEvent->getStartDate()->format('d/m/Y'), '%session_name%' => $session->getName()], 'cursus');
             break;
         case 'failed':
             $object = $failedObject;
             $content = $this->translator->trans('session_and_event_registration_failed', ['%event_name%' => $sessionEvent->getName(), '%event_start_date%' => $sessionEvent->getStartDate()->format('d/m/Y')], 'cursus');
             break;
         case 'pending':
             $object = $pendingObject;
             $content = $this->translator->trans('session_and_event_registration_pending_msg', ['%event_name%' => $sessionEvent->getName(), '%event_start_date%' => $sessionEvent->getStartDate()->format('d/m/Y'), '%session_name%' => $session->getName()], 'cursus');
             break;
         case 'none':
             switch ($sessionEventStatus) {
                 case 'success':
                     $object = $successObject;
                     $content = $this->translator->trans('session_event_registration_success_msg', ['%event_name%' => $sessionEvent->getName(), '%event_start_date%' => $sessionEvent->getStartDate()->format('d/m/Y')], 'cursus');
                     break;
                 case 'failed':
                     $object = $pendingObject;
                     $content = $this->translator->trans('session_event_registration_pending_msg', ['%event_name%' => $sessionEvent->getName(), '%event_start_date%' => $sessionEvent->getStartDate()->format('d/m/Y')], 'cursus');
                     break;
                 case 'pending_to_registered':
                     $object = $successObject;
                     $content = $this->translator->trans('session_event_registration_pending_to_registered_msg', ['%event_name%' => $sessionEvent->getName(), '%event_start_date%' => $sessionEvent->getStartDate()->format('d/m/Y')], 'cursus');
                     break;
             }
             break;
     }
     $message = $this->messageManager->create($content, $object, [$user]);
     $this->messageManager->send($message, true, false);
 }