Skip to content

Commit 7f2006f

Browse files
committed
Session: #add possibility to return session with no course - refs BT#23091
1 parent 7da8728 commit 7f2006f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

main/admin/add_sessions_to_usergroup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function validate_filter() {
9595
$onlyThisSessionList = array_column($sessionList, 'id');
9696
}
9797
}
98-
$session_list = SessionManager::get_sessions_list([], ['name'], null, null, 0, $onlyThisSessionList);
98+
$session_list = SessionManager::get_sessions_list([], ['name'], null, null, 0, $onlyThisSessionList, true);
9999
$elements_not_in = $elements_in = [];
100100

101101
if (!empty($session_list)) {

main/inc/lib/sessionmanager.lib.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3293,7 +3293,8 @@ public static function get_sessions_list(
32933293
$from = null,
32943294
$to = null,
32953295
$urlId = 0,
3296-
$onlyThisSessionList = []
3296+
$onlyThisSessionList = [],
3297+
$includeSessionWithNoCourse = false
32973298
) {
32983299
$session_table = Database::get_main_table(TABLE_MAIN_SESSION);
32993300
$session_category_table = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
@@ -3303,6 +3304,12 @@ public static function get_sessions_list(
33033304
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
33043305
$urlId = empty($urlId) ? api_get_current_access_url_id() : (int) $urlId;
33053306
$return_array = [];
3307+
$courseFrom ="LEFT JOIN " . $session_course_table . " sco ON (sco.session_id = s.id)
3308+
INNER JOIN " . $course_table . " c ON sco.c_id = c.id";
3309+
3310+
if ($includeSessionWithNoCourse) {
3311+
$courseFrom = "";
3312+
}
33063313

33073314
$sql_query = " SELECT
33083315
DISTINCT(s.id),
@@ -3318,8 +3325,7 @@ public static function get_sessions_list(
33183325
INNER JOIN $user_table u ON s.id_coach = u.user_id
33193326
INNER JOIN $table_access_url_rel_session ar ON ar.session_id = s.id
33203327
LEFT JOIN $session_category_table sc ON s.session_category_id = sc.id
3321-
LEFT JOIN $session_course_table sco ON (sco.session_id = s.id)
3322-
INNER JOIN $course_table c ON sco.c_id = c.id
3328+
$courseFrom
33233329
WHERE ar.access_url_id = $urlId ";
33243330

33253331
$availableFields = [

0 commit comments

Comments
 (0)