function FormatComment_Data($arFields, $arParams, $bMail = false, $arLog = array()) { $arResult = array("EVENT_FORMATTED" => array()); if (!CModule::IncludeModule("socialnetwork")) { return $arResult; } if (in_array($arLog["ENTITY_TYPE"], array(SONET_SUBSCRIBE_ENTITY_GROUP, SONET_SUBSCRIBE_ENTITY_USER))) { $arResult["ENTITY"] = CSocNetLogTools::FormatEvent_GetEntity($arLog, $arParams, $bMail); } if (!$bMail && $arParams["USE_COMMENT"] != "Y") { $arLog["ENTITY_ID"] = $arFields["ENTITY_ID"]; $arLog["ENTITY_TYPE"] = $arFields["ENTITY_TYPE"]; } if (!$bMail && array_key_exists("URL", $arLog) && strlen($arLog["URL"]) > 0) { $news_tmp = '<a href="' . $arLog["URL"] . '">' . $arLog["TITLE"] . '</a>'; } else { $news_tmp = $arLog["TITLE"]; } $title_tmp = $bMail ? GetMessage("LFP_SOCNET_LOG_DATA_COMMENT_" . $arLog["ENTITY_TYPE"] . "_TITLE_MAIL") : GetMessage("LFP_SOCNET_LOG_DATA_COMMENT_TITLE"); $title = str_replace(array("#TITLE#", "#ENTITY#"), array($news_tmp, $bMail ? $arResult["ENTITY"]["FORMATTED"] : $arResult["ENTITY"]["FORMATTED"]["NAME"]), $title_tmp); $arResult["EVENT_FORMATTED"] = array("TITLE" => $bMail || $arParams["USE_COMMENT"] != "Y" ? "<a href=\"asdfasdf\">" . $title . "</a>" : "", "MESSAGE" => $bMail ? $arFields["TEXT_MESSAGE"] : $arFields["MESSAGE"]); if ($bMail) { $url = CSocNetLogTools::FormatEvent_GetURL($arLog, true); if (strlen($url) > 0) { $arResult["EVENT_FORMATTED"]["URL"] = $url; } } else { $parserLog = new logTextParser(false, $arParams["PATH_TO_SMILE"]); $arAllow = array("HTML" => "Y", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "LOG_IMG" => "N", "QUOTE" => "Y", "LOG_QUOTE" => "N", "CODE" => "Y", "LOG_CODE" => "N", "FONT" => "Y", "LOG_FONT" => "N", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "Y", "MULTIPLE_BR" => "N", "VIDEO" => "Y", "LOG_VIDEO" => "N"); $arAllow = array("HTML" => "Y", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "LOG_VIDEO" => "N"); $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow)); if ($arParams["MOBILE"] != "Y" && $arParams["NEW_TEMPLATE"] != "Y") { $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow), 500); $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = CSocNetLogTools::FormatEvent_IsMessageShort($arResult["EVENT_FORMATTED"]["MESSAGE"], $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"]); } } return $arResult; }
$bCanAddComments = CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $arLog["ENTITY_TYPE"], $arLog["ENTITY_ID"], ($feature == "microblog" ? "blog" : $feature), $arCommentEvent["OPERATION_ADD"], $bCurrentUserIsAdmin); else $bCanAddComments = true; if ($bCanAddComments) { // add source object and get source_id, $source_url $arParams = array( "PATH_TO_SMILE" => $_REQUEST["p_smile"], "PATH_TO_USER_BLOG_POST" => $_REQUEST["p_ubp"], "PATH_TO_GROUP_BLOG_POST" => $_REQUEST["p_gbp"], "PATH_TO_USER_MICROBLOG_POST" => $_REQUEST["p_umbp"], "PATH_TO_GROUP_MICROBLOG_POST" => $_REQUEST["p_gmbp"], "BLOG_ALLOW_POST_CODE" => $_REQUEST["bapc"] ); $parser = new logTextParser(LANGUAGE_ID, $arParams["PATH_TO_SMILE"]); $comment_text = $_REQUEST["message"]; CUtil::decodeURIComponent($comment_text); $comment_text = Trim($comment_text); if (strlen($comment_text) > 0) { $arSearchParams = array(); if($arCommentEvent["EVENT_ID"] == "forum") { $arSearchParams["FORUM_ID"] = intval($_REQUEST["f_id"]); $arSearchParams["PATH_TO_GROUP_FORUM_MESSAGE"] = ( $arLog["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? str_replace(
public static function FormatComment_Report($arFields, $arParams, $bMail = false, $arLog = array()) { $arResult = array("EVENT_FORMATTED" => array()); if (!CModule::IncludeModule("socialnetwork")) { return $arResult; } if (!$bMail && $arParams["USE_COMMENT"] != "Y") { $arLog["ENTITY_ID"] = $arFields["ENTITY_ID"]; $arLog["ENTITY_TYPE"] = $arFields["ENTITY_TYPE"]; } $news_tmp = $arLog["TITLE"]; $title_tmp = GetMessage("REPORT_NEW_COMMENT") . '"' . $arLog["TITLE"] . '"' . "\n"; $title_tmp .= GetMessage("COMMENT_AUTHOR") . CUser::FormatName(CSite::GetNameFormat(false), array("NAME" => $arFields["CREATED_BY_NAME"], "LAST_NAME" => $arFields["CREATED_BY_LAST_NAME"], "SECOND_NAME" => $arFields["CREATED_BY_SECOND_NAME"], "LOGIN" => $arFields["CREATED_BY_LOGIN"]), true) . "\n"; $title_tmp .= GetMessage("COMMENT_TEXT"); $title = str_replace(array("#TITLE#", "#ENTITY#"), array($news_tmp, $bMail ? $arResult["ENTITY"]["FORMATTED"] : $arResult["ENTITY"]["FORMATTED"]["NAME"]), $title_tmp); $arResult["EVENT_FORMATTED"] = array("TITLE" => $bMail || $arParams["USE_COMMENT"] != "Y" ? $title : "", "MESSAGE" => $bMail ? $arFields["TEXT_MESSAGE"] : $arFields["MESSAGE"]); $arResult["ENTITY"]["TYPE_MAIL"] = GetMessage("REPORT_TITLE_FOR_MAIL"); if ($bMail) { $reportURL = COption::GetOptionString("timeman", "WORK_REPORT_PATH", "/company/work_report.php"); if (strlen($reportURL) == 0) { $reportURL = "/company/work_report.php"; } $reportURL = CSocNetLogTools::FormatEvent_GetURL(array("URL" => $reportURL, "SITE_ID" => $arFields["LOG_SITE_ID"])); if (strlen($reportURL) > 0) { $arResult["EVENT_FORMATTED"]["URL"] = $reportURL . "#user_id=" . $arLog["ENTITY_ID"] . "&report=" . $arLog["SOURCE_ID"]; } } else { static $parserLog = false; if (CModule::IncludeModule("forum")) { $arAllow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "LOG_IMG" => "N", "QUOTE" => "Y", "LOG_QUOTE" => "N", "CODE" => "Y", "LOG_CODE" => "N", "FONT" => "Y", "LOG_FONT" => "N", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "Y", "MULTIPLE_BR" => "N", "VIDEO" => "Y", "LOG_VIDEO" => "N", "USERFIELDS" => $arFields["UF"], "USER" => "Y"); if (!$parserLog) { $parserLog = new forumTextParser(LANGUAGE_ID); } $parserLog->pathToUser = $parserLog->userPath = $arParams["PATH_TO_USER"]; $parserLog->bMobile = $arParams["MOBILE"] == "Y"; $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), $arAllow)); } else { $arAllow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "N", "LOG_IMG" => "N", "QUOTE" => "Y", "LOG_QUOTE" => "N", "CODE" => "Y", "LOG_CODE" => "N", "FONT" => "Y", "LOG_FONT" => "N", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "Y", "MULTIPLE_BR" => "N", "VIDEO" => "Y", "LOG_VIDEO" => "N", "USERFIELDS" => $arFields["UF"]); if (!$parserLog) { $parserLog = new logTextParser(false, $arParams["PATH_TO_SMILE"]); } $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow)); } if ($arParams["MOBILE"] != "Y" && $arParams["NEW_TEMPLATE"] != "Y") { if (CModule::IncludeModule("forum")) { $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), $arAllow), 500); } else { $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow), 500); } $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = CSocNetLogTools::FormatEvent_IsMessageShort($arResult["EVENT_FORMATTED"]["MESSAGE"], $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"]); } } return $arResult; }
function FormatComment_News($arFields, $arParams, $bMail = false, $arLog = array()) { $arResult = array("EVENT_FORMATTED" => array()); if (!CModule::IncludeModule("socialnetwork")) { return $arResult; } if ($bMail) { $arResult["CREATED_BY"] = CSocNetLogTools::FormatEvent_GetCreatedBy($arFields, $arParams, $bMail); $arResult["ENTITY"] = CIntranetEventHandlers::GetEntity_News($arLog, $bMail); } elseif ($arParams["USE_COMMENT"] != "Y") { $arLog["ENTITY_ID"] = $arFields["ENTITY_ID"]; $arLog["ENTITY_TYPE"] = $arFields["ENTITY_TYPE"]; $arResult["ENTITY"] = CIntranetEventHandlers::GetEntity_News($arLog, false); } if (!$bMail && array_key_exists("URL", $arLog) && strlen($arLog["URL"]) > 0) { $news_tmp = '<a href="' . $arLog["URL"] . '">' . $arLog["TITLE"] . '</a>'; } else { $news_tmp = $arLog["TITLE"]; } $title_tmp = $bMail ? GetMessage("INTR_SOCNET_LOG_NEWS_COMMENT_TITLE_MAIL") : GetMessage("INTR_SOCNET_LOG_NEWS_COMMENT_TITLE"); $title = str_replace(array("#TITLE#", "#ENTITY#", "#CREATED_BY#"), array($news_tmp, $arResult["ENTITY"]["FORMATTED"], $bMail ? $arResult["CREATED_BY"]["FORMATTED"] : ""), $title_tmp); $arResult["EVENT_FORMATTED"] = array("TITLE" => $bMail || $arParams["USE_COMMENT"] != "Y" ? $title : "", "MESSAGE" => $bMail ? $arFields["TEXT_MESSAGE"] : $arFields["MESSAGE"]); if ($bMail) { $url = CSocNetLogTools::FormatEvent_GetURL($arLog); if (strlen($url) > 0) { $arResult["EVENT_FORMATTED"]["URL"] = $url; } } else { static $parserLog = false; if (CModule::IncludeModule("forum")) { if (!$parserLog) { $parserLog = new forumTextParser(LANGUAGE_ID); } $arAllow = array("HTML" => "N", "ALIGN" => "Y", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "Y", "VIDEO" => "Y", "LOG_VIDEO" => "N", "SHORT_ANCHOR" => "Y", "USERFIELDS" => $arFields["UF"], "USER" => "Y"); $parserLog->pathToUser = $parserLog->userPath = $arParams["PATH_TO_USER"]; $parserLog->arUserfields = $arFields["UF"]; $parserLog->bMobile = $arParams["MOBILE"] == "Y"; $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), $arAllow)); } else { if (!$parserLog) { $parserLog = new logTextParser(false, $arParams["PATH_TO_SMILE"]); } $arAllow = array("HTML" => "Y", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "LOG_IMG" => "N", "QUOTE" => "Y", "LOG_QUOTE" => "N", "CODE" => "Y", "LOG_CODE" => "N", "FONT" => "Y", "LOG_FONT" => "N", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "Y", "MULTIPLE_BR" => "N", "VIDEO" => "Y", "LOG_VIDEO" => "N"); $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow)); } if ($arParams["MOBILE"] != "Y" && $arParams["NEW_TEMPLATE"] != "Y") { if (CModule::IncludeModule("forum")) { $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), $arAllow), 500); } else { $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow), 500); } $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = CSocNetLogTools::FormatEvent_IsMessageShort($arResult["EVENT_FORMATTED"]["MESSAGE"], $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"]); } } return $arResult; }
static function FormatComment_Wiki($arFields, $arParams, $bMail = false, $arLog = array()) { $arResult = array("EVENT_FORMATTED" => array()); if ($bMail) { $arResult['CREATED_BY'] = CSocNetLogTools::FormatEvent_GetCreatedBy($arFields, $arParams, $bMail); $arResult['ENTITY'] = CSocNetLogTools::FormatEvent_GetEntity($arLog, $arParams, $bMail); } if (!$bMail && array_key_exists('URL', $arLog) && strlen($arLog['URL']) > 0) { $wiki_tmp = '<a href="' . $arLog['URL'] . '">' . $arLog['TITLE'] . '</a>'; } else { $wiki_tmp = $arLog['TITLE']; } $title = str_replace(array('#TITLE#', '#ENTITY#', '#CREATED_BY#'), array($wiki_tmp, $arResult['ENTITY']['FORMATTED'], $bMail ? $arResult['CREATED_BY']['FORMATTED'] : ''), $bMail ? GetMessage('WIKI_SOCNET_LOG_COMMENT_TITLE_MAIL') : GetMessage('WIKI_SOCNET_LOG_COMMENT_TITLE')); $arResult["EVENT_FORMATTED"] = array("TITLE" => $title, "MESSAGE" => $bMail ? CSocNetTextParser::killAllTags($arFields['MESSAGE']) : $arFields['MESSAGE']); if ($bMail) { $url = CSocNetLogTools::FormatEvent_GetURL($arLog); if (strlen($url) > 0) { $arResult['EVENT_FORMATTED']['URL'] = $url; } } else { static $parserLog = false; if (CModule::IncludeModule("forum")) { if (!$parserLog) { $parserLog = new forumTextParser(LANGUAGE_ID); } $arAllow = array("HTML" => "N", "ALIGN" => "Y", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "Y", "VIDEO" => "Y", "LOG_VIDEO" => "N", "SHORT_ANCHOR" => "Y", "USERFIELDS" => $arFields["UF"], "USER" => "Y"); $parserLog->pathToUser = $arParams["PATH_TO_USER"]; $parserLog->arUserfields = $arFields["UF"]; $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), $arAllow)); } else { if (!$parserLog) { $parserLog = new logTextParser(false, $arParams["PATH_TO_SMILE"]); } $arAllow = array("HTML" => "Y", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "LOG_IMG" => "N", "QUOTE" => "Y", "LOG_QUOTE" => "N", "CODE" => "Y", "LOG_CODE" => "N", "FONT" => "Y", "LOG_FONT" => "N", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "Y", "MULTIPLE_BR" => "Y", "VIDEO" => "Y", "LOG_VIDEO" => "N"); $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow)); } if ($arParams["MOBILE"] != "Y" && $arParams["NEW_TEMPLATE"] != "Y") { if (CModule::IncludeModule("forum")) { $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), $arAllow), 500); } else { $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow), 500); } $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = CSocNetLogTools::FormatEvent_IsMessageShort($arResult["EVENT_FORMATTED"]["MESSAGE"], $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"]); } } return $arResult; }
public static function FormatComment($arFields, $arParams, $bMail = false, $arLog = array()) { $arResult = array("EVENT_FORMATTED" => array()); if (!CModule::IncludeModule("socialnetwork")) { return $arResult; } $arResult["EVENT_FORMATTED"] = array("TITLE" => GetMessage('I_NEW_USER_TITLE'), "MESSAGE" => $bMail ? $arFields["TEXT_MESSAGE"] : $arFields["MESSAGE"]); $arResult["ENTITY"]["TYPE_MAIL"] = GetMessage('I_NEW_USER_TITLE'); if ($bMail) { } else { static $parserLog = false; if (CModule::IncludeModule("forum")) { if (!$parserLog) { $parserLog = new forumTextParser(LANGUAGE_ID); } $arAllow = array("HTML" => "N", "ALIGN" => "Y", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "Y", "VIDEO" => "Y", "LOG_VIDEO" => "N", "SHORT_ANCHOR" => "Y", "USERFIELDS" => $arFields["UF"], "USER" => $arParams["IM"] == "Y" ? "N" : "Y"); $parserLog->pathToUser = $parserLog->userPath = $arParams["PATH_TO_USER"]; $parserLog->arUserfields = $arFields["UF"]; $parserLog->bMobile = $arParams["MOBILE"] == "Y"; $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), $arAllow)); $arResult["EVENT_FORMATTED"]["MESSAGE"] = preg_replace("/\\[user\\s*=\\s*([^\\]]*)\\](.+?)\\[\\/user\\]/is" . BX_UTF_PCRE_MODIFIER, "\\2", $arResult["EVENT_FORMATTED"]["MESSAGE"]); } else { if (!$parserLog) { $parserLog = new logTextParser(false, $arParams["PATH_TO_SMILE"]); } $arAllow = array("HTML" => "Y", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "LOG_IMG" => "N", "QUOTE" => "Y", "LOG_QUOTE" => "N", "CODE" => "Y", "LOG_CODE" => "N", "FONT" => "Y", "LOG_FONT" => "N", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "Y", "MULTIPLE_BR" => "N", "VIDEO" => "Y", "LOG_VIDEO" => "N"); $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow)); } if ($arParams["MOBILE"] != "Y" && $arParams["NEW_TEMPLATE"] != "Y") { if (CModule::IncludeModule("forum")) { $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), $arAllow), 500); } else { $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow), 500); } $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = CSocNetLogTools::FormatEvent_IsMessageShort($arResult["EVENT_FORMATTED"]["MESSAGE"], $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"]); } } return $arResult; }
function ParseText($text, $arUF, $arParams) { static $parser = false; if (CModule::IncludeModule("forum")) { if (!$parser) { $parser = new forumTextParser(LANGUAGE_ID); } $parser->pathToUser = $arParams["PATH_TO_USER"]; $parser->arUserfields = $arUF; $textFormatted = $parser->convert($text, array("HTML" => "N", "ALIGN" => "Y", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "Y", "MULTIPLE_BR" => "N", "VIDEO" => "Y", "LOG_VIDEO" => "N", "SHORT_ANCHOR" => "Y", "USERFIELDS" => $arUF), "html"); } else { $parser = new logTextParser(false, $arParams["PATH_TO_SMILE"]); $textFormatted = $parser->convert($text, array(), array("HTML" => "N", "ALIGN" => "Y", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "Y", "MULTIPLE_BR" => "N", "VIDEO" => "Y", "LOG_VIDEO" => "N", "SHORT_ANCHOR" => "Y", "USERFIELDS" => $arUF)); } if (isset($arParams["MAX_LENGTH"]) && intval($arParams["MAX_LENGTH"]) > 0) { $textFormatted = $parser->html_cut($textFormatted, $arParams["MAX_LENGTH"]); } return $textFormatted; }
function FormatComment_Files($arFields, $arParams, $bMail = false, $arLog = array()) { if ($bMail && strlen($arFields["MAIL_LANGUAGE_ID"]) > 0) { IncludeModuleLangFile(__FILE__, $arFields["MAIL_LANGUAGE_ID"]); } $arResult = array("EVENT_FORMATTED" => array()); if ($bMail) { $arResult["CREATED_BY"] = CSocNetLogTools::FormatEvent_GetCreatedBy($arFields, $arParams, $bMail); $arResult["ENTITY"] = CSocNetLogTools::FormatEvent_GetEntity($arLog, $arParams, $bMail); } elseif ($arParams["USE_COMMENT"] != "Y") { $arResult["ENTITY"] = CSocNetLogTools::FormatEvent_GetEntity($arFields, $arParams, false); } if (!$bMail && array_key_exists("URL", $arLog) && strlen($arLog["URL"]) > 0) { $file_tmp = '<a href="' . $arLog["URL"] . '">' . $arLog["TITLE"] . '</a>'; } else { $file_tmp = $arLog["TITLE"]; } if ($bMail) { $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_" . ($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? "GROUP" : "USER") . "_FILE_COMMENT_MAIL"); } else { $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_FILE_COMMENT"); } $title = str_replace(array("#TITLE#", "#ENTITY#", "#CREATED_BY#"), array($file_tmp, $arResult["ENTITY"]["FORMATTED"], $bMail ? $arResult["CREATED_BY"]["FORMATTED"] : ""), $title_tmp); $arResult["EVENT_FORMATTED"] = array("TITLE" => $bMail || $arParams["USE_COMMENT"] != "Y" ? $title : "", "MESSAGE" => $bMail ? $arFields["TEXT_MESSAGE"] : $arFields["MESSAGE"]); if (!$bMail) { $parserLog = new logTextParser(false, $arParams["PATH_TO_SMILE"]); $arAllow = array("HTML" => "Y", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "LOG_VIDEO" => "N", "SHORT_ANCHOR" => "Y"); $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow)); } if ($bMail) { $url = CSocNetLogTools::FormatEvent_GetURL($arLog); if (strlen($url) > 0) { $arResult["EVENT_FORMATTED"]["URL"] = $url; } } if ($bMail && strlen($arFields["MAIL_LANGUAGE_ID"]) > 0) { IncludeModuleLangFile(__FILE__, LANGUAGE_ID); } return $arResult; }
$log_id = $_REQUEST["log_id"]; if ($arLog = CSocNetLog::GetByID($log_id)) { $arCommentEvent = CSocNetLogTools::FindLogCommentEventByLogEventID($arLog["EVENT_ID"]); if ($arCommentEvent) { $feature = CSocNetLogTools::FindFeatureByEventID($arCommentEvent["EVENT_ID"]); if (array_key_exists("OPERATION_ADD", $arCommentEvent) && $arCommentEvent["OPERATION_ADD"] == "log_rights") { $bCanAddComments = CSocNetLogRights::CheckForUser($log_id, $GLOBALS["USER"]->GetID()); } elseif ($feature && array_key_exists("OPERATION_ADD", $arCommentEvent) && strlen($arCommentEvent["OPERATION_ADD"]) > 0) { $bCanAddComments = CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $arLog["ENTITY_TYPE"], $arLog["ENTITY_ID"], $feature == "microblog" ? "blog" : $feature, $arCommentEvent["OPERATION_ADD"], $bCurrentUserIsAdmin); } else { $bCanAddComments = true; } if ($bCanAddComments) { // add source object and get source_id, $source_url $arParams = array("PATH_TO_SMILE" => $_REQUEST["p_smile"], "PATH_TO_USER_BLOG_POST" => $_REQUEST["p_ubp"], "PATH_TO_GROUP_BLOG_POST" => $_REQUEST["p_gbp"], "PATH_TO_USER_MICROBLOG_POST" => $_REQUEST["p_umbp"], "PATH_TO_GROUP_MICROBLOG_POST" => $_REQUEST["p_gmbp"], "BLOG_ALLOW_POST_CODE" => $_REQUEST["bapc"]); $parser = new logTextParser(LANGUAGE_ID, $arParams["PATH_TO_SMILE"]); $comment_text = $_REQUEST["message"]; CUtil::decodeURIComponent($comment_text); $comment_text = Trim($comment_text); if (strlen($comment_text) > 0) { $arAllow = array("HTML" => "N", "ANCHOR" => "Y", "LOG_ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "LIST" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "UPLOAD" => $arForum["ALLOW_UPLOAD"], "NL2BR" => "N", "SMILES" => "N"); $arFields = array("ENTITY_TYPE" => $arLog["ENTITY_TYPE"], "ENTITY_ID" => $arLog["ENTITY_ID"], "EVENT_ID" => $arCommentEvent["EVENT_ID"], "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE" => $parser->convert($comment_text, array(), $arAllow), "TEXT_MESSAGE" => $comment_text, "URL" => $source_url, "MODULE_ID" => false, "SOURCE_ID" => $source_id, "LOG_ID" => $arLog["TMP_ID"], "USER_ID" => $GLOBALS["USER"]->GetID(), "PATH_TO_USER_BLOG_POST" => $arParams["PATH_TO_USER_BLOG_POST"], "PATH_TO_GROUP_BLOG_POST" => $arParams["PATH_TO_GROUP_BLOG_POST"], "PATH_TO_USER_MICROBLOG_POST" => $arParams["PATH_TO_USER_MICROBLOG_POST"], "PATH_TO_GROUP_MICROBLOG_POST" => $arParams["PATH_TO_GROUP_MICROBLOG_POST"], "BLOG_ALLOW_POST_CODE" => $arParams["BLOG_ALLOW_POST_CODE"]); $comment = CSocNetLogComments::Add($arFields, true); if (!is_array($comment) && intval($comment) > 0) { $arResult["commentID"] = $comment; } elseif (is_array($comment) && array_key_exists("MESSAGE", $comment) && strlen($comment["MESSAGE"]) > 0) { $arResult["strMessage"] = $comment["MESSAGE"]; $arResult["commentText"] = $comment_text; } } else { $arResult["strMessage"] = GetMessage("SONET_LOG_COMMENT_EMPTY");
function onAfterMessageAdd($ID, $arFields) { $bSocNetLogRecordExists = false; // add log comment if ((!array_key_exists('PARAM1', $arFields) || $arFields['PARAM1'] != 'IB') && array_key_exists('PARAM2', $arFields) && intval($arFields['PARAM2']) > 0) { $dbRes = CSocNetLog::GetList(array('ID' => 'DESC'), array("EVENT_ID" => "wiki", "SOURCE_ID" => $arFields["PARAM2"]), false, false, array('ID', 'ENTITY_TYPE', 'ENTITY_ID', 'TMP_ID', 'URL')); if ($arRes = $dbRes->Fetch()) { $log_id = $arRes['TMP_ID']; $url = $arRes['URL']; $bSocNetLogRecordExists = true; } else { $rsElement = CIBlockElement::GetByID($arFields['PARAM2']); if ($arElement = $rsElement->Fetch()) { $arWikiElement = CWiki::GetElementById($arElement['ID'], array('IBLOCK_ID' => $arElement['IBLOCK_ID'])); $CWikiParser = new CWikiParser(); $parserLog = new logTextParser(); $arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "N", "TABLE" => "N"); $text4message = $CWikiParser->Parse($arElement['DETAIL_TEXT'], $arElement['DETAIL_TEXT_TYPE'], $arWikiElement['IMAGES']); $text4message = preg_replace("#<br[\\s]*\\/>#is", "#BR#", $text4message); $text4message = htmlspecialcharsback($parserLog->convert($text4message, array(), $arAllow)); $text4message = preg_replace("#\\#BR\\##is", "\n", $text4message); $text4message = $CWikiParser->Clear($text4message); $url = str_replace(array('#group_id#', '#wiki_name#'), array(intval($this->SonetGroupID), urlencode($arElement['NAME'])), $this->arPath['PATH_TO_POST']); $arSoFields = array('ENTITY_TYPE' => SONET_SUBSCRIBE_ENTITY_GROUP, 'IS_CUSTOM_ET' => 'N', 'ENTITY_ID' => intval($this->SonetGroupID), 'EVENT_ID' => 'wiki', 'USER_ID' => $arElement['CREATED_BY'], 'LOG_DATE' => $arElement['DATE_CREATE'], 'LOG_UPDATE' => $arElement['DATE_CREATE'], 'TITLE_TEMPLATE' => GetMessage('WIKI_SONET_LOG_TITLE_TEMPLATE'), 'TITLE' => $arElement['NAME'], 'MESSAGE' => $text4message, 'TEXT_MESSAGE' => '', 'MODULE_ID' => 'wiki', 'URL' => $url, 'CALLBACK_FUNC' => false, 'SOURCE_ID' => $arFields['PARAM2'], 'PARAMS' => 'forum_id=' . $this->ForumID, 'RATING_TYPE_ID' => 'IBLOCK_ELEMENT', 'RATING_ENTITY_ID' => intval($arFields['PARAM2'])); $log_id = CSocNetLog::Add($arSoFields, false); if (intval($log_id) > 0) { CSocNetLog::Update($log_id, array("TMP_ID" => $log_id)); CSocNetLogRights::SetForSonet($log_id, SONET_SUBSCRIBE_ENTITY_GROUP, intval($this->SonetGroupID), "wiki", "view", true); } } } if (intval($log_id) > 0) { $arForum = CForumNew::GetByID($this->ForumID); $parser = new textParser(LANGUAGE_ID, $this->arPath['PATH_TO_SMILE']); $parser->image_params['width'] = false; $parser->image_params['height'] = false; $arAllow = array('HTML' => "N", 'ANCHOR' => "N", 'BIU' => "N", 'IMG' => "N", 'LIST' => "N", 'QUOTE' => "N", 'CODE' => "N", 'FONT' => "N", 'UPLOAD' => $arForum['ALLOW_UPLOAD'], 'NL2BR' => "N", 'SMILES' => "N"); $sAuthorForMail = str_replace('#TITLE#', $arMessage['AUTHOR_NAME'], GetMessage('SONET_FORUM_LOG_TEMPLATE_GUEST')); if ($bSocNetLogRecordExists) { $arMessage = CForumMessage::GetByIDEx($ID); $parser = new textParser(LANGUAGE_ID, $this->arPath['PATH_TO_SMILE']); $parser->image_params['width'] = false; $parser->image_params['height'] = false; if (intVal($arMessage['AUTHOR_ID']) > 0) { $sAuthorForMail = str_replace(array('#URL#', '#TITLE#'), array('http://' . SITE_SERVER_NAME . CComponentEngine::MakePathFromTemplate($this->arPath['PATH_TO_USER'], array('user_id' => $arMessage['AUTHOR_ID'])), $arMessage['AUTHOR_NAME']), GetMessage('SONET_FORUM_LOG_TEMPLATE_AUTHOR')); } $arFieldsForSocnet = array('ENTITY_TYPE' => SONET_SUBSCRIBE_ENTITY_GROUP, 'ENTITY_ID' => intval($this->SonetGroupID), 'EVENT_ID' => 'wiki_comment', '=LOG_DATE' => $GLOBALS['DB']->CurrentTimeFunction(), 'MESSAGE' => $parser->convert($arMessage['POST_MESSAGE'], $arAllow), 'TEXT_MESSAGE' => $parser->convert4mail($arMessage['POST_MESSAGE'] . $sAuthorForMail), 'URL' => $url, 'MODULE_ID' => false, 'SOURCE_ID' => $ID, 'LOG_ID' => $log_id, 'RATING_TYPE_ID' => 'FORUM_POST', 'RATING_ENTITY_ID' => intval($arMessage['ID'])); if (intVal($arMessage['AUTHOR_ID']) > 0) { $arFieldsForSocnet['USER_ID'] = $arMessage['AUTHOR_ID']; } CSocNetLogComments::Add($arFieldsForSocnet); } else { $dbMessage = CForumMessage::GetListEx(array(), array('TOPIC_ID' => $arFields["TOPIC_ID"], "NEW_TOPIC" => "N")); while ($arMessage = $dbMessage->GetNext()) { if (intVal($arMessage['AUTHOR_ID']) > 0) { $sAuthorForMail = str_replace(array('#URL#', '#TITLE#'), array('http://' . SITE_SERVER_NAME . CComponentEngine::MakePathFromTemplate($this->arPath['PATH_TO_USER'], array('user_id' => $arMessage['AUTHOR_ID'])), $arMessage['AUTHOR_NAME']), GetMessage('SONET_FORUM_LOG_TEMPLATE_AUTHOR')); } $arFieldsForSocnet = array('ENTITY_TYPE' => SONET_SUBSCRIBE_ENTITY_GROUP, 'ENTITY_ID' => intval($this->SonetGroupID), 'EVENT_ID' => 'wiki_comment', '=LOG_DATE' => $GLOBALS['DB']->CharToDateFunction($arMessage['POST_DATE'], "FULL", SITE_ID), 'MESSAGE' => $parser->convert($arMessage['POST_MESSAGE'], $arAllow), 'TEXT_MESSAGE' => $parser->convert4mail($arMessage['POST_MESSAGE'] . $sAuthorForMail), 'URL' => $url, 'MODULE_ID' => false, 'SOURCE_ID' => $ID, 'LOG_ID' => $log_id, 'RATING_TYPE_ID' => 'FORUM_POST', 'RATING_ENTITY_ID' => intval($arMessage['ID'])); if (intVal($arMessage['AUTHOR_ID']) > 0) { $arFieldsForSocnet['USER_ID'] = $arMessage['AUTHOR_ID']; } CSocNetLogComments::Add($arFieldsForSocnet); } } } } }
private function createLogEntry($iblockElementID) { $rsElement = CIBlockElement::GetByID($iblockElementID); if ($arElement = $rsElement->Fetch()) { $arWikiElement = CWiki::GetElementById($arElement['ID'], array('IBLOCK_ID' => $arElement['IBLOCK_ID'])); $CWikiParser = new CWikiParser(); $parserLog = new logTextParser(); $arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "N", "TABLE" => "N"); $text4message = $CWikiParser->Parse($arElement['DETAIL_TEXT'], $arElement['DETAIL_TEXT_TYPE'], $arWikiElement['IMAGES']); $text4message = preg_replace("#<br[\\s]*\\/>#is", "#BR#", $text4message); $text4message = htmlspecialcharsback($parserLog->convert($text4message, array(), $arAllow)); $text4message = preg_replace("#\\#BR\\##is", "\n", $text4message); $text4message = $CWikiParser->Clear($text4message); $url = str_replace(array('#group_id#', '#wiki_name#'), array(intval($this->SonetGroupID), urlencode($arElement['NAME'])), $this->arPath['PATH_TO_POST']); $arSoFields = array('ENTITY_TYPE' => SONET_SUBSCRIBE_ENTITY_GROUP, 'IS_CUSTOM_ET' => 'N', 'ENTITY_ID' => intval($this->SonetGroupID), 'EVENT_ID' => 'wiki', 'USER_ID' => $arElement['CREATED_BY'], 'LOG_DATE' => $arElement['DATE_CREATE'], 'LOG_UPDATE' => $arElement['DATE_CREATE'], 'TITLE_TEMPLATE' => GetMessage('WIKI_SONET_LOG_TITLE_TEMPLATE'), 'TITLE' => $arElement['NAME'], 'MESSAGE' => $text4message, 'TEXT_MESSAGE' => '', 'MODULE_ID' => 'wiki', 'URL' => $url, 'CALLBACK_FUNC' => false, 'SOURCE_ID' => intval($iblockElementID), 'PARAMS' => 'forum_id=' . $this->ForumID, 'RATING_TYPE_ID' => 'IBLOCK_ELEMENT', 'RATING_ENTITY_ID' => intval($iblockElementID)); $log_id = CSocNetLog::Add($arSoFields, false); $log_user_id = $arElement['CREATED_BY']; $log_title = $arElement["NAME"]; if (intval($log_id) > 0) { CSocNetLog::Update($log_id, array("TMP_ID" => $log_id)); CSocNetLogRights::SetForSonet($log_id, SONET_SUBSCRIBE_ENTITY_GROUP, intval($this->SonetGroupID), "wiki", "view", true); return array("LOG_ID" => $log_id, "LOG_USER_ID" => $log_user_id, "LOG_TITLE" => $log_title, "URL" => $url); } } return false; }
function FormatComment_Data($arFields, $arParams, $bMail = false, $arLog = array()) { $arResult = array("EVENT_FORMATTED" => array()); if (!CModule::IncludeModule("socialnetwork")) { return $arResult; } if ($arLog["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_PROVIDER) { $arResult["ENTITY"] = CXDILFEventHandlers::GetEntity_Data($arLog, $bMail); } elseif (in_array($arLog["ENTITY_TYPE"], array(SONET_SUBSCRIBE_ENTITY_GROUP, SONET_SUBSCRIBE_ENTITY_USER))) { $arResult["ENTITY"] = CSocNetLogTools::FormatEvent_GetEntity($arLog, $arParams, $bMail); } if (!$bMail && $arParams["USE_COMMENT"] != "Y") { $arLog["ENTITY_ID"] = $arFields["ENTITY_ID"]; $arLog["ENTITY_TYPE"] = $arFields["ENTITY_TYPE"]; } if (!$bMail && array_key_exists("URL", $arLog) && strlen($arLog["URL"]) > 0) { $news_tmp = '<a href="' . $arLog["URL"] . '">' . $arLog["TITLE"] . '</a>'; } else { $news_tmp = $arLog["TITLE"]; } $title_tmp = $bMail ? GetMessage("LFP_SOCNET_LOG_DATA_COMMENT_" . $arLog["ENTITY_TYPE"] . "_TITLE_MAIL") : GetMessage("LFP_SOCNET_LOG_DATA_COMMENT_TITLE"); $title = str_replace(array("#TITLE#", "#ENTITY#"), array($news_tmp, $bMail ? $arResult["ENTITY"]["FORMATTED"] : $arResult["ENTITY"]["FORMATTED"]["NAME"]), $title_tmp); $arResult["EVENT_FORMATTED"] = array("TITLE" => $bMail || $arParams["USE_COMMENT"] != "Y" ? $title : "", "MESSAGE" => $bMail ? $arFields["TEXT_MESSAGE"] : $arFields["MESSAGE"]); if ($bMail) { $url = CSocNetLogTools::FormatEvent_GetURL($arLog, true); if (strlen($url) > 0) { $arResult["EVENT_FORMATTED"]["URL"] = $url; } } else { static $parserLog = false; if (CModule::IncludeModule("forum")) { $arAllow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "LOG_IMG" => "N", "QUOTE" => "Y", "LOG_QUOTE" => "N", "CODE" => "Y", "LOG_CODE" => "N", "FONT" => "Y", "LOG_FONT" => "N", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "Y", "MULTIPLE_BR" => "N", "VIDEO" => "Y", "LOG_VIDEO" => "N", "USERFIELDS" => $arFields["UF"], "USER" => $arParams["IM"] == "Y" ? "N" : "Y"); if (!$parserLog) { $parserLog = new forumTextParser(LANGUAGE_ID); } $parserLog->pathToUser = $arParams["PATH_TO_USER"]; $parserLog->arUserfields = $arFields["UF"]; $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), $arAllow)); $arResult["EVENT_FORMATTED"]["MESSAGE"] = preg_replace("/\\[user\\s*=\\s*([^\\]]*)\\](.+?)\\[\\/user\\]/is" . BX_UTF_PCRE_MODIFIER, "\\2", $arResult["EVENT_FORMATTED"]["MESSAGE"]); } else { $arAllow = array("HTML" => "Y", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "LOG_IMG" => "N", "QUOTE" => "Y", "LOG_QUOTE" => "N", "CODE" => "Y", "LOG_CODE" => "N", "FONT" => "Y", "LOG_FONT" => "N", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "Y", "MULTIPLE_BR" => "N", "VIDEO" => "Y", "LOG_VIDEO" => "N", "USERFIELDS" => $arFields["UF"], "USER" => "Y"); if (!$parserLog) { $parserLog = new logTextParser(false, $arParams["PATH_TO_SMILE"]); } $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow)); } if ($arParams["MOBILE"] != "Y" && $arParams["NEW_TEMPLATE"] != "Y") { if (CModule::IncludeModule("forum")) { $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), $arAllow), 500); } else { $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow), 500); } $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = CSocNetLogTools::FormatEvent_IsMessageShort($arResult["EVENT_FORMATTED"]["MESSAGE"], $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"]); } } return $arResult; }