- Модуль: calendar
- Путь к файлу: ~/bitrix/modules/calendar/classes/general/calendar_webservice.php
- Класс: CCalendarWebService
- Вызов: CCalendarWebService::__getRow
function __getRow($event, $listName, &$last_change)
{
$arStatusValues = $this->arStatusValues;
$arPriorityValues = $this->arPriorityValues;
$first_week_day = COption::GetOptionString('calendar', 'week_start', 'MO');
$first_week_day = mb_strtolower($first_week_day);
$change = MakeTimeStamp($event['TIMESTAMP_X']);
if ($last_change < $change)
{
$last_change = $change;
}
$bRecurrent = (isset($event['RRULE']) && $event['RRULE'] != "") ? 1 : 0;
$rrule = CCalendarEvent::ParseRRULE($event['RRULE']);
$bAllDay = $event['DT_SKIP_TIME'] !== 'N' ? 1 : 0;
$ts_start = CCalendar::Timestamp($event['DATE_FROM'], false, !$bAllDay);
$ts_finish = CCalendar::Timestamp($event['DATE_TO'], false, !$bAllDay);
if (!$bAllDay)
{
$ts_start -= $event['~USER_OFFSET_FROM'];
$ts_finish -= $event['~USER_OFFSET_FROM'];
}
$TZBias = intval(date('Z'));
$duration = $event['DT_LENGTH'];
if ($bAllDay)
$duration -= 20;
if (!$bAllDay || defined('OLD_OUTLOOK_VERSION'))
{
$ts_start = $event['DATE_FROM_TS_UTC']; // We need time in UTC
$ts_finish = $event['DATE_TO_TS_UTC'];
}
$obRow = new CXMLCreator('z:row');
$obRow->setAttribute('ows_ID', $event['ID']);
$obRow->setAttribute('ows_Title', htmlspecialcharsback($event['NAME'])); // we have data htmlspecialchared yet
$version = $event['VERSION'] ? $event['VERSION'] : 1;
$obRow->setAttribute('ows_Attachments', 0);
$obRow->setAttribute('ows_owshiddenversion', $version);
$obRow->setAttribute('ows_MetaInfo_vti_versionhistory', md5($event['ID']).':'.$version);
/*
ows_MetaInfo_BusyStatus='2' - Editor
ows_MetaInfo_IntendedBusyStatus='-1' - Creator
values:
-1 - Unspecified busy status. Protocol clients can choose to display one of the other values if BusyStatus is -1.
0 - Free - ACCESSIBILITY => 'free'
1 - Tentative - ACCESSIBILITY => 'quest'
2 - Busy - ACCESSIBILITY => 'busy'
3 - Out of Office - ACCESSIBILITY => 'absent'
*/
$status = $arStatusValues[$event['ACCESSIBILITY']];
$obRow->setAttribute('ows_MetaInfo_BusyStatus', $status === null ? -1 : $status);
$obRow->setAttribute('ows_MetaInfo_Priority', intval($arPriorityValues[$event['IMPORTANCE']]));
$obRow->setAttribute('ows_Created', $this->__makeDateTime(MakeTimeStamp($event['DATE_CREATE'])-$TZBias));
$obRow->setAttribute('ows_Modified', $this->__makeDateTime($change - $TZBias));
$obRow->setAttribute('ows_EventType', $bRecurrent ? 1 : 0);
$obRow->setAttribute('ows_Location', CCalendar::GetTextLocation($event['LOCATION']));
$obRow->setAttribute('ows_Description', $event['~DESCRIPTION']); // Description parsed from BB-codes to HTML
$obRow->setAttribute('ows_EventDate', $this->__makeDateTime($ts_start));
$obRow->setAttribute('ows_EndDate', $this->__makeDateTime($ts_start + $event['DT_LENGTH']));
$obRow->setAttribute('ows_fAllDayEvent', $bAllDay);
/* Recurrence */
$obRow->setAttribute('ows_fRecurrence', $bRecurrent);
if ($bRecurrent)
{
$obRow->setAttribute('ows_UID', CIntranetUtils::makeGUID(md5($event['ID'].'_'.$change)));
$tz_data = '';
$tz_data .= '';
$tz_data .= ''.(-intval(($TZBias - (date('I') ? 3600 : 0)) /60)).'';
$tz_data .= '-60';
$bUseTransition = COption::GetOptionString('intranet', 'tz_transition', 'Y') == 'Y';
if ($bUseTransition)
{
$transition_standard = COption::GetOptionString('intranet', 'tz_transition_standard', '');
$transition_daylight = COption::GetOptionString('intranet', 'tz_transition_daylight', '');
if (!$transition_standard) $transition_standard = '3:0:0';
if (!$transition_daylight) $transition_daylight = '2:0:0';
$tz_data .= ''.$transition_standard.''.$transition_daylight.'';
}
$tz_data .= '';
$obRow->setAttribute('ows_XMLTZone', $tz_data);
$recurence_data = '';
$recurence_data .= '';
$recurence_data .= '';
$recurence_data .= ''.$first_week_day.'';
$recurence_data .= '';
switch($rrule['FREQ'])
{
case 'DAILY':
$recurence_data .= '';
break;
case 'WEEKLY':
$days = '';
foreach ($rrule['BYDAY'] as $day)
$days .= mb_strtolower($day).'="TRUE" ';
$recurence_data .= '';
break;
case 'MONTHLY':
$recurence_data .= '';
break;
case 'YEARLY':
$recurence_data .= '';
break;
}
$recurence_data .= '';
if ($rrule['COUNT'])
{
$recurence_data .= ''.intval($rrule['COUNT']).'';
}
elseif($rrule['~UNTIL'])
{
$recurence_data .= ''.$this->__makeDateTime(CCalendar::Timestamp($rrule['UNTIL'])).'';
}
else
{
$recurence_data .= 'FALSE';
}
$recurence_data .= '';
$recurence_data .= '';
$obRow->setAttribute('ows_RecurrenceData', $recurence_data);
$obRow->setAttribute('ows_Duration', $duration);
}
else
{
$obRow->setAttribute('ows_Duration', $duration);
}
$obRow->setAttribute('ows_UniqueId', $event['ID'].';#'.$listName);
$obRow->setAttribute('ows_FSObjType', $event['ID'].';#0');
$obRow->setAttribute('ows_Editor', $event['CREATED_BY'].';#'.CCalendar::GetUserName($event['CREATED_BY']));
$obRow->setAttribute('ows_PermMask', '0x7fffffffffffffff');
$obRow->setAttribute('ows_ContentTypeId', '0x01020005CE290982A58C439E00342702139D1A');
return $obRow;
}