• Модуль: intranet
  • Путь к файлу: ~/bitrix/modules/intranet/classes/general/event_calendar.php
  • Класс: CEventCalendar
  • Вызов: CEventCalendar::GetUserPermissionsForCalendar
static function GetUserPermissionsForCalendar($calendarId, $userId)
{
	[$iblockId, $sectionId, $subSectionId, $ownerType, $owberId] = $calendarId;

	$ownerType = mb_strtoupper($ownerType);

	$arParams = array(
		'iblockId' => $iblockId,
		'userId' => $userId,
		'bOwner' => false,
		'ownerId' => null,
		'ownerType' => null,
		'bCheckSocNet' => false,
		'setProperties' => false,
	);
	if (!empty($ownerType))
	{
		$arParams['bCheckSocNet'] = true;
		$arParams['ownerType'] = $ownerType;
		$arParams['bOwner'] = true;

		$arFilter = Array(
			"ID" => $sectionId,
			"IBLOCK_ID" => $iblockId,
			"ACTIVE" => "Y",
		);

		$dbSection = CIBlockSection::GetList(array('ID' => 'ASC'), $arFilter);
		if ($arSection = $dbSection->Fetch())
		{
			if ($ownerType == 'USER')
				$arParams['ownerId'] = $arSection['CREATED_BY'];
			elseif ($ownerType == 'GROUP')
				$arParams['ownerId'] = $arSection['SOCNET_GROUP_ID'];
		}
	}

	CModule::IncludeModule("socialnetwork");

	$cal = self::GetInstance();
	$cal->Init(array(
			'iblockId' => $iblockId,
			'ownerId' => $arParams['ownerId'],
			'ownerType' => $ownerType,
	));

	$arPermissions = $cal->GetPermissions($arParams);

	if ($ownerType == 'USER' && $arParams['ownerId'] != $userId)
	{
		$privateStatus = CECCalendar::GetPrivateStatus($iblockId, ($subSectionId > 0 ? $subSectionId : $sectionId), "USER");
		if ($privateStatus == 'private')
			$arPermissions = array('bAccess' => false, 'bReadOnly' => true);

		$arPermissions["privateStatus"] = $privateStatus;
	}

	return $arPermissions;
}