Merge pull request #18925 from OPEN-DSI/v14-fix-cron-reload-user-langs
FIX reload user lang
This commit is contained in:
commit
4fba60d2bb
@ -76,9 +76,6 @@ $userlogin = $argv[2];
|
|||||||
$version = DOL_VERSION;
|
$version = DOL_VERSION;
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
// Language Management
|
|
||||||
$langs->loadLangs(array('main', 'admin', 'cron', 'dict'));
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Main
|
* Main
|
||||||
@ -125,7 +122,7 @@ if ($userlogin == 'firstadmin') {
|
|||||||
|
|
||||||
// Check user login
|
// Check user login
|
||||||
$user = new User($db);
|
$user = new User($db);
|
||||||
$result = $user->fetch('', $userlogin);
|
$result = $user->fetch('', $userlogin, '', 1);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
echo "User Error: ".$user->error;
|
echo "User Error: ".$user->error;
|
||||||
dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR);
|
dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR);
|
||||||
@ -137,6 +134,19 @@ if ($result < 0) {
|
|||||||
exit(-1);
|
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);
|
||||||
|
$langs->tab_translate = array();
|
||||||
|
}
|
||||||
|
// Language Management
|
||||||
|
$langs->loadLangs(array('main', 'admin', 'cron', 'dict'));
|
||||||
|
|
||||||
$user->getrights();
|
$user->getrights();
|
||||||
|
|
||||||
if (isset($argv[3]) && $argv[3]) {
|
if (isset($argv[3]) && $argv[3]) {
|
||||||
@ -195,8 +205,8 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) {
|
|||||||
$mysoc->setMysoc($conf);
|
$mysoc->setMysoc($conf);
|
||||||
|
|
||||||
// Force recheck that user is ok for the entity to process and reload permission for entity
|
// Force recheck that user is ok for the entity to process and reload permission for entity
|
||||||
if ($conf->entity != $user->entity && $user->entity != 0) {
|
if ($conf->entity != $user->entity) {
|
||||||
$result = $user->fetch('', $userlogin, '', 0, $conf->entity);
|
$result = $user->fetch('', $userlogin, '', 1);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
echo "\nUser Error: ".$user->error."\n";
|
echo "\nUser Error: ".$user->error."\n";
|
||||||
dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR);
|
dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR);
|
||||||
@ -218,6 +228,8 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) {
|
|||||||
}
|
}
|
||||||
if ($langs->getDefaultLang() != $langcode) {
|
if ($langs->getDefaultLang() != $langcode) {
|
||||||
$langs->setDefaultLang($langcode);
|
$langs->setDefaultLang($langcode);
|
||||||
|
$langs->tab_translate = array();
|
||||||
|
$langs->loadLangs(array('main', 'admin', 'cron', 'dict'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user