Fix permission from group not found

This commit is contained in:
Laurent Destailleur 2022-01-24 18:32:03 +01:00
parent bb11ab992b
commit d560483875

View File

@ -1149,9 +1149,12 @@ class User extends CommonObject
$sql .= " AND r.entity = ".((int) $conf->entity);
}
} else {
$sql .= " AND gr.entity = ".((int) $conf->entity);
$sql .= " AND gu.entity = ".((int) $conf->entity);
$sql .= " AND r.entity = ".((int) $conf->entity);
$sql .= " AND gr.entity = ".((int) $conf->entity); // Only groups created in current entity
// The entity on the table usergroup_user should be useless and shoumd never be used because it is alreay into gr and r.
// but when using MULTICOMPANY_TRANSVERSE_MODE, we may insert record that make rubbish result due to duplicate record of
// other entities, so we are forced to add a filter here
$sql .= " AND gu.entity IN (0,".$conf->entity.")";
$sql .= " AND r.entity = ".((int) $conf->entity); // Only permission of modules enabled in current entity
}
$sql .= " AND gr.fk_usergroup = gu.fk_usergroup";
$sql .= " AND gu.fk_user = ".((int) $this->id);