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/bookcal/availabilities_card.php b/htdocs/bookcal/availabilities_card.php index c1c16c872a3..3fd20bdc904 100644 --- a/htdocs/bookcal/availabilities_card.php +++ b/htdocs/bookcal/availabilities_card.php @@ -26,12 +26,6 @@ // Load Dolibarr environment require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_availabilities.lib.php'; - /** * @var Conf $conf * @var DoliDB $db @@ -40,6 +34,11 @@ require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_availabilities.lib.php'; * @var Translate $langs * @var User $user */ +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_availabilities.lib.php'; // Load translation files required by the page $langs->loadLangs(array("agenda", "other")); @@ -111,20 +110,20 @@ $upload_dir = $conf->bookcal->multidir_output[isset($object->entity) ? $object-> //if ($user->socid > 0) $socid = $user->socid; //$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0); //restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (!isModEnabled('bookcal')) { +if (!isModEnabled("bookcal")) { accessforbidden(); } if (!$permissiontoread) { accessforbidden(); } +$error = 0; + /* * Actions */ -$error = 0; - $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -151,11 +150,6 @@ if (empty($reshook)) { $startyear = GETPOSTINT('startyear'); $starthour = GETPOSTINT('startHour'); - if (GETPOST('startHour') == "" && ($action == 'add' || $action == 'update')) { // Test on permission not required - $error++; - setEventMessages($langs->trans("ErrorStartHourIsNull"), $hookmanager->errors, 'errors'); - } - $dateStartTimestamp = dol_mktime($starthour, 0, 0, $startmonth, $startday, $startyear); $endday = GETPOSTINT('endday'); @@ -163,28 +157,31 @@ if (empty($reshook)) { $endyear = GETPOSTINT('endyear'); $endhour = GETPOSTINT('endHour'); - if (GETPOST('endHour') == "" && ($action == 'add' || $action == 'update')) { // Test on permission not required - $error++; - setEventMessages($langs->trans("ErrorEndHourIsNull"), $hookmanager->errors, 'errors'); - } - $dateEndTimestamp = dol_mktime($endhour, 0, 0, $endmonth, $endday, $endyear); - // check hours - if ($starthour > $endhour) { - if ($dateStartTimestamp === $dateEndTimestamp) { + if (! $cancel) { + if (GETPOST('startHour') == "" && ($action == 'add' || $action == 'update')) { // Test on permission not required $error++; - setEventMessages($langs->trans("ErrorEndTimeMustBeGreaterThanStartTime"), $hookmanager->errors, 'errors'); + setEventMessages($langs->trans("ErrorStartHourIsNull"), $hookmanager->errors, 'errors'); + } + if (GETPOST('endHour') == "" && ($action == 'add' || $action == 'update')) { // Test on permission not required + $error++; + setEventMessages($langs->trans("ErrorEndHourIsNull"), $hookmanager->errors, 'errors'); + } + // Check hours + if ($starthour > $endhour) { + if ($dateStartTimestamp === $dateEndTimestamp) { + $error++; + setEventMessages($langs->trans("ErrorEndTimeMustBeGreaterThanStartTime"), $hookmanager->errors, 'errors'); + } + } + // Check date + if (($dateStartTimestamp != "") && ($dateStartTimestamp >= $dateEndTimestamp)) { + $error++; + setEventMessages($langs->trans("ErrorIncoherentDates"), $hookmanager->errors, 'errors'); } } - // check date - if (($dateStartTimestamp != "") && ($dateStartTimestamp >= $dateEndTimestamp)) { - $error++; - setEventMessages($langs->trans("ErrorIncoherentDates"), $hookmanager->errors, 'errors'); - } - - // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; @@ -251,6 +248,9 @@ if ($action == 'create') { if ($backtopageforcancel) { print ''; } + if ($dol_openinpopup) { + print ''; + } print dol_get_fiche_head(array(), ''); diff --git a/htdocs/bookcal/calendar_card.php b/htdocs/bookcal/calendar_card.php index f11d7034da7..d3c2f67c34f 100644 --- a/htdocs/bookcal/calendar_card.php +++ b/htdocs/bookcal/calendar_card.php @@ -118,6 +118,8 @@ if (!$permissiontoread) { accessforbidden(); } +$error = 0; + /* * Actions @@ -130,8 +132,6 @@ if ($reshook < 0) { } if (empty($reshook)) { - $error = 0; - $backurlforlist = dol_buildpath('/bookcal/calendar_list.php', 1); if (empty($backtopage) || ($cancel && empty($id))) { 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 32bf09fddc5..a2136039999 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9550,8 +9550,18 @@ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = ' $matches = array(); if (preg_match_all($pattern, $out, $matches)) { - // URLs are into $matches[1] - $urls = $matches[1]; + // URLs are into $matches[1] or $matches[2] + $urls = array(); + foreach ($matches[1] as $tmpval) { + if (!empty($tmpval)) { + $urls[] = $tmpval; + } + } + foreach ($matches[2] as $tmpval) { + if (!empty($tmpval)) { + $urls[] = $tmpval; + } + } // Show URLs $firstexturl = ''; @@ -11960,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)); @@ -12053,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/core/modules/modBookCal.class.php b/htdocs/core/modules/modBookCal.class.php index 99d9f267961..3e9bdd1abc1 100644 --- a/htdocs/core/modules/modBookCal.class.php +++ b/htdocs/core/modules/modBookCal.class.php @@ -323,7 +323,7 @@ class modBookCal extends DolibarrModules 'langs' => 'bookcal', 'position' => 1100 + $r, 'enabled' => '1', - 'perms' => '$user->rights->bookcal->calendar->read', + 'perms' => '$user->hasRight("bookcal", "calendar", "read")', 'user' => 0 ); @@ -340,9 +340,9 @@ class modBookCal extends DolibarrModules 'langs' => 'bookcal', 'position' => 1100 + $r, // Define condition to show or hide menu entry. Use '$conf->bookcal->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'enabled' => '$conf->bookcal->enabled', + 'enabled' => 'isModEnabled("bookcal")', // Use 'perms'=>'$user->rights->bookcal->level1->level2' if you want your menu with a permission rules - 'perms' => '$user->rights->bookcal->calendar->read', + 'perms' => '$user->hasRight("bookcal", "calendar", "read")', 'target' => '', // 0=Menu for internal users, 1=external users, 2=both 'user' => 2, @@ -360,9 +360,9 @@ class modBookCal extends DolibarrModules 'langs' => 'bookcal', 'position' => 1100 + $r, // Define condition to show or hide menu entry. Use '$conf->bookcal->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'enabled' => '$conf->bookcal->enabled', + 'enabled' => 'isModEnabled("bookcal")', // Use 'perms'=>'$user->rights->bookcal->level1->level2' if you want your menu with a permission rules - 'perms' => '$user->rights->bookcal->calendar->read', + 'perms' => '$user->hasRight("bookcal", "calendar", "read")', 'target' => '', // 0=Menu for internal users, 1=external users, 2=both 'user' => 2 @@ -384,9 +384,9 @@ class modBookCal extends DolibarrModules 'langs' => 'bookcal', 'position' => 1200 + $r, // Define condition to show or hide menu entry. Use '$conf->bookcal->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'enabled' => '$conf->bookcal->enabled', + 'enabled' => 'isModEnabled("bookcal")', // Use 'perms'=>'$user->rights->bookcal->level1->level2' if you want your menu with a permission rules - 'perms' => '$user->rights->bookcal->availabilities->read', + 'perms' => '$user->hasRight("bookcal", "availabilities", "read")', 'target' => '', // 0=Menu for internal users, 1=external users, 2=both 'user' => 2, @@ -404,9 +404,9 @@ class modBookCal extends DolibarrModules 'langs' => 'bookcal', 'position' => 1200 + $r, // Define condition to show or hide menu entry. Use '$conf->bookcal->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'enabled' => '$conf->bookcal->enabled', + 'enabled' => 'isModEnabled("bookcal")', // Use 'perms'=>'$user->rights->bookcal->level1->level2' if you want your menu with a permission rules - 'perms' => '$user->rights->bookcal->availabilities->read', + 'perms' => '$user->hasRight("bookcal", "availabilities", "read")', 'target' => '', // 0=Menu for internal users, 1=external users, 2=both 'user' => 2 diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 010f9a25d4d..f00273f3599 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -96,7 +96,7 @@ if (empty($origin_id) && !empty($origin)) { if (empty($origin_id) && !empty($origin)) { $origin_id = GETPOSTINT('object_id'); // Id of order or propal } -$socid = GETPOSTINT('socid'); +$socid = GETPOSTINT('socid'); $ref = GETPOST('ref', 'alpha'); $line_id = GETPOSTINT('lineid'); $facid = GETPOSTINT('facid'); @@ -105,8 +105,8 @@ $projectid = GETPOSTINT('projectid'); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); -$rank = (GETPOSTINT('rank') > 0) ? GETPOSTINT('rank') : -1; -$lineid = GETPOSTINT('lineid'); +$rank = (GETPOSTINT('rank') > 0) ? GETPOSTINT('rank') : -1; +$lineid = GETPOSTINT('lineid'); $backtopage = GETPOST('backtopage', 'alpha'); //PDF @@ -308,10 +308,10 @@ if (empty($reshook)) { $object->origin_type = $origin; $object->origin_id = $origin_id; $object->fk_project = GETPOSTINT('projectid'); - $object->weight = GETPOSTINT('weight') == '' ? "NULL" : GETPOSTINT('weight'); - $object->sizeH = GETPOSTINT('sizeH') == '' ? "NULL" : GETPOSTINT('sizeH'); - $object->sizeW = GETPOSTINT('sizeW') == '' ? "NULL" : GETPOSTINT('sizeW'); - $object->sizeS = GETPOSTINT('sizeS') == '' ? "NULL" : GETPOSTINT('sizeS'); + $object->weight = GETPOST('weight') == '' ? '' : GETPOSTFLOAT('weight'); + $object->sizeH = GETPOST('sizeH') == '' ? '' : GETPOSTFLOAT('sizeH'); + $object->sizeW = GETPOST('sizeW') == '' ? '' : GETPOSTFLOAT('sizeW'); + $object->sizeS = GETPOST('sizeS') == '' ? '' : GETPOSTFLOAT('sizeS'); $object->size_units = GETPOSTINT('size_units'); $object->weight_units = GETPOSTINT('weight_units'); $object->ref_customer = GETPOST('ref_customer', 'alpha'); @@ -350,10 +350,10 @@ if (empty($reshook)) { $object->origin_type = $origin; $object->origin_id = $origin_id; $object->fk_project = GETPOSTINT('projectid'); - $object->weight = GETPOSTINT('weight') == '' ? "NULL" : GETPOSTINT('weight'); - $object->sizeH = GETPOSTINT('sizeH') == '' ? "NULL" : GETPOSTINT('sizeH'); - $object->sizeW = GETPOSTINT('sizeW') == '' ? "NULL" : GETPOSTINT('sizeW'); - $object->sizeS = GETPOSTINT('sizeS') == '' ? "NULL" : GETPOSTINT('sizeS'); + $object->weight = GETPOST('weight') == '' ? '' : GETPOSTFLOAT('weight'); + $object->sizeH = GETPOST('sizeH') == '' ? '' : GETPOSTFLOAT('sizeH'); + $object->sizeW = GETPOST('sizeW') == '' ? '' : GETPOSTFLOAT('sizeW'); + $object->sizeS = GETPOST('sizeS') == '' ? '' : GETPOSTFLOAT('sizeS'); $object->size_units = GETPOSTINT('size_units'); $object->weight_units = GETPOSTINT('weight_units'); $object->ref_customer = GETPOST('ref_customer', 'alpha'); @@ -767,18 +767,18 @@ if (empty($reshook)) { $object->tracking_url = trim(GETPOST('tracking_url', 'restricthtml')); } if ($action == 'settrueWeight') { // Test on permission not required - $object->trueWeight = GETPOSTINT('trueWeight'); + $object->trueWeight = GETPOSTFLOAT('trueWeight'); $object->weight_units = GETPOSTINT('weight_units'); } if ($action == 'settrueWidth') { // Test on permission not required - $object->trueWidth = GETPOSTINT('trueWidth'); + $object->trueWidth = GETPOSTFLOAT('trueWidth'); } if ($action == 'settrueHeight') { // Test on permission not required - $object->trueHeight = GETPOSTINT('trueHeight'); + $object->trueHeight = GETPOSTFLOAT('trueHeight'); $object->size_units = GETPOSTINT('size_units'); } if ($action == 'settrueDepth') { // Test on permission not required - $object->trueDepth = GETPOSTINT('trueDepth'); + $object->trueDepth = GETPOSTFLOAT('trueDepth'); } if ($action == 'setshipping_method_id') { // Test on permission not required $object->shipping_method_id = GETPOSTINT('shipping_method_id'); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 60d870b4ef6..6d04fcdd71a 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -152,7 +152,7 @@ class Expedition extends CommonObject public $billed; /** - * @var null|int|string + * @var null|int|float|'' */ public $trueWeight; /** @@ -160,7 +160,7 @@ class Expedition extends CommonObject */ public $weight_units; /** - * @var null|int|string + * @var null|int|float|'' */ public $trueWidth; /** @@ -168,7 +168,7 @@ class Expedition extends CommonObject */ public $width_units; /** - * @var null|int|string + * @var null|int|float|'' */ public $trueHeight; /** @@ -176,7 +176,7 @@ class Expedition extends CommonObject */ public $height_units; /** - * @var null|int|string + * @var null|int|float|'' */ public $trueDepth; /** @@ -184,7 +184,7 @@ class Expedition extends CommonObject */ public $depth_units; /** - * @var null|string A denormalized value + * @var null|string A denormalized value ex '1x2x4' */ public $trueSize; 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')). diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index b2283d7d240..840e7f803a8 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -501,6 +501,7 @@ foreach ($arrayofpermission as $i => $obj) { // Permission and tick (2 columns) print ''; + // @phan-suppress-next-line PhanTypeMismatchArgumentNullableInternal if (in_array($obj->id, $permsgroupbyentitypluszero)) { // Own permission by group if ($permissiontoedit) { diff --git a/test/phpunit/SecurityGETPOSTTest.php b/test/phpunit/SecurityGETPOSTTest.php index 349522241be..ed423c6cdea 100644 --- a/test/phpunit/SecurityGETPOSTTest.php +++ b/test/phpunit/SecurityGETPOSTTest.php @@ -490,13 +490,13 @@ class SecurityGETPOSTTest extends CommonClassTest $_POST["pagecontentwithnowrapperlinks"] = ''; $result = GETPOST("pagecontentwithnowrapperlinks", 'restricthtml'); print __METHOD__." result=".$result."\n"; - $this->assertEquals('ErrorHTMLExternalLinksNotAllowed', $result, 'Test on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1 (no links to http allowed)'); + $this->assertEquals('ErrorHTMLExternalLinksNotAllowed (Example: https://aaa)', $result, 'Test on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1 (no links to http allowed)'); // Test that links not on wrapper and not data are disallowed $_POST["pagecontentwithnowrapperlinks"] = ''; $result = GETPOST("pagecontentwithnowrapperlinks", 'restricthtml'); print __METHOD__." result=".$result."\n"; - $this->assertEquals('ErrorHTMLExternalLinksNotAllowed', $result, 'Test on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1 (no links to http allowed)'); + $this->assertEquals('ErrorHTMLExternalLinksNotAllowed (Example: http://ddd)', $result, 'Test on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1 (no links to http allowed)'); // Test substitution in GET url