示例#1
0
function socialnetworkBlogPostCommentMobile(array $comment, array $arParams, array $arResult, SocialnetworkBlogPostComment $component)
{
    global $APPLICATION;
    $arParams["AVATAR_SIZE"] = intval($arParams["AVATAR_SIZE"]) ?: 58;
    $arAvatarSizes = array("AVATAR_SIZE" => intval(array_key_exists("AVATAR_SIZE_COMMON", $arParams) ? $arParams["AVATAR_SIZE_COMMON"] : $arParams["AVATAR_SIZE"]), "AVATAR_SIZE_COMMENT" => intval($arParams["AVATAR_SIZE_COMMENT"]));
    $arAvatarSizes["AVATAR_SIZE"] = $arAvatarSizes["AVATAR_SIZE"] > 0 ? $arAvatarSizes["AVATAR_SIZE"] : 42;
    // reference to CBlogUser::GetUserInfoArray
    $arAvatarSizes["AVATAR_SIZE_COMMENT"] = $arAvatarSizes["AVATAR_SIZE_COMMENT"] > 0 ? $arAvatarSizes["AVATAR_SIZE_COMMENT"] : 42;
    // reference to CBlogUser::GetUserInfoArray
    $avatarKey = "PERSONAL_PHOTO_RESIZED";
    if ($arAvatarSizes["AVATAR_SIZE"] == $arParams["AVATAR_SIZE"]) {
        $avatarKey = "PERSONAL_PHOTO_resized";
    } else {
        if ($arAvatarSizes["AVATAR_SIZE_COMMENT"] == $arParams["AVATAR_SIZE"]) {
            $avatarKey = "PERSONAL_PHOTO_resized_30";
        }
    }
    $arUser = $arResult["userCache"][$comment["AUTHOR_ID"]];
    if (!array_key_exists($avatarKey, $arUser) && intval($arUser["PERSONAL_PHOTO"]) > 0) {
        $arResult["userCache"][$comment["AUTHOR_ID"]][$avatarKey] = CFile::ResizeImageGet($arUser["PERSONAL_PHOTO"], array("width" => $arParams["AVATAR_SIZE"], "height" => $arParams["AVATAR_SIZE"]), BX_RESIZE_IMAGE_EXACT);
        $arUser = $arResult["userCache"][$comment["AUTHOR_ID"]];
    }
    $text = $comment["TextFormated"];
    if ($component->isWeb()) {
        static $parser = null;
        if ($parser == null) {
            $parser = new blogTextParser(false, $arParams["PATH_TO_SMILE"]);
            $parser->bMobile = true;
            $parser->LAZYLOAD = isset($arParams["LAZYLOAD"]) && $arParams["LAZYLOAD"] == "Y" ? "Y" : "N";
        }
        if (is_array($comment["COMMENT_PROPERTIES"]["DATA"]["UF_BLOG_COMMENT_FILE"])) {
            $parser->arUserfields = array("UF_BLOG_COMMENT_FILE" => array_merge($comment["COMMENT_PROPERTIES"]["DATA"]["UF_BLOG_COMMENT_FILE"], array("TAG" => "DOCUMENT ID")));
        }
        $text = $parser->convert($comment["POST_TEXT"], false, $comment["showedImages"], array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => COption::GetOptionString("blog", "allow_video", "Y") != "Y" || $arParams["ALLOW_VIDEO"] != "Y" ? "N" : "Y", "SHORT_ANCHOR" => "Y"), array("pathToUser" => "/mobile/users/?user_id=#user_id#"));
    }
    $res = 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" => !empty($comment["DATE_CREATE_TS"]) ? $comment["DATE_CREATE_TS"] + $arResult["TZ_OFFSET"] : MakeTimeStamp($comment["DATE_CREATE"]) - $arResult["TZ_OFFSET"], "AUTHOR" => array("ID" => $arUser["ID"], "NAME" => $arUser["~NAME"], "LAST_NAME" => $arUser["~LAST_NAME"], "SECOND_NAME" => $arUser["~SECOND_NAME"], "AVATAR" => array_key_exists($avatarKey, $arUser) ? $arUser[$avatarKey]["src"] : ''), "FILES" => false, "UF" => false, "POST_MESSAGE_TEXT" => $text, "~POST_MESSAGE_TEXT" => $comment["POST_TEXT"], "CLASSNAME" => "", "BEFORE_HEADER" => "", "BEFORE_ACTIONS" => "", "AFTER_ACTIONS" => "", "AFTER_HEADER" => "", "BEFORE" => "", "AFTER" => "", "BEFORE_RECORD" => "", "AFTER_RECORD" => "");
    if (!empty($arResult["arImages"][$comment["ID"]])) {
        $res["FILES"] = array();
        foreach ($arResult["arImages"][$comment["ID"]] as $i => $val) {
            $t = $arResult["Images"][$i];
            $res["FILES"][] = array("THUMBNAIL" => $val["small"], "SRC" => $val["full"], "FILE_SIZE" => $t["source"]["size"], "CONTENT_TYPE" => "image/xyz", "ORIGINAL_NAME" => $t["fileName"], "FILE_NAME" => $t["fileName"]);
        }
    }
    if ($comment["COMMENT_PROPERTIES"]["SHOW"] == "Y") {
        $res["UF"] = $comment["COMMENT_PROPERTIES"]["DATA"];
        foreach ($res["UF"] as $key => $arPostField) {
            if (!empty($arPostField["VALUE"])) {
                $res["UF"][$key]['POST_ID'] = $arParams['POST_DATA']['ID'];
                $res["UF"][$key]['URL_TO_POST'] = str_replace('#source_post_id#', $arPostField['POST_ID'], $arResult['urlToPost']);
            }
        }
    }
    return $res;
}
示例#2
0
                 $arPostField["~EDIT_FORM_LABEL"] = $arPostField["EDIT_FORM_LABEL"];
                 $arComment["COMMENT_PROPERTIES"]["DATA"][$FIELD_NAME] = $arPostField;
                 if (!empty($arPostField["VALUE"])) {
                     $bHasProps = true;
                 }
             }
         }
         if (!empty($arComment["COMMENT_PROPERTIES"]["DATA"])) {
             $arComment["COMMENT_PROPERTIES"]["SHOW"] = "Y";
         }
     }
 }
 if (is_array($arComment["COMMENT_PROPERTIES"]["DATA"]["UF_BLOG_COMMENT_FILE"])) {
     $p->arUserfields = array("UF_BLOG_COMMENT_FILE" => array_merge($arComment["COMMENT_PROPERTIES"]["DATA"]["UF_BLOG_COMMENT_FILE"], array("TAG" => "DOCUMENT ID")));
 }
 $arComment["TextFormated"] = $p->convert($arComment["POST_TEXT"], false, $arImages, $arAllow, $arParserParams);
 if (is_array($arComment["COMMENT_PROPERTIES"]["DATA"]["UF_BLOG_COMMENT_FILE"]) && is_array($arComment["COMMENT_PROPERTIES"]["DATA"]["UF_BLOG_COMMENT_FILE"]["VALUE"]) && is_array($p->arUserfields["UF_BLOG_COMMENT_FILE"]["PARSED"])) {
     $arComment["COMMENT_PROPERTIES"]["DATA"]["UF_BLOG_COMMENT_FILE"]["VALUE"] = array_diff($arComment["COMMENT_PROPERTIES"]["DATA"]["UF_BLOG_COMMENT_FILE"]["VALUE"], $p->arUserfields["UF_BLOG_COMMENT_FILE"]["PARSED"]);
 }
 $arComment["showedImages"] = $p->showedImages;
 if (!empty($p->showedImages)) {
     foreach ($p->showedImages as $val) {
         if (!empty($arResult["arImages"][$arComment["ID"]][$val])) {
             unset($arResult["arImages"][$arComment["ID"]][$val]);
         }
     }
 }
 $arComment["DateFormated"] = FormatDateFromDB($arComment["DATE_CREATE"], $arParams["DATE_TIME_FORMAT"], true);
 $arComment["DATE_CREATE_DATE"] = FormatDateFromDB($arComment["DATE_CREATE"], FORMAT_DATE);
 if (strcasecmp(LANGUAGE_ID, 'EN') !== 0 && strcasecmp(LANGUAGE_ID, 'DE') !== 0) {
     $arComment["DateFormated"] = ToLower($arComment["DateFormated"]);
示例#3
0
}
if (!$SocNetGroupID) {
    $SocNetGroupID = CBlogGroup::Add(array("SITE_ID" => WIZARD_SITE_ID, "NAME" => "[" . WIZARD_SITE_ID . "] " . GetMessage("BLOG_DEMO_GROUP_SOCNET")));
}
$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-" . WIZARD_SITE_ID, "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")));
$arBlogPostFields = array("TITLE" => GetMessage("BLOG_DEMO_MESSAGE_TITLE_1"), "DETAIL_TEXT" => 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_POST" => array(1 => BLOG_PERMS_READ, 2 => BLOG_PERMS_READ), "PERMS_COMMENT" => array(1 => BLOG_PERMS_WRITE, 2 => BLOG_PERMS_WRITE), "SOCNET_RIGHTS" => array("UA"));
$postID = CBlogPost::Add($arBlogPostFields);
if (CModule::IncludeModule("socialnetwork")) {
    $parserBlog = new blogTextParser(false, "/bitrix/images/socialnetwork/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($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")) {
示例#4
0
             $arTmp["urlToPost"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_POST"], array("blog" => $arPost["BLOG_URL"], "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arParams["ALLOW_POST_CODE"]), "user_id" => $arPost["BLOG_OWNER_ID"]));
         }
         $arTmp["urlToAuthor"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arPost["AUTHOR_ID"]));
         $arTmp["AuthorName"] = CBlogUser::GetUserName($arPost["BLOG_USER_ALIAS"], $arPost["AUTHOR_NAME"], $arPost["AUTHOR_LAST_NAME"], $arPost["AUTHOR_LOGIN"]);
         if ($itemCnt == 0) {
             $arTmp["FIRST"] = "Y";
         }
         $text = preg_replace("#\\[img\\](.+?)\\[/img\\]#is", "", $arPost["~DETAIL_TEXT"]);
         $text = preg_replace("#\\[url(.+?)\\](.*?)\\[/url\\]#is", "\\2", $text);
         $text = preg_replace("#\\[video(.+?)\\](.+?)\\[/video\\]#is", "", $text);
         $text = preg_replace("#^(.+?)<cut[\\s]*(/>|>).*?\$#is", "\\1", $text);
         $text = preg_replace("#^(.+?)\\[cut[\\s]*(/\\]|\\]).*?\$#is", "\\1", $text);
         $text = preg_replace("#(\\[|<)(/?)(b|u|i|list|code|quote|url|img|color|font|/*)(.*?)(\\]|>)#is", "", $text);
         $text = TruncateText($text, $arParams["MESSAGE_LENGTH"]);
         $text1 = $text;
         $title = $p->convert($text1, true, false, array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N"));
         $text = $p->convert($text, true, false, array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "Y", "NL2BR" => "N"));
         $text = CBlogTools::DeleteDoubleBR($text);
         $arTmp["TEXT_FORMATED"] = $text;
         $arTmp["DATE_PUBLISH_FORMATED"] = FormatDate($arParams["DATE_TIME_FORMAT"], MakeTimeStamp($arTmp["DATE_PUBLISH"], CSite::GetDateFormat("FULL")));
         if ($arTmp["MICRO"] == "Y") {
             $arTmp["TITLE"] = TruncateText(str_replace(array("<br />", "<br>", "'", "&quot;", "&lt;", "&gt;"), "", $title), 60);
             $arTmp["~TITLE"] = htmlspecialcharsback($arTmp["TITLE"]);
         }
         $itemCnt++;
         $arResult[] = $arTmp;
         $ids[] = $arTmp["ID"];
     }
     $arResult["IDS"] = $ids;
 }
 if ($arParams["CACHE_TIME"] > 0) {
示例#5
0
 function UpdateLog($postID, $arPost, $arBlog, $arParams)
 {
     if (!CModule::IncludeModule('socialnetwork')) {
         return;
     }
     global $DB;
     $parserBlog = new blogTextParser(false, $arParams["PATH_TO_SMILE"]);
     preg_match("#^(.*?)<cut[\\s]*(/>|>).*?\$#is", $arPost["DETAIL_TEXT"], $arMatches);
     if (count($arMatches) <= 0) {
         preg_match("#^(.*?)\\[cut[\\s]*(/\\]|\\]).*?\$#is", $arPost["DETAIL_TEXT"], $arMatches);
     }
     if (count($arMatches) > 0) {
         $cut_suffix = "#CUT#";
     } else {
         $cut_suffix = "";
     }
     $arImages = array();
     $res = CBlogImage::GetList(array("ID" => "ASC"), array("POST_ID" => $postID, "BLOG_ID" => $arBlog["ID"], "IS_COMMENT" => "N"));
     while ($arImage = $res->Fetch()) {
         $arImages[$arImage['ID']] = $arImage['FILE_ID'];
     }
     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"], true, $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"], true, $arImages, $arAllow, array("isSonetLog" => true));
     }
     $text4message .= $cut_suffix;
     $arSoFields = array("TITLE_TEMPLATE" => "#USER_NAME# " . GetMessage("BLG_SONET_TITLE"), "TITLE" => $arPost["TITLE"], "MESSAGE" => $text4message, "TEXT_MESSAGE" => $text4mail, "ENABLE_COMMENTS" => array_key_exists("ENABLE_COMMENTS", $arPost) && $arPost["ENABLE_COMMENTS"] == "N" ? "N" : "Y", "=LOG_UPDATE" => 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());
     $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "blog_post", "SOURCE_ID" => $postID), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID"));
     if ($arRes = $dbRes->Fetch()) {
         CSocNetLog::Update($arRes["ID"], $arSoFields);
         $socnetPerms = CBlogPost::GetSocNetPermsCode($postID);
         if (!in_array("U" . $arPost["AUTHOR_ID"], $socnetPerms)) {
             $socnetPerms[] = "U" . $arPost["AUTHOR_ID"];
         }
         if (CModule::IncludeModule("extranet")) {
             $arSiteID = CExtranet::GetSitesByLogDestinations($socnetPerms);
             CSocNetLog::Update($arRes["ID"], array("SITE_ID" => $arSiteID));
         }
         $socnetPerms[] = "SA";
         // socnet admin
         CSocNetLogRights::DeleteByLogID($arRes["ID"]);
         CSocNetLogRights::Add($arRes["ID"], $socnetPerms);
     }
 }
示例#6
0
     if (!empty($arResult["POST_PROPERTIES"]["DATA"])) {
         $arResult["POST_PROPERTIES"]["SHOW"] = "Y";
     }
 }
 $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'];
     $arResult["images"][$arImage['ID']] = array("small" => "/bitrix/components/bitrix/blog/show_file.php?fid=" . $arImage['ID'] . "&width=70&height=70&type=square", "full" => "/bitrix/components/bitrix/blog/show_file.php?fid=" . $arImage['ID'] . "&width=1000&height=1000");
 }
 $arParserParams = array("imageWidth" => $arParams["IMAGE_MAX_WIDTH"], "imageHeight" => $arParams["IMAGE_MAX_HEIGHT"]);
 if ($arPost["DETAIL_TEXT_TYPE"] == "html" && COption::GetOptionString("blog", "allow_html", "N") == "Y") {
     $arAllow = array("HTML" => "Y", "ANCHOR" => "Y", "IMG" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "QUOTE" => "Y", "CODE" => "Y");
     if (COption::GetOptionString("blog", "allow_video", "Y") != "Y") {
         $arAllow["VIDEO"] = "N";
     }
     $arResult["Post"]["textFormated"] = $p->convert($arPost["~DETAIL_TEXT"], false, $arImages, $arAllow, $arParserParams);
 } else {
     $arAllow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y");
     if (COption::GetOptionString("blog", "allow_video", "Y") != "Y") {
         $arAllow["VIDEO"] = "N";
     }
     $arResult["Post"]["textFormated"] = $p->convert($arPost["~DETAIL_TEXT"], false, $arImages, $arAllow, $arParserParams);
 }
 if (!empty($p->showedImages)) {
     foreach ($p->showedImages as $val) {
         if (!empty($arResult["images"][$val])) {
             unset($arResult["images"][$val]);
         }
     }
 }
 $arResult["Post"]["DATE_PUBLISH_FORMATED"] = FormatDate($arParams["DATE_TIME_FORMAT"], MakeTimeStamp($arResult["Post"]["DATE_PUBLISH"], CSite::GetDateFormat("FULL")));
示例#7
0
 }
 $arAllow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y");
 if (COption::GetOptionString("blog", "allow_video", "Y") != "Y" || $arParams["ALLOW_VIDEO"] != "Y") {
     $arAllow["VIDEO"] = "N";
 }
 if ($arParams["NO_URL_IN_COMMENTS"] == "L" || IntVal($arComment["AUTHOR_ID"]) <= 0 && $arParams["NO_URL_IN_COMMENTS"] == "A") {
     $arAllow["CUT_ANCHOR"] = "Y";
 }
 if ($arParams["NO_URL_IN_COMMENTS_AUTHORITY_CHECK"] == "Y" && $arAllow["CUT_ANCHOR"] != "Y" && IntVal($arComment["AUTHOR_ID"]) > 0) {
     $authorityRatingId = CRatings::GetAuthorityRating();
     $arRatingResult = CRatings::GetRatingResult($authorityRatingId, $arComment["AUTHOR_ID"]);
     if ($arRatingResult["CURRENT_VALUE"] < $arParams["NO_URL_IN_COMMENTS_AUTHORITY"]) {
         $arAllow["CUT_ANCHOR"] = "Y";
     }
 }
 $arComment["TextFormated"] = $p->convert($arComment["~POST_TEXT"], false, array(), $arAllow, $arParserParams);
 $arComment["DateFormated"] = FormatDate($arParams["DATE_TIME_FORMAT"], MakeTimeStamp($arComment["DATE_CREATE"], CSite::GetDateFormat("FULL")));
 if ($bUseTitle) {
     if (strlen($arComment["TITLE"]) > 0) {
         $arComment["TitleFormated"] = $p->convert($arComment["TITLE"], false);
     }
     if (strpos($arComment["TITLE"], "RE") === false) {
         $subj = "RE: " . $arComment["TITLE"];
     } else {
         if (strpos($arComment["TITLE"], "RE") == 0) {
             if (strpos($arComment["TITLE"], "RE:") !== false) {
                 $count = substr_count($arComment["TITLE"], "RE:");
                 $subj = substr($arComment["TITLE"], strrpos($arComment["TITLE"], "RE:") + 4);
             } else {
                 if (strpos($arComment["TITLE"], "[") == 2) {
                     $count = substr($arComment["TITLE"], 3, strpos($arComment["TITLE"], "]: ") - 3);
示例#8
0
 function OnSearchReindex($NS = array(), $oCallback = NULL, $callback_method = "")
 {
     global $DB;
     $arResult = array();
     //CBlogSearch::Trace('OnSearchReindex', 'NS', $NS);
     if ($NS["MODULE"] == "blog" && strlen($NS["ID"]) > 0) {
         $category = substr($NS["ID"], 0, 1);
         $id = intval(substr($NS["ID"], 1));
     } else {
         $category = 'B';
         //start with blogs
         $id = 0;
         //very first id
     }
     //CBlogSearch::Trace('OnSearchReindex', 'category+id', array("CATEGORY"=>$category,"ID"=>$id));
     //Reindex blogs
     if ($category == 'B') {
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tb.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t,b.REAL_URL\n\t\t\t\t\t,b.URL\n\t\t\t\t\t," . $DB->DateToCharFunction("b.DATE_UPDATE") . " as DATE_UPDATE\n\t\t\t\t\t,b.NAME\n\t\t\t\t\t,b.DESCRIPTION\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,b.SOCNET_GROUP_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\tFROM\n\t\t\t\t\tb_blog b\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID)\n\t\t\t\tWHERE\n\t\t\t\t\tb.ACTIVE = 'Y'\n\t\t\t\t\tAND b.SEARCH_INDEX = 'Y'\n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? "AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND b.ID > " . $id . "\n\t\t\t\tORDER BY\n\t\t\t\t\tb.ID\n\t\t\t";
         //CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql);
         $rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         while ($ar = $rs->Fetch()) {
             if ($ar["USE_SOCNET"] == "Y") {
                 $Result = array("ID" => "B" . $ar["ID"], "BODY" => "", "TITLE" => "");
             } else {
                 //CBlogSearch::Trace('OnSearchReindex', 'ar', $ar);
                 $arSite = array($ar["SITE_ID"] => CBlog::PreparePath($ar["URL"], $ar["SITE_ID"], false, $ar["OWNER_ID"], $ar["SOCNET_GROUP_ID"]));
                 //CBlogSearch::Trace('OnSearchReindex', 'arSite', $arSite);
                 $Result = array("ID" => "B" . $ar["ID"], "LAST_MODIFIED" => $ar["DATE_UPDATE"], "TITLE" => $ar["NAME"], "BODY" => blogTextParser::killAllTags($ar["DESCRIPTION"]), "SITE_ID" => $arSite, "PARAM1" => "BLOG", "PARAM2" => $ar["OWNER_ID"], "PERMISSIONS" => array(2));
                 //CBlogSearch::Trace('OnSearchReindex', 'Result', $Result);
             }
             if ($oCallback) {
                 $res = call_user_func(array($oCallback, $callback_method), $Result);
                 if (!$res) {
                     return $Result["ID"];
                 }
             } else {
                 $arResult[] = $Result;
             }
         }
         //all blogs indexed so let's start index posts
         $category = 'P';
         $id = 0;
     }
     if ($category == 'P') {
         $arUser2Blog = array();
         if (COption::GetOptionString("blog", "socNetNewPerms", "N") == "N") {
             $dbB = CBlog::GetList(array(), array("USE_SOCNET" => "Y", "!OWNER_ID" => false), false, false, array("ID", "OWNER_ID", "USE_SOCNET", "GROUP_ID"));
             while ($arB = $dbB->Fetch()) {
                 $arUser2Blog[$arB["OWNER_ID"]][$arB["GROUP_ID"]] = $arB["ID"];
             }
         }
         $bSonet = false;
         if (IsModuleInstalled("socialnetwork")) {
             $bSonet = true;
         }
         $parserBlog = new blogTextParser(false, "/bitrix/images/blog/smile/");
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tbp.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t,b.REAL_URL\n\t\t\t\t\t,b.URL\n\t\t\t\t\t," . $DB->DateToCharFunction("bp.DATE_PUBLISH") . " as DATE_PUBLISH\n\t\t\t\t\t,bp.TITLE\n\t\t\t\t\t,bp.DETAIL_TEXT\n\t\t\t\t\t,bp.BLOG_ID\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,bp.CATEGORY_ID\n\t\t\t\t\t,b.SOCNET_GROUP_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\t\t,b.GROUP_ID\n\t\t\t\t\t,bp.PATH\n\t\t\t\t\t,bp.MICRO\n\t\t\t\t\t,bp.PUBLISH_STATUS\n\t\t\t\t\t,bp.AUTHOR_ID " . ($bSonet ? ", BSL.ID as SLID" : "") . " FROM\n\t\t\t\t\tb_blog_post bp\n\t\t\t\t\tINNER JOIN b_blog b ON (bp.BLOG_ID = b.ID)\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID) " . ($bSonet ? "LEFT JOIN b_sonet_log BSL ON (BSL.EVENT_ID in ('blog_post', 'blog_post_micro') AND BSL.SOURCE_ID = bp.ID) " : "") . " WHERE\n\t\t\t\t\tbp.DATE_PUBLISH <= " . $DB->CurrentTimeFunction() . "\n\t\t\t\t\tAND b.ACTIVE = 'Y'\n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? "AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND bp.ID > " . $id . "\n\t\t\t\t\t\n\t\t\t\tORDER BY\n\t\t\t\t\tbp.ID\n\t\t\t";
         /*		AND bp.PUBLISH_STATUS = '".$DB->ForSQL(BLOG_PUBLISH_STATUS_PUBLISH)."'*/
         //AND b.SEARCH_INDEX = 'Y'
         //CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql);
         $rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         while ($ar = $rs->Fetch()) {
             //Check permissions
             $tag = "";
             if ($ar["USE_SOCNET"] != "Y") {
                 $PostPerms = CBlogUserGroup::GetGroupPerms(1, $ar["BLOG_ID"], $ar["ID"], BLOG_PERMS_POST);
                 if ($PostPerms < BLOG_PERMS_READ) {
                     continue;
                 }
             }
             //CBlogSearch::Trace('OnSearchReindex', 'ar', $ar);
             if (strlen($ar["PATH"]) > 0) {
                 $arSite = array($ar["SITE_ID"] => str_replace("#post_id#", $ar["ID"], $ar["PATH"]));
             } else {
                 $arSite = array($ar["SITE_ID"] => CBlogPost::PreparePath($ar["URL"], $ar["ID"], $ar["SITE_ID"], false, $ar["OWNER_ID"], $ar["SOCNET_GROUP_ID"]));
             }
             if (strlen($ar["CATEGORY_ID"]) > 0) {
                 $arC = explode(",", $ar["CATEGORY_ID"]);
                 $tag = "";
                 $arTag = array();
                 foreach ($arC as $v) {
                     $arCategory = CBlogCategory::GetByID($v);
                     $arTag[] = $arCategory["NAME"];
                 }
                 $tag = implode(",", $arTag);
             }
             //CBlogSearch::Trace('OnSearchReindex', 'arSite', $arSite);
             $Result = array("ID" => "P" . $ar["ID"], "LAST_MODIFIED" => $ar["DATE_PUBLISH"], "TITLE" => blogTextParser::killAllTags($ar["TITLE"]), "BODY" => blogTextParser::killAllTags($ar["DETAIL_TEXT"]), "SITE_ID" => $arSite, "PARAM1" => "POST", "PARAM2" => $ar["BLOG_ID"], "PERMISSIONS" => array(2), "TAGS" => $tag, "USER_ID" => $ar["AUTHOR_ID"], "ENTITY_TYPE_ID" => "BLOG_POST", "ENTITY_ID" => $ar["ID"]);
             if ($ar["USE_SOCNET"] == "Y" && CModule::IncludeModule("socialnetwork")) {
                 $arF = array();
                 if (COption::GetOptionString("blog", "socNetNewPerms", "N") == "N") {
                     if (IntVal($ar["SOCNET_GROUP_ID"]) > 0) {
                         $newBlogId = 0;
                         if (IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]) > 0) {
                             $newBlogId = IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]);
                         } else {
                             $arFields = array("=DATE_UPDATE" => $DB->CurrentTimeFunction(), "GROUP_ID" => $ar["GROUP_ID"], "ACTIVE" => "Y", "ENABLE_COMMENTS" => "Y", "ENABLE_IMG_VERIF" => "Y", "EMAIL_NOTIFY" => "Y", "ENABLE_RSS" => "Y", "ALLOW_HTML" => "N", "ENABLE_TRACKBACK" => "N", "SEARCH_INDEX" => "Y", "USE_SOCNET" => "Y", "=DATE_CREATE" => $DB->CurrentTimeFunction(), "PERMS_POST" => array(1 => "I", 2 => "I"), "PERMS_COMMENT" => array(1 => "P", 2 => "P"));
                             $bRights = false;
                             $rsUser = CUser::GetByID($ar["AUTHOR_ID"]);
                             $arUser = $rsUser->Fetch();
                             if (strlen($arUser["NAME"] . "" . $arUser["LAST_NAME"]) <= 0) {
                                 $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["LOGIN"];
                             } else {
                                 $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["NAME"] . " " . $arUser["LAST_NAME"];
                             }
                             $arFields["URL"] = str_replace(" ", "_", $arUser["LOGIN"]) . "-blog-" . $ar["SITE_ID"];
                             $arFields["OWNER_ID"] = $ar["AUTHOR_ID"];
                             $urlCheck = preg_replace("/[^a-zA-Z0-9_-]/is", "", $arFields["URL"]);
                             if ($urlCheck != $arFields["URL"]) {
                                 $arFields["URL"] = "u" . $arUser["ID"] . "-blog-" . $ar["SITE_ID"];
                             }
                             if (CBlog::GetByUrl($arFields["URL"])) {
                                 $uind = 0;
                                 do {
                                     $uind++;
                                     $arFields["URL"] = $arFields["URL"] . $uind;
                                 } while (CBlog::GetByUrl($arFields["URL"]));
                             }
                             $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $ar["AUTHOR_ID"], "blog", "view_post");
                             if ($featureOperationPerms == SONET_RELATIONS_TYPE_ALL) {
                                 $bRights = true;
                             }
                             $blogID = CBlog::Add($arFields);
                             if ($bRights) {
                                 CBlog::AddSocnetRead($blogID);
                             }
                             $newBlogId = $blogID;
                             $arUser2Blog[$arFields["OWNER_ID"]][$arFields["GROUP_ID"]] = $newBlogId;
                         }
                         if (intVal($newBlogId) > 0) {
                             $arF = array("BLOG_ID" => $newBlogId, "SOCNET_RIGHTS" => array("SG" . $ar["SOCNET_GROUP_ID"]));
                         }
                         if (IntVal($ar["SLID"]) > 0) {
                             CSocNetLog::Delete($ar["SLID"]);
                             $ar["SLID"] = 0;
                         }
                         $arSites = array();
                         $rsGroupSite = CSocNetGroup::GetSite($ar["SOCNET_GROUP_ID"]);
                         while ($arGroupSite = $rsGroupSite->Fetch()) {
                             $arSites[] = $arGroupSite["LID"];
                         }
                     } else {
                         $newBlogId = 0;
                         if ($ar["OWNER_ID"] != $ar["AUTHOR_ID"]) {
                             if (IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]) > 0) {
                                 $newBlogId = IntVal($arUser2Blog[$ar["AUTHOR_ID"]][$ar["GROUP_ID"]]);
                             } else {
                                 $arFields = array("=DATE_UPDATE" => $DB->CurrentTimeFunction(), "GROUP_ID" => $ar["GROUP_ID"], "ACTIVE" => "Y", "ENABLE_COMMENTS" => "Y", "ENABLE_IMG_VERIF" => "Y", "EMAIL_NOTIFY" => "Y", "ENABLE_RSS" => "Y", "ALLOW_HTML" => "N", "ENABLE_TRACKBACK" => "N", "SEARCH_INDEX" => "Y", "USE_SOCNET" => "Y", "=DATE_CREATE" => $DB->CurrentTimeFunction(), "PERMS_POST" => array(1 => "I", 2 => "I"), "PERMS_COMMENT" => array(1 => "P", 2 => "P"));
                                 $bRights = false;
                                 $rsUser = CUser::GetByID($ar["AUTHOR_ID"]);
                                 $arUser = $rsUser->Fetch();
                                 if (strlen($arUser["NAME"] . "" . $arUser["LAST_NAME"]) <= 0) {
                                     $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["LOGIN"];
                                 } else {
                                     $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["NAME"] . " " . $arUser["LAST_NAME"];
                                 }
                                 $arFields["URL"] = str_replace(" ", "_", $arUser["LOGIN"]) . "-blog-" . $ar["SITE_ID"];
                                 $arFields["OWNER_ID"] = $ar["AUTHOR_ID"];
                                 $urlCheck = preg_replace("/[^a-zA-Z0-9_-]/is", "", $arFields["URL"]);
                                 if ($urlCheck != $arFields["URL"]) {
                                     $arFields["URL"] = "u" . $arUser["ID"] . "-blog-" . $ar["SITE_ID"];
                                 }
                                 if (CBlog::GetByUrl($arFields["URL"])) {
                                     $uind = 0;
                                     do {
                                         $uind++;
                                         $arFields["URL"] = $arFields["URL"] . $uind;
                                     } while (CBlog::GetByUrl($arFields["URL"]));
                                 }
                                 $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $ar["AUTHOR_ID"], "blog", "view_post");
                                 if ($featureOperationPerms == SONET_RELATIONS_TYPE_ALL) {
                                     $bRights = true;
                                 }
                                 $blogID = CBlog::Add($arFields);
                                 if ($bRights) {
                                     CBlog::AddSocnetRead($blogID);
                                 }
                                 $newBlogId = $blogID;
                                 $arUser2Blog[$arFields["OWNER_ID"]][$arFields["GROUP_ID"]] = $newBlogId;
                             }
                             if (IntVal($ar["SLID"]) > 0) {
                                 CSocNetLog::Delete($ar["SLID"]);
                                 $ar["SLID"] = 0;
                             }
                         }
                         $arF = array("SOCNET_RIGHTS" => array());
                         if (intVal($newBlogId) > 0) {
                             $arF["BLOG_ID"] = $newBlogId;
                         }
                         $arSites = array($ar["SITE_ID"]);
                     }
                     if (!empty($arF)) {
                         if (IntVal($arF["BLOG_ID"]) > 0) {
                             $Result["PARAM2"] = $ar["BLOG_ID"];
                             $sqlR = "UPDATE b_blog_post SET BLOG_ID=" . IntVal($arF["BLOG_ID"]) . " WHERE ID=" . IntVal($ar["ID"]);
                             $DB->Query($sqlR, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                             $sqlR = "UPDATE b_blog_post_category SET BLOG_ID=" . IntVal($arF["BLOG_ID"]) . " WHERE POST_ID=" . IntVal($ar["ID"]);
                             $DB->Query($sqlR, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                             $sqlR = "UPDATE b_blog_image SET BLOG_ID=" . IntVal($arF["BLOG_ID"]) . " WHERE POST_ID=" . IntVal($ar["ID"]);
                             $DB->Query($sqlR, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                             $sqlR = "UPDATE b_blog_comment SET BLOG_ID=" . IntVal($arF["BLOG_ID"]) . " WHERE POST_ID=" . IntVal($ar["ID"]);
                             $DB->Query($sqlR, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                         }
                         $sqlR = "SELECT * FROM b_blog_socnet_rights where POST_ID=" . IntVal($ar["ID"]);
                         $dbBB = $DB->Query($sqlR);
                         if (!$dbBB->Fetch()) {
                             $arF["SC_PERM"] = CBlogPost::UpdateSocNetPerms($ar["ID"], $arF["SOCNET_RIGHTS"], array("AUTHOR_ID" => $ar["AUTHOR_ID"]));
                         }
                         if (IntVal($arF["BLOG_ID"]) > 0 && $ar["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) {
                             $dbComment = CBlogComment::GetList(array(), array("POST_ID" => $ar["ID"]), false, false, array("ID", "POST_ID", "BLOG_ID", "PATH"));
                             if ($arComment = $dbComment->Fetch()) {
                                 $arParamsComment = array("BLOG_ID" => $arF["BLOG_ID"], "POST_ID" => $ar["ID"], "SITE_ID" => $ar["SITE_ID"], "PATH" => $arPostSite[$arGroup["SITE_ID"]] . "?commentId=#comment_id###comment_id#", "USE_SOCNET" => "Y");
                                 CBlogComment::_IndexPostComments($arParamsComment);
                             }
                         }
                     }
                 }
                 if ($ar["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) {
                     if (empty($arF["SC_PERM"])) {
                         $arF["SC_PERM"] = CBlogPost::GetSocNetPermsCode($ar["ID"]);
                     }
                     $Result["PERMISSIONS"] = $arF["SC_PERM"];
                     if (IntVal($ar["SLID"]) <= 0) {
                         $arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "TABLE" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "N");
                         $text4message = $parserBlog->convert($ar["DETAIL_TEXT"], false, array(), $arAllow, array("isSonetLog" => true));
                         $arSoFields = array("EVENT_ID" => "blog_post", "=LOG_DATE" => $DB->CharToDateFunction($ar["DATE_PUBLISH"], "FULL", SITE_ID), "LOG_UPDATE" => $DB->CharToDateFunction($ar["DATE_PUBLISH"], "FULL", SITE_ID), "TITLE_TEMPLATE" => "#USER_NAME# add post", "TITLE" => $ar["TITLE"], "MESSAGE" => $text4message, "MODULE_ID" => "blog", "CALLBACK_FUNC" => false, "SOURCE_ID" => $ar["ID"], "ENABLE_COMMENTS" => "N", "ENTITY_TYPE" => SONET_ENTITY_USER, "ENTITY_ID" => $ar["AUTHOR_ID"], "USER_ID" => $ar["AUTHOR_ID"], "URL" => $arSite[$ar["SITE_ID"]], "SITE_ID" => $arSites);
                         $logID = CSocNetLog::Add($arSoFields, false);
                         if (intval($logID) > 0) {
                             $socnetPerms = $arF["SC_PERM"];
                             if (!in_array("U" . $ar["AUTHOR_ID"], $socnetPerms)) {
                                 $socnetPerms[] = "U" . $ar["AUTHOR_ID"];
                             }
                             $socnetPerms[] = "SA";
                             // socnet admin
                             CSocNetLog::Update($logID, array("TMP_ID" => $logID, "=LOG_UPDATE" => $arSoFields["LOG_UPDATE"]));
                             CSocNetLogRights::DeleteByLogID($logID);
                             CSocNetLogRights::Add($logID, $socnetPerms);
                         }
                     } else {
                         $socnetPerms = $arF["SC_PERM"];
                         if (!in_array("U" . $ar["AUTHOR_ID"], $socnetPerms)) {
                             $socnetPerms[] = "U" . $ar["AUTHOR_ID"];
                         }
                         $socnetPerms[] = "SA";
                         // socnet admin
                         CSocNetLogRights::DeleteByLogID($ar["SLID"]);
                         CSocNetLogRights::Add($ar["SLID"], $socnetPerms);
                     }
                 }
             }
             if ($ar["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH && $ar["SEARCH_INDEX"] == "Y") {
                 //CBlogSearch::Trace('OnSearchReindex', 'Result', $Result);
                 if ($oCallback) {
                     $res = call_user_func(array($oCallback, $callback_method), $Result);
                     if (!$res) {
                         return $Result["ID"];
                     }
                 } else {
                     $arResult[] = $Result;
                 }
             }
         }
         //all blog posts indexed so let's start index users
         $category = 'C';
         $id = 0;
         COption::SetOptionString("blog", "socNetNewPerms", "Y");
     }
     if ($category == 'C') {
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tbc.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t,bp.ID as POST_ID\n\t\t\t\t\t,b.URL\n\t\t\t\t\t,bp.TITLE as POST_TITLE\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,b.SOCNET_GROUP_ID\n\t\t\t\t\t,bc.TITLE\n\t\t\t\t\t,bc.POST_TEXT\n\t\t\t\t\t,bc.POST_ID\n\t\t\t\t\t,bc.BLOG_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\t\t,bc.PATH\n\t\t\t\t\t," . $DB->DateToCharFunction("bc.DATE_CREATE") . " as DATE_CREATE\n\t\t\t\t\t,bc.AUTHOR_ID\n\t\t\t\tFROM\n\t\t\t\t\tb_blog_comment bc\n\t\t\t\t\tINNER JOIN b_blog_post bp ON (bp.ID = bc.POST_ID)\n\t\t\t\t\tINNER JOIN b_blog b ON (bc.BLOG_ID = b.ID)\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID)\n\t\t\t\tWHERE\n\t\t\t\t\tbc.ID > " . $id . " \n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? " AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND b.SEARCH_INDEX = 'Y'\n\t\t\t\tORDER BY\n\t\t\t\t\tbc.ID\n\t\t\t";
         //CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql);
         $rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         while ($ar = $rs->Fetch()) {
             //Check permissions
             $tag = "";
             $PostPerms = CBlogUserGroup::GetGroupPerms(1, $ar["BLOG_ID"], $ar["POST_ID"], BLOG_PERMS_POST);
             if ($PostPerms < BLOG_PERMS_READ) {
                 continue;
             }
             //CBlogSearch::Trace('OnSearchReindex', 'ar', $ar);
             if (strlen($ar["PATH"]) > 0) {
                 $arSite = array($ar["SITE_ID"] => str_replace("#comment_id#", $ar["ID"], $ar["PATH"]));
             } else {
                 $arSite = array($ar["SITE_ID"] => CBlogPost::PreparePath($ar["URL"], $ar["POST_ID"], $ar["SITE_ID"], false, $ar["OWNER_ID"], $ar["SOCNET_GROUP_ID"]));
             }
             $Result = array("ID" => "C" . $ar["ID"], "SITE_ID" => $arSite, "LAST_MODIFIED" => $ar["DATE_CREATE"], "PARAM1" => "COMMENT", "PARAM2" => $ar["BLOG_ID"] . "|" . $ar["POST_ID"], "PERMISSIONS" => array(2), "TITLE" => $ar["TITLE"], "BODY" => blogTextParser::killAllTags($ar["POST_TEXT"]), "INDEX_TITLE" => false, "USER_ID" => IntVal($ar["AUTHOR_ID"]) > 0 ? $ar["AUTHOR_ID"] : false, "ENTITY_TYPE_ID" => "BLOG_COMMENT", "ENTITY_ID" => $ar["ID"]);
             if ($ar["USE_SOCNET"] == "Y") {
                 $arSp = CBlogComment::GetSocNetCommentPerms($ar["POST_ID"]);
                 if (is_array($arSp)) {
                     $Result["PERMISSIONS"] = $arSp;
                 }
             }
             if (strlen($ar["TITLE"]) <= 0) {
                 $Result["TITLE"] = substr($Result["BODY"], 0, 100);
             }
             if ($oCallback) {
                 $res = call_user_func(array($oCallback, $callback_method), $Result);
                 if (!$res) {
                     return $Result["ID"];
                 }
             } else {
                 $arResult[] = $Result;
             }
         }
         //all blog posts indexed so let's start index users
         $category = 'U';
         $id = 0;
     }
     if ($category == 'U') {
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tbu.ID\n\t\t\t\t\t,bg.SITE_ID\n\t\t\t\t\t," . $DB->DateToCharFunction("bu.LAST_VISIT") . " as LAST_VISIT\n\t\t\t\t\t," . $DB->DateToCharFunction("u.DATE_REGISTER") . " as DATE_REGISTER\n\t\t\t\t\t,bu.ALIAS\n\t\t\t\t\t,bu.DESCRIPTION\n\t\t\t\t\t,bu.INTERESTS\n\t\t\t\t\t,u.NAME\n\t\t\t\t\t,u.LAST_NAME\n\t\t\t\t\t,u.LOGIN\n\t\t\t\t\t,bu.USER_ID\n\t\t\t\t\t,b.OWNER_ID\n\t\t\t\t\t,b.USE_SOCNET\n\t\t\t\t\t,b.SEARCH_INDEX\n\t\t\t\tFROM\n\t\t\t\t\tb_blog_user bu\n\t\t\t\t\tINNER JOIN b_user u  ON (u.ID = bu.USER_ID)\n\t\t\t\t\tINNER JOIN b_blog b ON (u.ID = b.OWNER_ID)\n\t\t\t\t\tINNER JOIN b_blog_group bg ON (b.GROUP_ID = bg.ID)\n\t\t\t\tWHERE\n\t\t\t\t\tb.ACTIVE = 'Y'\n\t\t\t\t\t" . ($NS["SITE_ID"] != "" ? "AND bg.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "'" : "") . "\n\t\t\t\t\tAND bu.ID > " . $id . "\n\t\t\t\t\tAND b.SEARCH_INDEX = 'Y'\n\t\t\t\tORDER BY\n\t\t\t\t\tbu.ID\n\t\t\t";
         //CBlogSearch::Trace('OnSearchReindex', 'strSql', $strSql);
         $rs = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         while ($ar = $rs->Fetch()) {
             if ($ar["USE_SOCNET"] == "Y") {
                 $Result = array("ID" => "U" . $ar["ID"], "BODY" => "", "TITLE" => "");
             } else {
                 //CBlogSearch::Trace('OnSearchReindex', 'ar', $ar);
                 $arSite = array($ar["SITE_ID"] => CBlogUser::PreparePath($ar["USER_ID"], $ar["SITE_ID"]));
                 //CBlogSearch::Trace('OnSearchReindex', 'arSite', $arSite);
                 $Result = array("ID" => "U" . $ar["ID"], "LAST_MODIFIED" => $ar["LAST_VISIT"], "TITLE" => CBlogUser::GetUserName($ar["ALIAS"], $ar["NAME"], $ar["LAST_NAME"], $ar["LOGIN"]), "BODY" => blogTextParser::killAllTags($ar["DESCRIPTION"] . " " . $ar["INTERESTS"]), "SITE_ID" => $arSite, "PARAM1" => "USER", "PARAM2" => $ar["ID"], "PERMISSIONS" => array(2));
                 if (strlen($Result["LAST_MODIFIED"]) <= 0) {
                     $Result["LAST_MODIFIED"] = $ar["DATE_REGISTER"];
                 }
             }
             //CBlogSearch::Trace('OnSearchReindex', 'Result', $Result);
             if ($oCallback) {
                 $res = call_user_func(array($oCallback, $callback_method), $Result);
                 if (!$res) {
                     return $Result["ID"];
                 }
             } else {
                 $arResult[] = $Result;
             }
         }
     }
     if ($oCallback) {
         return false;
     }
     return $arResult;
 }
示例#9
0
 $arPost["AUTHOR_ID"] = $arUser["ID"];
 $arPost["CATEGORY_ID"] = implode(",", $iCategory);
 $postID = CBlogPost::Add($arPost);
 // posts to socialnetwork log
 if (CModule::IncludeModule("socialnetwork")) {
     $arPost["ID"] = $postID;
     $arParams = array("UserID" => $arUser["ID"], "allowHTML" => "N", "allowVideo" => "Y", "PATH_TO_SMILE" => false, "PATH_TO_POST" => WIZARD_SITE_DIR . 'people/user/#user_id#/blog/#post_id#/', "user_id" => $arUser["ID"]);
     $arBlog = CBlog::GetByID($blogID);
     if ($arPost["ID"]) {
         $parserBlog = new blogTextParser(false, $arParams["PATH_TO_SMILE"]);
         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", "SITE_ID" => WIZARD_SITE_ID);
         $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"]));
示例#10
0
         $CurPost["urlToBlog"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG"], array("blog" => $arBlog["URL"]));
     }
 }
 $CurPost["urlToPost"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_POST"], array("blog" => $arBlog["URL"], "post_id" => $CurPost["ID"]));
 $CurPost["urlToAuthor"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $CurPost["AUTHOR_ID"]));
 $arImages = array();
 $res = CBlogImage::GetList(array("ID" => "ASC"), array("POST_ID" => $arPost['ID'], "BLOG_ID" => $arBlog['ID']));
 while ($arImage = $res->Fetch()) {
     $arImages[$arImage['ID']] = $arImage['FILE_ID'];
 }
 if ($CurPost["DETAIL_TEXT_TYPE"] == "html" && COption::GetOptionString("blog", "allow_html", "N") == "Y") {
     $arAllow = array("HTML" => "Y", "ANCHOR" => "Y", "IMG" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "QUOTE" => "Y", "CODE" => "Y");
     if (COption::GetOptionString("blog", "allow_video", "Y") != "Y") {
         $arAllow["VIDEO"] = "N";
     }
     $CurPost["TEXT_FORMATED"] = $p->convert($CurPost["~DETAIL_TEXT"], true, $arImages, $arAllow);
 } else {
     $arAllow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y");
     if (COption::GetOptionString("blog", "allow_video", "Y") != "Y") {
         $arAllow["VIDEO"] = "N";
     }
     $CurPost["TEXT_FORMATED"] = $p->convert($CurPost["~DETAIL_TEXT"], true, $arImages, $arAllow);
 }
 $CurPost["IMAGES"] = $arImages;
 $CurPost["BlogUser"] = CBlogUser::GetByID($CurPost["AUTHOR_ID"], BLOG_BY_USER_ID);
 $CurPost["BlogUser"] = CBlogTools::htmlspecialcharsExArray($CurPost["BlogUser"]);
 $CurPost["BlogUser"]["AVATAR_file"] = CFile::GetFileArray($CurPost["BlogUser"]["AVATAR"]);
 if ($CurPost["BlogUser"]["AVATAR_file"] !== false) {
     $CurPost["BlogUser"]["AVATAR_img"] = CFile::ShowImage($CurPost["BlogUser"]["AVATAR_file"]["SRC"], 150, 150, "border=0 align='right'");
 }
 $dbUser = CUser::GetByID($CurPost["AUTHOR_ID"]);
示例#11
0
         } else {
             if ($v1["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH) {
                 unset($arResult["CommentsResult"][$k1]);
                 unset($arResult["IDS"][$k1]);
             }
         }
         if (isset($arResult["CommentsResult"][$k1])) {
             if (IntVal($arResult["ajax_comment"]) > 0 && $v1["ID"] == $arResult["ajax_comment"]) {
                 $p = new blogTextParser(false, $arParams["PATH_TO_SMILE"]);
                 $p->bMobile = true;
                 $arParserParams = array("pathToUser" => "/mobile/users/?user_id=#user_id#");
                 if (is_array($v1["COMMENT_PROPERTIES"]["DATA"]["UF_BLOG_COMMENT_FILE"])) {
                     $p->arUserfields = array("UF_BLOG_COMMENT_FILE" => array_merge($v1["COMMENT_PROPERTIES"]["DATA"]["UF_BLOG_COMMENT_FILE"], 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" => COption::GetOptionString("blog", "allow_video", "Y") != "Y" || $arParams["ALLOW_VIDEO"] != "Y" ? "N" : "Y", "SHORT_ANCHOR" => "Y");
                 $arResult["CommentsResult"][$k1]["TextFormatedMobile"] = $p->convert($v1["POST_TEXT"], false, array(), $arAllow, $arParserParams);
             } else {
                 $arResult["CommentsResult"][$k1]["TextFormatedMobile"] = "";
             }
         }
     }
 }
 if ($arResult["newCount"] < 3) {
     $arResult["newCount"] = 3;
 }
 $arResult["~newCount"] = $arResult["newCount"];
 if (IntVal($commentUrlID) > 0) {
     $arResult["newCount"] = count($arResult["CommentsResult"]);
 }
 if ($arParams["SHOW_RATING"] == "Y" && !empty($arResult["IDS"])) {
     $arResult['RATING'] = CRatings::GetRatingVoteResult('BLOG_COMMENT', $arResult["IDS"]);
示例#12
0
     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($arParams["NAME_TEMPLATE"], $arTmpUser, $arParams["SHOW_LOGIN"] != "N" ? true : false);
 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, '');
 $arPostFields = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("BLOG_COMMENT", $arComment["ID"], LANGUAGE_ID);
 if (is_array($arPostFields[$ufCode])) {
     $p->arUserfields = array($ufCode => array_merge($arPostFields[$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($arParams["PATH_TO_POST"]), array("post_id" => "#source_post_id#", "user_id" => $arPost["AUTHOR_ID"]));
 $urlToPost .= strpos($urlToPost, "?") !== false ? "&" : "?";
 $arFields = array("POST_ID" => $arBlogPost["ID"], "COMMENT_ID" => $commentId, "arComment" => $arComment, "arAuthor" => $arAuthor, "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($arParams["PATH_TO_USER"])), "RATING_TYPE" => "like", "SHOW_RATING" => $arParams["SHOW_RATING"]);
 $arParams["RATING_TYPE"] = "like";
示例#13
0
                    $cache_path = "/" . SITE_ID . "/blog/" . $arBlog["URL"] . "/post/" . $arPost["ID"] . "/";
                    if ($CACHE_TIME > 0 && $cache->InitCache($CACHE_TIME, $cache_id, $cache_path)) {
                        $cache->Output();
                    } else {
                        if ($CACHE_TIME > 0) {
                            $cache->StartDataCache($CACHE_TIME, $cache_id, $cache_path);
                        }
                        $urtToPost = CBlogPost::PreparePath($arBlog["URL"], $arPost["ID"], false, $is404);
                        $urtToBlog = CBlog::PreparePath($arBlog["URL"], false, $is404);
                        $urlToAuthor = CBlogUser::PreparePath($arPost["AUTHOR_ID"], false, $is404);
                        $p = new blogTextParser();
                        $res = CBlogImage::GetList(array("ID" => "ASC"), array("POST_ID" => $arPost['ID'], "BLOG_ID" => $arBlog['ID']));
                        while ($arImage = $res->Fetch()) {
                            $arImages[$arImage['ID']] = $arImage['FILE_ID'];
                        }
                        $text = $p->convert($arPost["DETAIL_TEXT"], false, $arImages);
                        $BlogUser = CBlogUser::GetByID($arPost["AUTHOR_ID"], BLOG_BY_USER_ID);
                        $dbUser = CUser::GetByID($arPost["AUTHOR_ID"]);
                        $arUser = $dbUser->Fetch();
                        $AuthorName = CBlogUser::GetUserName($BlogUser["ALIAS"], $arUser["NAME"], $arUser["LAST_NAME"], $arUser["LOGIN"]);
                        ?>
						<table class="blogtableborder" cellspacing="1" cellpadding="0" width="100%" border="0">
						<tr>
						<td>
							<table border="0" width="100%" cellpadding="3" cellspacing="0" class="blogtablebody">
							<tr>
								<td class="blogtablehead" align="left" nowrap width="100%" style="padding-left:10px;"><font class="blogpostdate"><?php 
                        echo $arPost["DATE_PUBLISH"];
                        ?>
</font></td>
								<td align="right" class="blogtablehead" nowrap style="padding-right:10px;"><font class="blogauthor"><a href="<?php 
示例#14
0
         $arTmp["urlToPost"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_GROUP_BLOG_POST"], array("blog" => $arPost["BLOG_URL"], "post_id" => $arPost["ID"], "group_id" => $arPost["BLOG_SOCNET_GROUP_ID"]));
     } else {
         $arTmp["urlToPost"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_POST"], array("blog" => $arPost["BLOG_URL"], "post_id" => $arPost["ID"], "user_id" => $arPost["BLOG_OWNER_ID"]));
     }
     $arTmp["urlToAuthor"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arPost["AUTHOR_ID"]));
     $arTmp["AuthorName"] = CBlogUser::GetUserName($arPost["BLOG_USER_ALIAS"], $arPost["AUTHOR_NAME"], $arPost["AUTHOR_LAST_NAME"], $arPost["AUTHOR_LOGIN"]);
     $arImage = array();
     $res = CBlogImage::GetList(array("ID" => "ASC"), array("POST_ID" => $arPost['ID']));
     while ($arImage = $res->Fetch()) {
         $arImages[$arImage['ID']] = $arImage['FILE_ID'];
     }
     if (preg_match("/(\\[CUT\\])/i", $arTmp['DETAIL_TEXT']) || preg_match("/(<CUT>)/i", $arTmp['DETAIL_TEXT'])) {
         $arTmp["CUT"] = "Y";
     }
     if ($arTmp["DETAIL_TEXT_TYPE"] == "html") {
         $arTmp["TEXT_FORMATED"] = $p->convert($arTmp["~DETAIL_TEXT"], true, $arImages, array("HTML" => "Y", "ANCHOR" => "Y", "IMG" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "QUOTE" => "Y", "CODE" => "Y"));
     } else {
         $arTmp["TEXT_FORMATED"] = $p->convert($arTmp["~DETAIL_TEXT"], true, $arImages);
     }
     $arTmp["IMAGES"] = $arImages;
     $arTmp["DATE_PUBLISH_FORMATED"] = date($arParams["DATE_TIME_FORMAT"], MakeTimeStamp($arTmp["DATE_PUBLISH"], CSite::GetDateFormat("FULL")));
     $dbCategory = CBlogPostCategory::GetList(array("NAME" => "ASC"), array("POST_ID" => $arTmp["ID"], "BLOG_ID" => $arPost["BLOG_ID"]));
     while ($arCategory = $dbCategory->GetNext()) {
         $arCategory["urlToCategory"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG_CATEGORY"], array("category_name" => urlencode($arCategory["NAME"])));
         $arTmp["CATEGORY"][] = $arCategory;
     }
     $arResult["POSTS"][] = $arTmp;
 }
 if ($arParams["SHOW_RATING"] == "Y" && !empty($arResult["IDS"])) {
     $arResult["RATING"] = CRatings::GetRatingVoteResult("BLOG_POST", $arResult["IDS"]);
 }
示例#15
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);
                 }
             }
         }
     }
 }
示例#16
0
                         $arDest[] = "[user="******"POST_DATA"]["SPERM_NAME"][$type][$entityId]["ID"] . "]" . htmlspecialcharsback($arParams["POST_DATA"]["SPERM_NAME"][$type][$entityId]["NAME"]) . "[/user]";
                     }
                 }
             }
             $arDest[] = GetMessage("B_B_SHARE_HIDDEN_1");
             $destText = GetMessage("B_B_SHARE_1");
             if (count($arDest) > 1) {
                 $destText = GetMessage("B_B_SHARE");
             }
             $destText .= implode(", ", $arDest);
             if (!$p) {
                 $p = new blogTextParser(false, $arParams["PATH_TO_SMILE"]);
                 $arParserParams = array("imageWidth" => $arParams["IMAGE_MAX_WIDTH"], "imageHeight" => $arParams["IMAGE_MAX_HEIGHT"], "pathToUser" => $arParams["PATH_TO_USER"]);
                 $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");
             }
             $arResult["CommentsResult"][$k1]["TextFormated"] = $p->convert($destText, false, array(), $arAllow, $arParserParams);
         }
     }
 }
 $bAuthor = false;
 if (IntVal($v1["AUTHOR_ID"]) > 0 && $v1["AUTHOR_ID"] == $user_id) {
     $bAuthor = true;
 }
 if ($bIntranetInstalled && $bAuthor || $arResult["Perm"] >= BLOG_PERMS_FULL && !$bIntranetInstalled || CSocNetUser::IsCurrentUserModuleAdmin() || $APPLICATION->GetGroupRight("blog") >= "W") {
     $arResult["CommentsResult"][$k1]["CAN_DELETE"] = "Y";
     $arResult["CommentsResult"][$k1]["CAN_EDIT"] = "Y";
 }
 if ($bAuthor && $arPost["AUTHOR_ID"] != $v1["AUTHOR_ID"] && strlen($v1["SHARE_DEST"]) > 0) {
     $arResult["CommentsResult"][$k1]["CAN_DELETE"] = "N";
     $arResult["CommentsResult"][$k1]["CAN_EDIT"] = "N";
 }
示例#17
0
     $arPostsAll[] = $arPost;
 }
 if (!empty($arIdToGet)) {
     $arResult["userCache"] = CBlogUser::GetUserInfoArray($arIdToGet, $arParams["PATH_TO_USER"], array("AVATAR_SIZE" => $arParams["AVATAR_SIZE"]));
     foreach ($arResult["userCache"] as $userId => $arUserCache) {
         $arUserCache["~AUTHOR_NAME"] = CUser::FormatName($arParams["NAME_TEMPLATE"], array("LAST_NAME" => $arUserCache["~LAST_NAME"], "NAME" => $arUserCache["~NAME"], "SECOND_NAME" => $arUserCache["~SECOND_NAME"], "LOGIN" => $arUserCache["~LOGIN"]), $arParams["SHOW_LOGIN"], false);
         $arUserCache["AUTHOR_NAME"] = htmlspecialcharsbx($arUserCache["~AUTHOR_NAME"]);
         $arResult["userCache"][$userId] = $arUserCache;
     }
 }
 $db_user = CUser::GetById($GLOBALS["USER"]->GetId());
 $arResult["USER"] = $db_user->Fetch();
 foreach ($arPostsAll as $arPost) {
     $text = preg_replace($patt, $repl, $arPost["~DETAIL_TEXT"]);
     $text = TruncateText($text, $arParams["MESSAGE_LENGTH"]);
     $text = CBlogTools::DeleteDoubleBR($p->convert($text, true, false, $allow));
     $arPost["~CLEAR_TEXT"] = $text;
     $arPost["CLEAR_TEXT"] = $p->wrap_long_words($text);
     $arPost["perms"] = $arResult["perms"];
     if (!$bGroupMode && $arParams["USER_ID"] == $user_id && (empty($arParams["4ME"]) || $arPost["AUTHOR_ID"] == $user_id)) {
         $arPost["perms"] = BLOG_PERMS_FULL;
     } elseif (!$bGroupMode && $arParams["USER_ID"] != $user_id || strlen($arParams["4ME"]) > 0) {
         $arPost["perms"] = CBlogPost::GetSocNetPostPerms($arPost["ID"], true);
     }
     $arUser = $arResult["userCache"][$arPost["AUTHOR_ID"]];
     $arPost["~AUTHOR_NAME"] = $arUser["~AUTHOR_NAME"];
     $arPost["AUTHOR_NAME"] = $arUser["AUTHOR_NAME"];
     $arPost["AUTHOR_AVATAR"] = $arUser["PERSONAL_PHOTO_resized"];
     $arPost["urlToPost"] = CComponentEngine::MakePathFromTemplate($arParams["~PATH_TO_POST"], array("post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arParams["ALLOW_POST_CODE"]), "user_id" => $arPost["BLOG_OWNER_ID"]));
     $arPost["urlToPosts"] = CComponentEngine::MakePathFromTemplate($arParams["~PATH_TO_BLOG_POSTS"], array("user_id" => $arPost["BLOG_OWNER_ID"]));
     $arPost["urlToPostsImportant"] = CComponentEngine::MakePathFromTemplate($arParams["~PATH_TO_POST_IMPORTANT"], array("user_id" => $arPost["BLOG_OWNER_ID"]));
示例#18
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));
        }
    }
示例#19
0
 $SORT = array($arParams["SORT_BY1"] => $arParams["SORT_ORDER1"], $arParams["SORT_BY2"] => $arParams["SORT_ORDER2"]);
 if ($arParams["COMMENT_COUNT"] > 0) {
     $COUNT = array("nTopCount" => $arParams["COMMENT_COUNT"]);
 } else {
     $COUNT = false;
 }
 $arResult = array();
 $dbComment = CBlogComment::GetList($SORT, $arFilter, false, $COUNT, $arSelectedFields);
 $p = new blogTextParser(false, $arParams["PATH_TO_SMILE"]);
 $itemCnt = 0;
 while ($arComment = $dbComment->GetNext()) {
     $text = preg_replace("#\\[img\\](.+?)\\[/img\\]#ie", "", $arComment["~POST_TEXT"]);
     $text = preg_replace("#\\[url(.+?)\\](.*?)\\[/url\\]#is", "\\2", $text);
     $text = preg_replace("#(\\[|<)(/?)(b|u|i|list|code|quote|url|img|color|font|/*)(.*?)(\\]|>)#is", "", $text);
     $text = TruncateText($text, $arParams["MESSAGE_LENGTH"]);
     $text = $p->convert($text, false, false, array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "N"));
     $arComment["TEXT_FORMATED"] = $text;
     if (IntVal($arComment["AUTHOR_ID"]) > 0) {
         $arComment["urlToAuthor"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arComment["AUTHOR_ID"]));
         $arComment["BlogUser"] = CBlogUser::GetByID($arComment["AUTHOR_ID"], BLOG_BY_USER_ID);
         $arComment["BlogUser"] = CBlogTools::htmlspecialcharsExArray($arComment["BlogUser"]);
         $dbUser = CUser::GetByID($arComment["AUTHOR_ID"]);
         $arComment["arUser"] = $dbUser->GetNext();
         $arComment["AuthorName"] = CBlogUser::GetUserName($arComment["BlogUser"]["ALIAS"], $arComment["arUser"]["NAME"], $arComment["arUser"]["LAST_NAME"], $arComment["arUser"]["LOGIN"]);
         $arComment["Blog"] = CBlog::GetByOwnerID(IntVal($arComment["AUTHOR_ID"]), $arParams["GROUP_ID"]);
         if (!empty($arComment["Blog"])) {
             $arComment["urlToBlog"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG"], array("blog" => $arComment["Blog"]["URL"], "user_id" => $arComment["AUTHOR_ID"]));
         } else {
             $arComment["urlToBlog"] = $arComment["urlToAuthor"];
         }
     } else {
示例#20
0
	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);
	}
示例#21
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;
    }
示例#22
0
         $bHasImg = true;
         $arImages[$arImage['ID']] = $arImage['FILE_ID'];
         $arResult["images"][$arImage['ID']] = array("small" => "/bitrix/components/bitrix/blog/show_file.php?fid=" . $arImage['ID'] . "&width=" . $arParams["ATTACHED_IMAGE_MAX_WIDTH_SMALL"] . "&height=" . $arParams["ATTACHED_IMAGE_MAX_HEIGHT_SMALL"] . "&type=square");
         $arResult["images"][$arImage['ID']]["full"] = "/bitrix/components/bitrix/blog/show_file.php?fid=" . $arImage['ID'] . "&width=" . $arParams["ATTACHED_IMAGE_MAX_WIDTH_FULL"] . "&height=" . $arParams["ATTACHED_IMAGE_MAX_HEIGHT_FULL"];
     }
 }
 $arParserParams = array("imageWidth" => $arParams["IMAGE_MAX_WIDTH"], "imageHeight" => $arParams["IMAGE_MAX_HEIGHT"], "pathToUser" => $arParams["PATH_TO_USER"]);
 $arAllow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "USER" => "Y", "TAG" => "Y", "SHORT_ANCHOR" => "Y");
 if (COption::GetOptionString("blog", "allow_video", "Y") != "Y") {
     $arAllow["VIDEO"] = "N";
 }
 if (is_array($arResult["POST_PROPERTIES"]["DATA"]["UF_BLOG_POST_FILE"])) {
     $p->arUserfields = array("UF_BLOG_POST_FILE" => array_merge($arResult["POST_PROPERTIES"]["DATA"]["UF_BLOG_POST_FILE"], array("TAG" => "DOCUMENT ID")));
 }
 $p->LAZYLOAD = isset($arParams["LAZYLOAD"]) && $arParams["LAZYLOAD"] == "Y" ? "Y" : "N";
 $arResult["Post"]["textFormated"] = $p->convert($arPost["~DETAIL_TEXT"], $arParams["USE_CUT"] == "Y" ? true : false, $arImages, $arAllow, $arParserParams);
 if (is_array($arResult["POST_PROPERTIES"]["DATA"]["UF_BLOG_POST_FILE"]) && is_array($arResult["POST_PROPERTIES"]["DATA"]["UF_BLOG_POST_FILE"]["VALUE"])) {
     $arResult["POST_PROPERTIES"]["DATA"]["UF_BLOG_POST_FILE"]["SOURCE_VALUE"] = $arResult["POST_PROPERTIES"]["DATA"]["UF_BLOG_POST_FILE"]["VALUE"];
 }
 if ($arParams["USE_CUT"] == "Y" && preg_match("/(\\[CUT\\])/i", $arPost['~DETAIL_TEXT'])) {
     $arResult["Post"]["CUT"] = "Y";
 }
 if (!empty($p->showedImages) && !empty($arResult["images"])) {
     foreach ($p->showedImages as $val) {
         if (!empty($arResult["images"][$val])) {
             unset($arResult["images"][$val]);
         }
     }
 }
 $arResult["Post"]["DATE_PUBLISH_FORMATED"] = FormatDateFromDB($arResult["Post"]["DATE_PUBLISH"], $arParams["DATE_TIME_FORMAT"], true);
 $arResult["Post"]["DATE_PUBLISH_DATE"] = FormatDateFromDB($arResult["Post"]["DATE_PUBLISH"], FORMAT_DATE);
示例#23
0
                }
                //вывод сообщения
                $dbPost = CBlogPost::GetList($SORT, $arFilter, array("ID", "DATE_PUBLISH", "MAX" => "PERMS"), array("bDescPageNumbering" => true, "nPageSize" => $MESSAGE_COUNT, "bShowAll" => false));
                if ($arPost = $dbPost->NavNext(false)) {
                    do {
                        $CurPost = CBlogPost::GetByID($arPost["ID"]);
                        $urtToPost = CBlogPost::PreparePath($arBlog["URL"], $CurPost["ID"], SITE_ID, $is404);
                        $urlToAuthor = CBlogUser::PreparePath($CurPost["AUTHOR_ID"], SITE_ID, $is404);
                        $urlToBlog = CBlog::PreparePath($arBlog["URL"], SITE_ID, $is404);
                        $p = new blogTextParser();
                        $arImage = array();
                        $res = CBlogImage::GetList(array("ID" => "ASC"), array("POST_ID" => $arPost['ID'], "BLOG_ID" => $arBlog['ID']));
                        while ($arImage = $res->Fetch()) {
                            $arImages[$arImage['ID']] = $arImage['FILE_ID'];
                        }
                        $text = $p->convert($CurPost["DETAIL_TEXT"], true, $arImages);
                        $BlogUser = CBlogUser::GetByID($CurPost["AUTHOR_ID"], BLOG_BY_USER_ID);
                        $dbUser = CUser::GetByID($CurPost["AUTHOR_ID"]);
                        $arUser = $dbUser->Fetch();
                        $AuthorName = CBlogUser::GetUserName($BlogUser["ALIAS"], $arUser["NAME"], $arUser["LAST_NAME"], $arUser["LOGIN"]);
                        ?>
						<table class="blogtableborder" cellspacing="1" cellpadding="0" width="100%" border="0">
						<tr>
						<td>
							<table border="0" width="100%" cellpadding="3" cellspacing="0" class="blogtablebody">
							<tr>
								<td class="blogtablehead" align="left" nowrap width="70%" style="padding-left:10px;"><font class="blogpostdate"><?php 
                        echo $CurPost["DATE_PUBLISH"];
                        ?>
</font></td>
								<td align="right" class="blogtablehead" nowrap width="30%"><font class="blogauthor"><?php 
示例#24
0
     if ($arOwnerBlog = CBlog::GetByOwnerID($arPost["AUTHOR_ID"], $arParams["GROUP_ID"])) {
         $arPost["urlToBlog"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG"], array("blog" => $arOwnerBlog["URL"]));
     }
 }
 $arImages = array();
 $dbImage = CBlogImage::GetList(array("ID" => "ASC"), array("POST_ID" => $arPost["ID"], "BLOG_ID" => $arBlog["ID"], "IS_COMMENT" => "N"));
 while ($arImage = $dbImage->Fetch()) {
     $arImages[$arImage['ID']] = $arImage['FILE_ID'];
     $arPost["arImages"][$arImage['ID']] = array("small" => "/bitrix/components/bitrix/blog/show_file.php?fid=" . $arImage['ID'] . "&width=70&height=70&type=square", "full" => "/bitrix/components/bitrix/blog/show_file.php?fid=" . $arImage['ID'] . "&width=1000&height=1000");
 }
 if ($arPost["DETAIL_TEXT_TYPE"] == "html" && COption::GetOptionString("blog", "allow_html", "N") == "Y") {
     $arAllow = array("HTML" => "Y", "ANCHOR" => "Y", "IMG" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "QUOTE" => "Y", "CODE" => "Y");
     if (COption::GetOptionString("blog", "allow_video", "Y") != "Y") {
         $arAllow["VIDEO"] = "N";
     }
     $arPost["TEXT_FORMATED"] = $p->convert($arPost["~DETAIL_TEXT"], true, $arImages, $arAllow, $arParserParams);
 } else {
     $arAllow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y");
     if (COption::GetOptionString("blog", "allow_video", "Y") != "Y") {
         $arAllow["VIDEO"] = "N";
     }
     $arPost["TEXT_FORMATED"] = $p->convert($arPost["~DETAIL_TEXT"], true, $arImages, $arAllow, $arParserParams);
 }
 $arPost["IMAGES"] = $arImages;
 if (!empty($p->showedImages)) {
     foreach ($p->showedImages as $val) {
         if (!empty($arPost["arImages"][$val])) {
             unset($arPost["arImages"][$val]);
         }
     }
 }
示例#25
0
 $text = preg_replace("#\\[code\\](.+?)\\[/code\\]#is", "", $text);
 $text = preg_replace("#\\[quote\\](.+?)\\[/quote\\]#is", "", $text);
 if ($arResult["NO_URL_IN_COMMENTS"] == "L" || IntVal($arComment["AUTHOR_ID"]) <= 0 && $arParams["NO_URL_IN_COMMENTS"] == "A") {
     $arAllow["CUT_ANCHOR"] = "Y";
     $arAllow["ANCHOR"] = "Y";
 } elseif ($arParams["NO_URL_IN_COMMENTS_AUTHORITY_CHECK"] == "Y" && $arAllow["CUT_ANCHOR"] != "Y" && IntVal($arComment["AUTHOR_ID"]) > 0) {
     $authorityRatingId = CRatings::GetAuthorityRating();
     $arRatingResult = CRatings::GetRatingResult($authorityRatingId, $arComment["AUTHOR_ID"]);
     if ($arRatingResult["CURRENT_VALUE"] < $arParams["NO_URL_IN_COMMENTS_AUTHORITY"]) {
         $arAllow["ANCHOR"] = "Y";
         $arAllow["CUT_ANCHOR"] = "Y";
     }
 } else {
     $text = preg_replace("#\\[url(.*?)\\](.*?)\\[/url\\]#is", "\\2", $text);
 }
 $text = $p->convert($text, false, false, $arAllow);
 $text = preg_replace("#(\\[|<)(/?)(b|u|i|list|code|quote|url|img|color|font|video|table|tr|td|align|user|/*)(.*?)(\\]|>)#is", "", $text);
 $text = TruncateText($text, $arParams["MESSAGE_LENGTH"]);
 $arComment["TEXT_FORMATED"] = $text;
 if (IntVal($arComment["AUTHOR_ID"]) > 0) {
     $arComment["urlToAuthor"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arComment["AUTHOR_ID"]));
     $arComment["BlogUser"] = CBlogUser::GetByID($arComment["AUTHOR_ID"], BLOG_BY_USER_ID);
     $arComment["BlogUser"] = CBlogTools::htmlspecialcharsExArray($arComment["BlogUser"]);
     $dbUser = CUser::GetByID($arComment["AUTHOR_ID"]);
     $arComment["arUser"] = $dbUser->GetNext();
     $arComment["AuthorName"] = CBlogUser::GetUserName($arComment["BlogUser"]["ALIAS"], $arComment["arUser"]["NAME"], $arComment["arUser"]["LAST_NAME"], $arComment["arUser"]["LOGIN"]);
     $arComment["Blog"] = CBlog::GetByOwnerID(IntVal($arComment["AUTHOR_ID"]), $arParams["GROUP_ID"]);
     if (!empty($arComment["Blog"])) {
         $arComment["urlToBlog"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG"], array("blog" => $arComment["Blog"]["URL"], "user_id" => $arComment["AUTHOR_ID"]));
     } else {
         $arComment["urlToBlog"] = $arComment["urlToAuthor"];
示例#26
0
function socialnetworkBlogPostCommentWeb(array $comment, array $arParams, array $arResult, SocialnetworkBlogPostComment $component)
{
    global $APPLICATION;
    $arParams["AVATAR_SIZE"] = intval($arParams["AVATAR_SIZE"]) ?: 58;
    $arAvatarSizes = array("AVATAR_SIZE" => intval(array_key_exists("AVATAR_SIZE_COMMON", $arParams) ? $arParams["AVATAR_SIZE_COMMON"] : $arParams["AVATAR_SIZE"]), "AVATAR_SIZE_COMMENT" => intval($arParams["AVATAR_SIZE_COMMENT"]));
    $arAvatarSizes["AVATAR_SIZE"] = $arAvatarSizes["AVATAR_SIZE"] > 0 ? $arAvatarSizes["AVATAR_SIZE"] : 42;
    // reference to CBlogUser::GetUserInfoArray
    $arAvatarSizes["AVATAR_SIZE_COMMENT"] = $arAvatarSizes["AVATAR_SIZE_COMMENT"] > 0 ? $arAvatarSizes["AVATAR_SIZE_COMMENT"] : 42;
    // reference to CBlogUser::GetUserInfoArray
    $avatarKey = "PERSONAL_PHOTO_RESIZED";
    if ($arAvatarSizes["AVATAR_SIZE"] == $arParams["AVATAR_SIZE"]) {
        $avatarKey = "PERSONAL_PHOTO_resized";
    } else {
        if ($arAvatarSizes["AVATAR_SIZE_COMMENT"] == $arParams["AVATAR_SIZE"]) {
            $avatarKey = "PERSONAL_PHOTO_resized_30";
        }
    }
    $arUser = $arResult["userCache"][$comment["AUTHOR_ID"]];
    if (is_array($arUser) && !array_key_exists($avatarKey, $arUser) && intval($arUser["PERSONAL_PHOTO"]) > 0) {
        $arResult["userCache"][$comment["AUTHOR_ID"]][$avatarKey] = CFile::ResizeImageGet($arUser["PERSONAL_PHOTO"], array("width" => $arParams["AVATAR_SIZE"], "height" => $arParams["AVATAR_SIZE"]), BX_RESIZE_IMAGE_EXACT);
        $arUser = $arResult["userCache"][$comment["AUTHOR_ID"]];
    }
    $text = $comment["TextFormated"];
    if (!$component->isWeb()) {
        static $parser = null;
        if ($parser == null) {
            $parser = new blogTextParser(false, $arParams["PATH_TO_SMILE"]);
            $parser->bMobile = false;
            $parser->LAZYLOAD = isset($arParams["LAZYLOAD"]) && $arParams["LAZYLOAD"] == "Y" ? "Y" : "N";
        }
        if (is_array($comment["COMMENT_PROPERTIES"]["DATA"]["UF_BLOG_COMMENT_FILE"])) {
            $parser->arUserfields = array("UF_BLOG_COMMENT_FILE" => array_merge($comment["COMMENT_PROPERTIES"]["DATA"]["UF_BLOG_COMMENT_FILE"], array("TAG" => "DOCUMENT ID")));
        }
        $text = $parser->convert($comment["POST_TEXT"], false, $comment["showedImages"], array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => COption::GetOptionString("blog", "allow_video", "Y") != "Y" || $arParams["ALLOW_VIDEO"] != "Y" ? "N" : "Y", "SHORT_ANCHOR" => "Y"), array("imageWidth" => $arParams["IMAGE_MAX_WIDTH"], "imageHeight" => $arParams["IMAGE_MAX_HEIGHT"]));
    }
    $res = 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" => !empty($comment["DATE_CREATE_TS"]) ? $comment["DATE_CREATE_TS"] + $arResult["TZ_OFFSET"] : MakeTimeStamp($comment["DATE_CREATE"]) - $arResult["TZ_OFFSET"], "AUTHOR" => array("ID" => is_array($arUser) ? $arUser["ID"] : false, "NAME" => is_array($arUser) ? $arUser["~NAME"] : '', "LAST_NAME" => is_array($arUser) ? $arUser["~LAST_NAME"] : '', "SECOND_NAME" => is_array($arUser) ? $arUser["~SECOND_NAME"] : '', "AVATAR" => is_array($arUser) && array_key_exists($avatarKey, $arUser) ? $arUser[$avatarKey]["src"] : ''), "FILES" => false, "UF" => false, "POST_MESSAGE_TEXT" => $text, "~POST_MESSAGE_TEXT" => $comment["POST_TEXT"], "CLASSNAME" => "", "BEFORE_HEADER" => "", "BEFORE_ACTIONS" => "", "AFTER_ACTIONS" => "", "AFTER_HEADER" => "", "BEFORE" => "", "AFTER" => "", "BEFORE_RECORD" => "", "AFTER_RECORD" => "");
    $aditStyle = ($comment["AuthorIsAdmin"] == "Y" ? "blog-comment-admin" : "") . ($comment["AuthorIsPostAuthor"] == "Y" ? "blog-comment-author" : "");
    if ($aditStyle) {
        $res["BEFORE_RECORD"] = "<div class='" . $aditStyle . "'>";
        $res["AFTER_RECORD"] = "</div>";
    }
    if (!empty($arResult["arImages"][$comment["ID"]])) {
        $res["FILES"] = array();
        foreach ($arResult["arImages"][$comment["ID"]] as $i => $val) {
            $t = $arResult["Images"][$i];
            $res["FILES"][] = array("THUMBNAIL" => $val["small"], "SRC" => $val["full"], "FILE_SIZE" => $t["source"]["size"], "CONTENT_TYPE" => "image/xyz", "ORIGINAL_NAME" => $t["fileName"], "FILE_NAME" => $t["fileName"]);
        }
    }
    if ($comment["COMMENT_PROPERTIES"]["SHOW"] == "Y") {
        $res["UF"] = $comment["COMMENT_PROPERTIES"]["DATA"];
        foreach ($res["UF"] as $key => $arPostField) {
            if (!empty($arPostField["VALUE"])) {
                $res["UF"][$key]['POST_ID'] = $arParams['POST_DATA']['ID'];
                $res["UF"][$key]['URL_TO_POST'] = str_replace('#source_post_id#', $arPostField['POST_ID'], $arResult['urlToPost']);
            }
        }
    }
    ob_start();
    ?>
<script>
		top.text<?php 
    echo $comment["ID"];
    ?>
 = text<?php 
    echo $comment["ID"];
    ?>
 = '<?php 
    echo CUtil::JSEscape($comment["POST_TEXT"]);
    ?>
';
		top.title<?php 
    echo $comment["ID"];
    ?>
 = title<?php 
    echo $comment["ID"];
    ?>
 = '<?php 
    echo CUtil::JSEscape($comment["TITLE"]);
    ?>
';
		top.arComFiles<?php 
    echo $comment["ID"];
    ?>
 = [];<?php 
    if ($comment["COMMENT_PROPERTIES"]["DATA"]) {
        foreach ($comment["COMMENT_PROPERTIES"]["DATA"] as $userField) {
            if (empty($userField["VALUE"])) {
                continue;
            } else {
                if ($userField["USER_TYPE_ID"] == "disk_file") {
                    ?>
					top.arComDFiles<?php 
                    echo $comment["ID"];
                    ?>
 = BX.util.array_merge((top.arComDFiles<?php 
                    echo $comment["ID"];
                    ?>
 || []), <?php 
                    echo CUtil::PhpToJSObject($userField["VALUE"]);
                    ?>
);
					<?php 
                } else {
                    if ($userField["USER_TYPE_ID"] == "webdav_element") {
                        ?>
					top.arComDocs<?php 
                        echo $comment["ID"];
                        ?>
 = BX.util.array_merge((top.arComDocs<?php 
                        echo $comment["ID"];
                        ?>
 || []), <?php 
                        echo CUtil::PhpToJSObject($userField["VALUE"]);
                        ?>
);
					<?php 
                    } else {
                        if ($userField["USER_TYPE_ID"] == "file") {
                            ?>
					top.arComFilesUf<?php 
                            echo $comment["ID"];
                            ?>
 = BX.util.array_merge((top.arComDocs<?php 
                            echo $comment["ID"];
                            ?>
 || []), <?php 
                            echo CUtil::PhpToJSObject($userField["VALUE"]);
                            ?>
);
					<?php 
                        }
                    }
                }
            }
        }
    }
    if (is_array($comment["COMMENT_PROPERTIES"]["HIDDEN_DATA"])) {
        foreach ($comment["COMMENT_PROPERTIES"]["HIDDEN_DATA"] as $userField) {
            if (empty($userField["VALUE"])) {
                continue;
            } else {
                if ($userField["USER_TYPE_ID"] == "url_preview") {
                    ?>
					top.UrlPreview<?php 
                    echo $comment["ID"];
                    ?>
 = '<?php 
                    echo CUtil::JSEscape($userField["VALUE"]);
                    ?>
';
					<?php 
                }
            }
        }
    }
    if (!empty($comment["showedImages"])) {
        foreach ($comment["showedImages"] as $imgId) {
            if (!empty($arResult["Images"][$imgId])) {
                ?>
top.arComFiles<?php 
                echo $comment["ID"];
                ?>
.push({
						id : '<?php 
                echo $imgId;
                ?>
',
						name : '<?php 
                echo CUtil::JSEscape($arResult["Images"][$imgId]["fileName"]);
                ?>
',
						type: 'image',
						src: '<?php 
                echo CUtil::JSEscape($arResult["Images"][$imgId]["source"]["src"]);
                ?>
',
						thumbnail: '<?php 
                echo CUtil::JSEscape($arResult["Images"][$imgId]["src"]);
                ?>
',
						isImage: true
					});<?php 
            }
        }
    }
    ?>
</script><?php 
    $res["AFTER"] .= ob_get_clean();
    return $res;
}
示例#27
0
	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);
					}
				}
			}
		}
	}