function Delete($ID)
 {
     global $DB;
     $ID = IntVal($ID);
     $arResult = CBlogComment::GetByID($ID);
     $db_events = GetModuleEvents("blog", "OnBeforeCommentDelete");
     while ($arEvent = $db_events->Fetch()) {
         if (ExecuteModuleEventEx($arEvent, array($ID)) === false) {
             return false;
         }
     }
     if ($arResult) {
         $DB->Query("UPDATE b_blog_comment SET " . "\tPARENT_ID = " . (IntVal($arResult["PARENT_ID"]) > 0 ? IntVal($arResult["PARENT_ID"]) : "null") . " " . "WHERE PARENT_ID = " . $ID . " " . "\tAND BLOG_ID = " . IntVal($arResult["BLOG_ID"]) . " " . "\tAND POST_ID = " . IntVal($arResult["POST_ID"]) . " ", true);
         if ($arResult["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) {
             CBlogPost::Update($arResult["POST_ID"], array("=NUM_COMMENTS" => "NUM_COMMENTS - 1"));
         }
         $res = CBlogImage::GetList(array(), array("BLOG_ID" => $arResult["BLOG_ID"], "POST_ID" => $arResult["POST_ID"], "IS_COMMENT" => "Y", "COMMENT_ID" => $ID));
         while ($aImg = $res->Fetch()) {
             CBlogImage::Delete($aImg['ID']);
         }
         $GLOBALS["USER_FIELD_MANAGER"]->Delete("BLOG_COMMENT", $ID);
     }
     unset($GLOBALS["BLOG_COMMENT"]["BLOG_COMMENT_CACHE_" . $ID]);
     $events = GetModuleEvents("blog", "OnCommentDelete");
     while ($arEvent = $events->Fetch()) {
         ExecuteModuleEventEx($arEvent, array($ID));
     }
     if (CModule::IncludeModule("search")) {
         CSearch::Index("blog", "C" . $ID, array("TITLE" => "", "BODY" => ""));
     }
     return $DB->Query("DELETE FROM b_blog_comment WHERE ID = " . $ID . "", true);
 }
示例#2
0
 function Add($arFields)
 {
     global $DB;
     $arFields1 = array();
     foreach ($arFields as $key => $value) {
         if (substr($key, 0, 1) == "=") {
             $arFields1[substr($key, 1)] = $value;
             unset($arFields[$key]);
         }
     }
     if (!CBlogComment::CheckFields("ADD", $arFields)) {
         return false;
     }
     $arInsert = $DB->PrepareInsert("b_blog_comment", $arFields);
     foreach ($arFields1 as $key => $value) {
         if (strlen($arInsert[0]) > 0) {
             $arInsert[0] .= ", ";
         }
         $arInsert[0] .= $key;
         if (strlen($arInsert[1]) > 0) {
             $arInsert[1] .= ", ";
         }
         $arInsert[1] .= $value;
     }
     $ID = False;
     if (strlen($arInsert[0]) > 0) {
         $strSql = "INSERT INTO b_blog_comment(" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")";
         $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $ID = IntVal($DB->LastID());
     }
     if ($ID) {
         $arComment = CBlogComment::GetByID($ID);
         CBlogPost::Update($arComment["POST_ID"], array("=NUM_COMMENTS" => "NUM_COMMENTS + 1"));
     }
     return $ID;
 }
示例#3
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");
示例#4
0
	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;
	}
示例#5
0
                            $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++;
示例#6
0
	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",
						),
					)
				);
			}
		}
	}
示例#7
0
    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));
        }
    }
示例#8
0
                 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');
示例#9
0
    /**
     * 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;
    }
示例#10
0
             CBlogComment::Update($commentId, $arFieldsHave, false);
             $arFieldsHave = array("HAS_COMMENT_IMAGES" => $bHasImg ? "Y" : "N");
             if ($arFieldsHave["HAS_COMMENT_IMAGES"] != $arPost["HAS_COMMENT_IMAGES"]) {
                 CBlogPost::Update($arPost["ID"], $arFieldsHave, false);
             }
         } else {
             if ($e = $APPLICATION->GetException()) {
                 $arResult["COMMENT_ERROR"] = "<b>" . GetMessage("B_B_PC_COM_ERROR") . "</b><br />" . $e->GetString();
             }
         }
     } else {
         $arResult["COMMENT_ERROR"] = strlen($strErrorMessage) > 0 ? $strErrorMessage : GetMessage("B_B_PC_COM_ERROR");
     }
 } else {
     $commentID = $_POST["edit_id"];
     $arOldComment = CBlogComment::GetByID($commentID);
     if ($commentID <= 0 || empty($arOldComment)) {
         $arResult["COMMENT_ERROR"] = "<b>" . GetMessage("B_B_PC_COM_ERROR_EDIT") . "</b><br />" . GetMessage("B_B_PC_COM_ERROR_LOST");
     } elseif ($arOldComment["AUTHOR_ID"] == $user_id || $arResult["Perm"] >= BLOG_PERMS_FULL) {
         $arFields = array("POST_TEXT" => $_POST["comment"], "URL" => $arBlog["URL"]);
         if ($arResult["Perm"] == BLOG_PERMS_PREMODERATE) {
             $arFields["PUBLISH_STATUS"] = BLOG_PUBLISH_STATUS_READY;
         }
         $fieldName = 'UF_BLOG_COMMENT_DOC';
         $arPostFields = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("BLOG_COMMENT", $commentID, LANGUAGE_ID);
         if (isset($GLOBALS[$fieldName]) && is_array($GLOBALS[$fieldName])) {
             $checkArray = $_SESSION["MFI_UPLOADED_FILES_" . $_POST["blog_upload_cid"]];
             $checkArray = array_merge(is_array($checkArray) ? $checkArray : array(), isset($arPostFields["UF_BLOG_COMMENT_DOC"]) ? $arPostFields["UF_BLOG_COMMENT_DOC"]["VALUE"] : array());
             $arAttachedFiles = array();
             foreach ($GLOBALS[$fieldName] as $fileID) {
                 $fileID = intval($fileID);
示例#11
0
 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;
 }
示例#12
0
 public static function CallBack_DeleteComment($arFields)
 {
     if (!CModule::IncludeModule("blog")) {
         return false;
     }
     if (!isset($arFields["SOURCE_ID"]) || intval($arFields["SOURCE_ID"]) <= 0) {
         return false;
     }
     $messageId = intval($arFields["SOURCE_ID"]);
     if (($arBlogComment = CBlogComment::GetByID($messageId)) && CBlogComment::Delete($messageId)) {
         $strOKMessage = GetMessage("IDEA_SONET_DELETE_COMMENT_SOURCE_SUCCESS");
         $cache = new CPHPCache();
         $cache->CleanDir(SITE_ID . "/idea/" . $arBlogComment["BLOG_ID"] . "/comment/" . $arBlogComment["POST_ID"] . "/");
         BXClearCache(True, "/" . SITE_ID . "/idea/" . $arBlogComment["BLOG_ID"] . "/first_page/");
         BXClearCache(True, "/" . SITE_ID . "/idea/" . $arBlogComment["BLOG_ID"] . "/pages/");
         BXClearCache(True, "/" . SITE_ID . "/idea/" . $arBlogComment["BLOG_ID"] . "/comment/" . $arBlogComment["POST_ID"] . "/");
         BXClearCache(True, "/" . SITE_ID . "/idea/" . $arBlogComment["BLOG_ID"] . "/post/" . $arBlogComment["POST_ID"] . "/");
     } else {
         $strErrorMessage = GetMessage("IDEA_SONET_DELETE_COMMENT_SOURCE_ERROR");
     }
     return array("ERROR" => $strErrorMessage, "NOTES" => $strOKMessage);
 }
示例#13
0
                CSocNetLog::Delete($arLogComment["ID"]);
            }
        }
    }
}
// convert blog
if (CModule::IncludeModule("blog")) {
    $arLogComments = array();
    $dbLog = CSocNetLog::GetList(array("LOG_DATE" => "ASC"), array("EVENT_ID" => "blog_comment"), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID", "LOG_DATE", "MESSAGE", "TEXT_MESSAGE", "URL", "SOURCE_ID", "USER_ID"));
    while ($arLog = $dbLog->Fetch()) {
        $arLogComments[] = $arLog;
    }
    foreach ($arLogComments as $arLogComment) {
        if (intval($arLogComment["SOURCE_ID"]) > 0) {
            $log_tmp_id = false;
            $arBlogComment = CBlogComment::GetByID($arLogComment["SOURCE_ID"]);
            if ($arBlogComment) {
                $dbLog = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "blog_post", "SOURCE_ID" => $arBlogComment["POST_ID"]), false, array("nTopCount" => 1), array("ID", "TMP_ID"));
                if ($arLog = $dbLog->Fetch()) {
                    $log_tmp_id = $arLog["TMP_ID"];
                }
            }
            if (intval($log_tmp_id) > 0) {
                $arFields = array("ENTITY_TYPE" => $arLogComment["ENTITY_TYPE"], "ENTITY_ID" => $arLogComment["ENTITY_ID"], "EVENT_ID" => "blog_comment", "LOG_DATE" => $arLogComment["LOG_DATE"], "MESSAGE" => $arLogComment["MESSAGE"], "TEXT_MESSAGE" => $arLogComment["TEXT_MESSAGE"], "URL" => $arLogComment["URL"], "MODULE_ID" => false, "SOURCE_ID" => $arLogComment["SOURCE_ID"], "LOG_ID" => $log_tmp_id, "USER_ID" => $arLogComment["USER_ID"]);
                CSocNetLogComments::Add($arFields, false, false, false);
                CSocNetLog::Delete($arLogComment["ID"]);
            }
        }
    }
}
$dbLog = CSocNetLog::GetList(array("LOG_DATE" => "ASC"), array("COMMENTS_COUNT" => false), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID", "LOG_DATE", "MESSAGE", "TEXT_MESSAGE", "URL", "SOURCE_ID", "USER_ID"));
示例#14
0
 function Update($ID, $arFields)
 {
     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;
     }
     $db_events = GetModuleEvents("blog", "OnBeforeCommentUpdate");
     while ($arEvent = $db_events->Fetch()) {
         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 " . "\t" . $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"]);
         }
         $db_events = GetModuleEvents("blog", "OnCommentUpdate");
         while ($arEvent = $db_events->Fetch()) {
             ExecuteModuleEventEx($arEvent, array($ID, &$arFields));
         }
         if (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"]);
                 $authorName = "";
                 if (IntVal($arComment["AUTHOR_ID"]) > 0) {
                     $dbUser = CUser::GetByID($arComment["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);
                     }
                 } elseif (strlen($arComment["AUTHOR_NAME"]) > 0) {
                     $authorName = $arComment["AUTHOR_NAME"];
                 }
                 if (strlen($authorName) > 0) {
                     $searchContent .= "\r\n" . $authorName;
                 }
                 $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"];
                     }
                 }
                 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;
 }
示例#15
0
 $BlogUser = CBlogUser::GetByID($USER->GetID(), BLOG_BY_USER_ID);
 $dbUser = CUser::GetByID($USER->GetID());
 $arUser = $dbUser->Fetch();
 $AuthorName = CBlogUser::GetUserName($BlogUser["ALIAS"], $arUser["NAME"], $arUser["LAST_NAME"], $arUser["LOGIN"]);
 if (strlen($AuthorName) <= 0) {
     $AuthorName = $arFields["AUTHOR_NAME"];
 }
 $arMailFields = array("BLOG_ID" => $arBlog['ID'], "BLOG_NAME" => $arBlog['NAME'], "BLOG_URL" => $arBlog['URL'], "MESSAGE_TITLE" => $arPost['TITLE'], "COMMENT_TITLE" => $_POST['subject'], "COMMENT_TEXT" => $_POST['comment'], "COMMENT_DATE" => ConvertTimeStamp(false, "FULL"), "COMMENT_PATH" => "http://" . COption::GetOptionString("main", "server_name") . $urlToPost . "#" . $commmentId, "AUTHOR" => $AuthorName, "EMAIL_FROM" => COption::GetOptionString("main", "email_from", "*****@*****.**"));
 if ($arBlog['EMAIL_NOTIFY'] == 'Y' && $USER->GetID() != $arPost['AUTHOR_ID']) {
     $res = CUser::GetByID($arPost['AUTHOR_ID']);
     $arOwner = $res->Fetch();
     $arMailFields["EMAIL_TO"] = $arOwner['EMAIL'];
     CEvent::Send("NEW_BLOG_COMMENT", SITE_ID, $arMailFields);
 }
 if ($arFields["PARENT_ID"] > 0) {
     $arPrev = CBlogComment::GetByID($arFields["PARENT_ID"]);
     if ($USER->GetID() != $arPrev['AUTHOR_ID']) {
         $email = '';
         $res = CUser::GetByID($arPrev['AUTHOR_ID']);
         if ($arOwner = $res->Fetch()) {
             $arPrevBlog = CBlog::GetByOwnerID($arPrev['AUTHOR_ID']);
             if ($arPrevBlog['EMAIL_NOTIFY'] != 'N') {
                 // јвтор верхнего комента хочет получать емайл
                 $email = $arOwner['EMAIL'];
             }
         } elseif ($arPrev['AUTHOR_EMAIL']) {
             // јноним, но оставил свой мейл
             $email = $arPrev['AUTHOR_EMAIL'];
         }
         if ($email) {
             $arMailFields['EMAIL_TO'] = $email;