• Модуль: intranet
  • Путь к файлу: ~/bitrix/modules/intranet/classes/general/event_calendar.php
  • Класс: CEventCalendar
  • Вызов: CEventCalendar::CheckPermissionForEvent
function CheckPermissionForEvent($arParams, $bOnlyUser = false)
{
	if (isset($GLOBALS['USER']) && $GLOBALS['USER']->CanDoOperation('edit_php'))
		return true;
	$ownerType = isset($arParams['ownerType']) ? $arParams['ownerType'] : $this->ownerType;
	if ($ownerType == 'USER' || $ownerType == 'GROUP')
	{
		$ownerId = isset($arParams['ownerId']) ? $arParams['ownerId'] : $this->ownerId;
		$SONET_ENT = $ownerType == 'USER' ? SONET_ENTITY_USER : SONET_ENTITY_GROUP;
		if (!CSocNetFeatures::IsActiveFeature($SONET_ENT, $ownerId, "calendar") ||
			!CSocNetFeaturesPerms::CanPerformOperation($this->userId, $SONET_ENT, $ownerId, "calendar", 'write'))
			return false;
		if ($bOnlyUser)
			return true;
		$calendarId = isset($arParams['calendarId']) ? intval($arParams['calendarId']) : 0;
		$sectionId = isset($arParams['sectionId']) ? $arParams['sectionId'] : $this->sectionId;
		$iblockId = isset($arParams['iblockId']) ? $arParams['iblockId'] : $this->iblockId;
		$arFilter = Array(
			"ID" => $calendarId,
			"SECTION_ID" => $sectionId,
			"IBLOCK_ID" => $iblockId,
			"ACTIVE" => "Y"
		);
		if ($ownerType == 'USER')
			$arFilter["CREATED_BY"] = $ownerId;
		else
			$arFilter["SOCNET_GROUP_ID"] = $ownerId;

		$rsData = CIBlockSection::GetList(Array('ID' => 'ASC'), $arFilter);

		$arRes = $rsData->Fetch();
		if (!$arRes)
			return false;
	}
	return true;
}