Skip to content

Commit 862cf0e

Browse files
committed
Add setting 'my_courses_show_courses_in_user_language_only' BT#13184
When using the my-courses list filter by category, set this option to true to only show courses in the user's configured language: $_configuration['my_courses_show_courses_in_user_language_only']=true;
1 parent 6136a53 commit 862cf0e

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

main/inc/lib/course.lib.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3767,6 +3767,15 @@ public static function returnCoursesCategories(
37673767
$userCategoryCondition = ' (course_rel_user.user_course_cat = 0 OR course_rel_user.user_course_cat IS NULL) ';
37683768
}
37693769

3770+
$languageCondition = '';
3771+
$onlyInUserLanguage = api_get_configuration_value('my_courses_show_courses_in_user_language_only');
3772+
if ($onlyInUserLanguage) {
3773+
$userInfo = api_get_user_info();
3774+
if (!empty($userInfo['language'])) {
3775+
$languageCondition = " AND course.course_language = '".$userInfo['language']."' ";
3776+
}
3777+
}
3778+
37703779
$sql = "SELECT DISTINCT
37713780
course.id,
37723781
course_rel_user.status status,
@@ -3779,8 +3788,9 @@ public static function returnCoursesCategories(
37793788
WHERE
37803789
course_rel_user.user_id = '".$user_id."' AND
37813790
$userCategoryCondition
3782-
$without_special_courses ";
3783-
3791+
$without_special_courses
3792+
$languageCondition
3793+
";
37843794
// If multiple URL access mode is enabled, only fetch courses
37853795
// corresponding to the current URL.
37863796
if (api_get_multiple_access_url() && $current_url_id != -1) {

main/install/configuration.dist.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,3 +591,7 @@
591591
];*/
592592
// Show language selector in main menu
593593
//$_configuration['show_language_selector_in_menu'] = false;
594+
595+
// When using the my-courses list filter by category, set this option to true
596+
// to only show courses in the user's configured language
597+
// $_configuration['my_courses_show_courses_in_user_language_only'] = false;

0 commit comments

Comments
 (0)