FIX compatibility with MULTICOMPANY_TRANSVERSE_MODE (#30599)

This commit is contained in:
Regis Houssin 2024-08-10 23:07:51 +02:00 committed by GitHub
parent a11a477b90
commit b235fa4f5b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -96,6 +96,10 @@ if (!isModEnabled('multicompany')) {
$langs->load("admin");
$bookmarkList .= '<br><span class="opacitymedium">'.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("MultiCompany")).'</span>';
$bookmarkList .= '<br><br>';
} elseif (!empty($user->entity) && !getDolGlobalInt('MULTICOMPANY_TRANSVERSE_MODE')) { // Should not be accessible if the option to centralize users on the main entity is not activated
$langs->load("errors");
$bookmarkList .= '<br><span class="opacitymedium">'.$langs->trans("ErrorForbidden").'</span>';
$bookmarkList .= '<br><br>';
} else {
// Instantiate hooks of thirdparty module
$hookmanager->initHooks(array('multicompany'));
@ -106,11 +110,15 @@ if (!isModEnabled('multicompany')) {
if (is_object($mc)) {
$listofentities = $mc->getEntitiesList($user->login, false, true);
$listofentities = $mc->getEntitiesList(true, false, true);
}
$multicompanyList .= '<ul class="ullistonly left" style="list-style: none;">';
foreach ($listofentities as $entityid => $entitycursor) {
// Check if the user has the right to access the entity
if (getDolGlobalInt('MULTICOMPANY_TRANSVERSE_MODE') && !empty($user->entity) && $mc->checkRight($user->id, $entityid) < 0) {
continue;
}
$url = DOL_URL_ROOT.'/core/multicompany_page.php?action=switchentity&token='.newToken().'&entity='.((int) $entityid).($backtourl ? '&backtourl='.urlencode($backtourl) : '');
$multicompanyList .= '<li class="lilistonly" style="height: 2.5em; font-size: 1.15em;">';
$multicompanyList .= '<a class="dropdown-item multicompany-item" id="multicompany-item-'.$entityid.'" data-id="'.$entityid.'" href="'.dol_escape_htmltag($url).'">';