public static function CallBack_AddComment($arFields)
 {
     if (!CModule::IncludeModule('blog')) {
         return false;
     }
     $arResult = array();
     $arLog = CSocNetLog::GetList(array("ID" => "DESC"), array("TMP_ID" => $arFields["LOG_ID"]), false, false, array("ID", "SOURCE_ID", "SITE_ID", "RATING_ENTITY_ID"))->Fetch();
     if ($arLog) {
         $arIdeaPost = CBlogPost::GetById($arLog["SOURCE_ID"]);
         if ($arIdeaPost) {
             $UserIP = CBlogUser::GetUserIP();
             $IdeaCommentId = CBlogComment::Add(array("BLOG_ID" => $arIdeaPost["BLOG_ID"], "POST_ID" => $arIdeaPost["ID"], "AUTHOR_ID" => $arFields["USER_ID"], "POST_TEXT" => $arFields["MESSAGE"], "DATE_CREATE" => ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL"), "PARENT_ID" => false, "AUTHOR_IP" => $UserIP[0], "AUTHOR_IP1" => $UserIP[1]));
             $arResult = array("SOURCE_ID" => $IdeaCommentId);
             if ($arLog["RATING_ENTITY_ID"] > 0) {
                 $arResult["RATING_TYPE_ID"] = "BLOG_COMMENT";
                 $arResult["RATING_ENTITY_ID"] = $IdeaCommentId;
             }
             if (intval($IdeaCommentId) == 0) {
                 global $APPLICATION;
                 if ($ex = $APPLICATION->GetException()) {
                     $arResult["ERROR"] = $ex->GetString();
                 }
             } else {
                 //clear cache on succcess
                 BXClearCache(True, "/" . SITE_ID . "/idea/" . $arIdeaPost["BLOG_ID"] . "/first_page/");
                 BXClearCache(True, "/" . SITE_ID . "/idea/" . $arIdeaPost["BLOG_ID"] . "/pages/");
                 BXClearCache(True, "/" . SITE_ID . "/idea/" . $arIdeaPost["BLOG_ID"] . "/comment/" . $arIdeaPost["ID"] . "/");
                 BXClearCache(True, "/" . SITE_ID . "/idea/" . $arIdeaPost["BLOG_ID"] . "/post/" . $arIdeaPost["ID"] . "/");
             }
         }
     }
     return $arResult;
 }
Ejemplo n.º 2
0
         if (strlen($name) > 0) {
             if (strlen($link) > 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 (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"));
Ejemplo n.º 3
0
 } else {
     $arFields["PARENT_ID"] = false;
 }
 if (strlen($_POST["comment"]) <= 0) {
     $strErrorMessage .= GetMessage("B_B_PC_NO_COMMENT") . "<br />";
 }
 if (strlen($strErrorMessage) <= 0) {
     $commentUrl = CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arParams["PATH_TO_POST"]), array("blog" => $arBlog["URL"], "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arParams["ALLOW_POST_CODE"]), "user_id" => $arBlog["OWNER_ID"], "group_id" => $arParams["SOCNET_GROUP_ID"]));
     $arFields["PATH"] = $commentUrl;
     if (strpos($arFields["PATH"], "?") !== false) {
         $arFields["PATH"] .= "&";
     } else {
         $arFields["PATH"] .= "?";
     }
     $arFields["PATH"] .= $arParams["COMMENT_ID_VAR"] . "=#comment_id###comment_id#";
     if ($commentID = CBlogComment::Add($arFields)) {
         //start custom, use UF binding ::@Idea
         if ($arResult["IDEA_MODERATOR"] && $_REQUEST["BIND_OFFICIAL_ANSWER"] == "Y") {
             // Bind offical answer
             CIdeaManagment::getInstance()->IdeaComment($commentID)->Bind();
         }
         if ($arResult["IDEA_MODERATOR"] && $_REQUEST["BIND_IDEA_STATUS"] != "") {
             CIdeaManagment::getInstance()->Idea($arPost["ID"])->SetStatus($_REQUEST["BIND_IDEA_STATUS"]);
             BXClearCache(True, '/' . SITE_ID . '/idea/statistic_list/');
         }
         /*end*/
         BXClearCache(True, "/" . SITE_ID . "/idea/" . $arBlog["ID"] . "/comment/" . $arPost["ID"] . "/");
         BXClearCache(True, "/" . SITE_ID . "/idea/" . $arBlog["ID"] . "/post/" . $arPost["ID"] . "/");
         BXClearCache(True, "/" . SITE_ID . "/idea/" . $arBlog["ID"] . "/first_page/");
         BXClearCache(True, "/" . SITE_ID . "/idea/" . $arBlog["ID"] . "/pages/");
         $AuthorName = CBlogUser::GetUserName($arResult["BlogUser"]["~ALIAS"], $arResult["arUser"]["~NAME"], $arResult["arUser"]["~LAST_NAME"], $arResult["arUser"]["~LOGIN"]);
Ejemplo n.º 4
0
$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"]));
Ejemplo n.º 5
0
 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);
             }
         }
     }
 }
Ejemplo n.º 6
0
 public static function AddComment_Photo_Blog($arFields, $BLOG_ID, $arLog)
 {
     if (!CModule::IncludeModule("blog")) {
         return false;
     }
     if (!CModule::IncludeModule("iblock")) {
         return false;
     }
     $arElement = false;
     $arFilter = array("ID" => $arLog["SOURCE_ID"]);
     $arSelectedFields = array("IBLOCK_ID", "ID", "NAME", "TAGS", "CODE", "IBLOCK_SECTION_ID", "DETAIL_PAGE_URL", "CREATED_BY", "PREVIEW_PICTURE", "PREVIEW_TEXT", "PROPERTY_BLOG_POST_ID", "PROPERTY_BLOG_COMMENT_CNT", "PROPERTY_REAL_PICTURE");
     $db_res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelectedFields);
     if ($db_res && ($res = $db_res->GetNext())) {
         $arElement = $res;
     }
     if ($arElement) {
         // check iblock properties
         $ELEMENT_BLOG_POST_ID = CSocNetLogTools::AddComment_Review_CheckIBlock_Blog($arElement);
         if ($ELEMENT_BLOG_POST_ID <= 0) {
             // Add Post
             $POST_ID = CSocNetLogTools::AddComment_Review_CreateRoot_Blog($arElement, $BLOG_ID);
             $bNewPost = true;
         } else {
             $POST_ID = $ELEMENT_BLOG_POST_ID;
         }
         if (intval($POST_ID) > 0) {
             // Add comment
             $commentID = false;
             $UserIP = CBlogUser::GetUserIP();
             $arFieldsComment = array("POST_ID" => $POST_ID, "BLOG_ID" => $BLOG_ID, "POST_TEXT" => trim($arFields["TEXT_MESSAGE"]), "DATE_CREATE" => ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL"), "AUTHOR_IP" => $UserIP[0], "AUTHOR_IP1" => $UserIP[1], "PARENT_ID" => false);
             if ($GLOBALS["USER"]->IsAuthorized()) {
                 $arFieldsComment["AUTHOR_ID"] = $GLOBALS["USER"]->GetID();
             }
             $commentID = CBlogComment::Add($arFieldsComment);
             if (!$commentID) {
                 $strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
             } else {
                 CSocNetLogTools::AddComment_Review_UpdateElement_Blog($arElement, $POST_ID, $BLOG_ID, $bNewPost);
             }
         } else {
             $strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
         }
     } else {
         $strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
     }
     return array("SOURCE_ID" => $commentID, "RATING_TYPE_ID" => "BLOG_COMMENT", "RATING_ENTITY_ID" => $commentID, "ERROR" => $strError, "NOTES" => "", "IM_MESSAGE" => $arFieldsComment ? $arFieldsComment["POST_TEXT"] : false);
 }
Ejemplo n.º 7
0
 function AddComment_Microblog($arFields)
 {
     if (!CModule::IncludeModule("blog")) {
         return false;
     }
     $dbResult = CSocNetLog::GetList(array(), array("ID" => $arFields["LOG_ID"]), false, false, array("ID", "SOURCE_ID", "SITE_ID"));
     if ($arLog = $dbResult->Fetch()) {
         $arPost = CBlogPost::GetByID($arLog["SOURCE_ID"]);
         if ($arPost) {
             $arBlog = CBlog::GetByID($arPost["BLOG_ID"]);
             $userID = $GLOBALS["USER"]->GetID();
             $arLogSites = array();
             $rsLogSite = CSocNetLog::GetSite($arLog["ID"]);
             while ($arLogSite = $rsLogSite->Fetch()) {
                 $arLogSites[] = $arLogSite["LID"];
             }
             $bCurrentUserIsAdmin = CSocNetUser::IsCurrentUserModuleAdmin($arLogSites);
             $strPermission = BLOG_PERMS_DENY;
             $strPostPermission = BLOG_PERMS_DENY;
             if ($arFields["ENTITY_TYPE"] == SONET_ENTITY_GROUP) {
                 if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "full_post", $bCurrentUserIsAdmin)) {
                     $strPostPermission = BLOG_PERMS_FULL;
                 } elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "premoderate_post")) {
                     $strPostPermission = BLOG_PERMS_PREMODERATE;
                 } elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "write_post")) {
                     $strPostPermission = BLOG_PERMS_WRITE;
                 } elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "moderate_post")) {
                     $strPostPermission = BLOG_PERMS_MODERATE;
                 } elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "view_post")) {
                     $strPostPermission = BLOG_PERMS_READ;
                 }
                 if ($strPostPermission > BLOG_PERMS_DENY) {
                     if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "full_comment", $bCurrentUserIsAdmin)) {
                         $strPermission = BLOG_PERMS_FULL;
                     } elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "moderate_comment")) {
                         $strPermission = BLOG_PERMS_MODERATE;
                     } elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "write_comment")) {
                         $strPermission = BLOG_PERMS_WRITE;
                     } elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "premoderate_comment")) {
                         $strPermission = BLOG_PERMS_PREMODERATE;
                     } elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "view_comment")) {
                         $strPermission = BLOG_PERMS_READ;
                     }
                 }
             } else {
                 if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "full_post", $bCurrentUserIsAdmin) || $GLOBALS["APPLICATION"]->GetGroupRight("blog") >= "W" || $arParams["USER_ID"] == $user_id) {
                     $strPostPermission = BLOG_PERMS_FULL;
                 } elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "moderate_post")) {
                     $strPostPermission = BLOG_PERMS_MODERATE;
                 } elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "write_post")) {
                     $strPostPermission = BLOG_PERMS_WRITE;
                 } elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "premoderate_post")) {
                     $strPostPermission = BLOG_PERMS_PREMODERATE;
                 } elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "view_post")) {
                     $strPostPermission = BLOG_PERMS_READ;
                 }
                 if ($strPostPermission > BLOG_PERMS_DENY) {
                     if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "full_comment", $bCurrentUserIsAdmin) || $GLOBALS["APPLICATION"]->GetGroupRight("blog") >= "W" || $arParams["USER_ID"] == $user_id) {
                         $strPermission = BLOG_PERMS_FULL;
                     } elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "moderate_comment")) {
                         $strPermission = BLOG_PERMS_MODERATE;
                     } elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "write_comment")) {
                         $strPermission = BLOG_PERMS_WRITE;
                     } elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "premoderate_comment")) {
                         $strPermission = BLOG_PERMS_PREMODERATE;
                     } elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "view_comment")) {
                         $strPermission = BLOG_PERMS_READ;
                     }
                 }
             }
             $UserIP = CBlogUser::GetUserIP();
             $path_to_post = $arFields["ENTITY_TYPE"] == SONET_ENTITY_GROUP ? $arFields["PATH_TO_GROUP_MICROBLOG_POST"] : $arFields["PATH_TO_USER_MICROBLOG_POST"];
             $arFieldsComment = array("POST_ID" => $arPost["ID"], "BLOG_ID" => $arBlog["ID"], "POST_TEXT" => $arFields["TEXT_MESSAGE"], "DATE_CREATE" => ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL"), "AUTHOR_IP" => $UserIP[0], "AUTHOR_IP1" => $UserIP[1], "AUTHOR_ID" => $userID, "PARENT_ID" => false);
             if ($strPermission == BLOG_PERMS_PREMODERATE) {
                 $arFieldsComment["PUBLISH_STATUS"] = BLOG_PUBLISH_STATUS_READY;
                 $strNotes = GetMessage("SONET_GL_ADD_COMMENT_BLOG_PREMODERATE");
             }
             $commentUrl = CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($path_to_post), array("blog" => $arBlog["URL"], "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arFields["BLOG_ALLOW_POST_CODE"]), "user_id" => $arBlog["OWNER_ID"], "group_id" => $arFields["ENTITY_TYPE"] == SONET_ENTITY_GROUP ? $arFields["ENTITY_ID"] : false));
             $arFieldsComment["PATH"] = $commentUrl . (strpos($arFieldsComment["PATH"], "?") !== false ? "&" : "?") . "commentId=#comment_id###comment_id#";
             $commentId = CBlogComment::Add($arFieldsComment);
             if ($strPermission == BLOG_PERMS_PREMODERATE) {
                 unset($commentId);
             }
             BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/comment/" . $arPost["ID"] . "/");
             BXClearCache(True, "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/post/" . $arPost["ID"] . "/");
             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/" . $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/");
         } else {
             $strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
         }
     }
     return array("SOURCE_ID" => $commentId, "RATING_TYPE_ID" => "BLOG_COMMENT", "RATING_ENTITY_ID" => $commentId, "ERROR" => $strError, "NOTES" => $strNotes);
 }
Ejemplo n.º 8
0
 function __blog_add_comments($arComments, $parentID, $arParams)
 {
     if (!is_array($arComments) || empty($arComments)) {
         return;
     }
     foreach ($arComments as $res) {
         $__arComments = array();
         if (!empty($res["COMMENTS"])) {
             $__arComments = $res["COMMENTS"];
         }
         $arComment = array("POST_TEXT" => $res["TEXT"], "BLOG_ID" => $arParams["blogID"], "POST_ID" => $arParams["postID"], "PARENT_ID" => $parentID, "AUTHOR_ID" => $arParams["ownerID"], "AUTHOR_NAME" => $res["AUTHOR"], "DATE_CREATE" => ConvertTimeStamp(false, "FULL"), "AUTHOR_IP" => "192.168.0.108", "PERMS_P" => array(), "PERMS_C" => array());
         if (!empty($res["AUTHOR"])) {
             unset($arComment["AUTHOR_ID"]);
         }
         $parentID = CBlogComment::Add($arComment);
         if ($parentID <= 0) {
             continue;
         }
         if (!empty($__arComments)) {
             __blog_add_comments($__arComments, $parentID, $arParams);
         }
     }
 }
Ejemplo n.º 9
0
<?php

if (CModule::IncludeModule("blog")) {
    $arComments = array();
    $dbLogComment = CSocNetLogComments::GetList(array("LOG_DATE" => "ASC"), array("EVENT_ID" => "blog_comment_micro", "SOURCE_ID" => false), false, false, array("ID", "LOG_SOURCE_ID", "USER_ID", "TEXT_MESSAGE", "LOG_DATE"));
    while ($arLogComment = $dbLogComment->Fetch()) {
        $arPost = CBlogPost::GetByID($arLogComment["LOG_SOURCE_ID"]);
        if ($arPost) {
            $arBlog = CBlog::GetByID($arPost["BLOG_ID"]);
            $arFieldsComment = array("POST_ID" => $arPost["ID"], "BLOG_ID" => $arBlog["ID"], "POST_TEXT" => $arLogComment["TEXT_MESSAGE"], "DATE_CREATE" => $arLogComment["LOG_DATE"], "AUTHOR_ID" => $arLogComment["USER_ID"], "PARENT_ID" => false);
            $commentId = CBlogComment::Add($arFieldsComment);
            $arComments[$arLogComment["ID"]] = $commentId;
        }
    }
    foreach ($arComments as $log_comment_id => $blog_comment_id) {
        CSocNetLogComments::Update($log_comment_id, array("SOURCE_ID" => $blog_comment_id));
    }
}
Ejemplo n.º 10
0
 if (!$strError) {
     if (isset($arFileStorage["DISC_FOLDER"])) {
         $commentText = "[DISK FILE ID=n" . $arSaveResult["ID"] . "]";
     } elseif (isset($arFileStorage["WEBDAV_DATA"])) {
         $commentText = "[DOCUMENT ID=" . $arSaveResult["ID"] . "]";
     } else {
         $commentText = ".";
     }
     $UserIP = CBlogUser::GetUserIP();
     $arCommentFields = array("POST_ID" => $post_id, "BLOG_ID" => $arBlogPost["BLOG_ID"], "TITLE" => "", "POST_TEXT" => $commentText, "DATE_CREATE" => ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL"), "AUTHOR_IP" => $UserIP[0], "AUTHOR_IP1" => $UserIP[1], "URL" => $arBlog["URL"], "PARENT_ID" => false, "AUTHOR_ID" => $GLOBALS["USER"]->GetId(), $ufCode => array(isset($arFileStorage["DISC_FOLDER"]) ? "n" . $arSaveResult["ID"] : $arSaveResult["ID"]));
     if ($perm == BLOG_PERMS_PREMODERATE) {
         $arCommentFields["PUBLISH_STATUS"] = BLOG_PUBLISH_STATUS_READY;
     }
     $commentUrl = CComponentEngine::MakePathFromTemplate(COption::GetOptionString("socialnetwork", "userblogpost_page", false, SITE_ID), array("blog" => $arBlog["URL"], "post_id" => $arBlogPost["ID"], "user_id" => $arBlog["OWNER_ID"]));
     $arCommentFields["PATH"] = $commentUrl . (strpos($arCommentFields["PATH"], "?") !== false ? "&" : "?") . "commentId=#comment_id###comment_id#";
     if (!($commentId = CBlogComment::Add($arCommentFields))) {
         $strError = "Can't add blog comment";
     } else {
         BXClearCache(true, "/blog/comment/" . intval($arBlogPost["ID"] / 100) . "/" . $arBlogPost["ID"] . "/");
     }
 }
 if (!$strError) {
     BXClearCache(true, "/blog/comment/" . $post_id . "/");
     $GLOBALS["DB"]->Query("UPDATE b_blog_image SET COMMENT_ID=" . IntVal($commentId) . " WHERE BLOG_ID=" . IntVal($arBlogPost["BLOG_ID"]) . " AND POST_ID=" . IntVal($post_id) . " AND IS_COMMENT = 'Y' AND (COMMENT_ID = 0 OR COMMENT_ID is null) AND USER_ID=" . IntVal($GLOBALS["USER"]->GetId()) . "", true);
     if ($arCommentFields["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH && strlen($arCommentFields["PUBLISH_STATUS"]) > 0) {
         $strError = "Blog comment hasn't been published";
     }
 }
 if (!$strError) {
     $rsLog = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => array("blog_post", "blog_post_important"), "SOURCE_ID" => $post_id), false, false, array("ID"));
     if (!($arLog = $rsLog->Fetch())) {
Ejemplo n.º 11
0
    $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($arBlogPostFields["DETAIL_TEXT"], true, array(), $arAllow);
    $arSoFields = array("EVENT_ID" => "blog_post", "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "TITLE_TEMPLATE" => "#USER_NAME# " . GetMessage("BPC_SONET_POST_TITLE"), "TITLE" => $arBlogPostFields["TITLE"], "MESSAGE" => $text4message, "TEXT_MESSAGE" => $arBlogPostFields["DETAIL_TEXT"], "MODULE_ID" => "blog", "CALLBACK_FUNC" => false, "ENTITY_TYPE" => "U", "ENTITY_ID" => 1, "URL" => CComponentEngine::MakePathFromTemplate(WIZARD_SITE_DIR . "company/personal/user/#user_id#/blog/#post_id#/", array("user_id" => 1, "post_id" => $postID)), "USER_ID" => 1, "SITE_ID" => WIZARD_SITE_ID, "SOURCE_ID" => $postID, "ENABLE_COMMENTS" => "Y", "RATING_TYPE_ID" => "BLOG_POST", "RATING_ENTITY_ID" => $postID);
    $logID = CSocNetLog::Add($arSoFields, false);
    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));
Ejemplo n.º 12
0
    if (IsModuleInstalled("socialnetwork")) {
        $rsUser = CUser::GetByID(1);
        $arUser = $rsUser->Fetch();
        $blogID = CBlog::Add(array("NAME" => GetMessage("BLG_NAME") . " " . $arUser["NAME"] . " " . $arUser["LAST_NAME"], "DESCRIPTION" => "", "GROUP_ID" => $SocNetGroupID, "ENABLE_IMG_VERIF" => 'Y', "EMAIL_NOTIFY" => 'Y', "USE_SOCNET" => 'Y', "ENABLE_RSS" => "Y", "ALLOW_HTML" => "Y", "URL" => str_replace(" ", "_", $arUser["LOGIN"]) . "-blog", "ACTIVE" => "Y", "=DATE_CREATE" => $DB->GetNowFunction(), "=DATE_UPDATE" => $DB->GetNowFunction(), "OWNER_ID" => 1, "PERMS_POST" => array("1" => BLOG_PERMS_READ, "2" => BLOG_PERMS_READ), "PERMS_COMMENT" => array("1" => BLOG_PERMS_WRITE, "2" => BLOG_PERMS_WRITE)));
        CBlog::AddSocnetRead($blogID);
        $categoryID[] = CBlogCategory::Add(array("BLOG_ID" => $blogID, "NAME" => GetMessage("BLOG_DEMO_CATEGORY_1")));
        $categoryID[] = CBlogCategory::Add(array("BLOG_ID" => $blogID, "NAME" => GetMessage("BLOG_DEMO_CATEGORY_2")));
        $postID = CBlogPost::Add(array("TITLE" => GetMessage("BLOG_DEMO_MESSAGE_TITLE_1"), "DETAIL_TEXT" => str_replace('[IMG ID=1]', "[IMG ID=2]", GetMessage("BLOG_DEMO_MESSAGE_BODY_1")), "DETAIL_TEXT_TYPE" => "text", "BLOG_ID" => $blogID, "AUTHOR_ID" => 1, "=DATE_CREATE" => $DB->GetNowFunction(), "=DATE_PUBLISH" => $DB->GetNowFunction(), "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH, "ENABLE_TRACKBACK" => 'N', "ENABLE_COMMENTS" => 'Y', "CATEGORY_ID" => implode(",", $categoryID), "PERMS_P" => array(1 => BLOG_PERMS_READ, 2 => BLOG_PERMS_READ), "PERMS_C" => array(1 => BLOG_PERMS_WRITE, 2 => BLOG_PERMS_WRITE)));
        foreach ($categoryID as $v) {
            CBlogPostCategory::Add(array("BLOG_ID" => $blogID, "POST_ID" => $postID, "CATEGORY_ID" => $v));
        }
        $arImage = CFile::MakeFileArray(dirname(__FILE__) . '/images/' . GetMessage("BLOG_DEMO_IMG"));
        $arImage["MODULE_ID"] = "blog";
        $arFields = array("BLOG_ID" => $blogID, "POST_ID" => $postID, "USER_ID" => 1, "=TIMESTAMP_X" => $DB->GetNowFunction(), "TITLE" => GetMessage("BLOG_DEMO_IMG_TITLE"), "IMAGE_SIZE" => $arImage["size"], "FILE_ID" => $arImage);
        CBlogImage::Add($arFields);
        CBlogComment::Add(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", "PERMS_P" => array(), "PERMS_C" => array()));
    }
}
DemoSiteUtil::AddMenuItem("/communication/.left.menu.php", array(GetMessage("BLOG_DEMO_LEFT_MENU_1"), "/communication/blog/", array(), array(), ""));
/*
DemoSiteUtil::AddMenuItem("/communication/blog/.left.menu.php", Array(
	GetMessage("BLOG_DEMO_LEFT_MENU_2"), 
	"/communication/blog/index.php", 
	Array(), 
	Array(), 
	"" 
));	
*/
$source_base = dirname(__FILE__);
CopyDirFiles($source_base . "/public/" . $LID, $_SERVER["DOCUMENT_ROOT"] . "/communication/blog", true, true);
if (!function_exists("file_get_contents")) {