From 1efc2eda694479940fd143cc8a5e6207c82a60be Mon Sep 17 00:00:00 2001 From: lvessiller Date: Fri, 8 Oct 2021 11:54:38 +0200 Subject: [PATCH 1/2] FIX reload user lang --- scripts/cron/cron_run_jobs.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 80f586a6788..7e6fb991478 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -125,7 +125,7 @@ if ($userlogin == 'firstadmin') { // Check user login $user = new User($db); -$result = $user->fetch('', $userlogin); +$result = $user->fetch('', $userlogin, '', 1); if ($result < 0) { echo "User Error: ".$user->error; dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR); @@ -137,6 +137,16 @@ if ($result < 0) { exit(-1); } } + +// Reload langs +$langcode = (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT); +if (!empty($user->conf->MAIN_LANG_DEFAULT)) { + $langcode = $user->conf->MAIN_LANG_DEFAULT; +} +if ($langs->getDefaultLang() != $langcode) { + $langs->setDefaultLang($langcode); +} + $user->getrights(); if (isset($argv[3]) && $argv[3]) { @@ -195,8 +205,8 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) { $mysoc->setMysoc($conf); // Force recheck that user is ok for the entity to process and reload permission for entity - if ($conf->entity != $user->entity && $user->entity != 0) { - $result = $user->fetch('', $userlogin, '', 0, $conf->entity); + if ($conf->entity != $user->entity) { + $result = $user->fetch('', $userlogin, '', 1); if ($result < 0) { echo "\nUser Error: ".$user->error."\n"; dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR); From 90be175c500d57f60118764b7a2110e118a7c07b Mon Sep 17 00:00:00 2001 From: lvessiller Date: Fri, 8 Oct 2021 16:20:51 +0200 Subject: [PATCH 2/2] FIX load tranlate array after setting lang --- scripts/cron/cron_run_jobs.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 7e6fb991478..8aa996f9c17 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -76,9 +76,6 @@ $userlogin = $argv[2]; $version = DOL_VERSION; $error = 0; -// Language Management -$langs->loadLangs(array('main', 'admin', 'cron', 'dict')); - /* * Main @@ -145,7 +142,10 @@ if (!empty($user->conf->MAIN_LANG_DEFAULT)) { } if ($langs->getDefaultLang() != $langcode) { $langs->setDefaultLang($langcode); + $langs->tab_translate = array(); } +// Language Management +$langs->loadLangs(array('main', 'admin', 'cron', 'dict')); $user->getrights(); @@ -228,6 +228,8 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) { } if ($langs->getDefaultLang() != $langcode) { $langs->setDefaultLang($langcode); + $langs->tab_translate = array(); + $langs->loadLangs(array('main', 'admin', 'cron', 'dict')); } }