public function __construct(CourseSession $session, User $user)
 {
     $course = $session->getCourse();
     $details = array();
     $details['username'] = $user->getUsername();
     $details['firsName'] = $user->getFirstName();
     $details['lastName'] = $user->getLastName();
     $details['sessionId'] = $session->getId();
     $details['sessionName'] = $session->getName();
     $details['sessionCreationDate'] = $session->getCreationDate()->format('d/m/Y H:i:s');
     $details['courseId'] = $course->getId();
     $details['courseTitle'] = $course->getTitle();
     $details['courseCode'] = $course->getCode();
     parent::__construct(self::ACTION, $details, $user);
 }
 public function __construct(CourseSession $session)
 {
     $course = $session->getCourse();
     $workspace = $session->getWorkspace();
     $learnerRole = $session->getLearnerRole();
     $tutorRole = $session->getTutorRole();
     $details = [];
     $details['id'] = $session->getId();
     $details['name'] = $session->getName();
     $details['defaultSession'] = $session->isDefaultSession();
     $details['creationDate'] = $session->getCreationDate();
     $details['publicRegistration'] = $session->getPublicRegistration();
     $details['publicUnregistration'] = $session->getPublicUnregistration();
     $details['registrationValidation'] = $session->getRegistrationValidation();
     $details['startDate'] = $session->getStartDate();
     $details['endDate'] = $session->getEndDate();
     $details['extra'] = $session->getExtra();
     $details['userValidation'] = $session->getUserValidation();
     $details['organizationValidation'] = $session->getOrganizationValidation();
     $details['maxUsers'] = $session->getMaxUsers();
     $details['type'] = $session->getType();
     $details['courseId'] = $course->getId();
     $details['courseTitle'] = $course->getTitle();
     $details['courseCode'] = $course->getCode();
     if (!is_null($workspace)) {
         $details['workspaceId'] = $workspace->getId();
         $details['workspaceName'] = $workspace->getName();
         $details['workspaceCode'] = $workspace->getCode();
         $details['workspaceGuid'] = $workspace->getGuid();
     }
     if (!is_null($learnerRole)) {
         $details['learnerRoleId'] = $learnerRole->getId();
         $details['learnerRoleName'] = $learnerRole->getName();
         $details['learnerRoleKey'] = $learnerRole->getTranslationKey();
     }
     if (!is_null($tutorRole)) {
         $details['tutorRoleId'] = $tutorRole->getId();
         $details['tutorRoleName'] = $tutorRole->getName();
         $details['tutorRoleKey'] = $tutorRole->getTranslationKey();
     }
     parent::__construct(self::ACTION, $details);
 }
 /**
  * @EXT\Route(
  *     "cursus/course/session/{session}/user/{user}/confirmation/mail/send",
  *     name="claro_cursus_course_session_user_confirmation_mail_send",
  *     options = {"expose"=true}
  * )
  * @EXT\ParamConverter("authenticatedUser", options={"authenticatedUser" = true})
  *
  * @param User $user
  */
 public function courseSessionUserConfirmationMailSendAction(CourseSession $session, User $user)
 {
     $confirmationEmail = $this->cursusManager->getConfirmationEmail();
     if (!is_null($confirmationEmail)) {
         $course = $session->getCourse();
         $startDate = $session->getStartDate();
         $endDate = $session->getEndDate();
         $title = $confirmationEmail->getTitle();
         $content = $confirmationEmail->getContent();
         $title = str_replace('%course%', $course->getTitle(), $title);
         $content = str_replace('%course%', $course->getTitle(), $content);
         $title = str_replace('%session%', $session->getName(), $title);
         $content = str_replace('%session%', $session->getName(), $content);
         if (!is_null($startDate)) {
             $title = str_replace('%start_date%', $session->getStartDate()->format('d-m-Y'), $title);
             $content = str_replace('%start_date%', $session->getStartDate()->format('d-m-Y'), $content);
         }
         if (!is_null($endDate)) {
             $title = str_replace('%end_date%', $session->getEndDate()->format('d-m-Y'), $title);
             $content = str_replace('%end_date%', $session->getEndDate()->format('d-m-Y'), $content);
         }
         $this->mailManager->send($title, $content, [$user]);
     }
     return new JsonResponse('success', 200);
 }
示例#4
0
 public function convertKeysForSession(CourseSession $session, $content, $withEventsList = true, User $user = null)
 {
     $course = $session->getCourse();
     $events = $session->getEvents();
     $eventsList = '';
     $sessionTrainers = $this->getUsersBySessionAndType($session, CourseSessionUser::TEACHER);
     $sessionTrainersHtml = '';
     if (count($sessionTrainers) > 0) {
         $sessionTrainersHtml = '<ul>';
         foreach ($sessionTrainers as $trainer) {
             $sessionTrainersHtml .= '<li>' . $trainer->getFirstName() . ' ' . $trainer->getLastName() . '</li>';
         }
         $sessionTrainersHtml .= '</ul>';
     }
     if ($withEventsList && count($events) > 0) {
         $eventsList = '<ul>';
         foreach ($events as $event) {
             $eventsList .= '<li>' . $event->getName() . ' [' . $event->getStartDate()->format('d/m/Y H:i') . ' -> ' . $event->getEndDate()->format('d/m/Y H:i') . ']';
             $location = $event->getLocation();
             if (!is_null($location)) {
                 $locationHtml = '<br>' . $location->getStreet() . ', ' . $location->getStreetNumber();
                 $locationHtml .= $location->getBoxNumber() ? ' / ' . $location->getBoxNumber() : '';
                 $locationHtml .= '<br>' . $location->getPc() . ' ' . $location->getTown() . '<br>' . $location->getCountry();
                 $locationHtml .= $location->getPhone() ? '<br>' . $location->getPhone() : '';
                 $eventsList .= $locationHtml;
             }
             $eventsList .= $event->getLocationExtra();
         }
         $eventsList .= '</ul>';
     }
     $now = new \DateTime();
     $keys = ['%date%', '%course_title%', '%course_code%', '%course_description%', '%session_name%', '%session_description%', '%session_start%', '%session_end%', '%session_trainers%'];
     $values = [$now->format('d/m/Y'), $course->getTitle(), $course->getCode(), $course->getDescription(), $session->getName(), $session->getDescription(), $session->getStartDate()->format('d/m/Y'), $session->getEndDate()->format('d/m/Y'), $sessionTrainersHtml];
     if ($withEventsList) {
         $keys[] = '%events_list%';
         $values[] = $eventsList;
     }
     if (!is_null($user)) {
         $keys[] = '%first_name%';
         $keys[] = '%last_name%';
         $values[] = $user->getFirstName();
         $values[] = $user->getLastName();
     }
     return str_replace($keys, $values, $content);
 }