function SetFeaturePermissions($entity_type, $entity_id, $feature, $operation, $new_perm) { if (substr($operation, 0, 4) == "view") { if (CModule::IncludeModule('search')) { global $arSonetFeaturesPermsCache; unset($arSonetFeaturesPermsCache[$entity_type . "_" . $entity_id]); $arGroups = CSocNetSearch::GetSearchGroups($entity_type, $entity_id, $feature, $operation); $arParams = CSocNetSearch::GetSearchParams($entity_type, $entity_id, $feature, $operation); CSearch::ChangePermission(false, $arGroups, false, false, false, false, $arParams); } } if ($feature == "blog" && in_array($operation, array("view_post", "view_comment")) && CModule::IncludeModule('blog')) { if ($operation == "view_post") { CBlogPost::ChangeSocNetPermission($entity_type, $entity_id, $operation); } if ($operation == "view_post") { $arPost = CBlogPost::GetSocNetPostsPerms($entity_type, $entity_id); foreach ($arPost as $id => $perms) { CSearch::ChangePermission("blog", $perms["PERMS"], "P" . $id); } } else { $arTmpCache = array(); $arPost = CBlogPost::GetSocNetPostsPerms($entity_type, $entity_id); $dbComment = CBlogComment::GetSocNetPostsPerms($entity_type, $entity_id); while ($arComment = $dbComment->Fetch()) { if (!empty($arPost[$arComment["POST_ID"]])) { if (empty($arPost[$arComment["POST_ID"]]["PERMS_CALC"])) { if (is_array($arPost[$arComment["POST_ID"]]["PERMS_FULL"]) && !empty($arPost[$arComment["POST_ID"]]["PERMS_FULL"])) { foreach ($arPost[$arComment["POST_ID"]]["PERMS_FULL"] as $e => $v) { if (in_array($v["TYPE"], array("SG", "U"))) { $type = $v["TYPE"] == "SG" ? "G" : "U"; if (array_key_exists($type . $v["ID"], $arTmpCache)) { $spt = $arTmpCache[$type . $v["ID"]]; } else { $spt = CBlogPost::GetSocnetGroups($type, $v["ID"], "view_comment"); $arTmpCache[$type . $v["ID"]] = $spt; } foreach ($spt as $vv) { if (!in_array($vv, $arPost[$arComment["POST_ID"]]["PERMS_CALC"])) { $arPost[$arComment["POST_ID"]]["PERMS_CALC"][] = $vv; } } } else { $arPost[$arComment["POST_ID"]]["PERMS_CALC"][] = $e; } } } } CSearch::ChangePermission("blog", $arPost[$arComment["POST_ID"]]["PERMS_CALC"], "C" . $arComment["ID"]); } } } } }