From 101ba8dad3cc7fb5f12dd011c55f0a2bbec49e34 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 31 May 2023 14:20:33 +0200 Subject: [PATCH] #11001 tips correction --- .../include/class/TipsWindow.class.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/class/TipsWindow.class.php b/pandora_console/include/class/TipsWindow.class.php index 0aafe10ff0..94a6f6a4ba 100644 --- a/pandora_console/include/class/TipsWindow.class.php +++ b/pandora_console/include/class/TipsWindow.class.php @@ -275,14 +275,14 @@ class TipsWindow $sql .= ' ORDER BY CASE WHEN id_lang = "'.$language.'" THEN id_lang END DESC, RAND()'; $tip = db_get_row_sql($sql); - + $check_tips = db_get_row_sql('SELECT count(*) AS tips FROM twelcome_tip WHERE id_lang = "'.$language.'"')['tips']; if (empty($tip) === false) { $tip['files'] = $this->getFilesFromTip($tip['id']); $tip['title'] = io_safe_output($tip['title']); $tip['text'] = io_safe_output($tip['text']); $tip['url'] = io_safe_output($tip['url']); - } else { + } else if ($check_tips === '0') { $language = 'en_GB'; $sql = 'SELECT id, title, text, url FROM twelcome_tip @@ -325,6 +325,15 @@ class TipsWindow global $config; $profilesUser = users_get_user_profile($config['id_user']); $idProfilesFilter = '0'; + $userInfo = users_get_user_by_id($config['id_user']); + $language = ($userInfo['language'] !== 'default') ? $userInfo['language'] : $config['language']; + + $check_tips = db_get_row_sql('SELECT count(*) AS tips FROM twelcome_tip WHERE id_lang = "'.$language.'"')['tips']; + + if ($check_tips === '0') { + $language = 'en_GB'; + } + foreach ($profilesUser as $key => $profile) { $idProfilesFilter .= ','.$profile['id_perfil']; } @@ -334,10 +343,9 @@ class TipsWindow WHERE enable = "1" '; $sql .= sprintf(' AND id_profile IN (%s)', $idProfilesFilter); - $sql .= sprintf(' AND id_lang = "%s"', $config['language']); - - $sql .= ' ORDER BY CASE WHEN id_lang = "'.$config['language'].'" THEN id_lang END DESC, RAND()'; + $sql .= sprintf(' AND id_lang = "%s"', $language); + $sql .= ' ORDER BY CASE WHEN id_lang = "'.$language.'" THEN id_lang END DESC, RAND()'; return db_get_sql($sql); }