Skip to content

Commit

Permalink
Session (create,edit): fix query
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsagkas committed Nov 19, 2024
1 parent 7b0751f commit 4296abd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 10 additions & 2 deletions modules/session/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions modules/session/new.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4296abd

Please sign in to comment.