Documentation

GetUserRight

string
CMain::GetUserRight(
 string module_id,
 mixed groups = false,
 string use_default_level = "Y",
 string max_right_for_super_admin = "Y",
 string site_id=false
)

The method returns the access permission within the module logic framework for a certain set of groups (by default - the groups of the current user).

Generally, each module has specific access permission descriptors. At the same time, there are several common descriptors:

  • D - access to the module is denied;
  • R - permission to view pages of the module (read-only access);
  • W - data modification is allowed.
A unique set of permissions can be assigned to the module using the GetModuleRightList method of a class named by the module ID. For example, the Web Forms module exposes method form::GetModuleRightList() defined in the file /bitrix/modules/form/install/index.php. Permissions are usually assigned using the module settings form.

Some modules require that the permissions are assigned individually (e.g. Information blocks) and some does not have access permissions at all (e.g. Compression). The GetModuleRightList method is not applicable to such modules.

Note. For any module, maximum level of permission is always indicated with the symbol W, (write), while the minimum permission - with D (deny).

Non-static method.

Parameters

ParameterDescription Available from version
module_id Module ID.
groups Array of groups for which the maximum access permission is to be determined. Setting this parameter to false, assumes the array of groups of the current user.
Optional parameter; false by default.
use_default_level If set to Y, the default access permission level is taken into consideration to determine the maximum access permission level.
Optional parameter; Y by default.
max_right_for_super_admin If set to Y and the groups = false, the maximum access permissionW is always returned for users in the Administrators group (#1) regardless of the module settings.
Optional parameter. По умолчанию - Y.
site_id Site ID.
Optional parameter; False by deafult.

See Also

  • CMain::GetUserRoles

    Examples of use

    <?
    // obtain the maximum access permission for the WebForms module for the current user
    if($APPLICATION->GetUserRight("form") <= "D") 
        $APPLICATION->AuthForm("access denied.");
    ?>


    © «Bitrix24», 2001-2022
    Up