- Модуль: dav
- Путь к файлу: ~/bitrix/modules/dav/classes/general/calendarhandler.php
- Класс: CDavCalendarHandler
- Вызов: CDavCalendarHandler::Propfind
public function Propfind(&$arResources, $siteId, $account, $arPath, $id = null)
{
$calendarId = $this->GetCalendarId($siteId, $account, $arPath);
if ($calendarId == null)
return '404 Not Found';
$request = $this->groupdav->GetRequest();
$currentPrincipal = $request->GetPrincipal();
if (!$this->CheckPrivileges('urn:ietf:params:xml:ns:caldav:read-free-busy', $currentPrincipal, $calendarId))
return '403 Forbidden';
$requestDocument = $request->GetXmlDocument();
$path = CDav::CheckIfRightSlashAdded($request->GetPath());
list($iblockId, $sectionId, $subSectionId, $accountType) = $calendarId;
$isCalendarCollection = (!empty($accountType) && $subSectionId != 0 || empty($accountType) && $sectionId != 0);
if (!$isCalendarCollection)
{
$arCalendarList = CEventCalendar::GetCalendarList($calendarId);
foreach ($arCalendarList as $calendar)
{
$resource = new CDavResource($path.$calendar["ID"]."/");
$this->GetCalendarProperties($resource, $siteId, $account, array($calendar["ID"]), 0);
$arResources[] = $resource;
}
return true;
}
$bCalendarData = (count($requestDocument->GetPath('/*/DAV::allprop')) > 0);
if (!$bCalendarData || $requestDocument->GetRoot()->GetXmlns() != CDavGroupDav::CALDAV)
{
$arProp = $requestDocument->GetPath('/*/DAV::prop/*');
foreach ($arProp as $prop)
{
if ($prop->GetTag() == 'calendar-data')
{
$bCalendarData = true;
break;
}
}
}
$arFilter = array(
'DATE_START' => ConvertTimeStamp(time() - 31 * 24 * 3600, "FULL"), // default one month back
'DATE_END' => ConvertTimeStamp(time() + 365 * 24 * 3600, "FULL"), // default one year into the future
);
if (($id || $requestDocument->GetRoot() && $requestDocument->GetRoot()->GetTag() != 'propfind') && !$this->PrepareFilters($arFilter, $requestDocument, $id))
return false;
$arEvents = CEventCalendar::GetCalendarEventsList($calendarId, $arFilter);
foreach ($arEvents as $event)
{
if (!$this->CheckPrivileges('DAV::read', $currentPrincipal, $calendarId))
$this->ClearPrivateData($event);
$resource = new CDavResource($path.$this->GetPath($event));
$resource->AddProperty('getetag', $this->GetETag($calendarId, $event));
$resource->AddProperty('getcontenttype', $request->GetAgent() != 'kde' ? 'text/calendar; charset=utf-8; component=VEVENT' : 'text/calendar');
$resource->AddProperty('getlastmodified', MakeTimeStamp($event['TIMESTAMP_X']));
$resource->AddProperty('resourcetype', '');
if ($bCalendarData)
{
$content = $this->GetICalContent($event, $siteId);
$resource->AddProperty('getcontentlength', mb_strlen($content));
$resource->AddProperty('calendar-data', $content, CDavGroupDav::CALDAV);
}
else
{
$resource->AddProperty('getcontentlength', "");
}
$arResources[] = $resource;
}
return true;
}