function BeforeIndex($arFields)
{
//Check if we in right context
if (
!isset($this)
|| !is_object($this)
|| !is_array($this->_params)
)
{
return $arFields;
}
if (isset($arFields["REINDEX_FLAG"]))
{
return $arFields;
}
//This was group modification
if($this->_group_id)
{
if(
$arFields["MODULE_ID"] === "forum"
&& (int) $arFields["PARAM1"] === (int) ($this->_params["FORUM_ID"] ?? null)
)
{
// forum feature
$arFields["LID"] = array();
$rsGroupSite = CSocNetGroup::GetSite($this->_group_id);
while($arGroupSite = $rsGroupSite->Fetch())
{
$arFields["LID"][$arGroupSite["LID"]] = $arFields["URL"];
}
$arFields = $this->BeforeIndexForum($arFields,
SONET_ENTITY_GROUP, $this->_group_id,
"forum", "view",
$this->_params["PATH_TO_GROUP_FORUM_MESSAGE"]
);
}
elseif(
$arFields["MODULE_ID"] === "forum"
&& (int) $arFields["PARAM1"] === (int) ($this->_params["FILES_FORUM_ID"] ?? null)
&& isModuleInstalled("webdav")
)
{
$arFields = $this->BeforeIndexForum($arFields,
SONET_ENTITY_GROUP, $this->_group_id,
"files", "view",
$this->Url($this->_params["PATH_TO_GROUP_FILES_ELEMENT"], array("MID"=>"#message_id#"), "message#message_id#")
);
}
elseif(
$arFields["MODULE_ID"] === "forum"
&& (int)$arFields["PARAM1"] === (int)$this->_params["TASK_FORUM_ID"]
&& !preg_match('/^EVENT_[0-9]+/', $arFields["TITLE"], $match) // calendar comments live in the same TASK_FORUM_ID :(
)
{
}
elseif (
$arFields["MODULE_ID"] === "forum"
&& preg_match('/^EVENT_[0-9]+/', $arFields["TITLE"], $match)
)
{
$arFields["TITLE"] = "";
$arFields["BODY"] = "";
}
elseif (
$arFields["MODULE_ID"] === "forum"
&& (int) $arFields["PARAM1"] === (int) ($this->_params["PHOTO_FORUM_ID"] ?? null)
)
{
$arFields = $this->BeforeIndexForum($arFields,
SONET_ENTITY_GROUP, $this->_group_id,
"photo", "view",
$this->Url($this->_params["PATH_TO_GROUP_PHOTO_ELEMENT"], array("MID"=>"#message_id#"), "message#message_id#")
);
}
}
elseif($this->_user_id)
{
if(
$arFields["MODULE_ID"] === "forum"
&& (int) $arFields["PARAM1"] === (int) ($this->_params["FORUM_ID"] ?? null)
)
{
// forum feature
$arFields["LID"] = array(SITE_ID => $arFields["URL"]);
$arFields = $this->BeforeIndexForum($arFields,
SONET_ENTITY_USER, $this->_user_id,
"forum", "view",
$this->_params["PATH_TO_USER_FORUM_MESSAGE"]
);
}
elseif(
$arFields["MODULE_ID"] === "forum"
&& (int) $arFields["PARAM1"] === (int) ($this->_params["FILES_FORUM_ID"] ?? null)
&& isModuleInstalled("webdav")
)
{
$arFields = $this->BeforeIndexForum($arFields,
SONET_ENTITY_USER, $this->_user_id,
"files", "view",
$this->Url($this->_params["PATH_TO_USER_FILES_ELEMENT"], array("MID"=>"#message_id#"), "message#message_id#")
);
}
elseif(
$arFields["MODULE_ID"] === "forum"
&& (int) $arFields["PARAM1"] === (int) ($this->_params["TASK_FORUM_ID"] ?? null)
)
{
}
elseif(
$arFields["MODULE_ID"] === "forum"
&& preg_match('/^EVENT_[0-9]+/', $arFields["TITLE"], $match)
) // don't index calendar comments!
{
$arFields["TITLE"] = "";
$arFields["BODY"] = "";
}
elseif(
$arFields["MODULE_ID"] === "forum"
&& (int) $arFields["PARAM1"] === (int) ($this->_params["PHOTO_FORUM_ID"] ?? null)
)
{
$arFields = $this->BeforeIndexForum(
$arFields,
SONET_ENTITY_USER,
$this->_user_id,
"photo",
"view",
$this->Url(
$this->_params["PATH_TO_USER_PHOTO_ELEMENT"],
array("MID"=>"#message_id#"),
"message#message_id#"
)
);
}
elseif(
$arFields["MODULE_ID"] === "blog"
&& (
($arFields["PARAM1"] ?? null) === "POST"
|| ($arFields["PARAM1"] ?? null) === "MICROBLOG"
)
)
{
$paramsTmp = self::GetSearchParams(
SONET_ENTITY_USER, $this->_user_id,
'blog', 'view_post'
);
$arFields["PARAMS"] = (
!empty($arFields["PARAMS"])
? array_merge($paramsTmp, $arFields["PARAMS"])
: $paramsTmp
);
}
elseif(
$arFields["MODULE_ID"] === "blog"
&& ($arFields["PARAM1"] ?? null) === "COMMENT"
)
{
$paramsTmp = self::GetSearchParams(
SONET_ENTITY_USER, $this->_user_id,
'blog', 'view_comment'
);
$arFields["PARAMS"] = (
!empty($arFields["PARAMS"])
? array_merge($paramsTmp, $arFields["PARAMS"])
: $paramsTmp
);
}
}
foreach(GetModuleEvents("socialnetwork", "BeforeIndexSocNet", true) as $arEvent)
{
$arEventResult = ExecuteModuleEventEx($arEvent, array($this, $arFields));
if(is_array($arEventResult))
{
$arFields = $arEventResult;
}
}
return $arFields;
}