|
16 | 16 | use Chamilo\CoreBundle\Settings\SettingsManager;
|
17 | 17 | use DateTime;
|
18 | 18 | use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
| 19 | +use Doctrine\Common\Collections\ArrayCollection; |
19 | 20 | use Doctrine\ORM\Query\Expr\Join;
|
20 | 21 | use Doctrine\ORM\QueryBuilder;
|
21 | 22 | use Doctrine\Persistence\ManagerRegistry;
|
@@ -130,8 +131,20 @@ public function getCurrentSessionsOfUserInUrl(User $user, AccessUrl $url): array
|
130 | 131 | {
|
131 | 132 | $sessions = $this->getSubscribedSessionsOfUserInUrl($user, $url);
|
132 | 133 |
|
133 |
| - $filterCurrentSessions = function (Session $session) use ($user) { |
134 |
| - // Determine if the user is a coach |
| 134 | + $filterCurrentSessions = function (Session $session) use ($user, $url) { |
| 135 | + |
| 136 | + $userIsGeneralCoach = $session->hasUserAsGeneralCoach($user); |
| 137 | + if (!$userIsGeneralCoach) { |
| 138 | + $coursesAsCoach = $this->getSessionCoursesByStatusInCourseSubscription($user, $session, Session::COURSE_COACH, $url); |
| 139 | + $coursesAsStudent = $this->getSessionCoursesByStatusInCourseSubscription($user, $session, Session::STUDENT, $url); |
| 140 | + $validCourses = array_merge($coursesAsCoach, $coursesAsStudent); |
| 141 | + |
| 142 | + if (empty($validCourses)) { |
| 143 | + return false; |
| 144 | + } |
| 145 | + $session->setCourses(new ArrayCollection($validCourses)); |
| 146 | + } |
| 147 | + |
135 | 148 | $userIsCoach = $session->hasCoach($user);
|
136 | 149 |
|
137 | 150 | // Check if session has a duration
|
|
0 commit comments