• Модуль: dav
  • Путь к файлу: ~/bitrix/modules/dav/classes/general/exchangecontacts.php
  • Класс: CDavExchangeContacts
  • Вызов: CDavExchangeContacts::UpdateItemBody
public function UpdateItemBody($arFields)
{
	$itemBody = "";

	static $arDictionaryURITypeMap = array(
		"EmailAddresses" => array("contacts:EmailAddress", "EmailAddress1", "EmailAddresses"),
		"ImAddresses" => array("contacts:ImAddress", "ImAddress1", "ImAddresses"),
		"PhysicalAddresses_Business_Street" => array("contacts:PhysicalAddress:Street", "Business", "PhysicalAddresses", "Street"),
		"PhysicalAddresses_Business_City" => array("contacts:PhysicalAddress:City", "Business", "PhysicalAddresses", "City"),
		"PhysicalAddresses_Business_State" => array("contacts:PhysicalAddress:State", "Business", "PhysicalAddresses", "State"),
		"PhysicalAddresses_Business_CountryOrRegion" => array("contacts:PhysicalAddress:CountryOrRegion", "Business", "PhysicalAddresses", "CountryOrRegion"),
		"PhysicalAddresses_Business_PostalCode" => array("contacts:PhysicalAddress:PostalCode", "Business", "PhysicalAddresses", "PostalCode"),
		"PhysicalAddresses_Home_Street" => array("contacts:PhysicalAddress:Street", "Home", "PhysicalAddresses", "Street"),
		"PhysicalAddresses_Home_City" => array("contacts:PhysicalAddress:City", "Home", "PhysicalAddresses", "City"),
		"PhysicalAddresses_Home_State" => array("contacts:PhysicalAddress:State", "Home", "PhysicalAddresses", "State"),
		"PhysicalAddresses_Home_CountryOrRegion" => array("contacts:PhysicalAddress:CountryOrRegion", "Home", "PhysicalAddresses", "CountryOrRegion"),
		"PhysicalAddresses_Home_PostalCode" => array("contacts:PhysicalAddress:PostalCode", "Home", "PhysicalAddresses", "PostalCode"),
		"PhoneNumbers_HomePhone" => array("contacts:PhoneNumber", "HomePhone", "PhoneNumbers"),
		"PhoneNumbers_HomePhone2" => array("contacts:PhoneNumber", "HomePhone2", "PhoneNumbers"),
		"PhoneNumbers_MobilePhone" => array("contacts:PhoneNumber", "MobilePhone", "PhoneNumbers"),
		"PhoneNumbers_Pager" => array("contacts:PhoneNumber", "Pager", "PhoneNumbers"),
		"PhoneNumbers_BusinessPhone" => array("contacts:PhoneNumber", "BusinessPhone", "PhoneNumbers"),
		"PhoneNumbers_BusinessPhone2" => array("contacts:PhoneNumber", "BusinessPhone2", "PhoneNumbers"),
		"PhoneNumbers_OtherTelephone" => array("contacts:PhoneNumber", "OtherTelephone", "PhoneNumbers"),
	);

	foreach ($arFields as $key => $value)
	{
		$fieldUri = (in_array($key, self::$arMapContact) ? "contacts" : "item").":".htmlspecialcharsbx($key);
		if (array_key_exists($key, $arDictionaryURITypeMap))
			$fieldUri = $arDictionaryURITypeMap[$key][0];

		if (false && is_null($value))
		{
			$itemBody .= "      ";
			if (array_key_exists($key, $arDictionaryURITypeMap))
				$itemBody .= "";
			else
				$itemBody .= "";
			$itemBody .= "rn";
		}
		else
		{
			$itemBody .= "      rn";
			if (array_key_exists($key, $arDictionaryURITypeMap))
				$itemBody .= "       rn";
			else
				$itemBody .= "       rn";
			$itemBody .= "       rn";

			if ($key == "Surname")
			{
				$itemBody .= "        ".htmlspecialcharsbx($value)."rn";
				$itemBody .= "       rn";
				$itemBody .= "      rn";

				$itemBody .= "      rn";
				$itemBody .= "       rn";
				$itemBody .= "       rn";

				$v = $arFields["Surname"];
				if ($v <> '' && ($arFields["GivenName"] <> '' || $arFields["MiddleName"] <> ''))
					$v .= ", ";
				$v .= $arFields["GivenName"];
				if ($v <> '' && $arFields["MiddleName"] <> '')
					$v .= " ";
				$v .= $arFields["MiddleName"];

				$itemBody .= "        ".htmlspecialcharsbx($v)."rn";
			}
			elseif (array_key_exists($key, $arDictionaryURITypeMap))
			{
				if ($arDictionaryURITypeMap[$key][2] == "EmailAddresses")
				{
					$itemBody .= "     rn";
					$itemBody .= "      ".htmlspecialcharsbx($arFields["EmailAddresses"])."rn";
					$itemBody .= "     rn";
				}
				elseif ($arDictionaryURITypeMap[$key][2] == "PhysicalAddresses")
				{
					$itemBody .= "      rn";
					$itemBody .= "       rn";
					$itemBody .= "        <".$arDictionaryURITypeMap[$key][3].">".htmlspecialcharsbx($value)."rn";
					$itemBody .= "       rn";
					$itemBody .= "      rn";
				}
				elseif ($arDictionaryURITypeMap[$key][2] == "PhoneNumbers")
				{
					$itemBody .= "	    rn";
					$itemBody .= "	     ".htmlspecialcharsbx($value)."rn";
					$itemBody .= "	    rn";
				}
				elseif ($arDictionaryURITypeMap[$key][2] == "ImAddresses")
				{
					$itemBody .= "     rn";
					$itemBody .= "      ".htmlspecialcharsbx($arFields["ImAddresses"])."rn";
					$itemBody .= "     rn";
				}
			}
			else
			{
				$itemBody .= "        <".htmlspecialcharsbx($key).">";
				if (is_bool($value))
					$itemBody .= ($value ? "true" : "false");
				else
					$itemBody .= htmlspecialcharsbx($value);
				$itemBody .= "rn";
			}

			$itemBody .= "       rn";
			$itemBody .= "      rn";
		}
	}

	return $itemBody;
}