Browse Source

Course Chat: Avoid list inactive users

Angel Fernando Quiroz Campos 6 years ago
parent
commit
84a39eeb3c
1 changed files with 13 additions and 4 deletions
  1. 13 4
      main/inc/lib/CourseChatUtils.php

+ 13 - 4
main/inc/lib/CourseChatUtils.php

@@ -701,7 +701,8 @@ class CourseChatUtils
                     'SELECT u FROM ChamiloUserBundle:User u
                     INNER JOIN ChamiloCourseBundle:CGroupRelUser gru
                         WITH u.id = gru.userId AND gru.cId = :course
-                    WHERE u.id != :user AND gru.groupId = :group'
+                    WHERE u.id != :user AND gru.groupId = :group
+                        AND u.active = true'
                 )
                 ->setParameters(['course' => $this->courseId, 'user' => $this->userId, 'group' => $this->groupId])
                 ->getResult();
@@ -710,7 +711,8 @@ class CourseChatUtils
                     'SELECT u FROM ChamiloUserBundle:User u
                     INNER JOIN ChamiloCourseBundle:CGroupRelTutor grt
                         WITH u.id = grt.userId AND grt.cId = :course
-                    WHERE u.id != :user AND grt.groupId = :group'
+                    WHERE u.id != :user AND grt.groupId = :group
+                        AND u.active = true'
                 )
                 ->setParameters(['course' => $this->courseId, 'user' => $this->userId, 'group' => $this->groupId])
                 ->getResult();
@@ -743,10 +745,17 @@ class CourseChatUtils
 
             return $session
                 ->getUserCourseSubscriptions()
-                ->matching($criteria);
+                ->matching($criteria)
+                ->filter(function (SessionRelCourseRelUser $sessionRelCourseRelUser) {
+                    return $sessionRelCourseRelUser->getUser()->isActive();
+                });
         }
 
-        return $course->getUsers();
+        return $course
+            ->getUsers()
+            ->filter(function (CourseRelUser $courseRelUser) {
+                return $courseRelUser->getUser()->isActive();
+            });
     }
 
     /**