• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/log_tools_photo.php
  • Класс: CSocNetPhotoCommentEvent
  • Вызов: CSocNetPhotoCommentEvent::OnAfterPhotoCommentDeleteBlog
function OnAfterPhotoCommentDeleteBlog($ID)
{
	if (!$this->IsSocnet)
		return;

	if (intval($ID) > 0)
	{
		$dbRes = CSocNetLogComments::GetList(
			array("ID" => "DESC"),
			array(
				"EVENT_ID"	=> "photo_comment",
				"SOURCE_ID"	=> $ID
			),
			false,
			false,
			array("ID", "LOG_ID")
		);

		if ($arRes = $dbRes->Fetch())
		{
			$res = CSocNetLogComments::Delete($arRes["ID"]);

			if ($res)
			{
				$dbResult = CSocNetLog::GetList(
					array(),
					array("ID" => $arRes["LOG_ID"]),
					false,
					false,
					array("ID", "COMMENTS_COUNT")
				);

				if ($arLog = $dbResult->Fetch())
				{
					if ($arLog["COMMENTS_COUNT"] == 0)
						CSocNetLog::Delete($arRes["LOG_ID"]);
				}
			}
		}
	}
}