Fix stylesheet update.

- Platform stylesheet theme is checked from the DB
- Move update to the top to avoid stylesheet that doesn't get updated.
pull/2487/head
jmontoyaa 9 years ago
parent 7370461f36
commit c804014cda
  1. 16
      main/admin/settings.lib.php
  2. 7
      main/admin/settings.php
  3. 17
      main/inc/lib/api.lib.php

@ -332,15 +332,11 @@ function handleStylesheets()
}
}
// Submit stylesheets.
if (isset($_POST['save'])) {
storeStylesheets();
Display::display_normal_message(get_lang('Saved'));
}
// Current style.
$selected = $currentStyle = api_get_setting('stylesheets');
$styleFromDatabase = api_get_settings_params_simple(['variable = ?' => 'stylesheets']);
$styleFromDatabase = api_get_settings_params_simple(
['variable = ? AND access_url = ?' => ['stylesheets', api_get_current_access_url_id()]]
);
if ($styleFromDatabase) {
$selected = $currentStyle = $styleFromDatabase['selected_value'];
}
@ -350,8 +346,8 @@ function handleStylesheets()
}
$themeDir = Template::getThemeDir($selected);
$dir = api_get_path(SYS_PUBLIC_PATH).'css/' . $themeDir . '/images/';
$url = api_get_path(WEB_CSS_PATH).'/' . $themeDir . '/images/';
$dir = api_get_path(SYS_PUBLIC_PATH).'css/'.$themeDir.'/images/';
$url = api_get_path(WEB_CSS_PATH).'/'.$themeDir.'/images/';
$logoFileName = 'header-logo.png';
$newLogoFileName = 'header-logo-custom' . api_get_current_access_url_id() . '.png';
$webPlatformLogoPath = ChamiloApi::getWebPlatformLogoPath($selected);
@ -698,7 +694,7 @@ function storeStylesheets()
/**
* This function checks if the given style is a recognize style that exists in the css directory as
* a standalone directory.
* @param string Style
* @param string $style
* @return bool True if this style is recognized, false otherwise
*/
function isStyle($style)

@ -25,6 +25,12 @@ $_SESSION['this_section'] = $this_section;
// Access restrictions.
api_protect_admin_script();
// Submit stylesheets.
if (isset($_POST['save']) && isset($_GET['category']) && $_GET['category'] === 'Stylesheets') {
storeStylesheets();
Display::addFlash(Display::return_message(get_lang('Saved')));
}
// Settings to avoid
$settings_to_avoid = array(
'use_session_mode' => 'true',
@ -468,7 +474,6 @@ foreach ($resultcategories as $row) {
$action_array[] = $url;
}
ob_start();
if (!empty($_GET['category'])) {
switch ($_GET['category']) {

@ -4289,12 +4289,23 @@ function api_get_visual_theme()
{
static $visual_theme;
if (!isset($visual_theme)) {
$platform_theme = api_get_setting('stylesheets');
// Get style directly from DB
$styleFromDatabase = api_get_settings_params_simple(
[
'variable = ? AND access_url = ?' => [
'stylesheets',
api_get_current_access_url_id(),
],
]
);
if ($styleFromDatabase) {
$platform_theme = $styleFromDatabase['selected_value'];
} else {
$platform_theme = api_get_setting('stylesheets');
}
// Platform's theme.
$visual_theme = $platform_theme;
if (api_get_setting('user_selected_theme') == 'true') {
$user_info = api_get_user_info();
if (isset($user_info['theme'])) {

Loading…
Cancel
Save