$iblockId = 1; // Replace this with the desired infoblock ID $permissions = CIBlock::GetPermission($iblockId); // Get the current user's permission to access the infoblock if ($permissions >= "W") { // User has write access to the infoblock // Add code here } else { // User does not have write access to the infoblock // Handle error here }
$iblockId = 5; // Replace this with the desired infoblock ID $permissions = CIBlock::GetPermission($iblockId); // Get the current user's permission to access the infoblock switch ($permissions) { case "D": // User has denied access to the infoblock // Handle error here break; case "R": // User has read-only access to the infoblock // Add code here to display infoblock contents break; case "U": // User has update access to the infoblock // Add code here to allow the user to edit the infoblock contents break; case "X": // User has full access to the infoblock // Add code here to allow the user to do everything with the infoblock break; }In this example, the code checks the current user's permission level for the infoblock with ID 5. Depending on the permission level, different functions are executed. This is useful for controlling what the user can do with the infoblock. The CIBlock GetPermission function is part of the Bitrix framework's iblock package library.