NEW Introduce getCurrency(). $conf is no more allowed into computed

formulae.
This commit is contained in:
Laurent Destailleur
2025-11-17 10:29:55 +01:00
parent f837fb4fa8
commit 1dd28e352a

View File

@@ -286,6 +286,17 @@ function getDolGlobalBool($key, $default = false)
return (bool) ($conf->global->$key ?? $default);
}
/**
* Return the main currency ('EUR', 'USD', ...)
*
* @return string Value returned
*/
function getDolCurrency()
{
global $conf;
return (string) $conf->currency;
}
/**
* Return Dolibarr user constant string value
*
@@ -11803,8 +11814,9 @@ function dol_eval_new($s)
function dol_eval_standard($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring = '1')
{
// Only this global variables can be read by eval function and returned to caller
global $conf; // Read of const is done with getDolGlobalString() but we need $conf->currency for example
global $db, $langs, $user, $website, $websitepage;
//global $conf; // Disabled. Read of const is done with getDolGlobalString() and read of $conf->currency is done with getDolCurrency()
global $db;
global $langs, $user, $website, $websitepage;
global $action, $mainmenu, $leftmenu;
global $mysoc;
global $objectoffield; // To allow the use of $objectoffield in computed fields