public static function CallBack_AddComment($arFields) { if (!CModule::IncludeModule('blog')) { return false; } $arResult = array(); $arLog = CSocNetLog::GetList(array("ID" => "DESC"), array("TMP_ID" => $arFields["LOG_ID"]), false, false, array("ID", "SOURCE_ID", "SITE_ID", "RATING_ENTITY_ID"))->Fetch(); if ($arLog) { $arIdeaPost = CBlogPost::GetById($arLog["SOURCE_ID"]); if ($arIdeaPost) { $UserIP = CBlogUser::GetUserIP(); $IdeaCommentId = CBlogComment::Add(array("BLOG_ID" => $arIdeaPost["BLOG_ID"], "POST_ID" => $arIdeaPost["ID"], "AUTHOR_ID" => $arFields["USER_ID"], "POST_TEXT" => $arFields["MESSAGE"], "DATE_CREATE" => ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL"), "PARENT_ID" => false, "AUTHOR_IP" => $UserIP[0], "AUTHOR_IP1" => $UserIP[1])); $arResult = array("SOURCE_ID" => $IdeaCommentId); if ($arLog["RATING_ENTITY_ID"] > 0) { $arResult["RATING_TYPE_ID"] = "BLOG_COMMENT"; $arResult["RATING_ENTITY_ID"] = $IdeaCommentId; } if (intval($IdeaCommentId) == 0) { global $APPLICATION; if ($ex = $APPLICATION->GetException()) { $arResult["ERROR"] = $ex->GetString(); } } else { //clear cache on succcess BXClearCache(True, "/" . SITE_ID . "/idea/" . $arIdeaPost["BLOG_ID"] . "/first_page/"); BXClearCache(True, "/" . SITE_ID . "/idea/" . $arIdeaPost["BLOG_ID"] . "/pages/"); BXClearCache(True, "/" . SITE_ID . "/idea/" . $arIdeaPost["BLOG_ID"] . "/comment/" . $arIdeaPost["ID"] . "/"); BXClearCache(True, "/" . SITE_ID . "/idea/" . $arIdeaPost["BLOG_ID"] . "/post/" . $arIdeaPost["ID"] . "/"); } } } return $arResult; }
} } } $arParams["COMMENT_PROPERTY"] = array("UF_BLOG_COMMENT_DOC"); if (CModule::IncludeModule("webdav") || CModule::IncludeModule("disk")) { $arParams["COMMENT_PROPERTY"][] = "UF_BLOG_COMMENT_FILE"; $arParams["COMMENT_PROPERTY"][] = "UF_BLOG_COMMENT_FH"; } $arParams["COMMENT_PROPERTY"][] = "UF_BLOG_COMM_URL_PRV"; $arBlog = $arParams["BLOG_DATA"]; $arPost = $arParams["POST_DATA"]; $arResult["Perm"] = BLOG_PERMS_DENY; $arResult["PostPerm"] = BLOG_PERMS_DENY; if (IntVal($_REQUEST["comment_post_id"]) > 0) { $arParams["ID"] = IntVal($_REQUEST["comment_post_id"]); $arPost = CBlogPost::GetById($arParams["ID"]); $arPost = CBlogTools::htmlspecialcharsExArray($arPost); $arBlog = CBlog::GetById($arPost["BLOG_ID"]); $arBlog = CBlogTools::htmlspecialcharsExArray($arBlog); if ($arPost["AUTHOR_ID"] == $user_id) { $arResult["Perm"] = BLOG_PERMS_FULL; $arResult["PostPerm"] = BLOG_PERMS_FULL; } else { $arResult["PostPerm"] = CBlogPost::GetSocNetPostPerms($arParams["ID"]); if ($arResult["PostPerm"] > BLOG_PERMS_DENY) { $arResult["Perm"] = CBlogComment::GetSocNetUserPerms($arParams["ID"], $arPost["AUTHOR_ID"]); } } $arResult["is_ajax_post"] = "Y"; } else { $arResult["PostPerm"] = strlen($arParams["POST_DATA"]["perms"]) <= 0 ? CBlogPost::GetSocNetPostPerms($arParams["ID"]) : $arParams["POST_DATA"]["perms"];