• Модуль: intranet
  • Путь к файлу: ~/bitrix/modules/intranet/classes/general/ws_calendar.php
  • Класс: CIntranetCalendarWS
  • Вызов: CIntranetCalendarWS::__getRow
function __getRow($arRes, $listName, &$last_change)
{
	global $APPLICATION, $USER;

	$arStatusValues = $this->arStatusValues;
	$arPriorityValues = $this->arPriorityValues;

	$first_week_day = COption::GetOptionString('intranet', 'first_week_day', 'mo');

	$dbEditor = CUser::GetByID($arRes['MODIFIED_BY']);
	$arEditor = $dbEditor->Fetch();

	$change = MakeTimeStamp($arRes['TIMESTAMP_X']);
	if ($last_change < $change)
		$last_change = $change;

	$row_count++;

	$bRecurrent = (isset($arRes['PERIOD']) && is_array($arRes['PERIOD'])) ? 1 : 0;

	$ts_start = MakeTimeStamp($arRes['DATE_FROM']);
	$ts_finish = MakeTimeStamp($arRes['DATE_TO']);

	$TZBias = intval(date('Z'));
	$TZBiasStart = intval(date('Z', $ts_start));

	$duration = $bRecurrent ? $arRes['PERIOD']['LENGTH'] : ($ts_finish-$ts_start);
	$bAllDay = ($duration % 86400 == 0) ? 1 : 0;

	if (!$bAllDay || defined('OLD_OUTLOOK_VERSION'))
	{
		$ts_start -= $TZBiasStart;
		$ts_finish -= $TZBiasStart;
	}

	$obRow = new CXMLCreator('z:row');
	$obRow->setAttribute('ows_ID', $arRes['ID']);

	$version = $arRes['VERSION'] ? $arRes['VERSION'] : 1;

	$obRow->setAttribute('ows_Attachments', 0);
	$obRow->setAttribute('ows_owshiddenversion', $version);
	$obRow->setAttribute('ows_MetaInfo_vti_versionhistory', md5($arRes['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[$arRes['ACCESSIBILITY']];
	$obRow->setAttribute('ows_MetaInfo_BusyStatus', $status === null ? -1 : $status);
	$obRow->setAttribute('ows_MetaInfo_Priority', intval($arPriorityValues[$arRes['IMPORTANCE']]));

	$obRow->setAttribute('ows_Created', $this->__makeDateTime(MakeTimeStamp($arRes['DATE_CREATE'])-$TZBias));
	$obRow->setAttribute('ows_Modified', $this->__makeDateTime($change-$TZBias));
	$obRow->setAttribute('ows_EventType', $bRecurrent ? 1 : 0);
	$obRow->setAttribute('ows_Title', htmlspecialcharsback($arRes['NAME'])); // we have data htmlspecialchared yet

	if ($arRes['LOCATION'])
	{
		$arLocationInfo = CEventCalendar::ParseLocation($arRes['LOCATION']);
		if ($arLocationInfo['mrid'] === false)
			$obRow->setAttribute('ows_Location', $arLocationInfo['str']);
		else
		{
			if (!($arMRInfo = $this->arMRInfo[$arLocationInfo['mrid']]))
				$arMRInfo = CEventCalendar::GetMeetingRoomById(array(
					'id' => $arLocationInfo['mrid'], 'RMiblockId' => $this->__getRMIblockID()
				));

			if ($arMRInfo)
			{
				$this->arMRInfo[$arLocationInfo['mrid']] = $arMRInfo;
				$obRow->setAttribute('ows_Location', $arMRInfo['NAME']);
			}
			else
			{
				$obRow->setAttribute('ows_Location', $arLocationInfo['str']);
			}
		}
	}

	$obRow->setAttribute('ows_Description', htmlspecialcharsback($arRes['DETAIL_TEXT'])); // we have data htmlspecialchared yet
	$obRow->setAttribute('ows_EventDate', $this->__makeDateTime($ts_start));
	$obRow->setAttribute('ows_EndDate', $this->__makeDateTime(((false && $bRecurrent) ? $ts_start + $arRes['PERIOD']['LENGTH'] : $ts_finish) + ($bAllDay ? 86340 : 0)));
	$obRow->setAttribute('ows_fAllDayEvent', $bAllDay);

	/* Recurrence */
	$obRow->setAttribute('ows_fRecurrence', $bRecurrent);

	if ($bRecurrent)
	{
		$arWeekDays = $this->arWeekDays;

		$obRow->setAttribute('ows_UID', CIntranetUtils::makeGUID(md5($arRes['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);
		//$obRow->setAttribute('ows_TimeZone', 7);

		$recurence_data = '';
		$recurence_data .= '';
		$recurence_data .= '';
		$recurence_data .= ''.$first_week_day.'';

		$recurence_data .= '';
		switch($arRes['PERIOD']['TYPE'])
		{
			case 'DAILY':
				$recurence_data .= '';
			break;

			case 'WEEKLY':
				$days = '';
				$arDays = explode(',', $arRes['PERIOD']['DAYS']);
				foreach ($arDays as $day) $days .= $arWeekDays[$day].'="TRUE" ';

				$recurence_data .= '';
			break;

			case 'MONTHLY':
				$recurence_data .= '';
			break;

			case 'YEARLY':
				$recurence_data .= '';
			break;
		}


		$recurence_data .= '';

		if (date('Y', $ts_finish) == '2038' || date('Y', $ts_finish) == '2037')
			$recurence_data .= 'FALSE';
		else
			$recurence_data .= ''.$this->__makeDateTime($ts_finish).'';

		$recurence_data .= '';
		$recurence_data .= '';
		$obRow->setAttribute('ows_RecurrenceData', $recurence_data);

		$obRow->setAttribute('ows_Duration', $arRes['PERIOD']['LENGTH'] + ($bAllDay ? 86340 : 0));
	}
	else
	{
		$obRow->setAttribute('ows_Duration', ($duration ? $duration : 86400)-60);
	}

	$obRow->setAttribute('ows_UniqueId', $arRes['ID'].';#'.$listName);
	$obRow->setAttribute('ows_FSObjType', $arRes['ID'].';#0');

	$name = $arEditor['NAME'];
	if ($arEditor['LAST_NAME'])
		$name .= ' '.$arEditor['LAST_NAME'];
	if (!$name)
		$name .= $arEditor['LOGIN'];
	$obRow->setAttribute('ows_Editor', $arEditor['ID'].';#'.$name);

	$obRow->setAttribute('ows_PermMask', '0x7fffffffffffffff');
	$obRow->setAttribute('ows_ContentTypeId', '0x01020005CE290982A58C439E00342702139D1A');

	return $obRow;
}