Bitrix Site Manager

CMain::GetUserRight

string
CMain::GetUserRight(
 string module_id,
 mixed groups = false,
 string use_default = "Y",
 string max_for_admin = "Y"
)

The method GetUserRight returns the access permission assigned to a number of groups (group of a current user by default) for the specified module. The permission descriptor returned is meaningful for the specified module.

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

A unique set of permissions can be assigned to the module using the method GetModuleRightList 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 method GetModuleRightList 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).

Parameters

ParameterDescription
module_id Module ID.
groups Array of groups for which the maximum permission is to be determined. Setting this parameter to false assumes the array of groups of the current user.
Optional; false by default.
use_default If set to "Y", the default access permission level is taken into consideration to determine the maximum permission level
Optional; "Y" by default.
max_for_admin If set to "Y" and the parameter groups is false, the maximum permission W is always returned for users in the Administrators group (#1) regardless of the module settings.
Optional; "Y" by default.

See Also

Example



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