public static function UpdateLog($commentID, $arBlogUser, $arUser, $arComment, $arPost, $arParams) { if (!CModule::IncludeModule('socialnetwork')) return; $AuthorName = CBlogUser::GetUserName($arBlogUser["~ALIAS"], $arUser["~NAME"], $arUser["~LAST_NAME"], $arUser["~LOGIN"], $arUser["~SECOND_NAME"]); $parserBlog = new blogTextParser(false, $arParams["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"); $text4message = $parserBlog->convert($arComment["POST_TEXT"], false, $arParams["IMAGES"], $arAllow, array("isSonetLog"=>true)); $text4mail = $parserBlog->convert4mail($arComment["POST_TEXT"], $arParams["IMAGES"]); $arSoFields = Array( "TITLE_TEMPLATE" => htmlspecialcharsback($AuthorName)." ".GetMessage("BLG_SONET_COMMENT_TITLE"), "TITLE" => $arPost['~TITLE'], "MESSAGE" => $text4message, "TEXT_MESSAGE" => $text4mail ); $dbRes = CSocNetLogComments::GetList( array("ID" => "DESC"), array( "EVENT_ID" => array("blog_comment", "blog_comment_micro"), "SOURCE_ID" => $commentID ), false, false, array("ID") ); while ($arRes = $dbRes->Fetch()) CSocNetLogComments::Update($arRes["ID"], $arSoFields); }
function Notify($arPost, $arBlog, $arParams) { global $DB; if (empty($arBlog)) { $arBlog = CBlog::GetByID($arPost["BLOG_ID"]); } if ($arParams["bSoNet"] || $arBlog["EMAIL_NOTIFY"] == "Y" && $arParams["user_id"] != $arBlog["OWNER_ID"]) { $BlogUser = CBlogUser::GetByID($arParams["user_id"], BLOG_BY_USER_ID); $BlogUser = CBlogTools::htmlspecialcharsExArray($BlogUser); $res = CUser::GetByID($arBlog["OWNER_ID"]); $arOwner = $res->GetNext(); $dbUser = CUser::GetByID($arParams["user_id"]); $arUser = $dbUser->Fetch(); $AuthorName = CBlogUser::GetUserNameEx($arUser, $BlogUser, $arParams); $parserBlog = new blogTextParser(false, $arParams["PATH_TO_SMILE"]); $text4mail = $arPost["DETAIL_TEXT"]; if ($arPost["DETAIL_TEXT_TYPE"] == "html") { $text4mail = HTMLToTxt($text4mail); } $arImages = array(); $res = CBlogImage::GetList(array("ID" => "ASC"), array("POST_ID" => $arPost["ID"], "BLOG_ID" => $arBlog["ID"], "IS_COMMENT" => "N")); while ($arImage = $res->Fetch()) { $arImages[$arImage['ID']] = $arImage['FILE_ID']; } $text4mail = $parserBlog->convert4mail($text4mail, $arImages); $dbSite = CSite::GetByID(SITE_ID); $arSite = $dbSite->Fetch(); $serverName = htmlspecialcharsEx($arSite["SERVER_NAME"]); if (strlen($serverName) <= 0) { if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) { $serverName = SITE_SERVER_NAME; } else { $serverName = COption::GetOptionString("main", "server_name", ""); } } } if (!$arParams["bSoNet"] && $arBlog["EMAIL_NOTIFY"] == "Y" && $arParams["user_id"] != $arBlog["OWNER_ID"] && IntVal($arBlog["OWNER_ID"]) > 0) { CEvent::Send("NEW_BLOG_MESSAGE", SITE_ID, array("BLOG_ID" => $arBlog["ID"], "BLOG_NAME" => htmlspecialcharsBack($arBlog["NAME"]), "BLOG_URL" => $arBlog["URL"], "MESSAGE_TITLE" => $arPost["TITLE"], "MESSAGE_TEXT" => $text4mail, "MESSAGE_DATE" => GetTime(MakeTimeStamp($arPost["DATE_PUBLISH"]) - CTimeZone::GetOffset(), "FULL"), "MESSAGE_PATH" => "http://" . $serverName . CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arParams["PATH_TO_POST"]), array("blog" => $arBlog["URL"], "post_id" => $arPost["ID"], "user_id" => $arBlog["OWNER_ID"], "group_id" => $arParams["SOCNET_GROUP_ID"])), "AUTHOR" => $AuthorName, "EMAIL_FROM" => COption::GetOptionString("main", "email_from", "*****@*****.**"), "EMAIL_TO" => $arOwner["EMAIL"])); } if ($arParams["bSoNet"] && $arPost["ID"] && CModule::IncludeModule("socialnetwork")) { if ($arPost["DETAIL_TEXT_TYPE"] == "html" && $arParams["allowHTML"] == "Y" && $arBlog["ALLOW_HTML"] == "Y") { $arAllow = array("HTML" => "Y", "ANCHOR" => "Y", "IMG" => "Y", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "Y", "QUOTE" => "Y", "CODE" => "Y"); if ($arParams["allowVideo"] != "Y") { $arAllow["VIDEO"] = "N"; } $text4message = $parserBlog->convert($arPost["DETAIL_TEXT"], false, $arImages, $arAllow); } else { $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($arPost["DETAIL_TEXT"], false, $arImages, $arAllow, array("isSonetLog" => true)); } $arSoFields = array("EVENT_ID" => "blog_post", "=LOG_DATE" => strlen($arPost["DATE_PUBLISH"]) > 0 ? MakeTimeStamp($arPost["DATE_PUBLISH"], CSite::GetDateFormat("FULL", $SITE_ID)) > time() + CTimeZone::GetOffset() ? $DB->CharToDateFunction($arPost["DATE_PUBLISH"], "FULL", SITE_ID) : $DB->CurrentTimeFunction() : $DB->CurrentTimeFunction(), "TITLE_TEMPLATE" => "#USER_NAME# " . GetMessage("BLG_SONET_TITLE"), "TITLE" => $arPost["TITLE"], "MESSAGE" => $text4message, "TEXT_MESSAGE" => $text4mail, "MODULE_ID" => "blog", "CALLBACK_FUNC" => false, "SOURCE_ID" => $arPost["ID"], "ENABLE_COMMENTS" => array_key_exists("ENABLE_COMMENTS", $arPost) && $arPost["ENABLE_COMMENTS"] == "N" ? "N" : "Y"); $arSoFields["RATING_TYPE_ID"] = "BLOG_POST"; $arSoFields["RATING_ENTITY_ID"] = intval($arPost["ID"]); if ($arParams["bGroupMode"]) { $arSoFields["ENTITY_TYPE"] = SONET_ENTITY_GROUP; $arSoFields["ENTITY_ID"] = $arParams["SOCNET_GROUP_ID"]; $arSoFields["URL"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_POST"], array("blog" => $arBlog["URL"], "user_id" => $arBlog["OWNER_ID"], "group_id" => $arParams["SOCNET_GROUP_ID"], "post_id" => $arPost["ID"])); } else { $arSoFields["ENTITY_TYPE"] = SONET_ENTITY_USER; $arSoFields["ENTITY_ID"] = $arBlog["OWNER_ID"]; $arSoFields["URL"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_POST"], array("blog" => $arBlog["URL"], "user_id" => $arBlog["OWNER_ID"], "group_id" => $arParams["SOCNET_GROUP_ID"], "post_id" => $arPost["ID"])); } if (intval($arParams["user_id"]) > 0) { $arSoFields["USER_ID"] = $arParams["user_id"]; } $logID = CSocNetLog::Add($arSoFields, false); if (intval($logID) > 0) { $socnetPerms = CBlogPost::GetSocNetPermsCode($arPost["ID"]); if (!in_array("U" . $arPost["AUTHOR_ID"], $socnetPerms)) { $socnetPerms[] = "U" . $arPost["AUTHOR_ID"]; } $socnetPerms[] = "SA"; // socnet admin CSocNetLog::Update($logID, array("TMP_ID" => $logID)); if (CModule::IncludeModule("extranet")) { $arSiteID = CExtranet::GetSitesByLogDestinations($socnetPerms); CSocNetLog::Update($logID, array("SITE_ID" => $arSiteID)); } CSocNetLogRights::DeleteByLogID($logID); CSocNetLogRights::Add($logID, $socnetPerms); CSocNetLog::SendEvent($logID, "SONET_NEW_EVENT", $logID); return $logID; } } }
if ($arFields["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH || strlen($arFields["PUBLISH_STATUS"]) <= 0) { $arFil = array("EVENT_ID" => array("blog_post", "blog_post_important"), "SOURCE_ID" => $arPost["ID"]); $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), $arFil, false, false, array("ID", "TMP_ID")); if ($arRes = $dbRes->Fetch()) { $log_id = $arRes["ID"]; } else { $arParamsNotify = array("bSoNet" => true, "UserID" => $arParams["USER_ID"], "allowVideo" => $arResult["allowVideo"], "bGroupMode" => $arResult["bGroupMode"], "PATH_TO_SMILE" => $arParams["PATH_TO_SMILE"], "PATH_TO_POST" => $arParams["PATH_TO_POST"], "SOCNET_GROUP_ID" => $arParams["SOCNET_GROUP_ID"], "user_id" => $user_id, "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"], "SHOW_LOGIN" => $arParams["SHOW_LOGIN"]); $log_id = CBlogPost::Notify($arPost, $arBlog, $arParamsNotify); } $arImages = array(); $res = CBlogImage::GetList(array("ID" => "ASC"), array("POST_ID" => $arPost["ID"], "BLOG_ID" => $arBlog["ID"], "IS_COMMENT" => "Y", "COMMENT_ID" => $commentId)); while ($arImage = $res->Fetch()) { $arImages[$arImage["ID"]] = $arImage["FILE_ID"]; } $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"); $text4mail = $parserBlog->convert4mail($_POST['comment'], $arImages); if (intval($log_id) > 0) { $text4message = $parserBlog->convert($_POST['comment'], false, $arImages, $arAllow, array("isSonetLog" => true)); $arFieldsForSocnet = array("ENTITY_TYPE" => SONET_ENTITY_USER, "ENTITY_ID" => $arBlog["OWNER_ID"], "EVENT_ID" => "blog_comment", "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE" => $text4message, "TEXT_MESSAGE" => $text4mail, "URL" => $commentUrl, "MODULE_ID" => false, "SOURCE_ID" => $commentId, "LOG_ID" => $log_id, "RATING_TYPE_ID" => "BLOG_COMMENT", "RATING_ENTITY_ID" => intval($commentId)); if (intval($user_id) > 0) { $arFieldsForSocnet["USER_ID"] = $user_id; } $log_comment_id = CSocNetLogComments::Add($arFieldsForSocnet, false, false); CSocNetLog::CounterIncrement($log_comment_id, false, false, "LC", CSocNetLogRights::CheckForUserAll($log_id)); } $arPSR = CBlogPost::GetSocnetPerms($arPost["ID"]); $arUsrS = array(); if (!empty($arPSR["U"])) { foreach ($arPSR["U"] as $k => $v) { $arUsrS[] = "U" . $k; }
} } if (strpos($commentUrl, "?") !== false) { $commentUrl .= "&"; } else { $commentUrl .= "?"; } if (strlen($arFields["PUBLISH_STATUS"]) > 0 && $arFields["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH) { $commentAddedUrl = $commentUrl . $arParams["COMMENT_ID_VAR"] . "=" . $commentID . "&hidden_add_comment_id=" . $commentID; } $commentUrl .= $arParams["COMMENT_ID_VAR"] . "=" . $commentID . "#" . $commentID; if (strlen($AuthorName) <= 0) { $AuthorName = $arFields["AUTHOR_NAME"]; } $IdeaParser = new blogTextParser(false, $arParams["PATH_TO_SMILE"]); $arNotifyFields = array_merge($arFields, array("TYPE" => 'IDEA_COMMENT', "ACTION" => 'ADD', "ID" => $commentID, "AUTHOR" => $AuthorName, "FULL_PATH" => "http://" . $serverName . $commentUrl, "IDEA_COMMENT_TEXT" => $IdeaParser->convert4mail($arFields["POST_TEXT"]), "IDEA_TITLE" => $arPost['~TITLE'])); //Notifications $Notify = CIdeaManagment::getInstance()->Notification($arNotifyFields); //Socialnetwork notification $Notify->getSonetNotify()->Send(); //Email notification $Notify->getEmailNotify()->Send(); //END -> Notifications if ($arFields["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH || strlen($arFields["PUBLISH_STATUS"]) <= 0) { if (!$bSoNet && $arFields["PARENT_ID"] > 0) { $arPrev = CBlogComment::GetByID($arFields["PARENT_ID"]); $arPrev = CBlogTools::htmlspecialcharsExArray($arPrev); if ($user_id != $arPrev['AUTHOR_ID']) { $email = ''; $res = CUser::GetByID($arPrev['AUTHOR_ID']); if ($arOwner = $res->GetNext()) {
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); } } } } }
BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/rss_out/" . $arPost["POST_ID"] . "/C/"); BXClearCache(True, "/" . SITE_ID . "/blog/last_messages/"); BXClearCache(True, "/" . SITE_ID . "/blog/commented_posts/"); BXClearCache(True, "/" . SITE_ID . "/blog/popular_posts/"); $images = array(); $res = CBlogImage::GetList(array("ID" => "ASC"), array("POST_ID" => $arPost["ID"], "BLOG_ID" => $arBlog["ID"], "IS_COMMENT" => "Y", "COMMENT_ID" => $commmentId)); while ($aImg = $res->Fetch()) { $images[$aImg["ID"]] = $aImg["FILE_ID"]; } $AuthorName = ""; if (IntVal($user_id) > 0) { $AuthorName = CBlogUser::GetUserNameEx($arResult["arUser"], $arResult["BlogUser"], $arParams); } $parserBlog = new blogTextParser(false, $arParams["PATH_TO_SMILE"]); $arParserParams = array("imageWidth" => $arParams["IMAGE_MAX_WIDTH"], "imageHeight" => $arParams["IMAGE_MAX_HEIGHT"]); $text4mail = $parserBlog->convert4mail($_POST['comment'], $images); $serverName = defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0 ? SITE_SERVER_NAME : COption::GetOptionString("main", "server_name", ""); if (strlen($serverName) <= 0) { $serverName = $_SERVER["SERVER_NAME"]; } if (strpos($commentUrl, "?") !== false) { $commentUrl .= "&"; } else { $commentUrl .= "?"; } if (strlen($arFields["PUBLISH_STATUS"]) > 0 && $arFields["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH) { $commentAddedUrl = $commentUrl . $arParams["COMMENT_ID_VAR"] . "=" . $commmentId . "&hidden_add_comment_id=" . $commmentId; } $commentUrl .= $arParams["COMMENT_ID_VAR"] . "=" . $commmentId . "#" . $commmentId; if (!preg_match("/^[a-z]+:\\/\\//", $commentUrl)) { $commentUrl = (CMain::IsHTTPS() ? 'https://' : 'http://') . $serverName . $commentUrl;
if (intval($logID) > 0) { $socnetPerms = array("U1", "G2"); CSocNetLog::Update($logID, array("TMP_ID" => $logID)); CSocNetLogRights::DeleteByLogID($logID); CSocNetLogRights::Add($logID, $socnetPerms); } } foreach ($categoryID as $v) { CBlogPostCategory::Add(array("BLOG_ID" => $blogID, "POST_ID" => $postID, "CATEGORY_ID" => $v)); } $arBlogCommentFields = array("TITLE" => GetMessage("BLOG_DEMO_COMMENT_TITLE"), "POST_TEXT" => GetMessage("BLOG_DEMO_COMMENT_BODY"), "BLOG_ID" => $blogID, "POST_ID" => $postID, "PARENT_ID" => 0, "AUTHOR_ID" => 1, "DATE_CREATE" => ConvertTimeStamp(false, "FULL"), "AUTHOR_IP" => "192.168.0.108"); $commmentId = CBlogComment::Add($arBlogCommentFields); if (CModule::IncludeModule("socialnetwork")) { $arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "N"); $text4message = $parserBlog->convert($arBlogCommentFields["POST_TEXT"], false, array(), $arAllow); $text4mail = $parserBlog->convert4mail($arBlogCommentFields["POST_TEXT"]); $arBlogUser = CBlogUser::GetByID(1, BLOG_BY_USER_ID); $arBlogUser = CBlogTools::htmlspecialcharsExArray($arBlogUser); $AuthorName = CBlogUser::GetUserName($arBlogUser["~ALIAS"], $arUser["~NAME"], $arUser["~LAST_NAME"], $arUser["~LOGIN"]); $commentUrl = CComponentEngine::MakePathFromTemplate(WIZARD_SITE_DIR . "company/personal/user/#user_id#/blog/#post_id#/", array("post_id" => $postID, "user_id" => 1)); if (strpos($commentUrl, "?") !== false) { $commentUrl .= "&"; } else { $commentUrl .= "?"; } $commentUrl .= "commentId=" . $commmentId . "#" . $commmentId; $arSoFields = array("ENTITY_TYPE" => "U", "ENTITY_ID" => 1, "EVENT_ID" => "blog_comment", "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE" => $text4message, "TEXT_MESSAGE" => $text4mail, "URL" => $commentUrl, "MODULE_ID" => false, "SOURCE_ID" => $commmentId, "USER_ID" => 1, "LOG_ID" => $logID, "RATING_TYPE_ID" => "BLOG_COMMENT", "RATING_ENTITY_ID" => intval($commmentId)); CSocNetLogComments::Add($arSoFields); } //CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH."/community/index.php", Array("SONET_GROUP_ID" => $SocNetGroupID)); CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/company/personal.php", array("BLOG_GROUP_ID" => $SocNetGroupID));
CBlogPostCategory::Add(array("BLOG_ID" => $arBlog["ID"], "POST_ID" => $newID, "CATEGORY_ID" => $v)); } $DB->Query("UPDATE b_blog_image SET POST_ID=" . $newID . " WHERE BLOG_ID=" . $arBlog["ID"] . " AND POST_ID=0", true); } if (IntVal($newID) > 0 && strlen($arResult["ERROR_MESSAGE"]) <= 0) { if ($arFields["ACTION"] == "ADD") { $arResult["SUCCESS_MESSAGE"] = GetMessage("IDEA_NEW_MESSAGE_SUCCESS"); } //Get Author Name $arResult["BlogUser"] = CBlogUser::GetByID($arFields["AUTHOR_ID"], BLOG_BY_USER_ID); $arResult["BlogUser"] = CBlogTools::htmlspecialcharsExArray($arResult["BlogUser"]); $arResult["arUser"] = CUser::GetByID($arFields["AUTHOR_ID"])->GetNext(); $AuthorName = CBlogUser::GetUserName($arResult["BlogUser"]["~ALIAS"], $arResult["arUser"]["~NAME"], $arResult["arUser"]["~LAST_NAME"], $arResult["arUser"]["~LOGIN"]); $IdeaParser = new blogTextParser(false, $arParams["PATH_TO_SMILE"]); $arCategoryList = CIdeaManagment::getInstance()->Idea()->GetCategoryList(); $arNotifyFields = array_merge($arFields, array("AUTHOR" => $AuthorName, "IDEA_TEXT" => $IdeaParser->convert4mail($arFields["DETAIL_TEXT"]), "SHOW_RATING" => $arParams["SHOW_RATING"], "RATING_TYPE_ID" => 'BLOG_POST', "RATING_ENTITY_ID" => $newID, "ID" => $newID, "TYPE" => "IDEA", "CATEGORY" => $arCategoryList[$arFields[CIdeaManagment::UFCategroryCodeField]]["NAME"], "FULL_PATH" => "http://" . $serverName . CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arFields["PATH"]), array("post_id" => $newID)), "PATH" => CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arFields["PATH"]), array("post_id" => $newID)))); //Notifications $Notify = CIdeaManagment::getInstance()->Notification($arNotifyFields); //Socialnetwork notification $Notify->getSonetNotify()->Send(); //Email notification $Notify->getEmailNotify()->Send(); //Clear Caching and redirect BXClearCache(True, "/" . SITE_ID . "/idea/" . $arBlog["ID"] . "/first_page/"); BXClearCache(True, "/" . SITE_ID . "/idea/" . $arBlog["ID"] . "/pages/"); BXClearCache(True, "/" . SITE_ID . "/idea/" . $arBlog["ID"] . "/post/" . $newID . "/"); BXClearCache(True, '/' . SITE_ID . '/idea/statistic_list/'); //Redirect if not AJAX if ($_REQUEST["AJAX"] != "Y") { LocalRedirect($arNotifyFields["PATH"]); }
function OnAfterPhotoCommentAddBlog($ID, $arFields) { if (!CModule::IncludeModule('iblock')) return; if (!$this->IsSocnet) return; if (intval($this->PhotoElementID) > 0) { $dbRes = CSocNetLog::GetList( array("ID" => "DESC"), array( "EVENT_ID" => "photo_photo", "SOURCE_ID" => $this->PhotoElementID ), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID", "TMP_ID") ); $bSocNetLogRecordExists = false; if ($arRes = $dbRes->Fetch()) { $log_id = $arRes["ID"]; $entity_type = $arRes["ENTITY_TYPE"]; $entity_id = $arRes["ENTITY_ID"]; $bSocNetLogRecordExists = true; } else { $rsElement = CIBlockElement::GetByID($this->PhotoElementID); if ($arElement = $rsElement->Fetch()) { $url = $this->arPath["DETAIL_URL"]; $sAuthorName = GetMessage("SONET_LOG_GUEST"); if (intval($arElement["CREATED_BY"]) > 0) { $rsUser = CUser::GetByID($arElement["CREATED_BY"]); if ($arUser = $rsUser->Fetch()) $sAuthorName = CUser::FormatName(CSite::GetNameFormat(false), $arUser, true, false); } if ( in_array($this->entity_type, array(SONET_ENTITY_USER, SONET_ENTITY_GROUP)) && intval($this->entity_id) > 0 ) { $entity_type = $this->entity_type; $entity_id = $this->entity_id; $alias = ($this->entity_type == SONET_ENTITY_GROUP ? "group" : "user")."_".$this->entity_id; } $arLogParams = array( "BLOG_ID" => intval($this->BlogID) ); $rsIBlock = CIBlock::GetByID($arElement["IBLOCK_ID"]); if($arIBlock = $rsIBlock->Fetch()) { $arLogParams["IBLOCK_ID"] = $arIBlock["ID"]; $arLogParams["IBLOCK_TYPE"] = $arIBlock["IBLOCK_TYPE_ID"]; } $rsSection = CIBlockSection::GetByID($arElement["IBLOCK_SECTION_ID"]); if ($arSection = $rsSection->Fetch()) { $arLogParams["SECTION_ID"] = $arSection["ID"]; $arLogParams["SECTION_NAME"] = $arSection["NAME"]; $arLogParams["SECTION_URL"] = str_replace("#SECTION_ID#", $arSection["ID"], $this->arPath["SECTION_URL"]); if (!$alias) { $arSectionPath = array(); $rsPath = CIBlockSection::GetNavChain($arLogParams["IBLOCK_ID"], intval($arLogParams["SECTION_ID"])); if($arPath = $rsPath->Fetch()) { $entity_type = SONET_ENTITY_USER; $entity_id = $arPath["CREATED_BY"]; $alias = $arPath["CODE"]; } } } $arLogParams["ALIAS"] = $alias; $arSonetFields = array( "ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "photo_photo", "LOG_DATE" => $arElement["TIMESTAMP_X"], "TITLE_TEMPLATE" => str_replace("#AUTHOR_NAME#", $sAuthorName, GetMessage("SONET_PHOTOPHOTO_LOG_1")), "TITLE" => $arElement["NAME"], "MESSAGE" => "", "TEXT_MESSAGE" => "", "URL" => CComponentEngine::MakePathFromTemplate($url, array( "ELEMENT_ID" => $arElement["ID"], "element_id" => $arElement["ID"], "SECTION_ID" => $arElement["IBLOCK_SECTION_ID"], "section_id" => $arElement["IBLOCK_SECTION_ID"] )), "MODULE_ID" => false, "CALLBACK_FUNC" => false, "SOURCE_ID" => $arElement["ID"], "PARAMS" => serialize($arLogParams), "RATING_TYPE_ID" => "IBLOCK_ELEMENT", "RATING_ENTITY_ID"=> $arElement["ID"], ); if (intval($arElement["CREATED_BY"]) > 0) $arSonetFields["USER_ID"] = $arElement["CREATED_BY"]; $log_id = CSocNetLog::Add($arSonetFields, false); if (intval($log_id) > 0) { CSocNetLog::Update($log_id, array("TMP_ID" => $log_id)); CSocNetLogRights::SetForSonet($log_id, $entity_type, $entity_id, "photo", "view", true); } } } if (intval($log_id) > 0) { $parserBlog = new blogTextParser(false, $this->arPath["PATH_TO_SMILE"]); $arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "N"); if ($bSocNetLogRecordExists) { $text4message = $parserBlog->convert($arFields["POST_TEXT"], true, array(), $arAllow); $text4mail = $parserBlog->convert4mail($arFields["POST_TEXT"]); $arFieldsForSocnet = array( "ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "photo_comment", "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE" => $text4message, "TEXT_MESSAGE" => $text4mail, "MODULE_ID" => false, "SOURCE_ID" => $ID, "LOG_ID" => $log_id, "RATING_TYPE_ID" => "BLOG_COMMENT", "RATING_ENTITY_ID" => $ID, ); if (intval($arFields["AUTHOR_ID"]) > 0) $arFieldsForSocnet["USER_ID"] = $arFields["AUTHOR_ID"]; CSocNetLogComments::Add($arFieldsForSocnet); } else //socnetlog record didn't exist - adding all comments { $dbComments = CBlogComment::GetList(array(), array( "BLOG_ID" => intval($this->BlogID), "POST_ID" => intval($this->PostID) ), false, false, array("ID", "BLOG_ID", "POST_ID", "AUTHOR_ID", "POST_TEXT", "DATE_CREATE") ); while ($arComment = $dbComments->GetNext()) { $text4message = $parserBlog->convert($arComment["POST_TEXT"], true, array(), $arAllow); $text4mail = $parserBlog->convert4mail($arComment["POST_TEXT"]); $arFieldsForSocnet = array( "ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "photo_comment", "=LOG_DATE" => $GLOBALS["DB"]->CharToDateFunction($arComment["DATE_CREATE"], "FULL", SITE_ID), "MESSAGE" => $text4message, "TEXT_MESSAGE" => $text4mail, "MODULE_ID" => false, "SOURCE_ID" => intval($arComment["ID"]), "LOG_ID" => $log_id, "RATING_TYPE_ID" => "BLOG_COMMENT", "RATING_ENTITY_ID" => intval($arComment["ID"]), ); if (intval($arFields["AUTHOR_ID"]) > 0) $arFieldsForSocnet["USER_ID"] = $arFields["AUTHOR_ID"]; CSocNetLogComments::Add($arFieldsForSocnet); } } } } }