• Модуль: dav
  • Путь к файлу: ~/bitrix/modules/dav/classes/general/addressbookhandler.php
  • Класс: CDavAddressbookHandler
  • Вызов: CDavAddressbookHandler::Put
public function Put($id, $siteId, $account, $arPath)
{
	$collectionId = $this->GetCollectionId($siteId, $account, $arPath);
	if ($collectionId == null)
		return '404 Not Found';

	$request = $this->groupdav->GetRequest();

	$oldCard = $this->GetEntry('PUT', $id, $collectionId);
	if (!is_null($oldCard) && !is_array($oldCard))
		return $oldCard;

	$charset = "utf-8";
	$arContentParameters = $request->GetContentParameters();

	if (!empty($arContentParameters['CONTENT_TYPE']))
	{
		$arContentType = explode(';', $arContentParameters['CONTENT_TYPE']);
		if (count($arContentType) > 1)
		{
			array_shift($arContentType);
			foreach ($arContentType as $attribute)
			{
				$attribute = trim($attribute);
				list($key, $value) = explode('=', $attribute);
				if (mb_strtolower($key) == 'charset')
					$charset = mb_strtolower($value);
			}
		}
	}

	$content = $request->GetRequestBody();
	$content = htmlspecialcharsback($content);

	if (is_array($oldCard))
		$contactId = $oldCard['ID'];
	else
		$contactId = 0;

	$cs = CDav::GetCharset($siteId);
	if (is_null($cs) || empty($cs))
		$cs = "utf-8";

	$content = $GLOBALS["APPLICATION"]->ConvertCharset($content, $charset, $cs);

	if ($this->IsMacAgent())
	{
		$card = new CDavICalendarComponent($content);
		$res = $this->GetDefaultResourceProvider()->Put($id, $card);
	}
	else
	{
		if (!empty($this->addressbookCollections[$arPath[0]]))
		{
			$card = new CDavICalendarComponent($content);
			$res = $this->addressbookCollections[$arPath[0]]->Put($id, $card);
		}
		else
		{
			$res = false;
		}
	}

	return $res ? "201 Created" : "501 Not Implemented";
}