• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/search.php
  • Класс: CSocNetSearch
  • Вызов: CSocNetSearch::BeforeIndexForum
function BeforeIndexForum($arFields, $entity_type, $entity_id, $feature, $operation, $path_template)
{
	global $USER;
	static $arSiteData;

	$SECTION_ID = "";
	$ELEMENT_ID = intval($_REQUEST["photo_element_id"] ?? 0);
	if (empty($ELEMENT_ID))
	{
		$ELEMENT_ID = intval($_REQUEST["ELEMENT_ID"] ?? 0);
	}

	if(
		$ELEMENT_ID > 0
		&& CModule::IncludeModule('iblock')
	)
	{
		$rsSections = CIBlockElement::GetElementGroups($ELEMENT_ID, true);
		$arSection = $rsSections->Fetch();
		if($arSection)
		{
			$SECTION_ID = $arSection["ID"];
		}
	}

	if (
		count($arFields["LID"]) > 1
		&& (
			(
				$entity_type == SONET_ENTITY_GROUP
				&& CModule::IncludeModule("extranet")
			)
			|| $entity_type == SONET_ENTITY_USER
		)
	)
	{
		if (!$arSiteData)
		{
			$arSiteData = CSocNetLogTools::GetSiteData();
		}

		foreach($arSiteData as $arUrl)
		{
			if($entity_type === SONET_ENTITY_GROUP
			&& mb_strpos($path_template, $arUrl["GROUPS_PATH"]) === 0)
			{
				$path_template = str_replace($arUrl["GROUPS_PATH"], "#GROUP_PATH#", $path_template);
				break;
			}

			if (
				$entity_type === SONET_ENTITY_USER
				&& mb_strpos($path_template, $arUrl["USER_PATH"]) === 0
			)
			{
				$path_template = str_replace($arUrl["USER_PATH"], "#USER_PATH#", $path_template);
				break;
			}
		}
	}

	foreach($arFields["LID"] as $site_id => $url)
	{
		$arFields["URL"] = $arFields["LID"][$site_id] = str_replace(
			array(
				"#user_id#",
				"#group_id#",
				"#topic_id#",
				"#message_id#",
				"#action#",
				"#user_alias#",
				"#section_id#",
				"#element_id#",
				"#task_id#",
				"#GROUP_PATH#",
				"#USER_PATH#"
			),
			array(
				($this->_user_id > 0 ? $this->_user_id : $USER->GetID()),
				$this->_group_id,
				$arFields["PARAM2"],
				$arFields["ITEM_ID"],
				"view",
				($entity_type === "G" ? "group_" : "user_") . $entity_id,
				$SECTION_ID,
				$ELEMENT_ID,
				$ELEMENT_ID,
				($arSiteData ? $arSiteData[$site_id]["GROUPS_PATH"] : ""),
				($arSiteData ? $arSiteData[$site_id]["USER_PATH"] : "")
			),
			$path_template
		);
	}

	if (
		$feature === 'tasks'
		&& $arFields["PARAM1"] == COption::GetOptionString("tasks", "task_forum_id", 0)
		&& CModule::IncludeModule('tasks')
	)
	{
		if (!preg_match('/^EVENT_[0-9]+/', $arFields["TITLE"], $match)) // calendar comments live in the same TASK_FORUM_ID :(
		{
			$rsTask = CTasks::GetList(array(), array("FORUM_TOPIC_ID" => $arFields['PARAM2']));
			if ($arTask = $rsTask->Fetch())
			{
				$arFields['PERMISSIONS'] = CTasks::__GetSearchPermissions($arTask);
			}
		}
	}
	else
	{
		$arFields["PERMISSIONS"] = self::GetSearchGroups(
			$entity_type,
			$entity_id,
			$feature,
			$operation
		);

		$paramsTmp = self::GetSearchParams(
			$entity_type,
			$entity_id,
			$feature,
			$operation
		);
		$arFields["PARAMS"] = (!empty($arFields["PARAMS"]) ? array_merge($paramsTmp, $arFields["PARAMS"]) : $paramsTmp);
	}

	return $arFields;
}