public function Get() { if (!$this->IsAvailable()) { return false; } return CBlogComment::GetList(array(), array("ID" => $this->CommentId))->Fetch(); }
function Update($ID, $arFields) { global $DB; $ID = IntVal($ID); $arFields1 = array(); foreach ($arFields as $key => $value) { if (substr($key, 0, 1) == "=") { $arFields1[substr($key, 1)] = $value; unset($arFields[$key]); } } if (!CBlogComment::CheckFields("UPDATE", $arFields, $ID)) { return false; } $strUpdate = $DB->PrepareUpdate("b_blog_comment", $arFields); foreach ($arFields1 as $key => $value) { if (strlen($strUpdate) > 0) { $strUpdate .= ", "; } $strUpdate .= $key . "=" . $value . " "; } if (strlen($strUpdate) > 0) { $strSql = "UPDATE b_blog_comment SET " . "\t" . $strUpdate . " " . "WHERE ID = " . $ID . " "; $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__); unset($GLOBALS["BLOG_COMMENT_CACHE_" . $ID]); return $ID; } return False; }
public function addComment($authorId, array $data) { $this->loadBlogPostData(); $commentFields = array("POST_ID" => $this->entityId, "BLOG_ID" => $this->blogPostData['BLOG_ID'], "POST_TEXT" => $data['text'], "DATE_CREATE" => new DateTime(), "PARENT_ID" => false, "AUTHOR_ID" => $authorId, "HAS_PROPS" => 'Y'); if (!empty($data['fileId'])) { $commentFields['UF_BLOG_COMMENT_FILE'] = array($data['fileId']); } elseif (!empty($data['versionId'])) { $commentFields['UF_BLOG_COMMENT_FH'] = $data['versionId']; } $comId = \CBlogComment::add($commentFields); if (!$comId) { return; } if (method_exists("CBlogComment", "addLiveComment")) { /** @noinspection PhpDynamicAsStaticMethodCallInspection */ \CBlogComment::addLiveComment($comId, array("MODE" => "PULL_MESSAGE")); } BXClearCache(true, "/blog/comment/" . $this->entityId . "/"); if (!Loader::includeModule('socialnetwork')) { return; } $query = \CSocNetLog::getList(array("ID" => "DESC"), array("EVENT_ID" => array("blog_post", "blog_post_important"), "SOURCE_ID" => $this->entityId), false, false, array("ID", "TMP_ID")); $row = $query->fetch(); if (!$row) { return; } $fieldsForSocnet = array("ENTITY_TYPE" => SONET_ENTITY_USER, "ENTITY_ID" => $this->blogPostData["AUTHOR_ID"], "EVENT_ID" => "blog_comment", "=LOG_DATE" => Application::getInstance()->getConnection()->getSqlHelper()->getCurrentDateTimeFunction(), "MESSAGE" => "file", "TEXT_MESSAGE" => "file", "URL" => "", "MODULE_ID" => false, "SOURCE_ID" => $comId, "LOG_ID" => $row["ID"], "RATING_TYPE_ID" => "BLOG_COMMENT", "RATING_ENTITY_ID" => $comId, "USER_ID" => $authorId); \CSocNetLogComments::add($fieldsForSocnet, false, false, false); }
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"]); } } } } }
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 AddLiveComment($commentId = 0, $path = "", $arParams = array()) { if (IntVal($commentId) <= 0) { return; } if (CModule::IncludeModule("pull") && CPullOptions::GetNginxStatus() && ($arComment = CBlogComment::GetByID($commentId)) && ($arPost = CBlogPost::GetByID($arComment["POST_ID"]))) { if (strlen($path) <= 0 && strlen($arComment["PATH"]) > 0) { $path = CComponentEngine::MakePathFromTemplate($arComment["PATH"], array("post_id" => $arComment["POST_ID"], "comment_id" => $commentId)); } if (strlen($path) <= 0) { $path = CComponentEngine::MakePathFromTemplate($arPost["PATH"], array("post_id" => $arComment["POST_ID"], "comment_id" => $commentId)) . "?commentId=" . $commentId; } $arFormatParams = array("PATH_TO_USER" => isset($arParams["PATH_TO_USER"]) ? $arParams["PATH_TO_USER"] : '', "PATH_TO_POST" => $path, "NAME_TEMPLATE" => isset($arParams["NAME_TEMPLATE"]) ? $arParams["NAME_TEMPLATE"] : CSite::GetNameFormat(), "SHOW_LOGIN" => isset($arParams["SHOW_LOGIN"]) ? $arParams["SHOW_LOGIN"] : true, "AVATAR_SIZE_COMMENT" => isset($arParams["AVATAR_SIZE_COMMENT"]) ? $arParams["AVATAR_SIZE_COMMENT"] : 58, "PATH_TO_SMILE" => isset($arParams["PATH_TO_SMILE"]) ? $arParams["PATH_TO_SMILE"] : '', "DATE_TIME_FORMAT" => isset($arParams["DATE_TIME_FORMAT"]) ? $arParams["DATE_TIME_FORMAT"] : '', "SHOW_RATING" => isset($arParams["SHOW_RATING"]) ? $arParams["SHOW_RATING"] : '', "RATING_TYPE" => "like"); $arComment["DateFormated"] = FormatDateFromDB($arComment["DATE_CREATE"], $arFormatParams["DATE_TIME_FORMAT"], true); if (strcasecmp(LANGUAGE_ID, 'EN') !== 0 && strcasecmp(LANGUAGE_ID, 'DE') !== 0) { $arComment["DateFormated"] = ToLower($arComment["DateFormated"]); } $arComment["UF"] = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("BLOG_COMMENT", $commentId, LANGUAGE_ID); $arAuthor = CBlogUser::GetUserInfo($arComment["AUTHOR_ID"], $arFormatParams["PATH_TO_USER"], array("AVATAR_SIZE_COMMENT" => $arFormatParams["AVATAR_SIZE_COMMENT"])); if (IsModuleInstalled('extranet') && CModule::IncludeModule('socialnetwork')) { CSocNetTools::InitGlobalExtranetArrays(); } $arTmpUser = array("NAME" => $arAuthor["~NAME"], "LAST_NAME" => $arAuthor["~LAST_NAME"], "SECOND_NAME" => $arAuthor["~SECOND_NAME"], "LOGIN" => $arAuthor["~LOGIN"], "NAME_LIST_FORMATTED" => ""); $arAuthor["NAME_FORMATED"] = CUser::FormatName($arFormatParams["NAME_TEMPLATE"], $arTmpUser, $arFormatParams["SHOW_LOGIN"] != "N"); if (intval($arAuthor["PERSONAL_PHOTO"]) > 0) { $image_resize = CFile::ResizeImageGet($arAuthor["PERSONAL_PHOTO"], array("width" => $arFormatParams["AVATAR_SIZE_COMMENT"], "height" => $arFormatParams["AVATAR_SIZE_COMMENT"]), BX_RESIZE_IMAGE_EXACT); $arAuthor["PERSONAL_PHOTO_RESIZED"] = array("src" => $image_resize["src"]); } $p = new blogTextParser(false, ''); $ufCode = "UF_BLOG_COMMENT_FILE"; if (is_array($arComment["UF"][$ufCode])) { $p->arUserfields = array($ufCode => array_merge($arComment["UF"][$ufCode], array("TAG" => "DOCUMENT ID"))); } $arAllow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "SHORT_ANCHOR" => "Y"); $arParserParams = array("imageWidth" => 800, "imageHeight" => 800); $arComment["TextFormated"] = $p->convert($arComment["POST_TEXT"], false, array(), $arAllow, $arParserParams); $p->bMobile = true; $arComment["TextFormatedMobile"] = $p->convert($arComment["POST_TEXT"], false, array(), $arAllow, $arParserParams); if ($perm >= BLOG_PERMS_MODERATE) { if ($arComment["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) { $arComment["CAN_HIDE"] = "Y"; } else { $arComment["CAN_SHOW"] = "Y"; } } else { $arComment["CAN_SHOW"] = $arComment["CAN_HIDE"] = "N"; } $urlToPost = CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arFormatParams["PATH_TO_POST"]), array("post_id" => "#source_post_id#", "user_id" => $arPost["AUTHOR_ID"])); $urlToPost .= strpos($urlToPost, "?") !== false ? "&" : "?"; $arUrl = array("LINK" => $urlToPost, "SHOW" => $urlToPost . "show_comment_id=#comment_id#&comment_post_id=#post_id#&" . bitrix_sessid_get(), "HIDE" => $urlToPost . "hide_comment_id=#comment_id#&comment_post_id=#post_id#&" . bitrix_sessid_get(), "DELETE" => $urlToPost . "delete_comment_id=#comment_id#&comment_post_id=#post_id#&" . bitrix_sessid_get(), "USER" => htmlspecialcharsback($arFormatParams["PATH_TO_USER"])); CRatingsComponentsMain::GetShowRating($arFormatParams); if ($arFormatParams["SHOW_RATING"] == "Y") { $arRating = CRatings::GetRatingVoteResult('BLOG_COMMENT', array($arComment["ID"])); } $arCommentParams = array("ID" => $commentId, "ENTITY_XML_ID" => "BLOG_" . $arPost["ID"], "FULL_ID" => array("BLOG_" . $arPost["ID"], $commentId), "ACTION" => "REPLY", "APPROVED" => "Y", "PANELS" => array("EDIT" => "N", "MODERATE" => "N", "DELETE" => "N"), "NEW" => "Y", "AUTHOR" => array("ID" => $GLOBALS["USER"]->GetID(), "NAME" => $arAuthor["NAME_FORMATED"], "URL" => $arAuthor["url"], "E-MAIL" => $arComment["AuthorEmail"], "AVATAR" => $arAuthor["PERSONAL_PHOTO_resized"]["src"], "IS_EXTRANET" => is_array($GLOBALS["arExtranetUserID"]) && in_array($GLOBALS["USER"]->GetID(), $GLOBALS["arExtranetUserID"])), "POST_TIMESTAMP" => $arComment["DATE_CREATE_TS"], "POST_TIME" => $arComment["DATE_CREATE_TIME"], "POST_DATE" => $arComment["DateFormated"], "POST_MESSAGE_TEXT" => $arComment["TextFormated"], "POST_MESSAGE_TEXT_MOBILE" => $arComment["TextFormatedMobile"], "URL" => array("LINK" => str_replace(array("##comment_id#", "#comment_id#"), array("", $commentId), $arUrl["LINK"]), "EDIT" => "__blogEditComment('" . $commentId . "', '" . $arPost["ID"] . "');", "MODERATE" => str_replace(array("#source_post_id#", "#post_id#", "#comment_id#", "&" . bitrix_sessid_get()), array($arPost["ID"], $arPost["ID"], $commentId, ""), $arComment["CAN_SHOW"] == "Y" ? $arUrl["SHOW"] : ($arComment["CAN_HIDE"] == "Y" ? $arUrl["HIDE"] : "")), "DELETE" => str_replace(array("#source_post_id#", "#post_id#", "#comment_id#", "&" . bitrix_sessid_get()), array($arPost["ID"], $arPost["ID"], $commentId, ""), $arUrl["DELETE"])), "AFTER" => "", "BEFORE_ACTIONS_MOBILE" => "", "AFTER_MOBILE" => ""); if ($arFormatParams["SHOW_RATING"] == "Y") { $arRatingData = array("ENTITY_TYPE_ID" => "BLOG_COMMENT", "ENTITY_ID" => $commentId, "OWNER_ID" => $arComment["AUTHOR_ID"], "USER_VOTE" => $arRating[$commentId]["USER_VOTE"], "USER_HAS_VOTED" => $arRating[$commentId]["USER_HAS_VOTED"], "TOTAL_VOTES" => $arRating[$commentId]["TOTAL_VOTES"], "TOTAL_POSITIVE_VOTES" => $arRating[$commentId]["TOTAL_POSITIVE_VOTES"], "TOTAL_NEGATIVE_VOTES" => $arRating[$commentId]["TOTAL_NEGATIVE_VOTES"], "TOTAL_VALUE" => $arRating[$commentId]["TOTAL_VALUE"], "PATH_TO_USER_PROFILE" => $arUrl["USER"]); ob_start(); $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:rating.vote", $arFormatParams["RATING_TYPE"], $arRatingData, false, array("HIDE_ICONS" => "Y")); $arCommentParams["BEFORE_ACTIONS"] = ob_get_clean(); ob_start(); $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:rating.vote", "mobile_comment_" . $arFormatParams["RATING_TYPE"], $arRatingData, false, array("HIDE_ICONS" => "Y")); $arCommentParams["BEFORE_ACTIONS_MOBILE"] = ob_get_clean(); } $arUFResult = self::BuildUFFields($arComment["UF"]); $arCommentParams["AFTER"] .= $arUFResult["AFTER"]; $arCommentParams["AFTER_MOBILE"] .= $arUFResult["AFTER_MOBILE"]; if ($arComment["CAN_EDIT"] == "Y") { ob_start(); ?> <script> top.text<?php echo $commentId; ?> = text<?php echo $commentId; ?> = '<?php echo CUtil::JSEscape(htmlspecialcharsBack($arComment["POST_TEXT"])); ?> '; top.title<?php echo $commentId; ?> = title<?php echo $commentId; ?> = '<?php echo isset($arComment["TITLE"]) ? CUtil::JSEscape($arComment["TITLE"]) : ''; ?> '; top.arComFiles<?php echo $commentId; ?> = [];<?php ?> </script><?php $arCommentParams["AFTER"] .= ob_get_clean(); } CPullWatch::AddToStack('UNICOMMENTSBLOG_' . $arPost["ID"], array('module_id' => 'unicomments', 'command' => 'comment', 'params' => $arCommentParams)); } }
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); }
/** * Use component main.post.list to work with LiveFeed * @param int $commentId Comment ID which needs to send. * @param array $arParams Array of settings (DATE_TIME_FORMAT, SHOW_RATING, PATH_TO_USER, AVATAR_SIZE, NAME_TEMPLATE, SHOW_LOGIN) * @return string */ public static function addLiveComment($commentId = 0, $arParams = array()) { $res = ""; if ($commentId > 0 && CModule::IncludeModule("pull") && \CPullOptions::GetNginxStatus() && ($comment = CBlogComment::GetByID($commentId)) && ($arPost = CBlogPost::GetByID($comment["POST_ID"]))) { global $DB, $APPLICATION; $arParams["DATE_TIME_FORMAT"] = isset($arParams["DATE_TIME_FORMAT"]) ? $arParams["DATE_TIME_FORMAT"] : $DB->DateFormatToPHP(CSite::GetDateFormat("FULL")); $arParams["SHOW_RATING"] = $arParams["SHOW_RATING"] == "N" ? "N" : "Y"; $arParams["PATH_TO_USER"] = isset($arParams["PATH_TO_USER"]) ? $arParams["PATH_TO_USER"] : ''; $arParams["AVATAR_SIZE_COMMENT"] = $arParams["AVATAR_SIZE_COMMENT"] > 0 ? $arParams["AVATAR_SIZE_COMMENT"] : ($arParams["AVATAR_SIZE"] > $arParams["AVATAR_SIZE"] ? $arParams["AVATAR_SIZE"] : 58); $arParams["NAME_TEMPLATE"] = isset($arParams["NAME_TEMPLATE"]) ? $arParams["NAME_TEMPLATE"] : CSite::GetNameFormat(); $arParams["SHOW_LOGIN"] = $arParams["SHOW_LOGIN"] == "N" ? "N" : "Y"; $comment["DateFormated"] = FormatDateFromDB($comment["DATE_CREATE"], $arParams["DATE_TIME_FORMAT"], true); $timestamp = MakeTimeStamp($comment["DATE_CREATE"]); if (strcasecmp(LANGUAGE_ID, 'EN') !== 0 && strcasecmp(LANGUAGE_ID, 'DE') !== 0) { $comment["DateFormated"] = ToLower($comment["DateFormated"]); } $comment["UF"] = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("BLOG_COMMENT", $commentId, LANGUAGE_ID); $arAuthor = CBlogUser::GetUserInfo($comment["AUTHOR_ID"], $arParams["PATH_TO_USER"], array("AVATAR_SIZE_COMMENT" => $arParams["AVATAR_SIZE_COMMENT"])); if (intval($arAuthor["PERSONAL_PHOTO"]) > 0) { $image_resize = CFile::ResizeImageGet($arAuthor["PERSONAL_PHOTO"], array("width" => $arParams["AVATAR_SIZE_COMMENT"], "height" => $arParams["AVATAR_SIZE_COMMENT"]), BX_RESIZE_IMAGE_EXACT); $arAuthor["PERSONAL_PHOTO_RESIZED"] = array("src" => $image_resize["src"]); } $p = new blogTextParser(false, ''); $ufCode = "UF_BLOG_COMMENT_FILE"; if (is_array($comment["UF"][$ufCode])) { $p->arUserfields = array($ufCode => array_merge($comment["UF"][$ufCode], array("TAG" => "DOCUMENT ID"))); } $arAllow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "SHORT_ANCHOR" => "Y"); $arParserParams = array("imageWidth" => 800, "imageHeight" => 800); $comment["TextFormated"] = $p->convert($comment["POST_TEXT"], false, array(), $arAllow, $arParserParams); $p->bMobile = true; $comment["TextFormatedMobile"] = $p->convert($comment["POST_TEXT"], false, array(), $arAllow, $arParserParams); $comment["TextFormatedJS"] = CUtil::JSEscape(htmlspecialcharsBack($comment["POST_TEXT"])); $comment["TITLE"] = CUtil::JSEscape(htmlspecialcharsBack($comment["TITLE"])); $eventHandlerID = AddEventHandler("main", "system.field.view.file", array("CSocNetLogTools", "logUFfileShow")); $res = $APPLICATION->IncludeComponent("bitrix:main.post.list", "", array("TEMPLATE_ID" => 'BLOG_COMMENT_BG_', "RATING_TYPE_ID" => $arParams["SHOW_RATING"] == "Y" ? "BLOG_COMMENT" : "", "ENTITY_XML_ID" => "BLOG_" . $arPost["ID"], "RECORDS" => array($commentId => array("ID" => $comment["ID"], "NEW" => $arParams["FOLLOW"] != "N" && $comment["NEW"] == "Y" ? "Y" : "N", "APPROVED" => $comment["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH ? "Y" : "N", "POST_TIMESTAMP" => $timestamp, "POST_TIME" => $comment["DATE_CREATE_TIME"], "POST_DATE" => $comment["DateFormated"], "AUTHOR" => array("ID" => $arAuthor["ID"], "NAME" => $arAuthor["~NAME"], "LAST_NAME" => $arAuthor["~LAST_NAME"], "SECOND_NAME" => $arAuthor["~SECOND_NAME"], "AVATAR" => $arAuthor["PERSONAL_PHOTO_resized"]["src"]), "FILES" => false, "UF" => $comment["UF"], "~POST_MESSAGE_TEXT" => $comment["POST_TEXT"], "WEB" => array("POST_TIME" => $comment["DATE_CREATE_TIME"], "POST_DATE" => $comment["DateFormated"], "CLASSNAME" => "", "POST_MESSAGE_TEXT" => $comment["TextFormated"], "AFTER" => <<<HTML <script>top.text{$commentId} = text{$commentId} = '{$comment["TextFormatedJS"]}';top.title{$commentId} = title{$commentId} = '{$comment["TITLE"]}';top.arComFiles{$commentId} = [];</script> HTML ), "MOBILE" => array("POST_TIME" => $comment["DATE_CREATE_TIME"], "POST_DATE" => $comment["DateFormated"], "CLASSNAME" => "", "POST_MESSAGE_TEXT" => $comment["TextFormatedMobile"]))), "NAV_STRING" => "", "NAV_RESULT" => "", "PREORDER" => "N", "RIGHTS" => array("MODERATE" => "N", "EDIT" => "N", "DELETE" => "N"), "VISIBLE_RECORDS_COUNT" => 1, "ERROR_MESSAGE" => "", "OK_MESSAGE" => "", "RESULT" => $commentId, "PUSH&PULL" => array("ACTION" => "REPLY", "ID" => $commentId), "MODE" => "PULL_MESSAGE", "VIEW_URL" => "", "EDIT_URL" => "", "MODERATE_URL" => "", "DELETE_URL" => "", "AUTHOR_URL" => "", "AVATAR_SIZE" => $arParams["AVATAR_SIZE_COMMENT"], "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"], "SHOW_LOGIN" => $arParams["SHOW_LOGIN"], "DATE_TIME_FORMAT" => "", "LAZYLOAD" => "", "NOTIFY_TAG" => "", "NOTIFY_TEXT" => "", "SHOW_MINIMIZED" => "Y", "SHOW_POST_FORM" => "", "IMAGE_SIZE" => "", "mfi" => ""), array(), null); if ($eventHandlerID !== false && intval($eventHandlerID) > 0) { RemoveEventHandler('main', 'system.field.view.file', $eventHandlerID); } } return $res; }
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"]); } }
function Update($ID, $arFields, $bSearchIndex = true) { global $DB; $ID = IntVal($ID); if(strlen($arFields["PATH"]) > 0) $arFields["PATH"] = str_replace("#post_id#", $ID, $arFields["PATH"]); $arFields1 = array(); foreach ($arFields as $key => $value) { if (substr($key, 0, 1) == "=") { $arFields1[substr($key, 1)] = $value; unset($arFields[$key]); } } if (!CBlogPost::CheckFields("UPDATE", $arFields, $ID)) return false; elseif(!$GLOBALS["USER_FIELD_MANAGER"]->CheckFields("BLOG_POST", $ID, $arFields)) return false; foreach(GetModuleEvents("blog", "OnBeforePostUpdate", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, Array($ID, &$arFields))===false) return false; } $arOldPost = CBlogPost::GetByID($ID); if(is_array($arFields["ATTACH_IMG"])) { if ( !array_key_exists("MODULE_ID", $arFields["ATTACH_IMG"]) || strlen($arFields["ATTACH_IMG"]["MODULE_ID"]) <= 0 ) $arFields["ATTACH_IMG"]["MODULE_ID"] = "blog"; $prefix = "blog"; if(strlen($arFields["URL"]) > 0) $prefix .= "/".$arFields["URL"]; CFile::SaveForDB($arFields, "ATTACH_IMG", $prefix); } $strUpdate = $DB->PrepareUpdate("b_blog_post", $arFields); foreach ($arFields1 as $key => $value) { if (strlen($strUpdate) > 0) $strUpdate .= ", "; $strUpdate .= $key."=".$value." "; } if (strlen($strUpdate) > 0) { $oldPostPerms = CBlogUserGroup::GetGroupPerms(1, $arOldPost["BLOG_ID"], $ID, BLOG_PERMS_POST); $strSql = "UPDATE b_blog_post SET ". " ".$strUpdate." ". "WHERE ID = ".$ID." "; $DB->Query($strSql, False, "File: ".__FILE__."<br>Line: ".__LINE__); unset($GLOBALS["BLOG_POST"]["BLOG_POST_CACHE_".$ID]); foreach(GetModuleEvents("blog", "OnBeforePostUserFieldUpdate", true) as $arEvent) ExecuteModuleEventEx($arEvent, Array("BLOG_POST", $ID, $arFields)); $GLOBALS["USER_FIELD_MANAGER"]->Update("BLOG_POST", $ID, $arFields); } else { $ID = False; } if ($ID) { $arNewPost = CBlogPost::GetByID($ID); if($arNewPost["PUBLISH_STATUS"] != $arOldPost["PUBLISH_STATUS"] || $arNewPost["BLOG_ID"] != $arOldPost["BLOG_ID"]) CBlog::SetStat($arNewPost["BLOG_ID"]); if ($arNewPost["BLOG_ID"] != $arOldPost["BLOG_ID"]) CBlog::SetStat($arOldPost["BLOG_ID"]); if (is_set($arFields, "PERMS_POST")) CBlogPost::SetPostPerms($ID, $arFields["PERMS_POST"], BLOG_PERMS_POST); if (is_set($arFields, "PERMS_COMMENT")) CBlogPost::SetPostPerms($ID, $arFields["PERMS_COMMENT"], BLOG_PERMS_COMMENT); if(array_key_exists("SOCNET_RIGHTS", $arFields)) { $arFields["SC_PERM_OLD"] = CBlogPost::GetSocNetPermsCode($ID); $arFields["SC_PERM"] = CBlogPost::UpdateSocNetPerms($ID, $arFields["SOCNET_RIGHTS"], $arNewPost); } foreach(GetModuleEvents("blog", "OnPostUpdate", true) as $arEvent) ExecuteModuleEventEx($arEvent, Array($ID, &$arFields)); if ($bSearchIndex && CModule::IncludeModule("search")) { $newPostPerms = CBlogUserGroup::GetGroupPerms(1, $arNewPost["BLOG_ID"], $ID, BLOG_PERMS_POST); $arBlog = CBlog::GetByID($arNewPost["BLOG_ID"]); if ( $arOldPost["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH && $oldPostPerms >= BLOG_PERMS_READ && ( $arNewPost["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH || $newPostPerms < BLOG_PERMS_READ ) || $arBlog["SEARCH_INDEX"] != "Y" ) { CSearch::Index("blog", "P".$ID, array( "TITLE" => "", "BODY" => "" ) ); CSearch::DeleteIndex("blog", false, "COMMENT", $arBlog["ID"]."|".$ID); } elseif ( $arNewPost["DATE_PUBLISHED"] == "Y" && $arNewPost["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH && $newPostPerms >= BLOG_PERMS_READ && $arBlog["SEARCH_INDEX"] == "Y" ) { $tag = ""; $arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]); if(strlen($arFields["PATH"]) > 0) { $arPostSite = array($arGroup["SITE_ID"] => $arFields["PATH"]); } elseif(strlen($arNewPost["PATH"]) > 0) { $arNewPost["PATH"] = ( strlen($arNewPost["CODE"]) > 0 ? str_replace("#post_id#", $arNewPost["CODE"], $arNewPost["PATH"]) : str_replace("#post_id#", $ID, $arNewPost["PATH"]) ); $arPostSite = array($arGroup["SITE_ID"] => $arNewPost["PATH"]); } else { $arPostSite = array( $arGroup["SITE_ID"] => CBlogPost::PreparePath( $arBlog["URL"], $arNewPost["ID"], $arGroup["SITE_ID"], false, $arBlog["OWNER_ID"], $arBlog["SOCNET_GROUP_ID"] ) ); } if ( $arBlog["USE_SOCNET"] == "Y" && CModule::IncludeModule("extranet") ) { $arPostSiteExt = CExtranet::GetSitesByLogDestinations($arFields["SC_PERM"]); foreach($arPostSiteExt as $lid) { if (!array_key_exists($lid, $arPostSite)) { $arPostSite[$lid] = str_replace( array("#user_id#", "#post_id#"), array($arBlog["OWNER_ID"], $arNewPost["ID"]), COption::GetOptionString("socialnetwork", "userblogpost_page", false, $lid) ); } } } if(strlen($arNewPost["CATEGORY_ID"])>0) { $arC = explode(",", $arNewPost["CATEGORY_ID"]); $arTag = Array(); foreach($arC as $v) { $arCategory = CBlogCategory::GetByID($v); $arTag[] = $arCategory["NAME"]; } $tag = implode(",", $arTag); } $searchContent = blogTextParser::killAllTags($arNewPost["DETAIL_TEXT"]); $searchContent .= "\r\n" . $GLOBALS["USER_FIELD_MANAGER"]->OnSearchIndex("BLOG_POST", $arNewPost["ID"]); $authorName = ""; if(IntVal($arNewPost["AUTHOR_ID"]) > 0) { $dbUser = CUser::GetByID($arNewPost["AUTHOR_ID"]); if($arUser = $dbUser->Fetch()) { $arTmpUser = array( "NAME" => $arUser["NAME"], "LAST_NAME" => $arUser["LAST_NAME"], "SECOND_NAME" => $arUser["SECOND_NAME"], "LOGIN" => $arUser["LOGIN"], ); $authorName = CUser::FormatName(CSite::GetNameFormat(), $arTmpUser, false, false); if(strlen($authorName) > 0) $searchContent .= "\r\n".$authorName; } } $arSearchIndex = array( "SITE_ID" => $arPostSite, "LAST_MODIFIED" => $arNewPost["DATE_PUBLISH"], "PARAM1" => "POST", "PARAM2" => $arNewPost["BLOG_ID"], "PARAM3" => $arNewPost["ID"], "PERMISSIONS" => array(2), "TITLE" => $arNewPost["TITLE"], "BODY" => $searchContent, "TAGS" => $tag, "USER_ID" => $arNewPost["AUTHOR_ID"], "ENTITY_TYPE_ID" => "BLOG_POST", "ENTITY_ID" => $arNewPost["ID"], ); $bIndexComment = false; if($arBlog["USE_SOCNET"] == "Y") { if(!empty($arFields["SC_PERM"])) { $arSearchIndex["PERMISSIONS"] = $arFields["SC_PERM"]; if($arFields["SC_PERM"] != $arFields["SC_PERM_OLD"]) $bIndexComment = true; } else $arSearchIndex["PERMISSIONS"] = CBlogPost::GetSocnetPermsCode($ID); if(!in_array("U".$arNewPost["AUTHOR_ID"], $arSearchIndex["PERMISSIONS"])) $arSearchIndex["PERMISSIONS"][] = "U".$arNewPost["AUTHOR_ID"]; if(is_array($arSearchIndex["PERMISSIONS"])) { $sgId = array(); foreach($arSearchIndex["PERMISSIONS"] 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", ); } } // get mentions and grats $arMentionedUserID = CBlogPost::GetMentionedUserID($arNewPost); if (!empty($arMentionedUserID)) { if (!isset($arSearchIndex["PARAMS"])) { $arSearchIndex["PARAMS"] = array(); } $arSearchIndex["PARAMS"]["mentioned_user_id"] = $arMentionedUserID; } } CSearch::Index("blog", "P".$ID, $arSearchIndex, True); if(($arOldPost["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH && $arNewPost["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) || $bIndexComment) //index comments { $arParamsComment = Array( "BLOG_ID" => $arBlog["ID"], "POST_ID" => $ID, "SITE_ID" => $arGroup["SITE_ID"], "PATH" => $arPostSite[$arGroup["SITE_ID"]]."?commentId=#comment_id###comment_id#", "BLOG_URL" => $arBlog["URL"], "OWNER_ID" => $arBlog["OWNER_ID"], "SOCNET_GROUP_ID" => $arBlog["SOCNET_GROUP_ID"], "USE_SOCNET" => $arBlog["USE_SOCNET"], ); CBlogComment::_IndexPostComments($arParamsComment); } } } } BXClearCache(true, '/blog/socnet_post/gen/'.$ID); return $ID; }
public static function Update($ID, $arFields, $bSearchIndex = true) { global $DB; $ID = IntVal($ID); if(strlen($arFields["PATH"]) > 0) $arFields["PATH"] = str_replace("#comment_id#", $ID, $arFields["PATH"]); $arFields1 = array(); foreach ($arFields as $key => $value) { if (substr($key, 0, 1) == "=") { $arFields1[substr($key, 1)] = $value; unset($arFields[$key]); } } if (!CBlogComment::CheckFields("UPDATE", $arFields, $ID)) return false; elseif(!$GLOBALS["USER_FIELD_MANAGER"]->CheckFields("BLOG_COMMENT", $ID, $arFields)) return false; foreach(GetModuleEvents("blog", "OnBeforeCommentUpdate", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, Array($ID, &$arFields))===false) return false; } $strUpdate = $DB->PrepareUpdate("b_blog_comment", $arFields); foreach ($arFields1 as $key => $value) { if (strlen($strUpdate) > 0) $strUpdate .= ", "; $strUpdate .= $key."=".$value." "; } if (strlen($strUpdate) > 0) { if(is_set($arFields["PUBLISH_STATUS"]) && strlen($arFields["PUBLISH_STATUS"]) > 0) { $arComment = CBlogComment::GetByID($ID); if($arComment["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH && $arFields["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH) CBlogPost::Update($arComment["POST_ID"], array("=NUM_COMMENTS" => "NUM_COMMENTS - 1")); elseif($arComment["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH && $arFields["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) CBlogPost::Update($arComment["POST_ID"], array("=NUM_COMMENTS" => "NUM_COMMENTS + 1")); } $strSql = "UPDATE b_blog_comment SET ". " ".$strUpdate." ". "WHERE ID = ".$ID." "; $DB->Query($strSql, False, "File: ".__FILE__."<br>Line: ".__LINE__); unset($GLOBALS["BLOG_COMMENT"]["BLOG_COMMENT_CACHE_".$ID]); $GLOBALS["USER_FIELD_MANAGER"]->Update("BLOG_COMMENT", $ID, $arFields); $arComment = CBlogComment::GetByID($ID); $arBlog = CBlog::GetByID($arComment["BLOG_ID"]); if($arBlog["USE_SOCNET"] == "Y") $arFields["SC_PERM"] = CBlogComment::GetSocNetCommentPerms($arComment["POST_ID"]); foreach(GetModuleEvents("blog", "OnCommentUpdate", true) as $arEvent) ExecuteModuleEventEx($arEvent, Array($ID, &$arFields)); if ($bSearchIndex && CModule::IncludeModule("search")) { $newPostPerms = CBlogUserGroup::GetGroupPerms(1, $arComment["BLOG_ID"], $arComment["POST_ID"], BLOG_PERMS_POST); if ($arBlog["SEARCH_INDEX"] != "Y" || $arComment["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH) { CSearch::Index("blog", "C".$ID, array( "TITLE" => "", "BODY" => "" ) ); } else { $arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]); if(strlen($arFields["PATH"]) > 0) { $arFields["PATH"] = str_replace("#comment_id#", $ID, $arFields["PATH"]); $arPostSite = array($arGroup["SITE_ID"] => $arFields["PATH"]); } elseif(strlen($arComment["PATH"]) > 0) { $arComment["PATH"] = str_replace("#comment_id#", $ID, $arComment["PATH"]); $arPostSite = array($arGroup["SITE_ID"] => $arComment["PATH"]); } else { $arPostSite = array( $arGroup["SITE_ID"] => CBlogPost::PreparePath( $arBlog["URL"], $arComment["POST_ID"], $arGroup["SITE_ID"], false, $arBlog["OWNER_ID"], $arBlog["SOCNET_GROUP_ID"] ) ); } $searchContent = blogTextParser::killAllTags($arComment["POST_TEXT"]); $searchContent .= "\r\n" . $GLOBALS["USER_FIELD_MANAGER"]->OnSearchIndex("BLOG_COMMENT", $arComment["ID"]); $arSearchIndex = array( "SITE_ID" => $arPostSite, "LAST_MODIFIED" => $arComment["DATE_CREATE"], "PARAM1" => "COMMENT", "PARAM2" => $arComment["BLOG_ID"]."|".$arComment["POST_ID"], "PERMISSIONS" => array(2), "TITLE" => $arComment["TITLE"], "BODY" => $searchContent, "USER_ID" => (IntVal($arComment["AUTHOR_ID"]) > 0) ? $arComment["AUTHOR_ID"] : false, "ENTITY_TYPE_ID" => "BLOG_COMMENT", "ENTITY_ID" => $arComment["ID"], ); if($arBlog["USE_SOCNET"] == "Y") { if(is_array($arFields["SC_PERM"])) { $arSearchIndex["PERMISSIONS"] = $arFields["SC_PERM"]; $sgId = array(); foreach($arFields["SC_PERM"] 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(!in_array("U".$arComment["AUTHOR_ID"], $arSearchIndex["PERMISSIONS"])) $arSearchIndex["PERMISSIONS"][] = "U".$arComment["AUTHOR_ID"]; } } if(strlen($arComment["TITLE"]) <= 0) { //$arPost = CBlogPost::GetByID($arComment["POST_ID"]); $arSearchIndex["TITLE"] = substr($arSearchIndex["BODY"], 0, 100); } CSearch::Index("blog", "C".$ID, $arSearchIndex, True); } } return $ID; } return False; }
$arResult["Comments"][$v["ID"]]["CAN_EDIT"] = "Y"; } } else { if ($blogModulePermissions >= "W") { $arResult["Comments"][$v["ID"]]["CAN_EDIT"] = "Y"; } } } } if ($arParams["SHOW_RATING"] == "Y" && !empty($arResult["IDS"])) { $arResult['RATING'] = CRatings::GetRatingVoteResult('BLOG_COMMENT', $arResult["IDS"]); } } if ($USER->IsAuthorized()) { if (IntVal($commentUrlID) > 0 && empty($arResult["Comments"][$commentUrlID])) { $arComment = CBlogComment::GetByID($commentUrlID); if ($arComment["AUTHOR_ID"] == $user_id && $arComment["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_READY) { $arResult["MESSAGE"] = GetMessage("B_B_PC_HIDDEN_POSTED"); } } } $this->IncludeComponentTemplate(); } } if (!is_array($arResult["CommentsResult"][0])) { return 0; } $PublishedComments = 0; foreach ($arResult["CommentsResult"][0] as $arComment) { if ($arComment["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) { $PublishedComments++;
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"]); }
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); } } } } }
$arComment["DATE_CREATE_DATE"] = str_replace(array('-' . $curYear, '/' . $curYear, ' ' . $curYear, '.' . $curYear), '', $arComment["DATE_CREATE_DATE"]); } if ($arParams["MOBILE"] == "Y") { $timestamp = MakeTimeStamp($arComment["DATE_CREATE"]); $arComment["DATE_CREATE_TIME"] = FormatDate(GetMessage("SONET_SBPC_MOBILE_FORMAT_TIME"), $timestamp); } else { $arComment["DATE_CREATE_TIME"] = FormatDateFromDB($arComment["DATE_CREATE"], strpos($arParams["DATE_TIME_FORMAT_S"], 'a') !== false || ($arParams["DATE_TIME_FORMAT_S"] == 'FULL' && IsAmPmMode()) !== false ? strpos(FORMAT_DATETIME, 'TT') !== false ? 'G:MI TT' : 'G:MI T' : 'GG:MI'); } $arResult["CommentsResult"][] = $arComment; $arResult["IDS"][] = $arComment["ID"]; $arFieldsHave = array(); if ($arComment["HAS_PROPS"] == "") { $arFieldsHave["HAS_PROPS"] = $bHasProps ? "Y" : "N"; } if (!empty($arFieldsHave)) { CBlogComment::Update($arComment["ID"], $arFieldsHave, false); } $i++; } while ($i < count($arCommentsAll) && ($arComment = $arCommentsAll[$i])); } unset($arResult["MESSAGE"]); unset($arResult["ERROR_MESSAGE"]); if ($arParams["CACHE_TIME"] > 0) { if (defined("BX_COMP_MANAGED_CACHE")) { $GLOBALS["CACHE_MANAGER"]->EndTagCache(); } $cache->EndDataCache(array("templateCachedData" => $this->GetTemplateCachedData(), "arResult" => $arResult)); } } } $arResult["MESSAGE"] = $tmp["MESSAGE"];
$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"]) {
/** * 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 Update($ID, $arFields) { global $DB; $ID = IntVal($ID); if (strlen($arFields["PATH"]) > 0) { $arFields["PATH"] = str_replace("#post_id#", $ID, $arFields["PATH"]); } $arFields1 = array(); foreach ($arFields as $key => $value) { if (substr($key, 0, 1) == "=") { $arFields1[substr($key, 1)] = $value; unset($arFields[$key]); } } if (!CBlogPost::CheckFields("UPDATE", $arFields, $ID)) { return false; } elseif (!$GLOBALS["USER_FIELD_MANAGER"]->CheckFields("BLOG_POST", $ID, $arFields)) { return false; } $db_events = GetModuleEvents("blog", "OnBeforePostUpdate"); while ($arEvent = $db_events->Fetch()) { if (ExecuteModuleEventEx($arEvent, array($ID, &$arFields)) === false) { return false; } } $arOldPost = CBlogPost::GetByID($ID); if (is_array($arFields["ATTACH_IMG"])) { if (!array_key_exists("MODULE_ID", $arFields["ATTACH_IMG"]) || strlen($arFields["ATTACH_IMG"]["MODULE_ID"]) <= 0) { $arFields["ATTACH_IMG"]["MODULE_ID"] = "blog"; } $prefix = "blog"; if (strlen($arFields["URL"]) > 0) { $prefix .= "/" . $arFields["URL"]; } CFile::SaveForDB($arFields, "ATTACH_IMG", $prefix); } $strUpdate = $DB->PrepareUpdate("b_blog_post", $arFields); foreach ($arFields1 as $key => $value) { if (strlen($strUpdate) > 0) { $strUpdate .= ", "; } $strUpdate .= $key . "=" . $value . " "; } if (strlen($strUpdate) > 0) { $oldPostPerms = CBlogUserGroup::GetGroupPerms(1, $arOldPost["BLOG_ID"], $ID, BLOG_PERMS_POST); $strSql = "UPDATE b_blog_post SET " . "\t" . $strUpdate . " " . "WHERE ID = " . $ID . " "; $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__); unset($GLOBALS["BLOG_POST"]["BLOG_POST_CACHE_" . $ID]); $GLOBALS["USER_FIELD_MANAGER"]->Update("BLOG_POST", $ID, $arFields); } else { $ID = False; } if ($ID) { $arNewPost = CBlogPost::GetByID($ID); if ($arNewPost["PUBLISH_STATUS"] != $arOldPost["PUBLISH_STATUS"] || $arNewPost["BLOG_ID"] != $arOldPost["BLOG_ID"]) { CBlog::SetStat($arNewPost["BLOG_ID"]); } if ($arNewPost["BLOG_ID"] != $arOldPost["BLOG_ID"]) { CBlog::SetStat($arOldPost["BLOG_ID"]); } if (is_set($arFields, "PERMS_POST")) { CBlogPost::SetPostPerms($ID, $arFields["PERMS_POST"], BLOG_PERMS_POST); } if (is_set($arFields, "PERMS_COMMENT")) { CBlogPost::SetPostPerms($ID, $arFields["PERMS_COMMENT"], BLOG_PERMS_COMMENT); } if (array_key_exists("SOCNET_RIGHTS", $arFields)) { $arFields["SC_PERM_OLD"] = CBlogPost::GetSocNetPermsCode($ID); $arFields["SC_PERM"] = CBlogPost::UpdateSocNetPerms($ID, $arFields["SOCNET_RIGHTS"], $arNewPost); } $db_events = GetModuleEvents("blog", "OnPostUpdate"); while ($arEvent = $db_events->Fetch()) { ExecuteModuleEventEx($arEvent, array($ID, &$arFields)); } if (CModule::IncludeModule("search")) { $newPostPerms = CBlogUserGroup::GetGroupPerms(1, $arNewPost["BLOG_ID"], $ID, BLOG_PERMS_POST); $arBlog = CBlog::GetByID($arNewPost["BLOG_ID"]); if ($arOldPost["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH && $oldPostPerms >= BLOG_PERMS_READ && ($arNewPost["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH || $newPostPerms < BLOG_PERMS_READ) || $arBlog["SEARCH_INDEX"] != "Y") { CSearch::Index("blog", "P" . $ID, array("TITLE" => "", "BODY" => "")); CSearch::DeleteIndex("blog", false, "COMMENT", $arBlog["ID"] . "|" . $ID); } elseif ($arNewPost["DATE_PUBLISHED"] == "Y" && $arNewPost["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH && $newPostPerms >= BLOG_PERMS_READ && $arBlog["SEARCH_INDEX"] == "Y") { $tag = ""; $arGroup = CBlogGroup::GetByID($arBlog["GROUP_ID"]); if (strlen($arFields["PATH"]) > 0) { $arPostSite = array($arGroup["SITE_ID"] => $arFields["PATH"]); } elseif (strlen($arNewPost["PATH"]) > 0) { if (strlen($arNewPost["CODE"]) > 0) { $arNewPost["PATH"] = str_replace("#post_id#", $arNewPost["CODE"], $arNewPost["PATH"]); } else { $arNewPost["PATH"] = str_replace("#post_id#", $ID, $arNewPost["PATH"]); } $arPostSite = array($arGroup["SITE_ID"] => $arNewPost["PATH"]); } else { $arPostSite = array($arGroup["SITE_ID"] => CBlogPost::PreparePath($arBlog["URL"], $arNewPost["ID"], $arGroup["SITE_ID"], false, $arBlog["OWNER_ID"], $arBlog["SOCNET_GROUP_ID"])); } if (strlen($arNewPost["CATEGORY_ID"]) > 0) { $arC = explode(",", $arNewPost["CATEGORY_ID"]); $arTag = array(); foreach ($arC as $v) { $arCategory = CBlogCategory::GetByID($v); $arTag[] = $arCategory["NAME"]; } $tag = implode(",", $arTag); } $arSearchIndex = array("SITE_ID" => $arPostSite, "LAST_MODIFIED" => $arNewPost["DATE_PUBLISH"], "PARAM1" => "POST", "PARAM2" => $arNewPost["BLOG_ID"], "PARAM3" => $arNewPost["ID"], "PERMISSIONS" => array(2), "TITLE" => $arNewPost["TITLE"], "BODY" => blogTextParser::killAllTags($arNewPost["DETAIL_TEXT"]), "TAGS" => $tag, "USER_ID" => $arNewPost["AUTHOR_ID"], "ENTITY_TYPE_ID" => "BLOG_POST", "ENTITY_ID" => $arNewPost["ID"]); $bIndexComment = false; if ($arBlog["USE_SOCNET"] == "Y") { if (!empty($arFields["SC_PERM"])) { $arSearchIndex["PERMISSIONS"] = $arFields["SC_PERM"]; if ($arFields["SC_PERM"] != $arFields["SC_PERM_OLD"]) { $bIndexComment = true; } } else { $arSearchIndex["PERMISSIONS"] = CBlogPost::GetSocnetPermsCode($ID); } } CSearch::Index("blog", "P" . $ID, $arSearchIndex, True); if ($arOldPost["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH && $arNewPost["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH || $bIndexComment) { $arParamsComment = array("BLOG_ID" => $arBlog["ID"], "POST_ID" => $ID, "SITE_ID" => $arGroup["SITE_ID"], "PATH" => $arPostSite[$arGroup["SITE_ID"]] . "?commentId=#comment_id###comment_id#", "BLOG_URL" => $arBlog["URL"], "OWNER_ID" => $arBlog["OWNER_ID"], "SOCNET_GROUP_ID" => $arBlog["SOCNET_GROUP_ID"], "USE_SOCNET" => $arBlog["USE_SOCNET"]); CBlogComment::_IndexPostComments($arParamsComment); } } } } return $ID; }
$arBlogPostId = array(); foreach ($arBlogPostFields as $BlogPostFields) { $arBlogPostId[] = CBlogPost::Add($BlogPostFields); } foreach ($arBlogPostId as $key => $BlogPostId) { if (!is_array($categoryID[$key])) { continue; } foreach ($categoryID[$key] as $v) { CBlogPostCategory::Add(array("BLOG_ID" => $blogID, "POST_ID" => $BlogPostId, "CATEGORY_ID" => $v)); } } //Post Comments $arBlogCommentFields = array(); $arBlogCommentFields[] = array("TITLE" => '', "POST_TEXT" => GetMessage("IDEA_BLOG_DEMO_COMMENT_BODY_1"), "BLOG_ID" => $blogID, "POST_ID" => $arBlogPostId[0], "PARENT_ID" => 0, "AUTHOR_ID" => 1, "DATE_CREATE" => ConvertTimeStamp(false, "FULL"), "AUTHOR_IP" => "192.168.0.108", "PATH" => "/services/idea/#post_id#/?commentId=#comment_id###comment_id#"); $arBlogCommentFields[] = array("TITLE" => '', "POST_TEXT" => GetMessage("IDEA_BLOG_DEMO_COMMENT_BODY_2"), "BLOG_ID" => $blogID, "POST_ID" => $arBlogPostId[0], "PARENT_ID" => 0, "AUTHOR_ID" => 1, "DATE_CREATE" => ConvertTimeStamp(false, "FULL"), "AUTHOR_IP" => "192.168.0.108", "PATH" => "/services/idea/#post_id#/?commentId=#comment_id###comment_id#"); $arCommentId = array(); foreach ($arBlogCommentFields as $BlogCommentFields) { $arCommentId[] = CBlogComment::Add($BlogCommentFields); } if ($arBlogPost = CBlogPost::GetList(array(), array("BLOG_ID" => $blogID, "ID" => $arBlogPostId[0]), false, false, array("ID", CIdeaManagment::UFAnswerIdField, CIdeaManagment::UFStatusField))->Fetch()) { //if Empty value make an array if (!is_array($arBlogPost[CIdeaManagment::UFAnswerIdField])) { $arBlogPost[CIdeaManagment::UFAnswerIdField] = array(); } $arBlogPost[CIdeaManagment::UFAnswerIdField][] = $arCommentId[1]; unset($arBlogPost["ID"]); CBlogPost::Update($arBlogPostId[0], $arBlogPost); } //Replace in file CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/services/idea/index.php", array("IDEA_BLOG_CODE" => $IdeaBlogUrl, "IDEA_BIND_STATUS_DEFAULT" => $arUFIdByName["NEW"]));
private function InstallBlogComment() { global $USER; $arBlogComments = $this->arResult["INSTALLATION"]["BLOG_COMMENT_ID"] = array(); if ($this->arResult["INSTALLATION"]["BLOG_POST_ID"]["NY"]) { $arBlogComments["COMMON"] = array("TITLE" => '', "POST_TEXT" => GetMessage("IDEA_BLOG_COMMENT_TEXT_1"), "BLOG_ID" => $this->arResult["INSTALLATION"]["BLOG_ID"], "POST_ID" => $this->arResult["INSTALLATION"]["BLOG_POST_ID"]["NY"], "PARENT_ID" => 0, "AUTHOR_ID" => $USER->GetID(), "DATE_CREATE" => ConvertTimeStamp(false, "FULL"), "PATH" => $this->PublicDir . "#post_id#/?commentId=#comment_id###comment_id#"); } if ($this->arResult["INSTALLATION"]["BLOG_POST_ID"]["NY"]) { $arBlogComments["OFFICIAL"] = array("TITLE" => '', "POST_TEXT" => GetMessage("IDEA_BLOG_COMMENT_TEXT_2"), "BLOG_ID" => $this->arResult["INSTALLATION"]["BLOG_ID"], "POST_ID" => $this->arResult["INSTALLATION"]["BLOG_POST_ID"]["NY"], "PARENT_ID" => 0, "AUTHOR_ID" => $USER->GetID(), "DATE_CREATE" => ConvertTimeStamp(false, "FULL"), "PATH" => $this->PublicDir . "#post_id#/"); } foreach ($arBlogComments as $key => $BlogComment) { $this->arResult["INSTALLATION"]["BLOG_COMMENT_ID"][$key] = CBlogComment::Add($BlogComment); //Make offical answer if ($key == "OFFICIAL" && $this->arResult["INSTALLATION"]["BLOG_COMMENT_ID"][$key] > 0) { if ($arBlogPost = CBlogPost::GetList(array(), array("BLOG_ID" => $this->arResult["INSTALLATION"]["BLOG_ID"], "ID" => $this->arResult["INSTALLATION"]["BLOG_POST_ID"]["NY"]), false, false, array("ID", CIdeaManagment::UFAnswerIdField, CIdeaManagment::UFStatusField))->Fetch()) { //if Empty value make an array if (!is_array($arBlogPost[CIdeaManagment::UFAnswerIdField])) { $arBlogPost[CIdeaManagment::UFAnswerIdField] = array(); } $arBlogPost[CIdeaManagment::UFAnswerIdField][] = $this->arResult["INSTALLATION"]["BLOG_COMMENT_ID"][$key]; unset($arBlogPost["ID"]); CBlogPost::Update($this->arResult["INSTALLATION"]["BLOG_POST_ID"]["NY"], $arBlogPost); } } } }
function AddLiveComment($commentId = 0, $path = "") { if(IntVal($commentId) <= 0) return; if(CModule::IncludeModule("pull") && CPullOptions::GetNginxStatus()) { if($arComment = CBlogComment::GetByID($commentId)) { if(strlen($path) <= 0 && strlen($arComment["PATH"]) > 0) $path = CComponentEngine::MakePathFromTemplate($arComment["PATH"], array("post_id" =>$arComment["POST_ID"], "comment_id"=>$arComment["ID"])); if(strlen($path) <= 0) { $arPost = CBlogPost::GetByID($arComment["POST_ID"]); $path = $path = CComponentEngine::MakePathFromTemplate($arPost["PATH"], array("post_id" =>$arComment["POST_ID"], "comment_id"=>$arComment["ID"]))."?commentId=".$arComment["ID"]; } CPullWatch::AddToStack("UNICOMMENTSBLOG_".$arComment["POST_ID"], array( 'module_id' => "unicomments", 'command' => "comment", 'params' => Array( "AUTHOR_ID" => $arComment["AUTHOR_ID"], "ID" => $arComment["ID"], "POST_ID" => $arComment["POST_ID"], "TS" => time(), "ACTION" => "REPLY", "URL" => array( "LINK" => $path, ), "ENTITY_XML_ID" => "BLOG_".$arComment["POST_ID"], "APPROVED" => "Y", "NEED_REQUEST" => "Y", ), ) ); } } }
$arNewRightsName[] = "[user="******"]" . htmlspecialcharsback($name) . "[/user]"; } else { $arNewRightsName[] = "[url=" . $link . "]" . htmlspecialcharsback($name) . "[/url]"; } } else { $arNewRightsName[] = htmlspecialcharsback($name); } } } } $UserIP = CBlogUser::GetUserIP(); $arComFields = array("POST_ID" => $arParams["ID"], "BLOG_ID" => $arPost["BLOG_ID"], "POST_TEXT" => (count($arNewRightsName) > 1 ? GetMessage("B_B_SHARE") : GetMessage("B_B_SHARE_1")) . implode(", ", $arNewRightsName), "DATE_CREATE" => ConvertTimeStamp(time() + $arResult["TZ_OFFSET"], "FULL"), "AUTHOR_IP" => $UserIP[0], "AUTHOR_IP1" => $UserIP[1], "PARENT_ID" => false, "AUTHOR_ID" => $user_id, "SHARE_DEST" => implode(",", $arNewRights)); if ($comId = CBlogComment::Add($arComFields)) { BXClearCache(true, "/blog/comment/" . $arParams["ID"] . "/"); if (method_exists("CBlogComment", "AddLiveComment")) { CBlogComment::AddLiveComment($comId, CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arParams["PATH_TO_POST"]), array("post_id" => $arParams["ID"], "user_id" => $arPost["AUTHOR_ID"])) . "?commentId=" . $comId); } if ($arPost["AUTHOR_ID"] != $user_id) { $arFieldsIM = array("TYPE" => "SHARE", "TITLE" => $arPost["TITLE"], "URL" => CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arParams["PATH_TO_POST"]), array("post_id" => $arParams["ID"], "user_id" => $arPost["AUTHOR_ID"])), "ID" => $arParams["ID"], "FROM_USER_ID" => $user_id, "TO_USER_ID" => array($arPost["AUTHOR_ID"])); CBlogPost::NotifyIm($arFieldsIM); } if (!empty($arUsers2Notify)) { $arFieldsIM = array("TYPE" => "SHARE2USERS", "TITLE" => $arPost["TITLE"], "URL" => CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arParams["PATH_TO_POST"]), array("post_id" => $arParams["ID"], "user_id" => $arPost["AUTHOR_ID"])), "ID" => $arParams["ID"], "FROM_USER_ID" => $user_id, "TO_USER_ID" => $arUsers2Notify); CBlogPost::NotifyIm($arFieldsIM); } } /* update socnet log rights*/ $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => array("blog_post", "blog_post_important"), "SOURCE_ID" => $arPost["ID"]), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID")); if ($arRes = $dbRes->Fetch()) { $arLogSites = array(); $rsLogSite = CSocNetLog::GetSite($arRes["ID"]);
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); } }
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/"); }
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 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; }
$arNewRightsName[] = "[user="******"]" . htmlspecialcharsback($name) . "[/user]"; } else { $arNewRightsName[] = "[url=" . $link . "]" . htmlspecialcharsback($name) . "[/url]"; } } else { $arNewRightsName[] = htmlspecialcharsback($name); } } } } $UserIP = CBlogUser::GetUserIP(); $arComFields = array("POST_ID" => $arParams["ID"], "BLOG_ID" => $arPost["BLOG_ID"], "POST_TEXT" => (count($arNewRightsName) > 1 ? GetMessage("B_B_SHARE") : GetMessage("B_B_SHARE_1")) . implode(", ", $arNewRightsName), "DATE_CREATE" => ConvertTimeStamp(time() + $arResult["TZ_OFFSET"], "FULL"), "AUTHOR_IP" => $UserIP[0], "AUTHOR_IP1" => $UserIP[1], "PARENT_ID" => false, "AUTHOR_ID" => $user_id, "SHARE_DEST" => implode(",", $arNewRights)); if ($comId = CBlogComment::Add($arComFields)) { BXClearCache(true, "/blog/comment/" . intval($arParams["ID"] / 100) . "/" . $arParams["ID"] . "/"); if (is_callable("CBlogComment::AddLiveComment")) { CBlogComment::addLiveComment($comId, "", array()); } if ($arPost["AUTHOR_ID"] != $user_id) { $arFieldsIM = array("TYPE" => "SHARE", "TITLE" => htmlspecialcharsback($arPost["TITLE"]), "URL" => CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arParams["PATH_TO_POST"]), array("post_id" => $arParams["ID"], "user_id" => $arPost["AUTHOR_ID"])), "ID" => $arParams["ID"], "FROM_USER_ID" => $user_id, "TO_USER_ID" => array($arPost["AUTHOR_ID"])); CBlogPost::NotifyIm($arFieldsIM); } if (!empty($arUsers2Notify)) { $arFieldsIM = array("TYPE" => "SHARE2USERS", "TITLE" => htmlspecialcharsback($arPost["TITLE"]), "URL" => CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arParams["PATH_TO_POST"]), array("post_id" => $arParams["ID"], "user_id" => $arPost["AUTHOR_ID"])), "ID" => $arParams["ID"], "FROM_USER_ID" => $user_id, "TO_USER_ID" => $arUsers2Notify); CBlogPost::NotifyIm($arFieldsIM); } } /* update socnet log rights*/ $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => array("blog_post", "blog_post_important"), "SOURCE_ID" => $arPost["ID"]), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID")); if ($arRes = $dbRes->Fetch()) { $arLogSites = array(); $rsLogSite = CSocNetLog::GetSite($arRes["ID"]);
if ($type == "U" && IntVal($id) > 0) { $arNewRightsName[] = "[user="******"]" . htmlspecialcharsback($name) . "[/user]"; } else { $arNewRightsName[] = "[url=" . $link . "]" . htmlspecialcharsback($name) . "[/url]"; } } else { $arNewRightsName[] = htmlspecialcharsback($name); } } } } $UserIP = CBlogUser::GetUserIP(); $arComFields = array("POST_ID" => $arParams["ID"], "BLOG_ID" => $arPost["BLOG_ID"], "POST_TEXT" => (count($arNewRightsName) > 1 ? GetMessage("B_B_SHARE") : GetMessage("B_B_SHARE_1")) . implode(", ", $arNewRightsName), "DATE_CREATE" => ConvertTimeStamp(time() + $arResult["TZ_OFFSET"], "FULL"), "AUTHOR_IP" => $UserIP[0], "AUTHOR_IP1" => $UserIP[1], "PARENT_ID" => false, "AUTHOR_ID" => $user_id, "SHARE_DEST" => implode(",", $arNewRights)); if ($comId = CBlogComment::Add($arComFields)) { BXClearCache(true, "/blog/comment/" . intval($arParams["ID"] / 100) . "/" . $arParams["ID"] . "/"); if (CModule::IncludeModule("pull") && CPullOptions::GetNginxStatus() && ($arComment = CBlogComment::GetByID($comId))) { $arAuthor = CBlogUser::GetUserInfo($arComment["AUTHOR_ID"], $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"])); $arPullFields = array("ID" => $arComment["ID"], "ENTITY_XML_ID" => "BLOG_" . $arComment["POST_ID"], "FULL_ID" => array("BLOG_" . $arComment["POST_ID"], $arComment["ID"]), "NEW" => "N", "APPROVED" => "Y", "POST_TIMESTAMP" => time() + $arResult["TZ_OFFSET"], "PANELS" => array("EDIT" => "N", "MODERATE" => "N", "DELETE" => "N"), "URL" => array("LINK" => $arResult['urlToPost'] . (strpos($arResult['urlToPost'], "?") !== false ? "&" : "?") . "commentId=" . $arComment["ID"] . "#com" . $arComment["ID"]), "AUTHOR" => array("ID" => $arComment["AUTHOR_ID"], "NAME" => CUser::FormatName($arParams["NAME_TEMPLATE"], $arAuthor, $arParams["SHOW_LOGIN"] != "N" ? true : false), "URL" => $arAuthor["url"], "AVATAR" => $arAuthor["PERSONAL_PHOTO_resized"]["src"], "IS_EXTRANET" => is_array($GLOBALS["arExtranetUserID"]) && in_array($arComment["AUTHOR_ID"], $GLOBALS["arExtranetUserID"])), "ACTION" => "REPLY"); $p = new blogTextParser(false, ""); $arPullFields["POST_MESSAGE_TEXT"] = $p->convert($arComment["POST_TEXT"], false, array(), array("HTML" => "N"), array("pathToUser" => $arParams["PATH_TO_USER"])); if (IsModuleInstalled("mobile")) { $p->bMobile = true; $arPullFields["POST_MESSAGE_TEXT_MOBILE"] = $p->convert($arComment["POST_TEXT"], false, array(), array("HTML" => "N"), array("pathToUser" => "/mobile/users/?user_id=#user_id#")); } $arPullFields["POST_TIME"] = FormatDateFromDB($arComment["DATE_CREATE"], strpos($arParams["DATE_TIME_FORMAT_S"], 'a') !== false || ($arParams["DATE_TIME_FORMAT_S"] == 'FULL' && IsAmPmMode()) !== false ? strpos(FORMAT_DATETIME, 'TT') !== false ? 'G:MI TT' : 'G:MI T' : 'GG:MI'); $arPullFields["POST_DATE"] = FormatDateFromDB($arComment["DATE_CREATE"], $arParams["DATE_TIME_FORMAT"], true); if (strcasecmp(LANGUAGE_ID, 'EN') !== 0 && strcasecmp(LANGUAGE_ID, 'DE') !== 0) { $arPullFields["POST_DATE"] = ToLower($arPullFields["POST_DATE"]); } if (!empty($arParams['DATE_TIME_FORMAT_S']) && ($arParams['DATE_TIME_FORMAT_S'] == 'j F Y G:i' || $arParams['DATE_TIME_FORMAT_S'] == 'j F Y g:i a')) { $arPullFields["POST_DATE"] = ltrim($arPullFields["POST_DATE"], '0');
} if (!function_exists("__blogUFfileEditMobile")) { function __blogUFfileEditMobile($arResult, $arParams) { $result = false; if (strpos($arParams['arUserField']['FIELD_NAME'], 'UF_BLOG_POST_DOC') === 0 || strpos($arParams['arUserField']['FIELD_NAME'], 'UF_BLOG_COMMENT_DOC') === 0) { $componentParams = array('INPUT_NAME' => $arParams["arUserField"]["FIELD_NAME"], 'INPUT_NAME_UNSAVED' => 'FILE_NEW_TMP', 'MAX_FILE_SIZE' => intval($arParams['arUserField']['SETTINGS']['MAX_ALLOWED_SIZE']) > 0 ? $arParams['arUserField']['SETTINGS']['MAX_ALLOWED_SIZE'] : 5000000, 'MULTIPLE' => $arParams['arUserField']['MULTIPLE'], 'MODULE_ID' => 'uf', 'ALLOW_UPLOAD' => 'I', 'POST_ID' => $arParams['POST_ID']); $GLOBALS["APPLICATION"]->IncludeComponent('bitrix:mobile.file.upload', '', $componentParams, false, array("HIDE_ICONS" => "Y")); } return true; } } if (!$arResult["FatalError"]) { if ($arParams["COMMENT_TYPE"] == "blog") { if (CModule::IncludeModule("blog")) { if ($arComment = CBlogComment::GetByID($arParams["COMMENT_ID"])) { $arResult["AUTHOR_ID"] = $arComment["AUTHOR_ID"]; $arResult["POST_ID"] = $arComment["POST_ID"]; $arResult["COMMENT_TEXT"] = htmlspecialcharsex($arComment["POST_TEXT"]); } } } elseif (CModule::IncludeModule("socialnetwork")) { $rsComment = CSocNetLogComments::GetList(array(), array("ID" => $arParams["COMMENT_ID"]), false, false, array("ID", "LOG_ID", "USER_ID", "MESSAGE")); if ($arComment = $rsComment->Fetch()) { $arResult["AUTHOR_ID"] = $arComment["USER_ID"]; $arResult["POST_ID"] = $arComment["LOG_ID"]; $arResult["COMMENT_TEXT"] = htmlspecialcharsex($arComment["MESSAGE"]); } } if (!$arComment) { $arResult["FatalError"] = GetMessage("MFP_COMMENT_NOT_FOUND");
function OnGetRatingContentOwner($arParams) { if ($arParams['ENTITY_TYPE_ID'] == 'BLOG_POST') { $arPost = CBlogPost::GetByID(IntVal($arParams['ENTITY_ID'])); return $arPost['AUTHOR_ID']; } elseif ($arParams['ENTITY_TYPE_ID'] == 'BLOG_COMMENT') { $arComment = CBlogComment::GetByID(IntVal($arParams['ENTITY_ID'])); return $arComment['AUTHOR_ID']; } return false; }