'courses', 'sides' => array( Side::STAFF->value ), 'staff_on' => false, 'staff_roles' => StaffRoles::TRAINERS, 'staff_choices' => array( 'trainers' ), 'timing' => 0, 'offset_min' => 0, 'placeholders' => array( 'recipient', 'learner', 'course', 'lesson', 'site', 'message' ), ); $entries[ self::QA_POSTED ] = array_merge( $staff, array( 'label' => __( 'New question or reply in a lesson\'s Q&A', 'rooster-lms' ), 'staff_label' => __( 'New question or reply in a lesson\'s Q&A', 'rooster-lms' ), 'description' => __( 'To the course\'s trainers only, when a learner posts in a lesson\'s Q&A.', 'rooster-lms' ), 'staff_subject' => __( 'New in the Q&A of {{ course.title }}', 'rooster-lms' ), 'staff_body' => __( 'A learner posted in the Q&A of the lesson {{ lesson.title }}. Posts that wait for approval are shown to the course\'s staff only.', 'rooster-lms' ), ) ); $entries[ self::REVIEW_POSTED ] = array_merge( $staff, array( 'label' => __( 'New course review', 'rooster-lms' ), 'staff_label' => __( 'New course review', 'rooster-lms' ), 'description' => __( 'To the course\'s trainers only, when a learner writes or edits a review.', 'rooster-lms' ), 'placeholders' => array( 'recipient', 'learner', 'course', 'site', 'message' ), 'staff_subject' => __( 'New review of {{ course.title }}', 'rooster-lms' ), 'staff_body' => __( 'A learner reviewed the course {{ course.title }}. Reviews that wait for approval are published once a moderator approves them.', 'rooster-lms' ), ) ); $entries[ self::COURSE_OPEN ] = array( 'group' => 'courses', 'label' => __( 'A course on your waiting list is open', 'rooster-lms' ), 'staff_label' => '', 'sides' => array( Side::LEARNER->value ), 'staff_on' => false, 'staff_roles' => 0, 'timing' => 0, 'offset_min' => 0, 'placeholders' => array( 'recipient', 'course', 'site', 'message' ), 'description' => __( 'Sent once to the people on a coming-soon course\'s waiting list when the course opens.', 'rooster-lms' ), 'subject' => __( '{{ course.title }} is open', 'rooster-lms' ), 'body' => __( 'The course you asked us to tell you about is open now: {{ course.title }}.', 'rooster-lms' ), ); return $entries; } public static function qa_posted( int $course_id, int $unit_id, int $user_id ): int { return EventDispatcher::staff_notice( self::QA_POSTED, array( 'course_id' => $course_id, 'unit_id' => $unit_id, 'user_id' => $user_id, ) ); } public static function review_posted( int $course_id, int $user_id ): int { return EventDispatcher::staff_notice( self::REVIEW_POSTED, array( 'course_id' => $course_id, 'user_id' => $user_id, ) ); } public static function course_open_row(): ?Template { $t = TemplateRepository::default_row( self::COURSE_OPEN, Side::LEARNER ); if ( null === $t && null !== Catalog::entry( self::COURSE_OPEN ) && Seeder::seed() > 0 ) { $t = TemplateRepository::default_row( self::COURSE_OPEN, Side::LEARNER ); } return null !== $t && $t->enabled ? $t : null; } public static function course_open( Template $t, int $course_id, int $user_id, string $email, string $lang, string $token = '' ): bool { if ( $user_id > 0 ) { return 'sent' === Sender::send( $t, $user_id, new Context( 0, '', $user_id, $course_id ), LogObject::COURSE, $course_id ); } if ( ! is_email( $email ) ) { return false; } $lang = Language::normalize( $lang ); $lang = '' !== $lang ? $lang : Names::default_language(); $message = Switcher::with( $lang, static function () use ( $t, $course_id, $lang, $token ): array { $ctx = new Context( 0, $lang, 0, $course_id ); $parts = Renderer::resolve( Renderer::texts( $t, $lang ), $ctx ); return array( 'subject' => $parts['subject'], 'html' => Services::branded_renderer()->render( 0, $lang, $parts['subject'], $parts['body'] . self::leave_footer( $token ), 0 ), ); } ); if ( '' === trim( $message['subject'] ) ) { return false; } return Services::notifier()->deliver( $email, $message['subject'], $message['html'], 0, $lang, array(), array(), self::COURSE_OPEN, 0 ); } public static function leave_footer( string $token ): string { if ( '' === $token ) { return ''; } return '

' . esc_html__( 'You get this e-mail because this address is on the course\'s waiting list.', 'rooster-lms' ) . ' ' . esc_html__( 'Leave the waiting list', 'rooster-lms' ) . '

'; } }