diff --git a/core/userrights.class.inc.php b/core/userrights.class.inc.php index f6fa7e7d2..9d7c897ab 100644 --- a/core/userrights.class.inc.php +++ b/core/userrights.class.inc.php @@ -1421,6 +1421,45 @@ class UserRights return $aAllowedPortals; } + /** + * @see UR_ACTION_READ, UR_ACTION_MODIFY, ... + * + * @param int $iActionCode + * @param array $aCategories + * @param bool $bWithLabels + * @param \User|null $oUser + * + * @return array + * @throws \DictExceptionMissingString + * @throws \CoreException + */ + public static function GetAllowedClasses($iActionCode, $aCategories = array('bizmodel'), $bWithLabels = false, $oUser = null) + { + $aAllowedClasses = []; + foreach(MetaModel::GetClasses(implode(',', $aCategories)) as $sClass) + { + if(static::IsActionAllowed($sClass, $iActionCode, null, $oUser) === UR_ALLOWED_YES) + { + if($bWithLabels) + { + $aAllowedClasses[$sClass] = MetaModel::GetName($sClass); + } + else + { + $aAllowedClasses[] = $sClass; + } + } + } + + // Sort by label + if($bWithLabels) + { + asort($aAllowedClasses); + } + + return $aAllowedClasses; + } + /** * @param \User|null $oUser *