|
|
|
@ -4,10 +4,12 @@ |
|
|
|
|
namespace Chamilo\ThemeBundle\EventListener; |
|
|
|
|
|
|
|
|
|
use Chamilo\CoreBundle\Framework\Container; |
|
|
|
|
use CourseManager; |
|
|
|
|
use SessionManager; |
|
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareTrait; |
|
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
|
|
|
|
use Symfony\Component\HttpKernel\Event\GetResponseEvent; |
|
|
|
|
use Symfony\Component\HttpKernel\Event\RequestEvent; |
|
|
|
|
use Symfony\Component\HttpKernel\KernelEvents; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -30,9 +32,9 @@ class TwigListener implements EventSubscriberInterface |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param GetResponseEvent $event |
|
|
|
|
* @param RequestEvent $event |
|
|
|
|
*/ |
|
|
|
|
public function onKernelRequest(GetResponseEvent $event) |
|
|
|
|
public function onKernelRequest(RequestEvent $event) |
|
|
|
|
{ |
|
|
|
|
if (!$event->isMasterRequest()) { |
|
|
|
|
return; |
|
|
|
@ -96,21 +98,23 @@ class TwigListener implements EventSubscriberInterface |
|
|
|
|
if (!empty($courseId)) { |
|
|
|
|
$tutorData = ''; |
|
|
|
|
if ($sessionId !== 0) { |
|
|
|
|
$coachEmail = \CourseManager::get_email_of_tutor_to_session( |
|
|
|
|
$sessionId, |
|
|
|
|
$courseId |
|
|
|
|
); |
|
|
|
|
$email_link = []; |
|
|
|
|
foreach ($coachEmail as $coach) { |
|
|
|
|
$email_link[] = \Display::encrypted_mailto_link($coach['email'], $coach['complete_name']); |
|
|
|
|
$users = SessionManager::getCoachesByCourseSession($sessionId, $courseId); |
|
|
|
|
$links = []; |
|
|
|
|
if (!empty($users)) { |
|
|
|
|
$coaches = []; |
|
|
|
|
foreach ($users as $userId) { |
|
|
|
|
$coaches[] = api_get_user_info($userId); |
|
|
|
|
} |
|
|
|
|
$links = array_column($coaches, 'complete_name_with_message_link'); |
|
|
|
|
} |
|
|
|
|
if (count($coachEmail) > 1) { |
|
|
|
|
$count = count($links); |
|
|
|
|
if ($count > 1) { |
|
|
|
|
$tutorData .= get_lang('Coachs').' : '; |
|
|
|
|
$tutorData .= array_to_string($email_link, \CourseManager::USER_SEPARATOR); |
|
|
|
|
} elseif (count($coachEmail) == 1) { |
|
|
|
|
$tutorData .= array_to_string($links, CourseManager::USER_SEPARATOR); |
|
|
|
|
} elseif ($count === 1) { |
|
|
|
|
$tutorData .= get_lang('Coach').' : '; |
|
|
|
|
$tutorData .= array_to_string($email_link, \CourseManager::USER_SEPARATOR); |
|
|
|
|
} elseif (count($coachEmail) == 0) { |
|
|
|
|
$tutorData .= array_to_string($links, CourseManager::USER_SEPARATOR); |
|
|
|
|
} elseif ($count === 0) { |
|
|
|
|
$tutorData .= ''; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -119,19 +123,19 @@ class TwigListener implements EventSubscriberInterface |
|
|
|
|
|
|
|
|
|
if (!empty($courseId)) { |
|
|
|
|
$teacherData = ''; |
|
|
|
|
$mail = \CourseManager::get_emails_of_tutors_to_course($courseId); |
|
|
|
|
if (!empty($mail)) { |
|
|
|
|
$teachers = CourseManager::getTeachersFromCourse($courseId); |
|
|
|
|
if (!empty($teachers)) { |
|
|
|
|
$teachersParsed = []; |
|
|
|
|
foreach ($mail as $value) { |
|
|
|
|
foreach ($value as $email => $name) { |
|
|
|
|
$teachersParsed[] = \Display::encrypted_mailto_link($email, $name); |
|
|
|
|
} |
|
|
|
|
foreach ($teachers as $teacher) { |
|
|
|
|
$userId = $teacher['id']; |
|
|
|
|
$teachersParsed[] = api_get_user_info($userId); |
|
|
|
|
} |
|
|
|
|
$links = array_column($teachersParsed, 'complete_name_with_message_link'); |
|
|
|
|
$label = get_lang('Teacher'); |
|
|
|
|
if (count($mail) > 1) { |
|
|
|
|
if (count($links) > 1) { |
|
|
|
|
$label = get_lang('Teachers'); |
|
|
|
|
} |
|
|
|
|
$teacherData .= $label.' : '.array_to_string($teachersParsed, \CourseManager::USER_SEPARATOR); |
|
|
|
|
$teacherData .= $label.' : '.array_to_string($links, CourseManager::USER_SEPARATOR); |
|
|
|
|
} |
|
|
|
|
$twig->addGlobal('teachers', $teacherData); |
|
|
|
|
} |
|
|
|
|