• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/group.php
  • Класс: CAllSocNetGroup
  • Вызов: CAllSocNetGroup::SearchIndex
static function SearchIndex($groupId, $arSiteID = array(), $arGroupOld = array()): void
{
	if (intval($groupId) <= 0)
	{
		return;
	}

	if (CModule::IncludeModule("search"))
	{
		$arGroupNew = CSocNetGroup::GetByID($groupId);
		if ($arGroupNew)
		{
			if (
				$arGroupNew["ACTIVE"] == "N"
				&& isset($arGroupOld)
				&& is_array($arGroupOld)
				&& isset($arGroupOld["ACTIVE"])
				&& $arGroupOld["ACTIVE"] == "Y"
			)
			{
				CSearch::DeleteIndex("socialnetwork", "G".$groupId);
			}
			elseif ($arGroupNew["ACTIVE"] == "Y")
			{
				$BODY = CSocNetTextParser::killAllTags($arGroupNew["~DESCRIPTION"]);
				$BODY .= $GLOBALS["USER_FIELD_MANAGER"]->OnSearchIndex("SONET_GROUP", $groupId);

				$arSearchIndexSiteID = array();
				if (
					is_array($arSiteID)
					&& !empty($arSiteID)
				)
				{
					foreach ($arSiteID as $site_id_tmp)
					{
						$arSearchIndexSiteID[$site_id_tmp] = str_replace("#group_id#", $groupId, Path::get('group_path_template', $site_id_tmp));
					}
				}
				else
				{
					$rsGroupSite = CSocNetGroup::GetSite($groupId);
					while ($arGroupSite = $rsGroupSite->Fetch())
					{
						$arSearchIndexSiteID[$arGroupSite["LID"]] = str_replace("#group_id#", $groupId, Path::get('group_path_template', $arGroupSite['LID']));
					}
				}

				$arSearchIndex = array(
					"SITE_ID" => $arSearchIndexSiteID,
					"LAST_MODIFIED" => $arGroupNew["DATE_ACTIVITY"],
					"PARAM1" => $arGroupNew["SUBJECT_ID"],
					"PARAM2" => $groupId,
					"PARAM3" => "GROUP",
					"PERMISSIONS" => (
						$arGroupNew["VISIBLE"] == "Y"?
							array('G2')://public
							array(
								'SG'.$groupId.'_A',//admins
								'SG'.$groupId.'_E',//moderators
								'SG'.$groupId.'_K',//members
							)
					),
					"PARAMS" =>array(
						"socnet_group" 	=> $groupId,
						"entity" 		=> "socnet_group",
					),
					"TITLE" => $arGroupNew["~NAME"],
					"BODY" => $BODY,
					"TAGS" => $arGroupNew["~KEYWORDS"],
				);

				CSearch::Index("socialnetwork", "G".$groupId, $arSearchIndex, True);
			}
		}
	}
}