public static function Delete($ID) { global $DB; $ID = IntVal($ID); $arPost = CBlogPost::GetByID($ID); if ($arPost) { foreach (GetModuleEvents("blog", "OnBeforePostDelete", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array($ID)) === false) { return false; } } $dbResult = CBlogComment::GetList(array(), array("POST_ID" => $ID), false, false, array("ID")); while ($arResult = $dbResult->Fetch()) { if (!CBlogComment::Delete($arResult["ID"])) { return False; } } $dbResult = CBlogUserGroupPerms::GetList(array(), array("POST_ID" => $ID, "BLOG_ID" => $arPost["BLOG_ID"]), false, false, array("ID")); while ($arResult = $dbResult->Fetch()) { if (!CBlogUserGroupPerms::Delete($arResult["ID"])) { return False; } } $dbResult = CBlogTrackback::GetList(array(), array("POST_ID" => $ID, "BLOG_ID" => $arPost["BLOG_ID"]), false, false, array("ID")); while ($arResult = $dbResult->Fetch()) { if (!CBlogTrackback::Delete($arResult["ID"])) { return False; } } $dbResult = CBlogPostCategory::GetList(array(), array("POST_ID" => $ID, "BLOG_ID" => $arPost["BLOG_ID"]), false, false, array("ID")); while ($arResult = $dbResult->Fetch()) { if (!CBlogPostCategory::Delete($arResult["ID"])) { return False; } } $strSql = "SELECT F.ID " . "FROM b_blog_post P, b_file F " . "WHERE P.ID = " . $ID . " " . "\tAND P.ATTACH_IMG = F.ID "; $z = $DB->Query($strSql, false, "FILE: " . __FILE__ . " LINE:" . __LINE__); while ($zr = $z->Fetch()) { CFile::Delete($zr["ID"]); } CBlogPost::DeleteSocNetPostPerms($ID); unset($GLOBALS["BLOG_POST"]["BLOG_POST_CACHE_" . $ID]); $arBlog = CBlog::GetByID($arPost["BLOG_ID"]); $result = $DB->Query("DELETE FROM b_blog_post WHERE ID = " . $ID . "", true); if (IntVal($arBlog["LAST_POST_ID"]) == $ID) { CBlog::SetStat($arPost["BLOG_ID"]); } if ($result) { $res = CBlogImage::GetList(array(), array("POST_ID" => $ID, "IS_COMMENT" => "N")); while ($aImg = $res->Fetch()) { CBlogImage::Delete($aImg['ID']); } } if ($result) { $GLOBALS["USER_FIELD_MANAGER"]->Delete("BLOG_POST", $ID); } foreach (GetModuleEvents("blog", "OnPostDelete", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($ID, &$result)); } if (CModule::IncludeModule("search")) { CSearch::Index("blog", "P" . $ID, array("TITLE" => "", "BODY" => "")); //CSearch::DeleteIndex("blog", false, "COMMENT", $arPost["BLOG_ID"]."|".$ID); } return $result; } else { return false; } return True; }