diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php
index 8b273aa41b1..b50ead06957 100644
--- a/htdocs/admin/system/security.php
+++ b/htdocs/admin/system/security.php
@@ -40,6 +40,8 @@ require '../../main.inc.php';
* @var string $dolibarr_main_restrict_ip
* @var string $dolibarr_main_db_pass
* @var string $dolibarr_main_db_encrypted_pass
+ * @var string $dolibarr_main_stream_to_disable
+ * @var string $dolibarr_nocsrfcheck
*/
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
@@ -398,7 +400,7 @@ if (empty($dolibarr_main_restrict_eval_methods)) {
} else {
print $dolibarr_main_restrict_eval_methods;
}
-print ' ('.$langs->trans("RecommendedValueIs", 'getDolGlobalString,getDolGlobalInt,getDolCurrency,fetchNoCompute,hasRight,isModEnabled,isStringVarMatching,abs,min,max,round,dol_now,dol_concat,preg_match').')';
+print ' ('.$langs->trans("RecommendedValueIs", 'getDolGlobalString,getDolGlobalInt,getDolCurrency,fetchNoCompute,hasRight,isAdmin,isModEnabled,isStringVarMatching,abs,min,max,round,dol_now,dol_concat,preg_match').')';
print '
';
if (!getDolGlobalString('SECURITY_DISABLE_TEST_ON_OBFUSCATED_CONF')) {
diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example
index 66b79e84ccf..045198af867 100644
--- a/htdocs/conf/conf.php.example
+++ b/htdocs/conf/conf.php.example
@@ -316,11 +316,11 @@ $dolibarr_main_restrict_os_commands='mariadb-dump, mariadb, mysqldump, mysql, pg
// ==================================
// A whitelist of functions and methods to restrict the commands you can execute in a custom calculated fields, like "computed fields" of
// extrafields or string conditions of extrafields.
-// Default value: 'getDolGlobalString, getDolGlobalInt, getDolCurrency, fetchNoCompute, hasRight, isModEnabled, isStringVarMatching, abs, round, dol_now, preg_match'
+// Default value: 'getDolGlobalString, getDolGlobalInt, getDolCurrency, fetchNoCompute, hasRight, isAdmin, isModEnabled, isStringVarMatching, abs, round, dol_now, preg_match'
// Examples:
-// $dolibarr_main_restrict_eval_methods='getDolGlobalString, getDolGlobalInt, getDolCurrency, fetchNoCompute, hasRight, isModEnabled, isStringVarMatching, abs, min, max, round, dol_now, dol_concat, preg_match';
+// $dolibarr_main_restrict_eval_methods='getDolGlobalString, getDolGlobalInt, getDolCurrency, fetchNoCompute, hasRight, isAdmin, isModEnabled, isStringVarMatching, abs, min, max, round, dol_now, dol_concat, preg_match';
//
-$dolibarr_main_restrict_eval_methods='getDolGlobalString, getDolGlobalInt, getDolCurrency, fetchNoCompute, hasRight, isModEnabled, isStringVarMatching, abs, min, max, round, dol_now, preg_match';
+$dolibarr_main_restrict_eval_methods='getDolGlobalString, getDolGlobalInt, getDolCurrency, fetchNoCompute, hasRight, isAdmin, isModEnabled, isStringVarMatching, abs, min, max, round, dol_now, preg_match';
// dolibarr_main_disabled_modules
// ==================================
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index b55214b6bb6..a2136039999 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -11970,7 +11970,7 @@ function dol_eval_standard($s, $hideerrors = 1, $onlysimplestring = '1')
// Set $dolibarr_main_restrict_eval_methods_array
if (!isset($dolibarr_main_restrict_eval_methods)) {
- $dolibarr_main_restrict_eval_methods = 'getDolGlobalString, getDolGlobalInt, getDolCurrency, fetchNoCompute, hasRight, isModEnabled, isStringVarMatching, abs, min, max, round, dol_now, preg_match';
+ $dolibarr_main_restrict_eval_methods = 'getDolGlobalString, getDolGlobalInt, getDolCurrency, fetchNoCompute, hasRight, isAdmin, isModEnabled, isStringVarMatching, abs, min, max, round, dol_now, preg_match';
}
//print '$dolibarr_main_restrict_eval_methods = '.$dolibarr_main_restrict_eval_methods."\n";
$dolibarr_main_restrict_eval_methods_array = explode(',', str_replace(" ", "", $dolibarr_main_restrict_eval_methods));
@@ -12063,13 +12063,14 @@ function dol_eval_standard($s, $hideerrors = 1, $onlysimplestring = '1')
$savescheck = $scheck;
$scheck = preg_replace('/\$conf->[a-z\_]+->enabled/', '__VARCONFENABLED__', $scheck); // Remove this once $user->module->enabled has been replaced everywhere with isModEnabled.
$scheck = preg_replace('/\$user->hasRight/', '__VARUSERHASRIGHT__', $scheck);
- $scheck = preg_replace('/\$user->rights/', '__VARUSERHASRIGHT__', $scheck); // Remove this once $user->rights->xxx is removed everywhere.
+ $scheck = preg_replace('/\$user->rights/', '__VARUSERHASRIGHT__', $scheck); // Remove this once $user->rights->xxx is replaced everywhere with $user->hasRight()
+ $scheck = preg_replace('/\$user->admin/', '__VARUSERISADMIN__', $scheck); // Remove this once $user->admin is replaced everywhere with $user->isAdmin()
$scheck = preg_replace('/\(\$db\)/', '__VARDB__', $scheck);
$scheck = preg_replace('/\$langs/', '__VARLANGSTRANS__', $scheck);
$scheck = preg_replace('/\$mysoc/', '__VARMYSOC__', $scheck);
$scheck = preg_replace('/\$action/', '__VARACTION__', $scheck);
- $scheck = preg_replace('/\$mainmenu/', '__VARMAINMENU__', $scheck);
- $scheck = preg_replace('/\$leftmenu/', '__VARLEFTMENU__', $scheck);
+ $scheck = preg_replace('/\$mainmenu/', '__VARMAINMENU__', $scheck); // Remove this once all tests on $mainmenu has been replaced with isStringVarMatching
+ $scheck = preg_replace('/\$leftmenu/', '__VARLEFTMENU__', $scheck); // Remove this once all tests on $mainmenu has been replaced with isStringVarMatching
$scheck = preg_replace('/\$websitepage/', '__VARWEBSITEPAGE__', $scheck);
$scheck = preg_replace('/\$website/', '__VARWEBSITE__', $scheck);
$scheck = preg_replace('/\$objectoffield/', '__VAROBJECTOFFIELD__', $scheck);
diff --git a/htdocs/core/modules/modBarcode.class.php b/htdocs/core/modules/modBarcode.class.php
index 537146ff9ac..e3a6995aeae 100644
--- a/htdocs/core/modules/modBarcode.class.php
+++ b/htdocs/core/modules/modBarcode.class.php
@@ -128,7 +128,7 @@ class modBarcode extends DolibarrModules
'url'=>'/barcode/codeinit.php?mainmenu=home&leftmenu=admintools',
'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>300,
- 'enabled'=>'isModEnabled("barcode") && preg_match(\'/^(admintools|all)/\',$leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
+ 'enabled'=>'isModEnabled("barcode") && preg_match(\'/^(admintools|all)/\', $leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'$user->admin',
'target'=>'',
'user'=>0, // 0=Menu for internal users, 1=external users, 2=both
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index 93a0a844303..9be513889f6 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -869,6 +869,18 @@ class User extends CommonObject
return 1;
}
+ /**
+ * Return if a user is an admin user
+ * It replaces old syntax: if ($user->admin)
+ *
+ * @return int<0,1> Return integer 1 if user is admin, 0 if not.
+ */
+ public function isAdmin()
+ {
+ return $this->admin;
+ }
+
+
/**
* Return if a user has a permission.
* You can use it like this: if ($user->hasRight('module', 'level11')).