From 4296abd21f15edd94783ac23a400d757e74fa503 Mon Sep 17 00:00:00 2001 From: ntsagkas Date: Tue, 19 Nov 2024 15:15:12 +0000 Subject: [PATCH] Session (create,edit): fix query --- modules/session/edit.php | 12 ++++++++++-- modules/session/new.php | 9 +++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/modules/session/edit.php b/modules/session/edit.php index 60f69e7673..339d3fdcb9 100644 --- a/modules/session/edit.php +++ b/modules/session/edit.php @@ -413,10 +413,18 @@ $sql = ""; if($is_consultant && !$is_coordinator){ - $consultant_as_tutor_group = Database::get()->queryArray("SELECT * FROM group_members WHERE user_id = ?d AND is_tutor = ?d", $uid, 1); + $consultant_as_tutor_group = Database::get()->queryArray("SELECT * FROM group_members + WHERE group_id IN (SELECT id FROM `group` WHERE course_id = $course_id) + AND user_id = ?d + AND is_tutor = ?d", $uid, 1); if(count($consultant_as_tutor_group) > 0){ + $arr_g = []; + foreach ($consultant_as_tutor_group as $g) { + $arr_g[] = $g->group_id; + } + $arr_as_str = implode(',',$arr_g); $sql = "AND course_user.user_id IN (SELECT user_id FROM group_members - WHERE group_id IN (SELECT group_id FROM group_members WHERE user_id = $uid AND is_tutor = 1))"; + WHERE group_id IN ($arr_as_str))"; } } $data['simple_users'] = Database::get()->queryArray("SELECT course_user.user_id,user.givenname,user.surname FROM course_user diff --git a/modules/session/new.php b/modules/session/new.php index 2d7b96f0ca..30da8943c5 100644 --- a/modules/session/new.php +++ b/modules/session/new.php @@ -258,10 +258,15 @@ WHERE group_id IN (SELECT id FROM `group` WHERE course_id = $course_id) AND user_id = ?d AND is_tutor = ?d", $uid, 1); - + if(count($consultant_as_tutor_group) > 0){ + $arr_g = []; + foreach ($consultant_as_tutor_group as $g) { + $arr_g[] = $g->group_id; + } + $arr_as_str = implode(',',$arr_g); $sql = "AND course_user.user_id IN (SELECT user_id FROM group_members - WHERE group_id IN (SELECT group_id FROM group_members WHERE user_id = $uid AND is_tutor = 1))"; + WHERE group_id IN ($arr_as_str))"; } } $data['simple_users'] = Database::get()->queryArray("SELECT course_user.user_id,user.givenname,user.surname FROM course_user