Skip to content

Commit

Permalink
Display: Fix course theme not picked up - refs #3711
Browse files Browse the repository at this point in the history
commit 6854d0f
Author: fabiowoj <36703444+fabiowoj@users.noreply.github.com>
Date:   Mon Dec 14 01:40:28 2020 -0300

    Fix to show theme for each course
    The select theme for specific course not loading. The platform theme still appear. This fix, solve that bug.
  • Loading branch information
ywarnier committed Aug 10, 2021
1 parent 32c4f86 commit c165bc5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions main/inc/lib/api.lib.php
Expand Up @@ -5245,15 +5245,21 @@ function api_get_visual_theme()
{
static $visual_theme;

// If call from CLI it should be reload.
$course_id = api_get_course_id();
$courseThemeAvailable = false;
// If called from CLI or from inside a course, it should be reloaded.
if ('cli' === PHP_SAPI) {
$visual_theme = null;
} elseif (!empty($course_id)) {
$courseThemeAvailable = api_get_setting('allow_course_theme') == 'true';
if ($courseThemeAvailable) {
$visual_theme = null;
}
}

if (!isset($visual_theme)) {
$cacheAvailable = api_get_configuration_value('apc');
$userThemeAvailable = api_get_setting('user_selected_theme') == 'true';
$courseThemeAvailable = api_get_setting('allow_course_theme') == 'true';
// only use a shared cache if no user-based or course-based theme is allowed
$useCache = ($cacheAvailable && !$userThemeAvailable && !$courseThemeAvailable);
$apcVar = '';
Expand Down Expand Up @@ -5298,7 +5304,6 @@ function api_get_visual_theme()
}
}

$course_id = api_get_course_id();
if (!empty($course_id)) {
if ($courseThemeAvailable) {
$course_theme = api_get_course_setting('course_theme', api_get_course_info());
Expand Down

0 comments on commit c165bc5

Please sign in to comment.