Пример #1
0
                    CBlogPostCategory::Add(array("BLOG_ID" => $arBlog["ID"], "POST_ID" => $newID, "CATEGORY_ID" => $key));
                }
                BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"]);
                BXClearCache(True, "/" . SITE_ID . "/blog/last_messages/");
                BXClearCache(True, "/" . SITE_ID . "/blog/groups/" . $arBlog["GROUP_ID"] . "/");
                $iCommentID = $newID;
                CIBlockElement::SetPropertyValues($arResult["ELEMENT"]["ID"], $arParams["IBLOCK_ID"], $iCommentID, "BLOG_POST_ID");
            }
        }
        $arResult["COMMENT_ID"] = $iCommentID;
        if ($arParams["CACHE_TIME"] > 0) {
            $cache->StartDataCache($arParams["CACHE_TIME"], $cache_id, $cache_path);
            $cache->EndDataCache(array("COMMENT_ID" => $arResult["COMMENT_ID"], "ELEMENT" => $arResult["ELEMENT"]));
        }
    }
    /*************************************************************************
    					/Caching
    	*************************************************************************/
    if (class_exists('CSocNetPhotoCommentEvent')) {
        $obPhotoCommentEventHandler = new CSocNetPhotoCommentEvent();
        $obPhotoCommentEventHandler->SetVars($arParams, $arResult);
        if (method_exists($obPhotoCommentEventHandler, "OnAfterPhotoCommentAddBlog")) {
            AddEventHandler("blog", "OnCommentAdd", array($obPhotoCommentEventHandler, "OnAfterPhotoCommentAddBlog"));
        }
        if (method_exists($obPhotoCommentEventHandler, "OnAfterPhotoCommentDeleteBlog")) {
            AddEventHandler("blog", "OnCommentDelete", array($obPhotoCommentEventHandler, "OnAfterPhotoCommentDeleteBlog"));
        }
    }
}
CUtil::InitJSCore(array('window', 'ajax'));
$this->IncludeComponentTemplate();
Пример #2
0
 public static function getCommentRatingType($logEventId, $logId = false)
 {
     $res = "LOG_COMMENT";
     $arCommentEventMeta = CSocNetLogTools::FindLogCommentEventByLogEventID($logEventId);
     if ($arCommentEventMeta && isset($arCommentEventMeta["RATING_TYPE_ID"])) {
         $res = $arCommentEventMeta["RATING_TYPE_ID"];
     } elseif ($logEventId == "photo_photo" && intval($logId) > 0) {
         $commentType = CSocNetPhotoCommentEvent::FindLogType($logId);
         if ($commentType && isset($commentType["TYPE"])) {
             if ($commentType["TYPE"] == "FORUM") {
                 $res = "FORUM_POST";
             } elseif ($commentType["TYPE"] == "BLOG") {
                 $res = "BLOG_COMMENT";
             }
         }
     } elseif (in_array($logEventId, array("wiki", "calendar", "news", "lists_new_element", "timeman_entry", "report"))) {
         $res = "FORUM_POST";
     } elseif (in_array($logEventId, array("idea"))) {
         $res = "BLOG_COMMENT";
     }
     return $res;
 }
Пример #3
0
 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);
                 }
             }
         }
     }
 }
Пример #4
0
	function AddComment_Photo_Blog($arFields, $BLOG_ID, $arLog)
	{
		return CSocNetPhotoCommentEvent::AddComment_Photo_Blog($arFields, $BLOG_ID, $arLog);
	}