public function Get() { if (!$this->IsAvailable()) { return false; } return CBlogComment::GetList(array(), array("ID" => $this->CommentId))->Fetch(); }
protected static function rewritePreviousHistoryComment(array $file) { if (!CModule::IncludeModule('blog')) { return; } $dbComments = CBlogComment::GetList(array('ID' => 'DESC'), array('POST_ID' => static::getPostIdForComment(), 'UF_BLOG_COMMENT_FH' => static::getStringForLike($file[0])), false, false, array('ID', 'POST_ID', 'BLOG_ID', 'UF_BLOG_COMMENT_FH')); if ($dbComments && ($lastComment = $dbComments->Fetch())) { $entityType = static::getEntityType($file[0]['ib_code']); $documentId = static::getEntityIdDocumentData($entityType, array('ELEMENT_ID' => $file[0]['id'])); $filter = array("DOCUMENT_ID" => $documentId); $historyDoc = static::getIdHistoryDocument($filter); if (!empty($historyDoc['ID'])) { $newFileData = static::getDataFromValue($lastComment['UF_BLOG_COMMENT_FH']); $newFileData[0]['v'] = $historyDoc['ID']; CBlogComment::Update($lastComment['ID'], array('UF_BLOG_COMMENT_FH' => static::genData($newFileData[0], $newFileData[1]), 'HAS_PROPS' => 'Y')); } } }
function _getBlogPostCommentFiles($postID) { $arCommentID = array(); $dbComments = CBlogComment::GetList(array(), array("POST_ID" => intval($postID)), false, false, array("ID")); if ($dbComments) { while ($arComment = $dbComments->Fetch()) { $arCommentID[] = $arComment['ID']; } } $arFiles = array(); foreach ($arCommentID as $commentID) { $entity_type = static::$UF_TYPE_BLOG_COMMENT; $entity_id = static::$UF_EID_BLOG_COMMENT; $arUF = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields($entity_type, $commentID); if (isset($arUF[$entity_id]) && is_array($arUF[$entity_id]['VALUE']) && sizeof($arUF[$entity_id]['VALUE']) > 0) { $arFiles = array_merge($arFiles, $arUF[$entity_id]['VALUE']); } } return array_unique($arFiles); }
function OnSearchReindex($NS = array(), $oCallback = NULL, $callback_method = "") { global $DB; $arResult = array(); //CBlogSearch::Trace('OnSearchReindex', 'NS', $NS); if ($NS["MODULE"] == "blog" && strlen($NS["ID"]) > 0) { $category = substr($NS["ID"], 0, 1); $id = intval(substr($NS["ID"], 1)); } else { $category = 'B'; //start with blogs $id = 0; //very first id } //CBlogSearch::Trace('OnSearchReindex', 'category+id', array("CATEGORY"=>$category,"ID"=>$id)); //Reindex blogs if ($category == 'B') { $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tb.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t,b.REAL_URL\n\t\t\t\t\t,b.URL\n\t\t\t\t\t," . $DB->DateToCharFunction("b.DATE_UPDATE") . " as DATE_UPDATE\n\t\t\t\t\t,b.NAME\n\t\t\t\t\t,b.DESCRIPTION\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,b.SOCNET_GROUP_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\tFROM\n\t\t\t\t\tb_blog b\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID)\n\t\t\t\tWHERE\n\t\t\t\t\tb.ACTIVE = 'Y'\n\t\t\t\t\tAND b.SEARCH_INDEX = 'Y'\n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? "AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND b.ID > " . $id . "\n\t\t\t\tORDER BY\n\t\t\t\t\tb.ID\n\t\t\t"; //CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql); $rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); while ($ar = $rs->Fetch()) { if ($ar["USE_SOCNET"] == "Y") { $Result = array("ID" => "B" . $ar["ID"], "BODY" => "", "TITLE" => ""); } else { //CBlogSearch::Trace('OnSearchReindex', 'ar', $ar); $arSite = array($ar["SITE_ID"] => CBlog::PreparePath($ar["URL"], $ar["SITE_ID"], false, $ar["OWNER_ID"], $ar["SOCNET_GROUP_ID"])); //CBlogSearch::Trace('OnSearchReindex', 'arSite', $arSite); $Result = array("ID" => "B" . $ar["ID"], "LAST_MODIFIED" => $ar["DATE_UPDATE"], "TITLE" => $ar["NAME"], "BODY" => blogTextParser::killAllTags($ar["DESCRIPTION"]), "SITE_ID" => $arSite, "PARAM1" => "BLOG", "PARAM2" => $ar["OWNER_ID"], "PERMISSIONS" => array(2)); //CBlogSearch::Trace('OnSearchReindex', 'Result', $Result); } if ($oCallback) { $res = call_user_func(array($oCallback, $callback_method), $Result); if (!$res) { return $Result["ID"]; } } else { $arResult[] = $Result; } } //all blogs indexed so let's start index posts $category = 'P'; $id = 0; } if ($category == 'P') { $arUser2Blog = array(); if (COption::GetOptionString("blog", "socNetNewPerms", "N") == "N") { $dbB = CBlog::GetList(array(), array("USE_SOCNET" => "Y", "!OWNER_ID" => false), false, false, array("ID", "OWNER_ID", "USE_SOCNET", "GROUP_ID")); while ($arB = $dbB->Fetch()) { $arUser2Blog[$arB["OWNER_ID"]][$arB["GROUP_ID"]] = $arB["ID"]; } } $bSonet = false; if (IsModuleInstalled("socialnetwork")) { $bSonet = true; } $parserBlog = new blogTextParser(false, "/bitrix/images/blog/smile/"); $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tbp.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t,b.REAL_URL\n\t\t\t\t\t,b.URL\n\t\t\t\t\t," . $DB->DateToCharFunction("bp.DATE_PUBLISH") . " as DATE_PUBLISH\n\t\t\t\t\t,bp.TITLE\n\t\t\t\t\t,bp.DETAIL_TEXT\n\t\t\t\t\t,bp.BLOG_ID\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,bp.CATEGORY_ID\n\t\t\t\t\t,b.SOCNET_GROUP_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\t\t,b.GROUP_ID\n\t\t\t\t\t,bp.PATH\n\t\t\t\t\t,bp.MICRO\n\t\t\t\t\t,bp.PUBLISH_STATUS\n\t\t\t\t\t,bp.AUTHOR_ID " . ($bSonet ? ", BSL.ID as SLID" : "") . " FROM\n\t\t\t\t\tb_blog_post bp\n\t\t\t\t\tINNER JOIN b_blog b ON (bp.BLOG_ID = b.ID)\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID) " . ($bSonet ? "LEFT JOIN b_sonet_log BSL ON (BSL.EVENT_ID in ('blog_post', 'blog_post_micro') AND BSL.SOURCE_ID = bp.ID) " : "") . " WHERE\n\t\t\t\t\tbp.DATE_PUBLISH <= " . $DB->CurrentTimeFunction() . "\n\t\t\t\t\tAND b.ACTIVE = 'Y'\n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? "AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND bp.ID > " . $id . "\n\t\t\t\t\t\n\t\t\t\tORDER BY\n\t\t\t\t\tbp.ID\n\t\t\t"; /* AND bp.PUBLISH_STATUS = '".$DB->ForSQL(BLOG_PUBLISH_STATUS_PUBLISH)."'*/ //AND b.SEARCH_INDEX = 'Y' //CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql); $rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); while ($ar = $rs->Fetch()) { //Check permissions $tag = ""; if ($ar["USE_SOCNET"] != "Y") { $PostPerms = CBlogUserGroup::GetGroupPerms(1, $ar["BLOG_ID"], $ar["ID"], BLOG_PERMS_POST); if ($PostPerms < BLOG_PERMS_READ) { continue; } } //CBlogSearch::Trace('OnSearchReindex', 'ar', $ar); if (strlen($ar["PATH"]) > 0) { $arSite = array($ar["SITE_ID"] => str_replace("#post_id#", $ar["ID"], $ar["PATH"])); } else { $arSite = array($ar["SITE_ID"] => CBlogPost::PreparePath($ar["URL"], $ar["ID"], $ar["SITE_ID"], false, $ar["OWNER_ID"], $ar["SOCNET_GROUP_ID"])); } if (strlen($ar["CATEGORY_ID"]) > 0) { $arC = explode(",", $ar["CATEGORY_ID"]); $tag = ""; $arTag = array(); foreach ($arC as $v) { $arCategory = CBlogCategory::GetByID($v); $arTag[] = $arCategory["NAME"]; } $tag = implode(",", $arTag); } //CBlogSearch::Trace('OnSearchReindex', 'arSite', $arSite); $Result = array("ID" => "P" . $ar["ID"], "LAST_MODIFIED" => $ar["DATE_PUBLISH"], "TITLE" => blogTextParser::killAllTags($ar["TITLE"]), "BODY" => blogTextParser::killAllTags($ar["DETAIL_TEXT"]), "SITE_ID" => $arSite, "PARAM1" => "POST", "PARAM2" => $ar["BLOG_ID"], "PERMISSIONS" => array(2), "TAGS" => $tag, "USER_ID" => $ar["AUTHOR_ID"], "ENTITY_TYPE_ID" => "BLOG_POST", "ENTITY_ID" => $ar["ID"]); if ($ar["USE_SOCNET"] == "Y" && CModule::IncludeModule("socialnetwork")) { $arF = array(); if (COption::GetOptionString("blog", "socNetNewPerms", "N") == "N") { if (IntVal($ar["SOCNET_GROUP_ID"]) > 0) { $newBlogId = 0; if (IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]) > 0) { $newBlogId = IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]); } else { $arFields = array("=DATE_UPDATE" => $DB->CurrentTimeFunction(), "GROUP_ID" => $ar["GROUP_ID"], "ACTIVE" => "Y", "ENABLE_COMMENTS" => "Y", "ENABLE_IMG_VERIF" => "Y", "EMAIL_NOTIFY" => "Y", "ENABLE_RSS" => "Y", "ALLOW_HTML" => "N", "ENABLE_TRACKBACK" => "N", "SEARCH_INDEX" => "Y", "USE_SOCNET" => "Y", "=DATE_CREATE" => $DB->CurrentTimeFunction(), "PERMS_POST" => array(1 => "I", 2 => "I"), "PERMS_COMMENT" => array(1 => "P", 2 => "P")); $bRights = false; $rsUser = CUser::GetByID($ar["AUTHOR_ID"]); $arUser = $rsUser->Fetch(); if (strlen($arUser["NAME"] . "" . $arUser["LAST_NAME"]) <= 0) { $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["LOGIN"]; } else { $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["NAME"] . " " . $arUser["LAST_NAME"]; } $arFields["URL"] = str_replace(" ", "_", $arUser["LOGIN"]) . "-blog-" . $ar["SITE_ID"]; $arFields["OWNER_ID"] = $ar["AUTHOR_ID"]; $urlCheck = preg_replace("/[^a-zA-Z0-9_-]/is", "", $arFields["URL"]); if ($urlCheck != $arFields["URL"]) { $arFields["URL"] = "u" . $arUser["ID"] . "-blog-" . $ar["SITE_ID"]; } if (CBlog::GetByUrl($arFields["URL"])) { $uind = 0; do { $uind++; $arFields["URL"] = $arFields["URL"] . $uind; } while (CBlog::GetByUrl($arFields["URL"])); } $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $ar["AUTHOR_ID"], "blog", "view_post"); if ($featureOperationPerms == SONET_RELATIONS_TYPE_ALL) { $bRights = true; } $blogID = CBlog::Add($arFields); if ($bRights) { CBlog::AddSocnetRead($blogID); } $newBlogId = $blogID; $arUser2Blog[$arFields["OWNER_ID"]][$arFields["GROUP_ID"]] = $newBlogId; } if (intVal($newBlogId) > 0) { $arF = array("BLOG_ID" => $newBlogId, "SOCNET_RIGHTS" => array("SG" . $ar["SOCNET_GROUP_ID"])); } if (IntVal($ar["SLID"]) > 0) { CSocNetLog::Delete($ar["SLID"]); $ar["SLID"] = 0; } $arSites = array(); $rsGroupSite = CSocNetGroup::GetSite($ar["SOCNET_GROUP_ID"]); while ($arGroupSite = $rsGroupSite->Fetch()) { $arSites[] = $arGroupSite["LID"]; } } else { $newBlogId = 0; if ($ar["OWNER_ID"] != $ar["AUTHOR_ID"]) { if (IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]) > 0) { $newBlogId = IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]); } else { $arFields = array("=DATE_UPDATE" => $DB->CurrentTimeFunction(), "GROUP_ID" => $ar["GROUP_ID"], "ACTIVE" => "Y", "ENABLE_COMMENTS" => "Y", "ENABLE_IMG_VERIF" => "Y", "EMAIL_NOTIFY" => "Y", "ENABLE_RSS" => "Y", "ALLOW_HTML" => "N", "ENABLE_TRACKBACK" => "N", "SEARCH_INDEX" => "Y", "USE_SOCNET" => "Y", "=DATE_CREATE" => $DB->CurrentTimeFunction(), "PERMS_POST" => array(1 => "I", 2 => "I"), "PERMS_COMMENT" => array(1 => "P", 2 => "P")); $bRights = false; $rsUser = CUser::GetByID($ar["AUTHOR_ID"]); $arUser = $rsUser->Fetch(); if (strlen($arUser["NAME"] . "" . $arUser["LAST_NAME"]) <= 0) { $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["LOGIN"]; } else { $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["NAME"] . " " . $arUser["LAST_NAME"]; } $arFields["URL"] = str_replace(" ", "_", $arUser["LOGIN"]) . "-blog-" . $ar["SITE_ID"]; $arFields["OWNER_ID"] = $ar["AUTHOR_ID"]; $urlCheck = preg_replace("/[^a-zA-Z0-9_-]/is", "", $arFields["URL"]); if ($urlCheck != $arFields["URL"]) { $arFields["URL"] = "u" . $arUser["ID"] . "-blog-" . $ar["SITE_ID"]; } if (CBlog::GetByUrl($arFields["URL"])) { $uind = 0; do { $uind++; $arFields["URL"] = $arFields["URL"] . $uind; } while (CBlog::GetByUrl($arFields["URL"])); } $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $ar["AUTHOR_ID"], "blog", "view_post"); if ($featureOperationPerms == SONET_RELATIONS_TYPE_ALL) { $bRights = true; } $blogID = CBlog::Add($arFields); if ($bRights) { CBlog::AddSocnetRead($blogID); } $newBlogId = $blogID; $arUser2Blog[$arFields["OWNER_ID"]][$arFields["GROUP_ID"]] = $newBlogId; } if (IntVal($ar["SLID"]) > 0) { CSocNetLog::Delete($ar["SLID"]); $ar["SLID"] = 0; } } $arF = array("SOCNET_RIGHTS" => array()); if (intVal($newBlogId) > 0) { $arF["BLOG_ID"] = $newBlogId; } $arSites = array($ar["SITE_ID"]); } if (!empty($arF)) { if (IntVal($arF["BLOG_ID"]) > 0) { $Result["PARAM2"] = $ar["BLOG_ID"]; $sqlR = "UPDATE b_blog_post SET BLOG_ID=" . IntVal($arF["BLOG_ID"]) . " WHERE ID=" . IntVal($ar["ID"]); $DB->Query($sqlR, False, "File: " . __FILE__ . "<br>Line: " . __LINE__); $sqlR = "UPDATE b_blog_post_category SET BLOG_ID=" . IntVal($arF["BLOG_ID"]) . " WHERE POST_ID=" . IntVal($ar["ID"]); $DB->Query($sqlR, False, "File: " . __FILE__ . "<br>Line: " . __LINE__); $sqlR = "UPDATE b_blog_image SET BLOG_ID=" . IntVal($arF["BLOG_ID"]) . " WHERE POST_ID=" . IntVal($ar["ID"]); $DB->Query($sqlR, False, "File: " . __FILE__ . "<br>Line: " . __LINE__); $sqlR = "UPDATE b_blog_comment SET BLOG_ID=" . IntVal($arF["BLOG_ID"]) . " WHERE POST_ID=" . IntVal($ar["ID"]); $DB->Query($sqlR, False, "File: " . __FILE__ . "<br>Line: " . __LINE__); } $sqlR = "SELECT * FROM b_blog_socnet_rights where POST_ID=" . IntVal($ar["ID"]); $dbBB = $DB->Query($sqlR); if (!$dbBB->Fetch()) { $arF["SC_PERM"] = CBlogPost::UpdateSocNetPerms($ar["ID"], $arF["SOCNET_RIGHTS"], array("AUTHOR_ID" => $ar["AUTHOR_ID"])); } if (IntVal($arF["BLOG_ID"]) > 0 && $ar["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) { $dbComment = CBlogComment::GetList(array(), array("POST_ID" => $ar["ID"]), false, false, array("ID", "POST_ID", "BLOG_ID", "PATH")); if ($arComment = $dbComment->Fetch()) { $arParamsComment = array("BLOG_ID" => $arF["BLOG_ID"], "POST_ID" => $ar["ID"], "SITE_ID" => $ar["SITE_ID"], "PATH" => $arPostSite[$arGroup["SITE_ID"]] . "?commentId=#comment_id###comment_id#", "USE_SOCNET" => "Y"); CBlogComment::_IndexPostComments($arParamsComment); } } } } if ($ar["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) { if (empty($arF["SC_PERM"])) { $arF["SC_PERM"] = CBlogPost::GetSocNetPermsCode($ar["ID"]); } $Result["PERMISSIONS"] = $arF["SC_PERM"]; if (IntVal($ar["SLID"]) <= 0) { $arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "TABLE" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "N"); $text4message = $parserBlog->convert($ar["DETAIL_TEXT"], false, array(), $arAllow, array("isSonetLog" => true)); $arSoFields = array("EVENT_ID" => "blog_post", "=LOG_DATE" => $DB->CharToDateFunction($ar["DATE_PUBLISH"], "FULL", SITE_ID), "LOG_UPDATE" => $DB->CharToDateFunction($ar["DATE_PUBLISH"], "FULL", SITE_ID), "TITLE_TEMPLATE" => "#USER_NAME# add post", "TITLE" => $ar["TITLE"], "MESSAGE" => $text4message, "MODULE_ID" => "blog", "CALLBACK_FUNC" => false, "SOURCE_ID" => $ar["ID"], "ENABLE_COMMENTS" => "N", "ENTITY_TYPE" => SONET_ENTITY_USER, "ENTITY_ID" => $ar["AUTHOR_ID"], "USER_ID" => $ar["AUTHOR_ID"], "URL" => $arSite[$ar["SITE_ID"]], "SITE_ID" => $arSites); $logID = CSocNetLog::Add($arSoFields, false); if (intval($logID) > 0) { $socnetPerms = $arF["SC_PERM"]; if (!in_array("U" . $ar["AUTHOR_ID"], $socnetPerms)) { $socnetPerms[] = "U" . $ar["AUTHOR_ID"]; } $socnetPerms[] = "SA"; // socnet admin CSocNetLog::Update($logID, array("TMP_ID" => $logID, "=LOG_UPDATE" => $arSoFields["LOG_UPDATE"])); CSocNetLogRights::DeleteByLogID($logID); CSocNetLogRights::Add($logID, $socnetPerms); } } else { $socnetPerms = $arF["SC_PERM"]; if (!in_array("U" . $ar["AUTHOR_ID"], $socnetPerms)) { $socnetPerms[] = "U" . $ar["AUTHOR_ID"]; } $socnetPerms[] = "SA"; // socnet admin CSocNetLogRights::DeleteByLogID($ar["SLID"]); CSocNetLogRights::Add($ar["SLID"], $socnetPerms); } } } if ($ar["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH && $ar["SEARCH_INDEX"] == "Y") { //CBlogSearch::Trace('OnSearchReindex', 'Result', $Result); if ($oCallback) { $res = call_user_func(array($oCallback, $callback_method), $Result); if (!$res) { return $Result["ID"]; } } else { $arResult[] = $Result; } } } //all blog posts indexed so let's start index users $category = 'C'; $id = 0; COption::SetOptionString("blog", "socNetNewPerms", "Y"); } if ($category == 'C') { $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tbc.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t,bp.ID as POST_ID\n\t\t\t\t\t,b.URL\n\t\t\t\t\t,bp.TITLE as POST_TITLE\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,b.SOCNET_GROUP_ID\n\t\t\t\t\t,bc.TITLE\n\t\t\t\t\t,bc.POST_TEXT\n\t\t\t\t\t,bc.POST_ID\n\t\t\t\t\t,bc.BLOG_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\t\t,bc.PATH\n\t\t\t\t\t," . $DB->DateToCharFunction("bc.DATE_CREATE") . " as DATE_CREATE\n\t\t\t\t\t,bc.AUTHOR_ID\n\t\t\t\tFROM\n\t\t\t\t\tb_blog_comment bc\n\t\t\t\t\tINNER JOIN b_blog_post bp ON (bp.ID = bc.POST_ID)\n\t\t\t\t\tINNER JOIN b_blog b ON (bc.BLOG_ID = b.ID)\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID)\n\t\t\t\tWHERE\n\t\t\t\t\tbc.ID > " . $id . " \n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? " AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND b.SEARCH_INDEX = 'Y'\n\t\t\t\tORDER BY\n\t\t\t\t\tbc.ID\n\t\t\t"; //CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql); $rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); while ($ar = $rs->Fetch()) { //Check permissions $tag = ""; $PostPerms = CBlogUserGroup::GetGroupPerms(1, $ar["BLOG_ID"], $ar["POST_ID"], BLOG_PERMS_POST); if ($PostPerms < BLOG_PERMS_READ) { continue; } //CBlogSearch::Trace('OnSearchReindex', 'ar', $ar); if (strlen($ar["PATH"]) > 0) { $arSite = array($ar["SITE_ID"] => str_replace("#comment_id#", $ar["ID"], $ar["PATH"])); } else { $arSite = array($ar["SITE_ID"] => CBlogPost::PreparePath($ar["URL"], $ar["POST_ID"], $ar["SITE_ID"], false, $ar["OWNER_ID"], $ar["SOCNET_GROUP_ID"])); } $Result = array("ID" => "C" . $ar["ID"], "SITE_ID" => $arSite, "LAST_MODIFIED" => $ar["DATE_CREATE"], "PARAM1" => "COMMENT", "PARAM2" => $ar["BLOG_ID"] . "|" . $ar["POST_ID"], "PERMISSIONS" => array(2), "TITLE" => $ar["TITLE"], "BODY" => blogTextParser::killAllTags($ar["POST_TEXT"]), "INDEX_TITLE" => false, "USER_ID" => IntVal($ar["AUTHOR_ID"]) > 0 ? $ar["AUTHOR_ID"] : false, "ENTITY_TYPE_ID" => "BLOG_COMMENT", "ENTITY_ID" => $ar["ID"]); if ($ar["USE_SOCNET"] == "Y") { $arSp = CBlogComment::GetSocNetCommentPerms($ar["POST_ID"]); if (is_array($arSp)) { $Result["PERMISSIONS"] = $arSp; } } if (strlen($ar["TITLE"]) <= 0) { $Result["TITLE"] = substr($Result["BODY"], 0, 100); } if ($oCallback) { $res = call_user_func(array($oCallback, $callback_method), $Result); if (!$res) { return $Result["ID"]; } } else { $arResult[] = $Result; } } //all blog posts indexed so let's start index users $category = 'U'; $id = 0; } if ($category == 'U') { $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tbu.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t," . $DB->DateToCharFunction("bu.LAST_VISIT") . " as LAST_VISIT\n\t\t\t\t\t," . $DB->DateToCharFunction("u.DATE_REGISTER") . " as DATE_REGISTER\n\t\t\t\t\t,bu.ALIAS\n\t\t\t\t\t,bu.DESCRIPTION\n\t\t\t\t\t,bu.INTERESTS\n\t\t\t\t\t,u.NAME\n\t\t\t\t\t,u.LAST_NAME\n\t\t\t\t\t,u.LOGIN\n\t\t\t\t\t,bu.USER_ID\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\tFROM\n\t\t\t\t\tb_blog_user bu\n\t\t\t\t\tINNER JOIN b_user u ON (u.ID = bu.USER_ID)\n\t\t\t\t\tINNER JOIN b_blog b ON (u.ID = b.OWNER_ID)\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID)\n\t\t\t\tWHERE\n\t\t\t\t\tb.ACTIVE = 'Y'\n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? "AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND bu.ID > " . $id . "\n\t\t\t\t\tAND b.SEARCH_INDEX = 'Y'\n\t\t\t\tORDER BY\n\t\t\t\t\tbu.ID\n\t\t\t"; //CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql); $rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); while ($ar = $rs->Fetch()) { if ($ar["USE_SOCNET"] == "Y") { $Result = array("ID" => "U" . $ar["ID"], "BODY" => "", "TITLE" => ""); } else { //CBlogSearch::Trace('OnSearchReindex', 'ar', $ar); $arSite = array($ar["SITE_ID"] => CBlogUser::PreparePath($ar["USER_ID"], $ar["SITE_ID"])); //CBlogSearch::Trace('OnSearchReindex', 'arSite', $arSite); $Result = array("ID" => "U" . $ar["ID"], "LAST_MODIFIED" => $ar["LAST_VISIT"], "TITLE" => CBlogUser::GetUserName($ar["ALIAS"], $ar["NAME"], $ar["LAST_NAME"], $ar["LOGIN"]), "BODY" => blogTextParser::killAllTags($ar["DESCRIPTION"] . " " . $ar["INTERESTS"]), "SITE_ID" => $arSite, "PARAM1" => "USER", "PARAM2" => $ar["ID"], "PERMISSIONS" => array(2)); if (strlen($Result["LAST_MODIFIED"]) <= 0) { $Result["LAST_MODIFIED"] = $ar["DATE_REGISTER"]; } } //CBlogSearch::Trace('OnSearchReindex', 'Result', $Result); if ($oCallback) { $res = call_user_func(array($oCallback, $callback_method), $Result); if (!$res) { return $Result["ID"]; } } else { $arResult[] = $Result; } } } if ($oCallback) { return false; } return $arResult; }
private function RemoveMessage($MessageId = false) { $arNotification = $this->Notify->getNotification(); //Remove comments $oComment = CBlogComment::GetList( array(), array( "POST_ID" => $MessageId?$MessageId:$arNotification["ID"], ), false, false, array("ID") ); while ($arComment = $oComment->Fetch()) $this->RemoveComment($arComment["ID"]); //Remove message $oLogMessage = CSocNetLog::GetList( array("ID" => "DESC"), array("SOURCE_ID" => $MessageId?$MessageId:$arNotification["ID"]), false, false, array("ID") ); while($arLogMessage = $oLogMessage->Fetch()) CSocNetLog::Delete($arLogMessage["ID"]); }
} } $arResult["Assets"] = array("CSS" => array(), "JS" => array()); $arResult["Images"] = array(); $arResult["CommentsResult"] = array(); $arResult["IDS"] = array(); $arOrder = array("DATE_CREATE" => "ASC", "ID" => "ASC"); $arFilter = array("POST_ID" => $arParams["ID"], "BLOG_ID" => $arPost["BLOG_ID"]); if ($arResult["is_ajax_post"] == "Y" && IntVal($arResult["ajax_comment"]) > 0) { $arFilter["ID"] = $arResult["ajax_comment"]; } $arSelectedFields = array("ID", "BLOG_ID", "POST_ID", "AUTHOR_ID", "AUTHOR_NAME", "AUTHOR_EMAIL", "POST_TEXT", "DATE_CREATE", "PUBLISH_STATUS", "HAS_PROPS", "SHARE_DEST"); if ($GLOBALS["DB"]->type == "MYSQL") { $arSelectedFields[] = "DATE_CREATE_TS"; } $dbComment = CBlogComment::GetList($arOrder, $arFilter, false, false, $arSelectedFields); $resComments = array(); $arCommentsAll = array(); $arIdToGet = array(); while ($arComment = $dbComment->Fetch()) { if (IntVal($arComment["AUTHOR_ID"]) > 0) { $arIdToGet[] = $arComment["AUTHOR_ID"]; } $arCommentsAll[] = $arComment; } if (!empty($arIdToGet)) { $arResult["userCache"] = CBlogUser::GetUserInfoArray($arIdToGet, $arParams["PATH_TO_USER"], array("AVATAR_SIZE" => isset($arParams["AVATAR_SIZE_COMMON"]) ? $arParams["AVATAR_SIZE_COMMON"] : $arParams["AVATAR_SIZE"], "AVATAR_SIZE_COMMENT" => $arParams["AVATAR_SIZE_COMMENT"])); foreach ($arResult["userCache"] as $userId => $arUserCache) { $arTmpUser = array("NAME" => $arUserCache["~NAME"], "LAST_NAME" => $arUserCache["~LAST_NAME"], "SECOND_NAME" => $arUserCache["~SECOND_NAME"], "LOGIN" => $arUserCache["~LOGIN"], "NAME_LIST_FORMATTED" => ""); $arResult["userCache"][$userId]["NAME_FORMATED"] = CUser::FormatName($arParams["NAME_TEMPLATE"], $arTmpUser, $arParams["SHOW_LOGIN"] != "N" ? true : false); }
public function OnAfterPhotoCommentAddBlog($ID, $arFields) { if (!CModule::IncludeModule('iblock')) { return; } if (!$this->IsSocnet) { return; } if (intval($this->PhotoElementID) > 0) { $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "photo_photo", "SOURCE_ID" => $this->PhotoElementID), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID", "TMP_ID", "TITLE", "URL", "USER_ID", "PARAMS")); $bSocNetLogRecordExists = false; if ($arRes = $dbRes->Fetch()) { $log_id = $arRes["ID"]; $entity_type = $arRes["ENTITY_TYPE"]; $entity_id = $arRes["ENTITY_ID"]; $log_title = $arRes["TITLE"]; $log_url = $arRes["URL"]; $log_user_id = $arRes["USER_ID"]; $bSocNetLogRecordExists = true; if (strlen($arRes["PARAMS"]) > 0) { $arTmp = unserialize($arRes["PARAMS"]); if ($arTmp) { if (array_key_exists("SECTION_NAME", $arTmp) && strlen($arTmp["SECTION_NAME"]) > 0) { $log_section_name = $arTmp["SECTION_NAME"]; } if (array_key_exists("SECTION_URL", $arTmp) && strlen($arTmp["SECTION_URL"]) > 0) { $log_section_url = $arTmp["SECTION_URL"]; } } } } else { $rsElement = CIBlockElement::GetByID($this->PhotoElementID); if ($arElement = $rsElement->Fetch()) { $url = $this->arPath["DETAIL_URL"]; $sAuthorName = GetMessage("SONET_PHOTO_LOG_GUEST"); if (intval($arElement["CREATED_BY"]) > 0) { $rsUser = CUser::GetByID($arElement["CREATED_BY"]); if ($arUser = $rsUser->Fetch()) { $sAuthorName = CUser::FormatName(CSite::GetNameFormat(false), $arUser, true, false); } } if (in_array($this->entity_type, array(SONET_ENTITY_USER, SONET_ENTITY_GROUP)) && intval($this->entity_id) > 0) { $entity_type = $this->entity_type; $entity_id = $this->entity_id; $alias = ($this->entity_type == SONET_ENTITY_GROUP ? "group" : "user") . "_" . $this->entity_id; } $arLogParams = array("BLOG_ID" => intval($this->BlogID)); $rsIBlock = CIBlock::GetByID($arElement["IBLOCK_ID"]); if ($arIBlock = $rsIBlock->Fetch()) { $arLogParams["IBLOCK_ID"] = $arIBlock["ID"]; $arLogParams["IBLOCK_TYPE"] = $arIBlock["IBLOCK_TYPE_ID"]; } $rsSection = CIBlockSection::GetByID($arElement["IBLOCK_SECTION_ID"]); if ($arSection = $rsSection->Fetch()) { $arLogParams["SECTION_ID"] = $arSection["ID"]; $arLogParams["SECTION_NAME"] = $arSection["NAME"]; $arLogParams["SECTION_URL"] = str_replace("#SECTION_ID#", $arSection["ID"], $this->arPath["SECTION_URL"]); $arSectionPath = array(); $bPassword = false; $dbSectionPath = CIBlockSection::GetList(array("LEFT_MARGIN" => "ASC"), array("IBLOCK_ID" => intval($arLogParams["IBLOCK_ID"]), "<=LEFT_BORDER" => intval($arSection["LEFT_MARGIN"]), ">=RIGHT_BORDER" => intval($arSection["RIGHT_MARGIN"]), "<=DEPTH_LEVEL" => intval($arSection["DEPTH_LEVEL"])), false, array("ID", "IBLOCK_ID", "NAME", "CREATED_BY", "DEPTH_LEVEL", "LEFT_MARGIN", "RIGHT_MARGIN", "UF_PASSWORD")); while ($arPath = $dbSectionPath->Fetch()) { $arSectionPath[] = $arPath; if (strlen(trim($arPath["UF_PASSWORD"])) > 0) { $bPassword = true; break; } } if (!$alias) { $entity_type = SONET_ENTITY_USER; $entity_id = $arSectionPath[0]["CREATED_BY"]; $alias = $arSectionPath[0]["CODE"]; } } $arLogParams["ALIAS"] = $alias; $arSonetFields = array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "photo_photo", "LOG_DATE" => $arElement["TIMESTAMP_X"], "TITLE_TEMPLATE" => str_replace("#AUTHOR_NAME#", $sAuthorName, GetMessage("SONET_PHOTOPHOTO_LOG_1")), "TITLE" => $arElement["NAME"], "MESSAGE" => "", "TEXT_MESSAGE" => "", "URL" => CComponentEngine::MakePathFromTemplate($url, array("ELEMENT_ID" => $arElement["ID"], "element_id" => $arElement["ID"], "SECTION_ID" => $arElement["IBLOCK_SECTION_ID"], "section_id" => $arElement["IBLOCK_SECTION_ID"])), "MODULE_ID" => false, "CALLBACK_FUNC" => false, "SOURCE_ID" => $arElement["ID"], "PARAMS" => serialize($arLogParams), "RATING_TYPE_ID" => "IBLOCK_ELEMENT", "RATING_ENTITY_ID" => $arElement["ID"]); if (intval($arElement["CREATED_BY"]) > 0) { $arSonetFields["USER_ID"] = $arElement["CREATED_BY"]; } $log_id = CSocNetLog::Add($arSonetFields, false); if (intval($log_id) > 0) { $log_title = $arSonetFields["TITLE"]; $log_url = $arSonetFields["URL"]; $log_section_name = $arLogParams["SECTION_NAME"]; $log_section_url = $arLogParams["SECTION_URL"]; $log_user_id = $arSonetFields["USER_ID"]; CSocNetLog::Update($log_id, array("TMP_ID" => $log_id)); if ($bPassword) { CSocNetLogRights::DeleteByLogID($log_id); CSocNetLogRights::Add($log_id, array("U" . $GLOBALS["USER"]->GetID(), "SA")); } else { CSocNetLogRights::SetForSonet($log_id, $entity_type, $entity_id, "photo", "view", true); } } } } if (intval($log_id) > 0) { $parserBlog = new blogTextParser(false, $this->arPath["PATH_TO_SMILE"]); $arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "N"); if ($bSocNetLogRecordExists) { $text4message = $parserBlog->convert($arFields["POST_TEXT"], true, array(), $arAllow); $text4mail = $parserBlog->convert4mail($arFields["POST_TEXT"]); $arFieldsForSocnet = array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "photo_comment", "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE" => $text4message, "TEXT_MESSAGE" => $text4mail, "MODULE_ID" => false, "SOURCE_ID" => $ID, "LOG_ID" => $log_id, "RATING_TYPE_ID" => "BLOG_COMMENT", "RATING_ENTITY_ID" => $ID); if (intval($arFields["AUTHOR_ID"]) > 0) { $arFieldsForSocnet["USER_ID"] = $arFields["AUTHOR_ID"]; } $comment_id = CSocNetLogComments::Add($arFieldsForSocnet, false, false); if ($comment_id) { CSocNetLog::CounterIncrement($comment_id, false, false, "LC"); $arFieldsIM = array("TYPE" => "COMMENT", "TITLE" => $log_title, "MESSAGE" => $arFieldsForSocnet["MESSAGE"], "URL" => $log_url, "SECTION_NAME" => $log_section_name, "SECTION_URL" => $log_section_url, "ID" => $this->PhotoElementID, "PHOTO_AUTHOR_ID" => $log_user_id, "COMMENT_AUTHOR_ID" => $arFields["AUTHOR_ID"]); CSocNetPhotoCommentEvent::NotifyIm($arFieldsIM); } } else { $dbComments = CBlogComment::GetList(array(), array("BLOG_ID" => intval($this->BlogID), "POST_ID" => intval($this->PostID)), false, false, array("ID", "BLOG_ID", "POST_ID", "AUTHOR_ID", "POST_TEXT", "DATE_CREATE")); while ($arComment = $dbComments->GetNext()) { $text4message = $parserBlog->convert($arComment["POST_TEXT"], true, array(), $arAllow); $text4mail = $parserBlog->convert4mail($arComment["POST_TEXT"]); $arFieldsForSocnet = array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "photo_comment", "=LOG_DATE" => $GLOBALS["DB"]->CharToDateFunction($arComment["DATE_CREATE"], "FULL", SITE_ID), "MESSAGE" => $text4message, "TEXT_MESSAGE" => $text4mail, "MODULE_ID" => false, "SOURCE_ID" => intval($arComment["ID"]), "LOG_ID" => $log_id, "RATING_TYPE_ID" => "BLOG_COMMENT", "RATING_ENTITY_ID" => intval($arComment["ID"])); if (intval($arFields["AUTHOR_ID"]) > 0) { $arFieldsForSocnet["USER_ID"] = $arFields["AUTHOR_ID"]; } $comment_id = CSocNetLogComments::Add($arFieldsForSocnet, false, false); if ($comment_id) { CSocNetLog::CounterIncrement($comment_id, false, false, "LC"); $arFieldsIM = array("TYPE" => "COMMENT", "TITLE" => $log_title, "MESSAGE" => $arFieldsForSocnet["MESSAGE"], "URL" => $log_url, "SECTION_NAME" => $log_section_name, "SECTION_URL" => $log_section_url, "ID" => $this->PhotoElementID, "PHOTO_AUTHOR_ID" => $log_user_id, "COMMENT_AUTHOR_ID" => $arFields["AUTHOR_ID"]); CSocNetPhotoCommentEvent::NotifyIm($arFieldsIM); } } if ($arElement) { self::InheriteAlbumFollow($arElement["IBLOCK_SECTION_ID"], $log_id, intVal($arElement["CREATED_BY"]) > 0 ? $arElement["CREATED_BY"] : false); } } } } }
function OnAfterPhotoCommentAddBlog($ID, $arFields) { if (!CModule::IncludeModule('iblock')) return; if (!$this->IsSocnet) return; if (intval($this->PhotoElementID) > 0) { $dbRes = CSocNetLog::GetList( array("ID" => "DESC"), array( "EVENT_ID" => "photo_photo", "SOURCE_ID" => $this->PhotoElementID ), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID", "TMP_ID") ); $bSocNetLogRecordExists = false; if ($arRes = $dbRes->Fetch()) { $log_id = $arRes["ID"]; $entity_type = $arRes["ENTITY_TYPE"]; $entity_id = $arRes["ENTITY_ID"]; $bSocNetLogRecordExists = true; } else { $rsElement = CIBlockElement::GetByID($this->PhotoElementID); if ($arElement = $rsElement->Fetch()) { $url = $this->arPath["DETAIL_URL"]; $sAuthorName = GetMessage("SONET_LOG_GUEST"); if (intval($arElement["CREATED_BY"]) > 0) { $rsUser = CUser::GetByID($arElement["CREATED_BY"]); if ($arUser = $rsUser->Fetch()) $sAuthorName = CUser::FormatName(CSite::GetNameFormat(false), $arUser, true, false); } if ( in_array($this->entity_type, array(SONET_ENTITY_USER, SONET_ENTITY_GROUP)) && intval($this->entity_id) > 0 ) { $entity_type = $this->entity_type; $entity_id = $this->entity_id; $alias = ($this->entity_type == SONET_ENTITY_GROUP ? "group" : "user")."_".$this->entity_id; } $arLogParams = array( "BLOG_ID" => intval($this->BlogID) ); $rsIBlock = CIBlock::GetByID($arElement["IBLOCK_ID"]); if($arIBlock = $rsIBlock->Fetch()) { $arLogParams["IBLOCK_ID"] = $arIBlock["ID"]; $arLogParams["IBLOCK_TYPE"] = $arIBlock["IBLOCK_TYPE_ID"]; } $rsSection = CIBlockSection::GetByID($arElement["IBLOCK_SECTION_ID"]); if ($arSection = $rsSection->Fetch()) { $arLogParams["SECTION_ID"] = $arSection["ID"]; $arLogParams["SECTION_NAME"] = $arSection["NAME"]; $arLogParams["SECTION_URL"] = str_replace("#SECTION_ID#", $arSection["ID"], $this->arPath["SECTION_URL"]); if (!$alias) { $arSectionPath = array(); $rsPath = CIBlockSection::GetNavChain($arLogParams["IBLOCK_ID"], intval($arLogParams["SECTION_ID"])); if($arPath = $rsPath->Fetch()) { $entity_type = SONET_ENTITY_USER; $entity_id = $arPath["CREATED_BY"]; $alias = $arPath["CODE"]; } } } $arLogParams["ALIAS"] = $alias; $arSonetFields = array( "ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "photo_photo", "LOG_DATE" => $arElement["TIMESTAMP_X"], "TITLE_TEMPLATE" => str_replace("#AUTHOR_NAME#", $sAuthorName, GetMessage("SONET_PHOTOPHOTO_LOG_1")), "TITLE" => $arElement["NAME"], "MESSAGE" => "", "TEXT_MESSAGE" => "", "URL" => CComponentEngine::MakePathFromTemplate($url, array( "ELEMENT_ID" => $arElement["ID"], "element_id" => $arElement["ID"], "SECTION_ID" => $arElement["IBLOCK_SECTION_ID"], "section_id" => $arElement["IBLOCK_SECTION_ID"] )), "MODULE_ID" => false, "CALLBACK_FUNC" => false, "SOURCE_ID" => $arElement["ID"], "PARAMS" => serialize($arLogParams), "RATING_TYPE_ID" => "IBLOCK_ELEMENT", "RATING_ENTITY_ID"=> $arElement["ID"], ); if (intval($arElement["CREATED_BY"]) > 0) $arSonetFields["USER_ID"] = $arElement["CREATED_BY"]; $log_id = CSocNetLog::Add($arSonetFields, false); if (intval($log_id) > 0) { CSocNetLog::Update($log_id, array("TMP_ID" => $log_id)); CSocNetLogRights::SetForSonet($log_id, $entity_type, $entity_id, "photo", "view", true); } } } if (intval($log_id) > 0) { $parserBlog = new blogTextParser(false, $this->arPath["PATH_TO_SMILE"]); $arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "N"); if ($bSocNetLogRecordExists) { $text4message = $parserBlog->convert($arFields["POST_TEXT"], true, array(), $arAllow); $text4mail = $parserBlog->convert4mail($arFields["POST_TEXT"]); $arFieldsForSocnet = array( "ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "photo_comment", "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE" => $text4message, "TEXT_MESSAGE" => $text4mail, "MODULE_ID" => false, "SOURCE_ID" => $ID, "LOG_ID" => $log_id, "RATING_TYPE_ID" => "BLOG_COMMENT", "RATING_ENTITY_ID" => $ID, ); if (intval($arFields["AUTHOR_ID"]) > 0) $arFieldsForSocnet["USER_ID"] = $arFields["AUTHOR_ID"]; CSocNetLogComments::Add($arFieldsForSocnet); } else //socnetlog record didn't exist - adding all comments { $dbComments = CBlogComment::GetList(array(), array( "BLOG_ID" => intval($this->BlogID), "POST_ID" => intval($this->PostID) ), false, false, array("ID", "BLOG_ID", "POST_ID", "AUTHOR_ID", "POST_TEXT", "DATE_CREATE") ); while ($arComment = $dbComments->GetNext()) { $text4message = $parserBlog->convert($arComment["POST_TEXT"], true, array(), $arAllow); $text4mail = $parserBlog->convert4mail($arComment["POST_TEXT"]); $arFieldsForSocnet = array( "ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "photo_comment", "=LOG_DATE" => $GLOBALS["DB"]->CharToDateFunction($arComment["DATE_CREATE"], "FULL", SITE_ID), "MESSAGE" => $text4message, "TEXT_MESSAGE" => $text4mail, "MODULE_ID" => false, "SOURCE_ID" => intval($arComment["ID"]), "LOG_ID" => $log_id, "RATING_TYPE_ID" => "BLOG_COMMENT", "RATING_ENTITY_ID" => intval($arComment["ID"]), ); if (intval($arFields["AUTHOR_ID"]) > 0) $arFieldsForSocnet["USER_ID"] = $arFields["AUTHOR_ID"]; CSocNetLogComments::Add($arFieldsForSocnet); } } } } }
public static function _IndexPostComments($arParams = Array()) { if(IntVal($arParams["BLOG_ID"]) <= 0 || IntVal($arParams["POST_ID"]) <= 0 || !CModule::IncludeModule("search")) return false; if($arParams["USE_SOCNET"] == "Y") $arSp = CBlogComment::GetSocNetCommentPerms($arParams["POST_ID"]); $dbComment = CBlogComment::GetList(Array(), Array("BLOG_ID" => $arParams["BLOG_ID"], "POST_ID" => $arParams["POST_ID"], "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH), false, false, Array("ID", "POST_ID", "BLOG_ID", "PUBLISH_STATUS", "PATH", "DATE_CREATE", "POST_TEXT", "TITLE", "AUTHOR_ID")); while($arComment = $dbComment->Fetch()) { if(strlen($arComment["PATH"]) > 0) $arComment["PATH"] = str_replace("#comment_id#", $arComment["ID"], $arComment["PATH"]); elseif(strlen($arParams["PATH"]) > 0) $arComment["PATH"] = str_replace("#comment_id#", $arComment["ID"], $arParams["PATH"]); else { $arComment["PATH"] = CBlogPost::PreparePath( $arParams["BLOG_URL"], $arComment["POST_ID"], $arParams["SITE_ID"], false, $arParams["OWNER_ID"], $arParams["SOCNET_GROUP_ID"] ); } $arSearchIndex = array( "SITE_ID" => array($arParams["SITE_ID"] => $arComment["PATH"]), "LAST_MODIFIED" => $arComment["DATE_CREATE"], "PARAM1" => "COMMENT", "PARAM2" => $arComment["BLOG_ID"]."|".$arComment["POST_ID"], "PERMISSIONS" => array(2), "TITLE" => $arComment["TITLE"], "BODY" => blogTextParser::killAllTags($arComment["POST_TEXT"]), "INDEX_TITLE" => false, "USER_ID" => (IntVal($arComment["AUTHOR_ID"]) > 0) ? $arComment["AUTHOR_ID"] : false, "ENTITY_TYPE_ID" => "BLOG_COMMENT", "ENTITY_ID" => $arComment["ID"], ); if($arParams["USE_SOCNET"] == "Y") { $arSearchIndex["PERMISSIONS"] = $arSp; if(!in_array("U".$arComment["AUTHOR_ID"], $arSearchIndex["PERMISSIONS"])) $arSearchIndex["PERMISSIONS"][] = "U".$arComment["AUTHOR_ID"]; if(is_array($arSp)) { $sgId = array(); foreach($arSp as $perm) { if(strpos($perm, "SG") !== false) { $sgIdTmp = str_replace("SG", "", substr($perm, 0, strpos($perm, "_"))); if(!in_array($sgIdTmp, $sgId) && IntVal($sgIdTmp) > 0) $sgId[] = $sgIdTmp; } } if(!empty($sgId)) { $arSearchIndex["PARAMS"] = array( "socnet_group" => $sgId, "entity" => "socnet_group", ); } } } if(strlen($arComment["TITLE"]) <= 0) $arSearchIndex["TITLE"] = substr($arSearchIndex["BODY"], 0, 100); CSearch::Index("blog", "C".$arComment["ID"], $arSearchIndex, True); } }
function AddComment_Review_UpdateElement_Blog($arElement, $postID, $blogID, $bNewPost) { if (!CModule::IncludeModule("blog")) { return false; } if ($bNewPost) { CIBlockElement::SetPropertyValues($arElement["ID"], $arElement["IBLOCK_ID"], intVal($postID), "BLOG_POST_ID"); $BLOG_COMMENT_CNT = 1; } else { $BLOG_COMMENT_CNT = CBlogComment::GetList(array(), array("POST_ID" => $postID), array()); } CIBlockElement::SetPropertyValues($arElement["ID"], $arElement["IBLOCK_ID"], intVal($BLOG_COMMENT_CNT), "BLOG_COMMENT_CNT"); $arBlog = CBlog::GetByID($blogID); BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/comment/" . $postID . "/"); BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/post/" . $postID . "/"); BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/first_page/"); BXClearCache(True, "/" . SITE_ID . "/blog/last_comments/"); BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/rss_out/" . $postID . "/C/"); BXClearCache(True, "/" . SITE_ID . "/blog/last_messages/"); BXClearCache(True, "/" . SITE_ID . "/blog/commented_posts/"); BXClearCache(True, "/" . SITE_ID . "/blog/popular_posts/"); }
CBlogPostCategory::Add(array("BLOG_ID" => $arCopyBlog["ID"], "POST_ID" => $copyID, "CATEGORY_ID" => $v)); $arCopyCat[] = $v; } if (!empty($arCopyCat)) { $arCopyPostUpdate["CATEGORY_ID"] = implode(",", $arCopyCat); } if ($_POST["move2blogcopy"] == "Y") { $arCopyPostUpdate["NUM_COMMENTS"] = 0; } if (!empty($arCopyPostUpdate)) { $copyID = CBlogPost::Update($copyID, $arCopyPostUpdate); $arCopyPost = CBlogPost::GetByID($copyID); } if ($_POST["move2blogcopy"] != "Y") { if (CBlogPost::CanUserDeletePost($arParams["ID"], $user_id)) { $dbC = CBlogComment::GetList(array("ID" => "ASC"), array("BLOG_ID" => $arBlog["ID"], "POST_ID" => $arParams["ID"]), false, false, array("PATH", "PUBLISH_STATUS", "POST_TEXT", "TITLE", "DATE_CREATE", "AUTHOR_IP1", "AUTHOR_IP", "AUTHOR_EMAIL", "AUTHOR_NAME", "AUTHOR_ID", "PARENT_ID", "POST_ID", "BLOG_ID", "ID")); while ($arC = $dbC->Fetch()) { $arCTmp = array("BLOG_ID" => $arCopyBlog["ID"], "POST_ID" => $copyID); CBlogComment::Update($arC["ID"], $arCTmp); } $arFilter = array("POST_ID" => $arParams["ID"], "BLOG_ID" => $arBlog["ID"], "IS_COMMENT" => "Y"); $res = CBlogImage::GetList(array("ID" => "ASC"), $arFilter); while ($arImg = $res->GetNext()) { $arNewImg = array("BLOG_ID" => $arCopyBlog["ID"], "POST_ID" => $copyID); CBlogImage::Update($arImg["ID"], $arNewImg); } if (!CBlogPost::Delete($arParams["ID"])) { $arResult["ERROR_MESSAGE"] = GetMessage("BPE_COPY_DELETE_ERROR"); } else { CBlogPost::DeleteLog($arParams["ID"], $arParams["MICROBLOG"]); }
BXClearCache(True, "/" . $site . "/blog/commented_posts/"); BXClearCache(True, "/" . $site . "/blog/popular_posts/"); } } } $arHeaders = array(array("id" => "ID", "content" => "ID", "sort" => "ID", "default" => true), array("id" => "PUBLISH_STATUS", "content" => GetMessage("BLB_PUBLISH_STATUS"), "sort" => "PUBLISH_STATUS", "default" => true), array("id" => "DATE_CREATE", "content" => GetMessage('BLB_DATE_CREATE'), "sort" => "DATE_CREATE", "default" => true), array("id" => "AUTHOR_ID", "content" => GetMessage('BLB_AUTHOR_ID'), "sort" => "", "default" => true, "sort" => "AUTHOR_ID"), array("id" => "POST_TEXT", "content" => GetMessage("BLB_COMMENT"), "sort" => "POST_TEXT", "default" => true), array("id" => "POST_TITLE", "content" => GetMessage("BLB_POST_ID"), "sort" => "POST_TITLE", "default" => true), array("id" => "BLOG_ID", "content" => GetMessage("BLB_BLOG_ID"), "sort" => "BLOG_ID", "default" => true), array("id" => "AUTHOR_IP", "content" => "IP", "sort" => "AUTHOR_IP", "default" => true)); $USER_FIELD_MANAGER->AdminListAddHeaders("BLOG_COMMENT", $arHeaders); $lAdmin->AddHeaders($arHeaders); $arVisibleColumns = $lAdmin->GetVisibleHeaderColumns(); $arSelectedFields = array("ID", "BLOG_ID", "POST_ID", "PARENT_ID", "AUTHOR_ID", "AUTHOR_NAME", "AUTHOR_EMAIL", "AUTHOR_IP", "AUTHOR_IP1", "DATE_CREATE", "POST_TEXT", "PUBLISH_STATUS", "PATH", "USER_LOGIN", "USER_NAME", "USER_LAST_NAME", "BLOG_URL", "BLOG_OWNER_ID", "BLOG_SOCNET_GROUP_ID", "BLOG_ACTIVE", "BLOG_GROUP_ID", "BLOG_GROUP_SITE_ID", "BLOG_NAME", "POST_TITLE"); foreach ($arVisibleColumns as $val) { if (!in_array($val, $arSelectedFields)) { $arSelectedFields[] = $val; } } $dbResultList = CBlogComment::GetList(array($by => $order), $arFilter, false, array("nPageSize" => CAdminResult::GetNavSize($sTableID)), $arSelectedFields); $dbResultList = new CAdminResult($dbResultList, $sTableID); $dbResultList->NavStart(); $lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("BLB_GROUP_NAV"))); $arServerName = array(); $dbSite = CSite::GetList($b = "SORT", $o = "ASC"); while ($arSite = $dbSite->Fetch()) { $serverName = $arSite["SERVER_NAME"]; if (strLen($serverName) <= 0) { if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) { $serverName = SITE_SERVER_NAME; } else { $serverName = COption::GetOptionString("main", "server_name", ""); } if (strlen($serverName) <= 0) { $serverName = $_SERVER["SERVER_NAME"];
$arResult["FILE_INFO"] = array(); $user_id = IntVal($USER->GetID()); $arError = array(); if (intVal($arParams["FILE_ID"]) > 0) { if ($res = CBlogImage::GetByID($arParams["FILE_ID"])) { $arResult["FILE_INFO"] = $res; $arResult["FILE"] = CFile::GetFileArray($arResult["FILE_INFO"]["FILE_ID"]); } } elseif (intVal($arParams["BP_FILE_ID"]) > 0) { $arResult["FILE"] = CFile::GetFileArray(intVal($arParams['BP_FILE_ID'])); if (!empty($arResult["FILE"])) { $dbPost = CBlogPost::GetList(array(), array('UF_BLOG_POST_DOC' => intVal($arParams['BP_FILE_ID']))); if ($dbPost && ($arPost = $dbPost->Fetch())) { $arResult["FILE_INFO"] = array('POST_ID' => $arPost['ID'], 'BLOG_ID' => $arPost['BLOG_ID']); } else { $dbPost = CBlogComment::GetList(array(), array('UF_BLOG_COMMENT_DOC' => intVal($arParams['BP_FILE_ID']))); if ($dbPost && ($arPost = $dbPost->Fetch())) { $arResult["FILE_INFO"] = array('POST_ID' => $arPost['POST_ID'], 'BLOG_ID' => $arPost['BLOG_ID']); } } } } if (empty($arResult["FILE"])) { $arError = array("code" => "EMPTY FILE", "title" => GetMessage("F_EMPTY_FID")); } else { if (intVal($arResult["FILE_INFO"]["POST_ID"]) > 0) { if (empty($arResult['POST'])) { $dbPost = CBlogPost::GetList(array(), array("ID" => $arResult["FILE_INFO"]["POST_ID"], "BLOG_ID" => $arResult["FILE_INFO"]["BLOG_ID"]), false, false, array("ID", "BLOG_ID", "BLOG_OWNER_ID", "BLOG_SOCNET_GROUP_ID", "BLOG_USE_SOCNET", "AUTHOR_ID")); $arResult["POST"] = $dbPost->Fetch(); } if (!empty($arResult['POST'])) {
$res = CBlogSmile::GetList(array("SORT" => "ASC", "ID" => "DESC"), array("SMILE_TYPE" => "S", "LANG_LID" => LANGUAGE_ID), false, false, $arSelectFields); while ($arr = $res->GetNext()) { list($type) = explode(" ", $arr["TYPING"]); $arr["TYPE"] = str_replace("'", "\\'", $type); $arr["TYPE"] = str_replace("\\", "\\\\", $arr["TYPE"]); $arSmiles[] = $arr; } $arResult["Smiles"] = $arSmiles; if (IntVal($arParams["ID"]) > 0) { $arOrder = array("ID" => "ASC", "DATE_CREATE" => "ASC"); $arFilter = array("POST_ID" => $arParams["ID"]); if ($arResult["Perm"] < BLOG_PERMS_MODERATE || !$arResult["IDEA_MODERATOR"]) { $arFilter["PUBLISH_STATUS"] = BLOG_PUBLISH_STATUS_PUBLISH; } $arSelectedFields = array("ID", "BLOG_ID", "POST_ID", "PARENT_ID", "AUTHOR_ID", "AUTHOR_NAME", "AUTHOR_EMAIL", "AUTHOR_IP", "AUTHOR_IP1", "TITLE", "POST_TEXT", "DATE_CREATE", "PUBLISH_STATUS"); $dbComment = CBlogComment::GetList($arOrder, array_merge($extFilter, $arFilter), false, false, $arSelectedFields); $resComments = array(); $arResult["firstLevel"] = 0; if ($arComment = $dbComment->GetNext()) { $p = new blogTextParser(false, $arParams["PATH_TO_SMILE"]); $arParserParams = array("imageWidth" => $arParams["IMAGE_MAX_WIDTH"], "imageHeight" => $arParams["IMAGE_MAX_HEIGHT"]); do { $arResult["Comments"][$arComment["ID"]] = array("ID" => $arComment["ID"], "PARENT_ID" => $arComment["PARENT_ID"]); $arComment["ShowIP"] = $arResult["ShowIP"]; if (empty($resComments[IntVal($arComment["PARENT_ID"])])) { $resComments[IntVal($arComment["PARENT_ID"])] = array(); if (strlen($arResult["firstLevel"]) <= 0) { $arResult["firstLevel"] = IntVal($arComment["PARENT_ID"]); } } if (IntVal($arComment["AUTHOR_ID"]) > 0) {
/** * Checking blog comment for spam * @param &array Comment fields to check * @return null|boolean NULL when success or FALSE when spam detected */ function OnBeforeCommentAddHandler(&$arFields) { global $APPLICATION, $USER; $ct_status = COption::GetOptionString('cleantalk.antispam', 'status', '0'); $ct_comment_blog = COption::GetOptionString('cleantalk.antispam', 'form_comment_blog', '0'); if ($ct_status == 1 && $ct_comment_blog == 1) { if ($USER->IsAdmin()) { return; } // Skip authorized user with more than 5 approved comments if ($USER->IsAuthorized()) { $approved_comments = CBlogComment::GetList(array('ID' => 'ASC'), array('AUTHOR_ID' => $arFields['AUTHOR_ID'], 'PUBLISH_STATUS' => BLOG_PUBLISH_STATUS_PUBLISH), array()); if (intval($approved_comments) > 5) { return; } } $aComment = array(); $aComment['type'] = 'comment'; $aComment['sender_email'] = isset($arFields['AUTHOR_EMAIL']) ? $arFields['AUTHOR_EMAIL'] : ''; $aComment['sender_nickname'] = isset($arFields['AUTHOR_NAME']) ? $arFields['AUTHOR_NAME'] : ''; $aComment['message_title'] = ''; $aComment['message_body'] = isset($arFields['POST_TEXT']) ? $arFields['POST_TEXT'] : ''; $aComment['example_title'] = ''; $aComment['example_body'] = ''; $aComment['example_comments'] = ''; if (COption::GetOptionString('cleantalk.antispam', 'form_send_example', '0') == 1) { $arPost = CBlogPost::GetByID($arFields['POST_ID']); if (is_array($arPost)) { $aComment['example_title'] = $arPost['TITLE']; $aComment['example_body'] = $arPost['DETAIL_TEXT']; // Find last 10 approved comments $db_res = CBlogComment::GetList(array('DATE_CREATE' => 'DESC'), array('POST_ID' => $arFields['POST_ID'], 'PUBLISH_STATUS' => BLOG_PUBLISH_STATUS_PUBLISH), false, array('nTopCount' => 10), array('POST_TEXT')); while ($ar_res = $db_res->Fetch()) { $aComment['example_comments'] .= $ar_res['TITLE'] . "\n\n" . $ar_res['POST_TEXT'] . "\n\n"; } } } $aResult = self::CheckAllBefore($aComment, TRUE); if (isset($aResult) && is_array($aResult)) { if ($aResult['errno'] == 0) { if ($aResult['allow'] == 1) { // Not spammer - just return; return; } else { if ($aResult['stop_queue'] == 1) { // Spammer and stop_queue - return false and throw if (preg_match('//u', $aResult['ct_result_comment'])) { $err_str = preg_replace('/^[^\\*]*?\\*\\*\\*|\\*\\*\\*[^\\*]*?$/iu', '', $aResult['ct_result_comment']); $err_str = preg_replace('/<[^<>]*>/iu', '', $err_str); } else { $err_str = preg_replace('/^[^\\*]*?\\*\\*\\*|\\*\\*\\*[^\\*]*?$/i', '', $aResult['ct_result_comment']); $err_str = preg_replace('/<[^<>]*>/i', '', $err_str); } $APPLICATION->ThrowException($err_str); return FALSE; } else { // Spammer and NOT stop_queue - to manual approvement // BLOG_PUBLISH_STATUS_READY // It doesn't work // values below results in endless 'Loading' AJAX message :( //$arFields['PUBLISH_STATUS'] = BLOG_PUBLISH_STATUS_READY; //$arFields['PUBLISH_STATUS'] = BLOG_PUBLISH_STATUS_DRAFT; //return; // It doesn't work too // Status setting in OnCommentAddHandler still results in endless 'Loading' AJAX message :( //$GLOBALS['ct_after_CommentAdd_status'] = BLOG_PUBLISH_STATUS_READY; //return; if (preg_match('//u', $aResult['ct_result_comment'])) { $err_str = preg_replace('/^[^\\*]*?\\*\\*\\*|\\*\\*\\*[^\\*]*?$/iu', '', $aResult['ct_result_comment']); $err_str = preg_replace('/<[^<>]*>/iu', '', $err_str); } else { $err_str = preg_replace('/^[^\\*]*?\\*\\*\\*|\\*\\*\\*[^\\*]*?$/i', '', $aResult['ct_result_comment']); $err_str = preg_replace('/<[^<>]*>/i', '', $err_str); } $APPLICATION->ThrowException($err_str); return FALSE; } } } } } }
function _IndexPostComments($arParams = array()) { if (IntVal($arParams["BLOG_ID"]) <= 0 || IntVal($arParams["POST_ID"]) <= 0 || !CModule::IncludeModule("search")) { return false; } if ($arParams["USE_SOCNET"] == "Y") { $arSp = CBlogComment::GetSocNetCommentPerms($arParams["POST_ID"]); } $dbComment = CBlogComment::GetList(array(), array("BLOG_ID" => $arParams["BLOG_ID"], "POST_ID" => $arParams["POST_ID"], "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH), false, false, array("ID", "POST_ID", "BLOG_ID", "PUBLISH_STATUS", "PATH", "DATE_CREATE", "POST_TEXT", "TITLE", "AUTHOR_ID")); while ($arComment = $dbComment->Fetch()) { if (strlen($arComment["PATH"]) > 0) { $arComment["PATH"] = str_replace("#comment_id#", $arComment["ID"], $arComment["PATH"]); } elseif (strlen($arParams["PATH"]) > 0) { $arComment["PATH"] = str_replace("#comment_id#", $arComment["ID"], $arParams["PATH"]); } else { $arComment["PATH"] = CBlogPost::PreparePath($arParams["BLOG_URL"], $arComment["POST_ID"], $arParams["SITE_ID"], false, $arParams["OWNER_ID"], $arParams["SOCNET_GROUP_ID"]); } $arSearchIndex = array("SITE_ID" => array($arParams["SITE_ID"] => $arComment["PATH"]), "LAST_MODIFIED" => $arComment["DATE_CREATE"], "PARAM1" => "COMMENT", "PARAM2" => $arComment["BLOG_ID"] . "|" . $arComment["POST_ID"], "PERMISSIONS" => array(2), "TITLE" => $arComment["TITLE"], "BODY" => blogTextParser::killAllTags($arComment["POST_TEXT"]), "INDEX_TITLE" => false, "USER_ID" => IntVal($arComment["AUTHOR_ID"]) > 0 ? $arComment["AUTHOR_ID"] : false, "ENTITY_TYPE_ID" => "BLOG_COMMENT", "ENTITY_ID" => $arComment["ID"]); if ($arParams["USE_SOCNET"] == "Y") { $arSearchIndex["PERMISSIONS"] = $arSp; } if (strlen($arComment["TITLE"]) <= 0) { $arSearchIndex["TITLE"] = substr($arSearchIndex["BODY"], 0, 100); } CSearch::Index("blog", "C" . $arComment["ID"], $arSearchIndex, True); } }
$perms = BLOG_PERMS_WRITE; } elseif (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "blog", "view_post")) { $perms = BLOG_PERMS_READ; } } } } if ($perms != BLOG_PERMS_DENY) { $SORT = array($arParams["SORT_BY1"] => $arParams["SORT_ORDER1"], $arParams["SORT_BY2"] => $arParams["SORT_ORDER2"]); if ($arParams["COMMENT_COUNT"] > 0) { $COUNT = array("nTopCount" => $arParams["COMMENT_COUNT"]); } else { $COUNT = false; } $arResult = array(); $dbComment = CBlogComment::GetList($SORT, $arFilter, false, $COUNT, $arSelectedFields); $p = new blogTextParser(false, $arParams["PATH_TO_SMILE"]); $itemCnt = 0; while ($arComment = $dbComment->GetNext()) { $arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "N", "USER" => "N"); $text = preg_replace("#\\[img\\](.+?)\\[/img\\]#ie", "", $arComment["~POST_TEXT"]); $text = preg_replace("#\\[user\\](.+?)\\[/user\\]#ie", "", $text); $text = preg_replace("#\\[code\\](.+?)\\[/code\\]#is", "", $text); $text = preg_replace("#\\[quote\\](.+?)\\[/quote\\]#is", "", $text); if ($arResult["NO_URL_IN_COMMENTS"] == "L" || IntVal($arComment["AUTHOR_ID"]) <= 0 && $arParams["NO_URL_IN_COMMENTS"] == "A") { $arAllow["CUT_ANCHOR"] = "Y"; $arAllow["ANCHOR"] = "Y"; } elseif ($arParams["NO_URL_IN_COMMENTS_AUTHORITY_CHECK"] == "Y" && $arAllow["CUT_ANCHOR"] != "Y" && IntVal($arComment["AUTHOR_ID"]) > 0) { $authorityRatingId = CRatings::GetAuthorityRating(); $arRatingResult = CRatings::GetRatingResult($authorityRatingId, $arComment["AUTHOR_ID"]); if ($arRatingResult["CURRENT_VALUE"] < $arParams["NO_URL_IN_COMMENTS_AUTHORITY"]) {
function DeleteLog($postID, $bMicroblog = false) { if (!CModule::IncludeModule('socialnetwork')) { return; } $dbComment = CBlogComment::GetList(array(), array("POST_ID" => $postID), false, false, array("ID")); while ($arComment = $dbComment->Fetch()) { $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => array("blog_comment", "blog_comment_micro"), "SOURCE_ID" => $arComment["ID"]), false, false, array("ID")); while ($arRes = $dbRes->Fetch()) { CSocNetLog::Delete($arRes["ID"]); } } $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => array("blog_post_micro", "blog_post"), "SOURCE_ID" => $postID), false, false, array("ID")); while ($arRes = $dbRes->Fetch()) { CSocNetLog::Delete($arRes["ID"]); } }
return; } //Plug-in Blogs if (!CModule::IncludeModule("blog")) { $this->AbortResultCache(); ShowError(GetMessage("BLOG_MODULE_NOT_INSTALLED")); return; } //Get the number of participants $participantsCount = CUser::GetCount(); $arResult["PARTICIPANTS"] = $participantsCount; //Get the number of experts $groupId = $arParams["EXPERTS_GROUP"]; $arExperts = CGroup::GetGroupUser($groupId); //Alternative CGroup::GetList with SHOW_USERS_AMOUNT $arResult["EXPERTS"] = count($arExperts); //Get the number of questions $arFilter = array("IBLOCK_ID" => $arParams["QUESTIONS_IBLOCK_ID"], "ACTIVE" => "Y"); $arResult["QUESTIONS"] = CIBlockElement::GetList(array(), $arFilter, array(), false, array()); //Get the number of categoties $arFilter = array("IBLOCK_ID" => $arParams["CATEGORIES_IBLOCK_ID"], "ACTIVE" => "Y", "DEPTH_LEVEL" => 1); $arResult["CATEGORIES"] = CIBlockSection::GetCount($arFilter); //Get the number of work $arFilter = array("IBLOCK_ID" => $arParams["WORK_IBLOCK_ID"], "ACTIVE" => "Y"); $arResult["WORK"] = CIBlockElement::GetList(array(), $arFilter, array(), false, array()); //Get the number of comments $arFilter = array("BLOG_ID" => $arParams["BLOG_ID"]); $arResult["COMMENTS"] = CBlogComment::GetList(array(), $arFilter, array(), false, array()); //Plug-in tenplate $this->IncludeComponentTemplate(); }