function onExecuteStartWriting(\Bitrix\Main\Event $event) { $parameters = $event->getParameters(); $userId = $parameters[0]; $dialogId = $parameters[1] . $parameters[2]; if ($userId > 0) { if (!\Bitrix\Main\Loader::includeModule('pull')) { return; } \CPushManager::DeleteFromQueueBySubTag($userId, 'IM_MESS'); if (intval($dialogId) > 0) { \CPullStack::AddByUser($dialogId, array('module_id' => 'im', 'command' => 'startWriting', 'expiry' => 60, 'params' => array('senderId' => $userId, 'dialogId' => $dialogId))); } elseif (substr($dialogId, 0, 4) == 'chat') { $chatId = substr($dialogId, 4); $arRelation = \CIMChat::GetRelationById($chatId); unset($arRelation[$userId]); $pullMessage = array('module_id' => 'im', 'command' => 'startWriting', 'expiry' => 60, 'params' => array('senderId' => $userId, 'dialogId' => $dialogId)); \CPullStack::AddByUsers(array_keys($arRelation), $pullMessage); $orm = \Bitrix\Im\ChatTable::getById($chatId); $chat = $orm->fetch(); if ($chat['TYPE'] == IM_MESSAGE_OPEN) { \CPullWatch::AddToStack('IM_PUBLIC_' . $chatId, $pullMessage); } } } }
/** * @return bool */ public function executeComponent() { if (!CModule::IncludeModule('pull')) { return false; } global $USER; // set pull watch tag for current user CPullWatch::Add($USER->GetId(), 'PULL_TEST'); $this->arResult['ajaxLink'] = $this->getPath() . '/ajax.php'; $this->includeComponentTemplate(); return true; }
$entity_xml_id = "TASK_" . $arActivity["ASSOCIATED_ENTITY_ID"]; } elseif ($arLog["ENTITY_TYPE"] == "WF" && $arLog["SOURCE_ID"] > 0 && CModule::IncludeModule('bizproc') && ($workflowId = \CBPStateService::getWorkflowByIntegerId($arLog["SOURCE_ID"]))) { $entity_xml_id = "WF_" . $workflowId; } elseif (array_key_exists($arLog["EVENT_ID"], $entities_xml_id) && $arLog["SOURCE_ID"] > 0) { $entity_xml_id = $entities_xml_id[$arLog["EVENT_ID"]][0] . "_" . $arLog["SOURCE_ID"]; } else { $entity_xml_id = strtoupper($arLog["EVENT_ID"]) . "_" . $arLog["ID"]; } $commentId = !!$arComment["SOURCE_ID"] ? $arComment["SOURCE_ID"] : $arComment["ID"]; $arPullMessageParams = array("ID" => $commentId, "ENTITY_XML_ID" => $entity_xml_id, "FULL_ID" => array($entity_xml_id, $commentId), "NEW" => "Y", "APPROVED" => "Y", "POST_TIMESTAMP" => $arResult["timestamp"] - CTimeZone::GetOffset(), "POST_TIME" => $arTmpCommentEvent["LOG_TIME_FORMAT"], "POST_DATE" => $arTmpCommentEvent["LOG_TIME_FORMAT"], "~POST_MESSAGE_TEXT" => $arComment["~MESSAGE"], "POST_MESSAGE_TEXT" => $arTmpCommentEvent["MESSAGE_FORMAT"], "URL" => array("LINK" => $arComment["URL"]), "AUTHOR" => array("ID" => $arComment["USER_ID"], "NAME" => $arCreatedBy["FORMATTED"], "URL" => $arCreatedBy["URL"], "AVATAR" => $arTmpCommentEvent["AVATAR_SRC"]), "BEFORE_ACTIONS" => $arTmpCommentEvent["RATING"], "AFTER" => $arTmpCommentEvent["UF"], "ACTION" => "REPLY"); if (IsModuleInstalled("mobile")) { $arPullMessageParams["POST_MESSAGE_TEXT_MOBILE"] = $strMessageMobile; $arPullMessageParams["AFTER_MOBILE"] = $strUFMobile; $arPullMessageParams["BEFORE_ACTIONS_MOBILE"] = $strRatingMobile; } CPullWatch::AddToStack('UNICOMMENTS' . $entity_xml_id, array('module_id' => 'unicomments', 'command' => 'comment', 'params' => $arPullMessageParams)); } } } elseif (is_array($commentIdres) && array_key_exists("MESSAGE", $commentIdres) && strlen($commentIdres["MESSAGE"]) > 0) { $arResult["strMessage"] = $commentIdres["MESSAGE"]; $arResult["commentText"] = $comment_text; } } else { $arResult["strMessage"] = GetMessage("SONET_LOG_COMMENT_EMPTY"); } } else { $arResult["strMessage"] = GetMessage("SONET_LOG_COMMENT_NO_PERMISSIONS"); } } } } elseif ($action == "get_comment") {
public function DeleteUser($chatId, $userId, $checkPermission = true) { global $DB; $chatId = intval($chatId); $userId = intval($userId); if ($chatId <= 0 || $userId <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_EMPTY_USER_OR_CHAT"), "EMPTY_USER_OR_CHAT"); return false; } $strSql = "\n\t\t\tSELECT R.CHAT_ID, C.TITLE CHAT_TITLE, C.AUTHOR_ID CHAT_AUTHOR_ID, C.EXTRANET CHAT_EXTRANET, C.TYPE CHAT_TYPE\n\t\t\tFROM b_im_relation R LEFT JOIN b_im_chat C ON R.CHAT_ID = C.ID\n\t\t\tWHERE R.USER_ID = " . $userId . " AND R.MESSAGE_TYPE IN ('" . IM_MESSAGE_OPEN . "','" . IM_MESSAGE_CHAT . "') AND R.CHAT_ID = " . $chatId; $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); if ($arRes = $dbRes->Fetch()) { $extranetFlag = $arRes["CHAT_EXTRANET"] == "" ? "" : ($arRes["CHAT_EXTRANET"] == "Y" ? true : false); $chatTitle = $arRes['CHAT_TITLE']; $chatType = $arRes['CHAT_TYPE']; $chatAuthorId = intval($arRes['CHAT_AUTHOR_ID']); if ($chatAuthorId == $userId) { $strSql = "\n\t\t\t\t\tSELECT R.USER_ID\n\t\t\t\t\tFROM b_im_relation R\n\t\t\t\t\tWHERE R.CHAT_ID = " . $chatId . " AND R.USER_ID <> " . $chatAuthorId; $strSql = $DB->TopSql($strSql, 1); $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); if ($arRes = $dbRes->Fetch()) { $strSql = "UPDATE b_im_chat SET AUTHOR_ID = " . $arRes['USER_ID'] . " WHERE ID = " . $chatId; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); } } $bSelf = true; $arUsers = array($userId); if (is_object($GLOBALS["USER"]) && $GLOBALS["USER"]->GetId() != $userId) { if ($checkPermission && $chatAuthorId != $GLOBALS["USER"]->GetId()) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_KICK"), "IM_ERROR_KICK"); return false; } $bSelf = false; $arUsers[] = $GLOBALS["USER"]->GetId(); } $arOldRelation = CIMChat::GetRelationById($chatId); $arUsers = CIMContactList::GetUserData(array('ID' => array_keys($arOldRelation), 'DEPARTMENT' => 'N', 'USE_CACHE' => 'N')); $arUsers = $arUsers['users']; if ($bSelf) { $message = GetMessage("IM_CHAT_LEAVE_" . $arUsers[$userId]['gender'], array('#USER_NAME#' => htmlspecialcharsback($arUsers[$userId]['name']))); } else { $message = GetMessage("IM_CHAT_KICK_" . $arUsers[$GLOBALS["USER"]->GetId()]['gender'], array('#USER_1_NAME#' => htmlspecialcharsback($arUsers[$GLOBALS["USER"]->GetId()]['name']), '#USER_2_NAME#' => htmlspecialcharsback($arUsers[$userId]['name']))); } $CIMChat = new CIMChat($userId); $CIMChat->SetReadMessage($chatId); CIMContactList::CleanChatCache($userId); $publicPullWatch = false; if ($chatType == IM_MESSAGE_OPEN && CModule::IncludeModule("pull")) { $publicPullWatch = true; } $relationList = IM\RelationTable::getList(array("select" => array("ID", "USER_ID"), "filter" => array("=CHAT_ID" => $chatId, "=USER_ID" => $userId))); while ($relation = $relationList->fetch()) { if ($publicPullWatch && !$arUsers[$relation["USER_ID"]]['extranet']) { CPullWatch::Add($relation["USER_ID"], 'IM_PUBLIC_' . $chatId, true); } Im\RelationTable::delete($relation["ID"]); CIMContactList::DeleteRecent($chatId, true, $relation["USER_ID"]); if ($extranetFlag !== false) { $isExtranet = false; foreach ($arUsers as $userData) { if ($userData['id'] == $userId) { continue; } if ($userData['extranet']) { $isExtranet = true; break; } } if (!$isExtranet || $extranetFlag === "") { IM\ChatTable::update($chatId, array('EXTRANET' => $isExtranet ? "Y" : "N")); } $extranetFlag = $isExtranet; } } CIMDisk::ChangeFolderMembers($chatId, $userId, false); self::AddMessage(array("TO_CHAT_ID" => $chatId, "MESSAGE" => $message, "FROM_USER_ID" => $this->user_id, "SYSTEM" => 'Y')); foreach ($arOldRelation as $rel) { CPullStack::AddByUser($rel['USER_ID'], array('module_id' => 'im', 'command' => 'chatUserLeave', 'params' => array('chatId' => $chatId, 'chatTitle' => $chatTitle, 'userId' => $userId, 'message' => $bSelf ? '' : htmlspecialcharsbx($message)))); } return true; } $GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_USER_NOT_FOUND"), "USER_NOT_FOUND"); return false; }
public static function onOrderUpdate($orderId, $arFields) { if (!CModule::IncludeModule("pull")) { return false; } CPullWatch::AddToStack('saleOrder', array('module_id' => 'sale', 'command' => 'orderUpdate', 'params' => array("id" => $orderId))); }
?> <script>BX.ready(function(){BX.PULL.extendWatch('VOTE_<?php echo $arResult["VOTE_ID"]; ?> ');});</script><?php } if ($_SERVER["REQUEST_METHOD"] == "POST" && array_key_exists("VOTING.RESULT", $arResult) && array_key_exists("arResult", $arResult["VOTING.RESULT"]) && ($questions = $arResult["VOTING.RESULT"]["arResult"]["QUESTIONS"]) && !empty($questions) && array_key_exists("PUBLIC_VOTE_ID", $_REQUEST) && $_REQUEST["PUBLIC_VOTE_ID"] == $arResult["VOTE_ID"] && array_key_exists("vote", $_REQUEST) && strlen($_REQUEST["vote"]) > 0 && ($GLOBALS["VOTING_ID"] == $arResult["VOTE_ID"] && is_array($_SESSION["VOTE_ARRAY"]) && in_array($arResult["VOTE_ID"], $_SESSION["VOTE_ARRAY"])) && CModule::IncludeModule("pull")) { $result = array(); foreach ($questions as $question) { $result[$question["ID"]] = array(); foreach ($question["ANSWERS"] as $arAnswer) { $result[$question["ID"]][$arAnswer["ID"]] = array('PERCENT' => $arAnswer["PERCENT"], 'USERS' => $arAnswer["USERS"], 'COUNTER' => $arAnswer["COUNTER"]); } } if (!empty($result)) { CPullWatch::AddToStack('VOTE_' . $arResult["VOTE_ID"], array('module_id' => 'vote', 'command' => 'voting', 'params' => array("VOTE_ID" => $arResult["VOTE_ID"], "AUTHOR_ID" => $GLOBALS["USER"]->GetId(), "QUESTIONS" => $result))); } } CJSCore::Init(array('ajax', 'popup')); $GLOBALS['APPLICATION']->SetAdditionalCSS('/bitrix/components/bitrix/rating.vote/templates/like/popup.css'); $uid = $this->params["uid"]; $controller = $this->params["controller"]; $lastVote = intval($this->params["lastVote"]); ?> <script type="text/javascript"> BX.ready(function(){ window.__votevar<?php echo $uid; ?> = 0; window.__vote<?php
/** * Method will be invoked after an database record updated. * * @param array $oldRecord All fields before update. * @param array $newRecord All fields after update. * * @return void */ public function afterUpdateTrigger(array $oldRecord, array $newRecord) { if (!\Bitrix\Main\Loader::includeModule('pull')) { return; } $arFields = \CIMMessenger::GetById($newRecord['ID'], array('WITH_FILES' => 'Y')); if (!$arFields) { return; } $arFields['DATE_MODIFY'] = time() + \CTimeZone::GetOffset(); $CCTP = new \CTextParser(); $CCTP->MaxStringLen = 200; $CCTP->allow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "Y", "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N"); $pullMessage = $CCTP->convertText(htmlspecialcharsbx($arFields['MESSAGE'])); $relations = \CIMChat::GetRelationById($arFields['CHAT_ID']); $arPullMessage = array('id' => $arFields['ID'], 'type' => $arFields['MESSAGE_TYPE'] == IM_MESSAGE_PRIVATE ? 'private' : 'chat', 'text' => $pullMessage, 'date' => $arFields['DATE_MODIFY']); if ($arFields['MESSAGE_TYPE'] == IM_MESSAGE_PRIVATE) { $arFields['FROM_USER_ID'] = $arFields['AUTHOR_ID']; foreach ($relations as $rel) { if ($rel['USER_ID'] != $arFields['AUTHOR_ID']) { $arFields['TO_USER_ID'] = $rel['USER_ID']; } } $arPullMessage['fromUserId'] = $arFields['FROM_USER_ID']; $arPullMessage['toUserId'] = $arFields['TO_USER_ID']; } else { $arPullMessage['chatId'] = $arFields['CHAT_ID']; $arPullMessage['senderId'] = $arFields['AUTHOR_ID']; } \CPullStack::AddByUsers(array_keys($relations), $p = array('module_id' => 'im', 'command' => $arFields['PARAMS']['IS_DELETED'] === 'Y' ? 'messageDelete' : 'messageUpdate', 'params' => $arPullMessage)); foreach ($relations as $rel) { $obCache = new \CPHPCache(); $obCache->CleanDir('/bx/imc/recent' . \CIMMessenger::GetCachePath($rel['USER_ID'])); } if ($newRecord['MESSAGE_TYPE'] == IM_MESSAGE_OPEN) { \CPullWatch::AddToStack('IM_PUBLIC_' . $arFields['CHAT_ID'], array('module_id' => 'im', 'command' => $arFields['PARAMS']['IS_DELETED'] === 'Y' ? 'messageDelete' : 'messageUpdate', 'params' => $arPullMessage)); } foreach (\GetModuleEvents("im", "OnAfterMessagesUpdate", true) as $arEvent) { \ExecuteModuleEventEx($arEvent, array(intval($newRecord['ID']), $arFields)); } }
$arPullFields["POST_DATE"] = ltrim($arPullFields["POST_DATE"], '0'); $curYear = date('Y'); $arPullFields["POST_DATE"] = str_replace(array('-' . $curYear, '/' . $curYear, ' ' . $curYear, '.' . $curYear), '', $arPullFields["POST_DATE"]); } if ($arParams["SHOW_RATING"] == "Y") { $arRating = CRatings::GetRatingVoteResult('BLOG_COMMENT', $arComment["ID"]); ob_start(); $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:rating.vote", $arParams["RATING_TYPE"], array("ENTITY_TYPE_ID" => "BLOG_COMMENT", "ENTITY_ID" => $arComment["ID"], "OWNER_ID" => $arComment["AUTHOR_ID"], "USER_VOTE" => $arRating["USER_VOTE"], "USER_HAS_VOTED" => $arRating["USER_HAS_VOTED"], "TOTAL_VOTES" => $arRating["TOTAL_VOTES"], "TOTAL_POSITIVE_VOTES" => $arRating["TOTAL_POSITIVE_VOTES"], "TOTAL_NEGATIVE_VOTES" => $arRating["TOTAL_NEGATIVE_VOTES"], "TOTAL_VALUE" => $arRating["TOTAL_VALUE"], "PATH_TO_USER_PROFILE" => $arParams["~PATH_TO_USER"]), null, array("HIDE_ICONS" => "Y")); $arPullFields["BEFORE_ACTIONS"] = ob_get_clean(); if (IsModuleInstalled("mobile")) { ob_start(); $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:rating.vote", "mobile_comment_" . $arParams["RATING_TYPE"], array("ENTITY_TYPE_ID" => "BLOG_COMMENT", "ENTITY_ID" => $arComment["ID"], "OWNER_ID" => $arComment["AUTHOR_ID"], "USER_VOTE" => $arRating["USER_VOTE"], "USER_HAS_VOTED" => $arRating["USER_HAS_VOTED"], "TOTAL_VOTES" => $arRating["TOTAL_VOTES"], "TOTAL_POSITIVE_VOTES" => $arRating["TOTAL_POSITIVE_VOTES"], "TOTAL_NEGATIVE_VOTES" => $arRating["TOTAL_NEGATIVE_VOTES"], "TOTAL_VALUE" => $arRating["TOTAL_VALUE"], "PATH_TO_USER_PROFILE" => $arParams["~PATH_TO_USER"]), null, array("HIDE_ICONS" => "Y")); $arPullFields["BEFORE_ACTIONS_MOBILE"] = ob_get_clean(); } } CPullWatch::AddToStack('UNICOMMENTSBLOG_' . $arComment["POST_ID"], array('module_id' => 'unicomments', 'command' => 'comment', 'params' => $arPullFields)); } if ($arPost["AUTHOR_ID"] != $user_id) { $arFieldsIM = array("TYPE" => "SHARE", "TITLE" => $arPost["TITLE"], "URL" => CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arParams["PATH_TO_POST"]), array("post_id" => $arParams["ID"], "user_id" => $arPost["AUTHOR_ID"])), "ID" => $arParams["ID"], "FROM_USER_ID" => $user_id, "TO_USER_ID" => array($arPost["AUTHOR_ID"])); CBlogPost::NotifyIm($arFieldsIM); } if (!empty($arUsers2Notify)) { $arFieldsIM = array("TYPE" => "SHARE2USERS", "TITLE" => $arPost["TITLE"], "URL" => CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arParams["PATH_TO_POST"]), array("post_id" => $arParams["ID"], "user_id" => $arPost["AUTHOR_ID"])), "ID" => $arParams["ID"], "FROM_USER_ID" => $user_id, "TO_USER_ID" => $arUsers2Notify); CBlogPost::NotifyIm($arFieldsIM); } } /* update socnet log rights*/ $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => array("blog_post", "blog_post_important"), "SOURCE_ID" => $arPost["ID"]), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID")); if ($arRes = $dbRes->Fetch()) { $arLogSites = array(); $rsLogSite = CSocNetLog::GetSite($arRes["ID"]);
} $arParams = array("MOBILE" => "Y", "PATH_TO_USER" => $_REQUEST["p_user"], "PATH_TO_GROUP" => $_REQUEST["p_group"], "PATH_TO_CONPANY_DEPARTMENT" => $_REQUEST["p_dep"], "PATH_TO_CRMLEAD" => $_REQUEST["p_crmlead"], "PATH_TO_CRMDEAL" => $_REQUEST["p_crmdeal"], "PATH_TO_CRMCONTACT" => $_REQUEST["p_crmcontact"], "PATH_TO_CRMCOMPANY" => $_REQUEST["p_crmcompany"], "NAME_TEMPLATE" => $_REQUEST["nt"], "SHOW_LOGIN" => $_REQUEST["sl"], "DESTINATION_LIMIT" => 100, "CHECK_PERMISSIONS_DEST" => "N", "CREATED_BY" => $author_id); $arDestinations = CSocNetLogTools::FormatDestinationFromRights($arRights, $arParams, $iMoreCount); if (is_array($arDestinations)) { $iDestinationsHidden = 0; $arGroupID = CSocNetLogTools::GetAvailableGroups(); foreach ($arDestinations as $key => $arDestination) { if (array_key_exists("TYPE", $arDestination) && array_key_exists("ID", $arDestination) && $arDestination["TYPE"] == "SG" && !in_array(intval($arDestination["ID"]), $arGroupID)) { unset($arDestinations[$key]); $iDestinationsHidden++; } } $arResult["arDestinations"] = array_slice($arDestinations, $iDestinationLimit); $arResult["iDestinationsHidden"] = $iDestinationsHidden; } } } elseif ($action == "send_comment_writing" && CModule::IncludeModule("pull")) { $arParams = array("ENTITY_XML_ID" => $_REQUEST["ENTITY_XML_ID"], "NAME_TEMPLATE" => $_REQUEST["nt"], "SHOW_LOGIN" => $_REQUEST["sl"], "AVATAR_SIZE_COMMENT" => intval($as)); $rsUser = CUser::GetList($by = "last_name", $order = "asc", array("ID" => intval($GLOBALS["USER"]->GetId())), array("FIELDS" => array("ID", "NAME", "LAST_NAME", "SECOND_NAME", "LOGIN", "PERSONAL_GENDER", "PERSONAL_PHOTO"))); if ($arUser = $rsUser->Fetch()) { $arFileTmp = CFile::ResizeImageGet($arUser["PERSONAL_PHOTO"], array("width" => $arParams["AVATAR_SIZE_COMMENT"], "height" => $arParams["AVATAR_SIZE_COMMENT"]), BX_RESIZE_IMAGE_EXACT, false); CPullWatch::AddToStack('UNICOMMENTS' . $_REQUEST["ENTITY_XML_ID"], array('module_id' => 'unicomments', 'command' => 'answer', 'expiry' => 60, 'params' => array("USER_ID" => $arUser["ID"], "ENTITY_XML_ID" => $_REQUEST["ENTITY_XML_ID"], "TS" => time(), "NAME" => CUser::FormatName($arParams["NAME_TEMPLATE"], $arUser, $arParams["SHOW_LOGIN"] != "N" ? true : false), "AVATAR" => $arFileTmp && isset($arFileTmp['src']) ? $arFileTmp['src'] : false))); $arResult["SUCCESS"] = 'Y'; } } header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); echo \Bitrix\Main\Web\Json::encode($arResult); } define('PUBLIC_AJAX_MODE', true); require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php"; die;
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } if ($GLOBALS["USER"]->IsAuthorized() && CModule::IncludeModule("pull")) { CPullWatch::Add($GLOBALS["USER"]->GetID(), 'VOTE_' . $arResult["VOTE_ID"]); ?> <script>BX.ready(function(){BX.PULL.extendWatch('VOTE_<?php echo $arResult["VOTE_ID"]; ?> ');});</script><?php } if ($this->__page == "result") { ?> <div class="bx-vote-block bx-vote-block-result"><?php } else { ?> <div class="bx-vote-block"><?php } if (isset($_REQUEST["AUTH_FORM"]) && $_REQUEST["AUTH_FORM"] != '') { $_REQUEST["AJAX_POST"] = "N"; } if ($_REQUEST["VOTE_ID"] == $arParams["VOTE_ID"] && $_REQUEST["AJAX_POST"] == "Y" && check_bitrix_sessid()) { ob_start(); }
?> </div><?php } ?> </div><?php ?> </div><?php } ?> </div><?php // post-item-top-wrap if (!$arParams["IS_LIST"]) { if ($arResult["Post"]["ENABLE_COMMENTS"] == "Y" && strlen($strCommentsBlock) > 0) { echo $strCommentsBlock; if ($GLOBALS["USER"]->IsAuthorized() && CModule::IncludeModule("pull") && CPullOptions::GetNginxStatus()) { CPullWatch::Add($GLOBALS["USER"]->GetID(), "UNICOMMENTSBLOG_" . intval($arResult["Post"]["ID"])); } } } ?> </div><?php // post-wrap / lenta-item ?> <script type="text/javascript"> BX.ready(function() { oMSL.arBlockToCheck[<?php echo $arParams["LOG_ID"]; ?> ] = { lenta_item_id: 'lenta_item_<?php
public static function Like($id, $action = 'auto') { global $USER; if (!CModule::IncludeModule('pull')) { return false; } $action = in_array($action, array('plus', 'minus')) ? $action : 'auto'; $message = self::GetById($id, array('WITH_FILES' => 'Y')); if (!$message) { return false; } $relations = CIMMessenger::GetRelationById($id); if (!isset($relations[$USER->GetId()])) { return false; } $isLike = false; if (isset($message['PARAMS']['LIKE'])) { $isLike = in_array($USER->GetId(), $message['PARAMS']['LIKE']); } if ($isLike && $action == 'plus') { return false; } else { if (!$isLike && $action == 'minus') { return false; } } $isLike = true; if (isset($message['PARAMS']['LIKE'])) { $like = $message['PARAMS']['LIKE']; $selfLike = array_search($USER->GetId(), $like); if ($selfLike !== false) { $isLike = false; unset($like[$selfLike]); } else { $like[] = $USER->GetId(); } } else { $like = array($USER->GetId()); } sort($like); CIMMessageParam::Set($id, array('LIKE' => $like)); $result = IM\ChatTable::getList(array('filter' => array('=ID' => $message['CHAT_ID']))); $chat = $result->fetch(); if ($message['AUTHOR_ID'] > 0 && $message['AUTHOR_ID'] != $USER->GetId() && $isLike) { $CCTP = new CTextParser(); $CCTP->MaxStringLen = 200; $CCTP->allow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N"); $message['MESSAGE'] = str_replace('<br />', ' ', $CCTP->convertText($message['MESSAGE'])); $message['MESSAGE'] = preg_replace("/\\[s\\].*?\\[\\/s\\]/i", "", $message['MESSAGE']); $message['MESSAGE'] = preg_replace("/\\[[bui]\\](.*?)\\[\\/[bui]\\]/i", "\$1", $message['MESSAGE']); $message['MESSAGE'] = preg_replace("/\\[USER=([0-9]{1,})\\](.*?)\\[\\/USER\\]/i", "\$2", $message['MESSAGE']); $message['MESSAGE'] = preg_replace('#\\-{54}.+?\\-{54}#s', " [" . GetMessage('IM_QUOTE') . "] ", str_replace(array("#BR#"), array(" "), $message['MESSAGE'])); if (count($message['FILES']) > 0 && strlen($message['MESSAGE']) < 200) { foreach ($message['FILES'] as $file) { $file = " [" . GetMessage('IM_MESSAGE_FILE') . ": " . $file['name'] . "]"; if (strlen($message['MESSAGE'] . $file) > 200) { break; } $message['MESSAGE'] .= $file; } $message['MESSAGE'] = trim($message['MESSAGE']); } $isChat = $chat && strlen($chat['TITLE']) > 0; $dot = strlen($message['MESSAGE']) >= 200 ? '...' : ''; $message['MESSAGE'] = substr($message['MESSAGE'], 0, 199) . $dot; $message['MESSAGE'] = strlen($message['MESSAGE']) > 0 ? $message['MESSAGE'] : '-'; $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => $message['AUTHOR_ID'], "FROM_USER_ID" => $USER->GetId(), "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "im", "NOTIFY_EVENT" => "like", "NOTIFY_TAG" => "RATING|IM|" . ($isChat ? 'G' : 'P') . "|" . ($isChat ? $chat['ID'] : $USER->GetId()) . "|" . $id, "NOTIFY_MESSAGE" => GetMessage($isChat ? 'IM_MESSAGE_LIKE' : 'IM_MESSAGE_LIKE_PRIVATE', array('#MESSAGE#' => $message['MESSAGE'], '#TITLE#' => $isChat ? '[CHAT=' . $chat['ID'] . ']' . $chat['TITLE'] . '[/CHAT]' : $chat['TITLE'])), "NOTIFY_MESSAGE_OUT" => GetMessage($isChat ? 'IM_MESSAGE_LIKE' : 'IM_MESSAGE_LIKE_PRIVATE', array('#MESSAGE#' => $message['MESSAGE'], '#TITLE#' => $chat['TITLE']))); CIMNotify::Add($arMessageFields); } $arPullMessage = array('id' => $id, 'chatId' => $chat['ID'], 'senderId' => $USER->GetId(), 'users' => $like); foreach ($relations as $rel) { CPullStack::AddByUser($rel['USER_ID'], array('module_id' => 'im', 'command' => 'messageLike', 'params' => $arPullMessage)); } if ($chat['TYPE'] == IM_MESSAGE_OPEN) { CPullWatch::AddToStack('IM_PUBLIC_' . $chat['ID'], array('module_id' => 'im', 'command' => 'messageLike', 'params' => $arPullMessage)); } return $like; }
public static function EmitPullWithTag($arRecipients, $tag, $cmd, $arParams) { if (!is_array($arRecipients)) { throw new TasksException('EA_PARAMS', TasksException::TE_WRONG_ARGUMENTS); } $arRecipients = array_unique($arRecipients); if (!CModule::IncludeModule('pull')) { return; } $bWasFatalError = false; foreach ($arRecipients as $userId) { $userId = (int) $userId; if ($userId < 1) { $bWasFatalError = true; continue; // skip invalid items } //CPullStack::AddByUser($userId, $arEventData); CPullWatch::AddToStack($tag, array('module_id' => 'tasks', 'command' => $cmd, 'params' => $arParams)); } if ($bWasFatalError) { throw new TasksException('EA_PARAMS', TasksException::TE_WRONG_ARGUMENTS); } }
protected function sendIntoPull(array &$arParams, array &$arResult) { if ((check_bitrix_sessid() && ($this->request->getPost("ENTITY_XML_ID") == $arParams["ENTITY_XML_ID"] || $this->request->getQuery("ENTITY_XML_ID") == $arParams["ENTITY_XML_ID"]) || $arParams["MODE"] == "PULL_MESSAGE") && is_array($arParams["PUSH&PULL"]) && $arParams["PUSH&PULL"]["ID"] > 0 && CModule::IncludeModule("pull") && \CPullOptions::GetNginxStatus()) { if ($arParams["PUSH&PULL"]["ACTION"] != "DELETE") { if (($res = $arParams["RECORDS"][$arParams["PUSH&PULL"]["ID"]]) && $res) { $comment = array_merge($res, $res["WEB"]); unset($comment["WEB"]); unset($comment["MOBILE"]); $comment["ACTION"] = $arParams["PUSH&PULL"]["ACTION"]; $comment["USER_ID"] = $this->getUser()->getId(); \CPullWatch::AddToStack('UNICOMMENTSEXTENDED' . $arParams["ENTITY_XML_ID"], array('module_id' => 'unicomments', 'command' => 'comment', 'params' => $comment)); if ($comment["APPROVED"] == "Y") { \CPullWatch::AddToStack('UNICOMMENTS' . $arParams["ENTITY_XML_ID"], array('module_id' => 'unicomments', 'command' => 'comment', 'params' => $comment)); } else { if ($comment["ACTION"] == "MODERATE") { \CPullWatch::AddToStack('UNICOMMENTS' . $arParams["ENTITY_XML_ID"], array('module_id' => 'unicomments', 'command' => 'comment', 'params' => array("ID" => $comment["ID"], "ENTITY_XML_ID" => $comment["ENTITY_XML_ID"], "APPROVED" => "N", "ACTION" => "HIDE", "USER_ID" => $comment["USER_ID"]))); } } if (IsModuleInstalled("mobile")) { $comment = array_merge($comment, $res["MOBILE"]); \CPullWatch::AddToStack('UNICOMMENTSMOBILEEXTENDED' . $arParams["ENTITY_XML_ID"], array('module_id' => 'unicomments', 'command' => 'comment_mobile', 'params' => $comment)); if ($comment["APPROVED"] == "Y") { \CPullWatch::AddToStack('UNICOMMENTSMOBILE' . $arParams["ENTITY_XML_ID"], array('module_id' => 'unicomments', 'command' => 'comment_mobile', 'params' => $comment)); } else { if ($comment["ACTION"] == "MODERATE") { \CPullWatch::AddToStack('UNICOMMENTSMOBILE' . $arParams["ENTITY_XML_ID"], array('module_id' => 'unicomments', 'command' => 'comment_mobile', 'params' => array("ID" => $comment["ID"], "ENTITY_XML_ID" => $comment["ENTITY_XML_ID"], "APPROVED" => "N", "ACTION" => "HIDE", "USER_ID" => $comment["USER_ID"]))); } } } } } else { \CPullWatch::AddToStack('UNICOMMENTS' . $arParams["ENTITY_XML_ID"], array('module_id' => 'unicomments', 'command' => 'comment', 'params' => array("ID" => $arParams["PUSH&PULL"]["ID"], "ENTITY_XML_ID" => $arParams["ENTITY_XML_ID"], "ACTION" => "DELETE", "USER_ID" => $this->getUser()->getId()))); \CPullWatch::AddToStack('UNICOMMENTSEXTENDED' . $arParams["ENTITY_XML_ID"], array('module_id' => 'unicomments', 'command' => 'comment', 'params' => array("ID" => $arParams["PUSH&PULL"]["ID"], "ENTITY_XML_ID" => $arParams["ENTITY_XML_ID"], "ACTION" => "DELETE", "USER_ID" => $this->getUser()->getId()))); if (IsModuleInstalled("mobile")) { \CPullWatch::AddToStack('UNICOMMENTSMOBILEEXTENDED' . $arParams["ENTITY_XML_ID"], array('module_id' => 'unicomments', 'command' => 'comment_mobile', 'params' => array("ID" => $arParams["PUSH&PULL"]["ID"], "ENTITY_XML_ID" => $arParams["ENTITY_XML_ID"], "ACTION" => "DELETE", "USER_ID" => $this->getUser()->getId()))); \CPullWatch::AddToStack('UNICOMMENTSMOBILE' . $arParams["ENTITY_XML_ID"], array('module_id' => 'unicomments', 'command' => 'comment_mobile', 'params' => array("ID" => $arParams["PUSH&PULL"]["ID"], "ENTITY_XML_ID" => $arParams["ENTITY_XML_ID"], "ACTION" => "DELETE", "USER_ID" => $this->getUser()->getId()))); } } } }
public static function StartWriting($dialogId) { global $USER; if (substr($dialogId, 0, 4) == 'chat') { $arRelation = CIMChat::GetRelationById(substr($dialogId, 4)); if (!isset($arRelation[$USER->GetID()])) { return false; } } foreach (\Bitrix\Main\EventManager::getInstance()->findEventHandlers("im", "OnStartWriting") as $event) { $result = ExecuteModuleEventEx($event, array($USER->GetID(), $dialogId)); } if ($USER->GetID() > 0 && strlen($dialogId) > 0 && CModule::IncludeModule("pull")) { CPushManager::DeleteFromQueueBySubTag($USER->GetID(), 'IM_MESS'); if (intval($dialogId) > 0) { CPullStack::AddByUser($dialogId, array('module_id' => 'im', 'command' => 'startWriting', 'expiry' => 60, 'params' => array('senderId' => $USER->GetID(), 'dialogId' => $dialogId))); } elseif (substr($dialogId, 0, 4) == 'chat') { unset($arRelation[$USER->GetID()]); $pullMessage = array('module_id' => 'im', 'command' => 'startWriting', 'expiry' => 60, 'params' => array('senderId' => $USER->GetID(), 'dialogId' => $dialogId)); CPullStack::AddByUsers(array_keys($arRelation), $pullMessage); $orm = \Bitrix\Im\ChatTable::getById(substr($dialogId, 4)); $chat = $orm->fetch(); if ($chat['TYPE'] == IM_MESSAGE_OPEN) { CPullWatch::AddToStack('IM_PUBLIC_' . $chat['ID'], $pullMessage); } } return true; } return false; }
} } else { $userId = PULL_USER_ID; } if (check_bitrix_sessid()) { if ($_POST['PULL_GET_CHANNEL'] == 'Y') { session_write_close(); $arConfig = CPullChannel::GetConfig($userId, $_POST['CACHE'] == 'Y', $_POST['CACHE'] == 'Y' ? false : true, $_POST['MOBILE'] == 'Y'); if (is_array($arConfig)) { echo CUtil::PhpToJsObject($arConfig); } else { echo CUtil::PhpToJsObject(array('ERROR' => 'ERROR_OPEN_CHANNEL')); } } elseif ($_POST['PULL_UPDATE_WATCH'] == 'Y') { foreach ($_POST['WATCH'] as $tag) { CPullWatch::Extend($userId, $tag); } echo CUtil::PhpToJsObject(array('ERROR' => '')); } elseif ($_POST['PULL_UPDATE_STATE'] == 'Y') { $arMessage = CPullStack::Get($_POST['CHANNEL_ID'], intval($_POST['CHANNEL_LAST_ID'])); $arResult["COUNTERS"] = CUserCounter::GetAllValues($userId); if (!empty($arResult["COUNTERS"])) { $arMessage[] = array('module_id' => 'main', 'command' => 'user_counter', 'params' => $arResult["COUNTERS"]); } echo CUtil::PhpToJsObject(array('MESSAGE' => $arMessage, 'ERROR' => '')); } else { echo CUtil::PhpToJsObject(array('ERROR' => 'UNKNOWN_ERROR')); } } else { echo CUtil::PhpToJsObject(array('BITRIX_SESSID' => bitrix_sessid(), 'ERROR' => 'SESSION_ERROR')); }
public static function UploadAvatar($hash, &$file, &$package, &$upload, &$error) { $post = \Bitrix\Main\Context::getCurrent()->getRequest()->getPostList()->toArray(); $chatId = intval($post['CHAT_ID']); if ($chatId <= 0) { return false; } $chat = IM\ChatTable::getById($chatId)->fetch(); if (!$chat) { return false; } $relationError = true; $chatRelation = CIMChat::GetRelationById($chatId); foreach ($chatRelation as $relation) { if ($relation['USER_ID'] == self::GetUserId()) { $relationError = false; break; } } if ($relationError) { $error = GetMessage('IM_DISK_ERR_AVATAR_1'); return false; } $fileId = CFile::saveFile($file["files"]["default"], self::MODULE_ID); if ($fileId > 0) { if ($chat['AVATAR'] > 0) { CFile::DeLete($chat['AVATAR']); } IM\ChatTable::update($chatId, array('AVATAR' => $fileId)); $file['chatId'] = $chatId; $file['chatAvatar'] = CIMChat::GetAvatarImage($fileId); if ($chat["ENTITY_TYPE"] != 'CALL') { CIMChat::AddSystemMessage(array('CHAT_ID' => $chatId, 'USER_ID' => self::GetUserId(), 'MESSAGE_CODE' => 'IM_DISK_AVATAR_CHANGE_')); } if (CModule::IncludeModule('pull')) { $pullMessage = array('module_id' => 'im', 'command' => 'chatAvatar', 'params' => array('chatId' => $chatId, 'chatAvatar' => $file['chatAvatar'])); CPullStack::AddByUsers(array_keys($chatRelation), $pullMessage); $orm = \Bitrix\Im\ChatTable::getById($chatId); $chat = $orm->fetch(); if ($chat['TYPE'] == IM_MESSAGE_OPEN) { CPullWatch::AddToStack('IM_PUBLIC_' . $chat['ID'], $pullMessage); } } } else { return false; } return true; }
$userId = $USER->GetId(); if (CIMChat::GetGeneralChatId() != intval($_POST['CHAT_ID'])) { CUtil::decodeURIComponent($_POST); $CIMChat = new CIMChat(); $CIMChat->Rename($_POST['CHAT_ID'], $_POST['CHAT_TITLE']); } echo CUtil::PhpToJsObject(array('CHAT_ID' => intval($_POST['CHAT_ID']), 'CHAT_TITLE' => $_POST['CHAT_TITLE'], 'ERROR' => '')); } else { if ($_POST['IM_CHAT_DATA_LOAD'] == 'Y') { CUtil::decodeURIComponent($_POST); $chatId = $_POST['CHAT_ID']; $arChat = CIMChat::GetChatData(array('ID' => $chatId, 'USE_CACHE' => 'Y', 'USER_ID' => $USER->GetId())); $arUser = CIMContactList::GetUserData(array('ID' => $arChat['userInChat'][$chatId])); if (!in_array($USER->GetId(), $arChat['userInChat'][$chatId])) { if ($arChat['chat'][$chatId]['messageType'] == IM_MESSAGE_OPEN && CModule::IncludeModule("pull")) { CPullWatch::Add($USER->GetId(), 'IM_PUBLIC_' . $chatId, true); } } echo CUtil::PhpToJsObject(array('CHAT' => $arChat['chat'], 'CHAT_ID' => $_POST['CHAT_ID'], 'USER_IN_CHAT' => $arChat['userInChat'], 'USER_BLOCK_CHAT' => $arChat['userChatBlockStatus'], 'USERS' => isset($arUser['users']) ? $arUser['users'] : array(), 'USER_IN_GROUP' => isset($arUser['userInGroup']) ? $arUser['userInGroup'] : array(), 'WO_USER_IN_GROUP' => isset($arUser['woUserInGroup']) ? $arUser['woUserInGroup'] : array(), 'ERROR' => '')); } else { if ($_POST['IM_GET_EXTERNAL_DATA'] == 'Y') { $error = ''; $arResult = array('TS' => $_POST['TS'], 'TYPE' => $_POST['TYPE'], 'ERROR' => ''); $arMessage = array(); if ($_POST['TYPE'] == 'user') { $arResult['USER_ID'] = intval($_POST['USER_ID']); if (CIMContactList::AllowToSend(array('TO_USER_ID' => $_POST['USER_ID']))) { $ar = CIMContactList::GetUserData(array('ID' => array($_POST['USER_ID']), 'DEPARTMENT' => 'Y', 'USE_CACHE' => 'N', 'PHONES' => IsModuleInstalled('voximplant') ? 'Y' : 'N')); $arResult['USERS'] = isset($ar['users']) ? $ar['users'] : array(); $arResult['USER_IN_GROUP'] = isset($ar['userInGroup']) ? $ar['userInGroup'] : array(); $arResult['WO_USER_IN_GROUP'] = isset($ar['woUserInGroup']) ? $ar['woUserInGroup'] : array();
'CHANNEL_DT' => $arChannel['CHANNEL_DT'], 'LAST_ID' => $pullChannel['LAST_ID'], 'PATH' => $pullPath, 'PATH_WS' => ($nginxStatus && $webSocketStatus? (CMain::IsHTTPS()? CPullOptions::GetWebSocketSecureUrl($arChannels): CPullOptions::GetWebSocketUrl($arChannels)): ''), 'METHOD' => ($nginxStatus? 'LONG': 'PULL'), 'REVISION' => PULL_REVISION, 'ERROR' => '', )); } else echo CUtil::PhpToJsObject(Array('ERROR' => 'ERROR_OPEN_CHANNEL')); } elseif ($_POST['PULL_UPDATE_WATCH'] == 'Y') { foreach ($_POST['WATCH'] as $tag) CPullWatch::Extend($USER->GetID(), $tag); echo CUtil::PhpToJsObject(Array('ERROR' => '')); } elseif ($_POST['PULL_UPDATE_STATE'] == 'Y') { $arMessage = CPullStack::Get($_POST['CHANNEL_ID'], intval($_POST['CHANNEL_LAST_ID'])); $arResult["COUNTERS"] = CUserCounter::GetAllValues($USER->GetID()); if (!empty($arResult["COUNTERS"])) { $arMessage[] = Array( 'module_id' => 'main', 'command' => 'user_counter', 'params' => $arResult["COUNTERS"] );
define("PULL_AJAX_INIT", true); define("PUBLIC_AJAX_MODE", true); define("NO_KEEP_STATISTIC", "Y"); define("NO_AGENT_STATISTIC", "Y"); define("NO_AGENT_CHECK", true); define("NOT_CHECK_PERMISSIONS", true); define("DisableEventsCheck", true); require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); if (!CModule::IncludeModule("pull")) { echo CUtil::PhpToJsObject(array('ERROR' => 'PULL_MODULE_IS_NOT_INSTALLED')); CMain::FinalActions(); die; } if (intval($USER->GetID()) <= 0) { echo CUtil::PhpToJsObject(array('ERROR' => 'AUTHORIZE_ERROR')); CMain::FinalActions(); die; } if (check_bitrix_sessid()) { if ($_POST['SEND'] == 'Y') { CPullWatch::AddToStack('PULL_TEST', array('module_id' => 'test', 'command' => 'check', 'params' => array("TIME" => time()))); echo CUtil::PhpToJsObject(array('ERROR' => '')); } else { echo CUtil::PhpToJsObject(array('ERROR' => 'UNKNOWN_ERROR')); } } else { echo CUtil::PhpToJsObject(array('BITRIX_SESSID' => bitrix_sessid(), 'ERROR' => 'SESSION_ERROR')); } CMain::FinalActions(); die;
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)); } }
'; MBTasks.preloadedData = false; MBTasks.residentTaskId = false; // ID of task currently located on page MBTasks.showedBaseDataHash = false; // This is for check, that base data changed MBTasks.selectedMatrix = false; MBTasks.gear = 'L'; MBTasks.cache = {}; </script> <!-- <div id="tasks-router-view" style="display:none;"> --> <?php if (CModule::IncludeModule('pull')) { CPullWatch::Add($arParams['USER_ID'], 'TASKS_GENERAL_' . $arParams['USER_ID']); } $arComParams = $arParams; $arComParams['JUST_SHOW_BULK_TEMPLATE'] = 'Y'; $APPLICATION->IncludeComponent('bitrix:mobile.tasks.detail', '.default', $arComParams, false); ?> <!-- </div> --> <div id="tasks-router-edit" style="display:none;"> This is edit form placeholder </div> <div id="tasks-router-removed-task" style="display:none;"> <?php echo GetMessage('MB_TASKS_TASK_SNMROUTER_TASK_WAS_REMOVED'); ?> </div>
function AddLiveComment($commentId = 0, $path = "") { if(IntVal($commentId) <= 0) return; if(CModule::IncludeModule("pull") && CPullOptions::GetNginxStatus()) { if($arComment = CBlogComment::GetByID($commentId)) { if(strlen($path) <= 0 && strlen($arComment["PATH"]) > 0) $path = CComponentEngine::MakePathFromTemplate($arComment["PATH"], array("post_id" =>$arComment["POST_ID"], "comment_id"=>$arComment["ID"])); if(strlen($path) <= 0) { $arPost = CBlogPost::GetByID($arComment["POST_ID"]); $path = $path = CComponentEngine::MakePathFromTemplate($arPost["PATH"], array("post_id" =>$arComment["POST_ID"], "comment_id"=>$arComment["ID"]))."?commentId=".$arComment["ID"]; } CPullWatch::AddToStack("UNICOMMENTSBLOG_".$arComment["POST_ID"], array( 'module_id' => "unicomments", 'command' => "comment", 'params' => Array( "AUTHOR_ID" => $arComment["AUTHOR_ID"], "ID" => $arComment["ID"], "POST_ID" => $arComment["POST_ID"], "TS" => time(), "ACTION" => "REPLY", "URL" => array( "LINK" => $path, ), "ENTITY_XML_ID" => "BLOG_".$arComment["POST_ID"], "APPROVED" => "Y", "NEED_REQUEST" => "Y", ), ) ); } } }
$arResult["newCount"] = 3; } 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"]); } } $arResult["urlToPost"] = CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arParams["PATH_TO_POST"]), array("post_id" => "#source_post_id#", "user_id" => $arPost["AUTHOR_ID"])); if (strpos($arResult["urlToPost"], "?") !== false) { $arResult["urlToPost"] .= "&"; } else { $arResult["urlToPost"] .= "?"; } if ($USER->IsAuthorized()) { $arResult["urlToDelete"] = $arResult["urlToPost"] . "delete_comment_id=#comment_id#&comment_post_id=#post_id#&" . bitrix_sessid_get(); $arResult["urlToHide"] = $arResult["urlToPost"] . "hide_comment_id=#comment_id#&comment_post_id=#post_id#&" . bitrix_sessid_get(); $arResult["urlToShow"] = $arResult["urlToPost"] . "show_comment_id=#comment_id#&comment_post_id=#post_id#&" . bitrix_sessid_get(); } $arResult["urlToMore"] = $arResult["urlToPost"] . "last_comment_id=#comment_id#&comment_post_id=#post_id#&IFRAME=Y"; $arResult["urlToNew"] = $arResult["urlToPost"] . "new_comment_id=#comment_id#&comment_post_id=#post_id#&IFRAME=Y"; include_once $_SERVER["DOCUMENT_ROOT"] . $componentPath . "/component_adit.php"; if (CModule::IncludeModule("pull") && IntVal($arResult["userID"]) > 0 && $arResult["is_ajax_post"] != "Y" && !$arParams["bFromList"]) { CPullWatch::Add($arResult["userID"], 'BLOG_POST_' . $arPost["ID"]); } } $arResult["Post"] = $arPost; $this->IncludeComponentTemplate(); return array("CanUserComment" => $arResult["CanUserComment"], "newCountWOMark" => $arResult["newCountWOMark"]); }
<?php define("PUBLIC_AJAX_MODE", true); define("NO_KEEP_STATISTIC", "Y"); define("NO_AGENT_STATISTIC", "Y"); define("NO_AGENT_CHECK", true); define("DisableEventsCheck", true); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; $arParams["AVATAR_SIZE"] = intval($_REQUEST["AVATAR_SIZE"]); $arParams["AVATAR_SIZE"] = $arParams["AVATAR_SIZE"] > 0 ? $arParams["AVATAR_SIZE"] : 42; $arParams["NAME_TEMPLATE"] = !!$_REQUEST["NAME_TEMPLATE"] ? $_REQUEST["NAME_TEMPLATE"] : CSite::GetNameFormat(); $arParams["SHOW_LOGIN"] = $_REQUEST["SHOW_LOGIN"] == "Y" ? "Y" : "N"; $arResult = array(); if (check_bitrix_sessid() && $_REQUEST["MODE"] == "PUSH&PULL" && $GLOBALS["USER"]->IsAuthorized() && !!$_REQUEST["ENTITY_XML_ID"] && is_array($_SESSION["UC"]) && array_key_exists($_REQUEST["ENTITY_XML_ID"], $_SESSION["UC"]) && time() - $_SESSION["UC"][$_REQUEST["ENTITY_XML_ID"]]["ACTIVITY"] > 10 && CModule::IncludeModule("pull") && CPullOptions::GetNginxStatus()) { $_SESSION["UC"][$_REQUEST["ENTITY_XML_ID"]]["ACTIVITY"] = time(); $dbUser = CUser::GetList($sort_by = array('ID' => 'desc'), $dummy = '', array("ID" => $GLOBALS["USER"]->GetId()), array("FIELDS" => array("ID", "LAST_NAME", "NAME", "SECOND_NAME", "LOGIN", "PERSONAL_PHOTO", "PERSONAL_GENDER"))); $arUser = array(); if ($dbUser && ($arUser = $dbUser->GetNext()) && intval($arUser["PERSONAL_PHOTO"]) > 0) { $arUser["PERSONAL_PHOTO_file"] = CFile::GetFileArray($arUser["PERSONAL_PHOTO"]); $arUser["PERSONAL_PHOTO_resized_30"] = CFile::ResizeImageGet($arUser["PERSONAL_PHOTO_file"], array("width" => $arParams["AVATAR_SIZE"], "height" => $arParams["AVATAR_SIZE"]), BX_RESIZE_IMAGE_EXACT, false, false, true); } $arUserInfo = !!$arUser ? $arUser : array("PERSONAL_PHOTO_resized_30" => array("src" => "")); $arUserInfo["NAME_FORMATED"] = CUser::FormatName($arParams["NAME_TEMPLATE"], array("NAME" => $arUserInfo["~NAME"], "LAST_NAME" => $arUserInfo["~LAST_NAME"], "SECOND_NAME" => $arUserInfo["~SECOND_NAME"], "LOGIN" => $arUserInfo["~LOGIN"], "NAME_LIST_FORMATTED" => ""), $arParams["SHOW_LOGIN"] != "N" ? true : false, false); CPullWatch::AddToStack('UNICOMMENTS' . $_REQUEST["ENTITY_XML_ID"], array('module_id' => 'unicomments', 'command' => 'answer', 'expiry' => 60, 'params' => array("USER_ID" => $GLOBALS["USER"]->GetId(), "ENTITY_XML_ID" => $_REQUEST["ENTITY_XML_ID"], "TS" => time(), "NAME" => $arUserInfo["NAME_FORMATED"], "AVATAR" => $arUserInfo["PERSONAL_PHOTO_resized_30"]["src"]))); die; }
public static function PullChange($type, $arParams) { if (!CModule::IncludeModule('pull')) { return; } $type = strval($type); if ($type === '') { $type = 'update'; } else { $type = strtolower($type); } CPullWatch::AddToStack('CRM_QUOTE_CHANGE', array('module_id' => 'crm', 'command' => "crm_quote_{$type}", 'params' => $arParams)); }
public static function SendPullComment($type, $arFields) { if (!CModule::IncludeModule("pull")) { return; } if ($type == "blog") { $arCommentParams = array("ID" => $arFields["COMMENT_ID"], "ENTITY_XML_ID" => "BLOG_" . $arFields["POST_ID"], "FULL_ID" => array("BLOG_" . $arFields["POST_ID"], $arFields["COMMENT_ID"]), "ACTION" => "REPLY", "APPROVED" => "Y", "PANELS" => array("EDIT" => "N", "MODERATE" => "N", "DELETE" => "N"), "NEW" => "Y", "AUTHOR" => array("ID" => $GLOBALS["USER"]->GetID(), "NAME" => $arFields["arAuthor"]["NAME_FORMATED"], "URL" => $arFields["arAuthor"]["url"], "E-MAIL" => $arFields["arComment"]["AuthorEmail"], "AVATAR" => $arFields["arAuthor"]["PERSONAL_PHOTO_resized"]["src"], "IS_EXTRANET" => is_array($GLOBALS["arExtranetUserID"]) && in_array($GLOBALS["USER"]->GetID(), $GLOBALS["arExtranetUserID"])), "POST_TIMESTAMP" => $arFields["arComment"]["DATE_CREATE_TS"], "POST_TIME" => $arFields["arComment"]["DATE_CREATE_TIME"], "POST_DATE" => $arFields["arComment"]["DateFormated"], "POST_MESSAGE_TEXT" => $arFields["arComment"]["TextFormated"], "POST_MESSAGE_TEXT_MOBILE" => $arFields["arComment"]["TextFormatedMobile"], "URL" => array("LINK" => str_replace(array("##comment_id#", "#comment_id#"), array("", $arFields["COMMENT_ID"]), $arFields["arUrl"]["LINK"]), "EDIT" => "__blogEditComment('" . $arFields["COMMENT_ID"] . "', '" . $arFields["POST_ID"] . "');", "MODERATE" => str_replace(array("#source_post_id#", "#post_id#", "#comment_id#", "&" . bitrix_sessid_get()), array($arFields["POST_ID"], $arFields["POST_ID"], $arFields["COMMENT_ID"], ""), $arFields["arComment"]["CAN_SHOW"] == "Y" ? $arFields["arUrl"]["SHOW"] : ($arFields["arComment"]["CAN_HIDE"] == "Y" ? $arFields["arUrl"]["HIDE"] : "")), "DELETE" => str_replace(array("#source_post_id#", "#post_id#", "#comment_id#", "&" . bitrix_sessid_get()), array($arFields["POST_ID"], $arFields["POST_ID"], $arFields["COMMENT_ID"], ""), $arFields["arUrl"]["DELETE"])), "AFTER" => "", "BEFORE_ACTIONS_MOBILE" => "", "AFTER_MOBILE" => ""); if ($arFields["SHOW_RATING"] == "Y") { ob_start(); $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:rating.vote", $arFields["RATING_TYPE"], array("ENTITY_TYPE_ID" => "BLOG_COMMENT", "ENTITY_ID" => $arFields["arComment"]["ID"], "OWNER_ID" => $arFields["arComment"]["AUTHOR_ID"], "USER_VOTE" => $arFields["arRating"][$arFields["arComment"]["ID"]]["USER_VOTE"], "USER_HAS_VOTED" => $arFields["arRating"][$arFields["arComment"]["ID"]]["USER_HAS_VOTED"], "TOTAL_VOTES" => $arFields["arRating"][$arFields["arComment"]["ID"]]["TOTAL_VOTES"], "TOTAL_POSITIVE_VOTES" => $arFields["arRating"][$arFields["arComment"]["ID"]]["TOTAL_POSITIVE_VOTES"], "TOTAL_NEGATIVE_VOTES" => $arFields["arRating"][$arFields["arComment"]["ID"]]["TOTAL_NEGATIVE_VOTES"], "TOTAL_VALUE" => $arFields["arRating"][$arFields["arComment"]["ID"]]["TOTAL_VALUE"], "PATH_TO_USER_PROFILE" => $arFields["arUrl"]["USER"]), false, array("HIDE_ICONS" => "Y")); $arCommentParams["BEFORE_ACTIONS"] = ob_get_clean(); ob_start(); $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:rating.vote", "mobile_comment_" . $arFields["RATING_TYPE"], array("ENTITY_TYPE_ID" => "BLOG_COMMENT", "ENTITY_ID" => $arFields["arComment"]["ID"], "OWNER_ID" => $arFields["arComment"]["AUTHOR_ID"], "USER_VOTE" => $arFields["arRating"][$arFields["arComment"]["ID"]]["USER_VOTE"], "USER_HAS_VOTED" => $arFields["arRating"][$arFields["arComment"]["ID"]]["USER_HAS_VOTED"], "TOTAL_VOTES" => $arFields["arRating"][$arFields["arComment"]["ID"]]["TOTAL_VOTES"], "TOTAL_POSITIVE_VOTES" => $arFields["arRating"][$arFields["arComment"]["ID"]]["TOTAL_POSITIVE_VOTES"], "TOTAL_NEGATIVE_VOTES" => $arFields["arRating"][$arFields["arComment"]["ID"]]["TOTAL_NEGATIVE_VOTES"], "TOTAL_VALUE" => $arFields["arRating"][$arFields["arComment"]["ID"]]["TOTAL_VALUE"], "PATH_TO_USER_PROFILE" => $arFields["arUrl"]["USER"]), false, array("HIDE_ICONS" => "Y")); $arCommentParams["BEFORE_ACTIONS_MOBILE"] = ob_get_clean(); } $arComment["UF"] = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("BLOG_COMMENT", $arFields["arComment"]["ID"], LANGUAGE_ID); $arUFResult = self::BuildUFFields($arComment["UF"]); $arCommentParams["AFTER"] .= $arUFResult["AFTER"]; $arCommentParams["AFTER_MOBILE"] .= $arUFResult["AFTER_MOBILE"]; if ($arFields["arComment"]["CAN_EDIT"] == "Y") { ob_start(); ?> <script> top.text<?php echo $arFields["arComment"]["ID"]; ?> = text<?php echo $arFields["arComment"]["ID"]; ?> = '<?php echo CUtil::JSEscape(htmlspecialcharsBack($arFields["arComment"]["POST_TEXT"])); ?> '; top.title<?php echo $arFields["arComment"]["ID"]; ?> = title<?php echo $arFields["arComment"]["ID"]; ?> = '<?php echo isset($arFields["arComment"]["TITLE"]) ? CUtil::JSEscape($arFields["arComment"]["TITLE"]) : ''; ?> '; top.arComFiles<?php echo $arFields["arComment"]["ID"]; ?> = [];<?php ?> </script><?php $arCommentParams["AFTER"] .= ob_get_clean(); } CPullWatch::AddToStack('UNICOMMENTSBLOG_' . $arFields["POST_ID"], array('module_id' => 'unicomments', 'command' => 'comment', 'params' => $arCommentParams)); } }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } if ($_REQUEST["AJAX_POST"] == "Y" && $_REQUEST["ENTITY_XML_ID"] == $arParams["ENTITY_XML_ID"] && in_array($_REQUEST["MODE"], array("LIST", "RECORD"))) { include_once __DIR__ . "/html_parser.php"; AddEventHandler('main.post.list', 'OnCommentsDisplayTemplate', __MPLParseRecordsHTML); } if (check_bitrix_sessid() && $GLOBALS["USER"]->IsAuthorized() && !!$_REQUEST["ENTITY_XML_ID"] && $_REQUEST["ENTITY_XML_ID"] == $arParams["ENTITY_XML_ID"] && is_array($arParams["PUSH&PULL"]) && $arParams["PUSH&PULL"]["ACTION"] == "REPLY" && CModule::IncludeModule("pull") && CPullOptions::GetNginxStatus()) { $_SESSION["UC"][$_REQUEST["ENTITY_XML_ID"]]["RECORDS"][] = $arParams["PUSH&PULL"]["ID"]; $res = $arParams["RECORDS"][$arParams["PUSH&PULL"]["ID"]]; if ($res["APPROVED"] != "Y") { $res = array("ID" => $res["ID"], "URL" => $res["URL"], "APPROVED" => "N", "ENTITY_XML_ID" => $res["ENTITY_XML_ID"]); } else { $res["PANELS"] = array("EDIT" => "N", "MODERATE" => "N", "DELETE" => "N"); } CPullWatch::AddToStack('UNICOMMENTS' . $arParams["ENTITY_XML_ID"], array('module_id' => 'unicomments', 'command' => 'comment', 'params' => array_merge($res, array("ACTION" => "REPLY")))); } if ($GLOBALS["USER"]->IsAuthorized() && CModule::IncludeModule("pull") && CPullOptions::GetNginxStatus()) { CPullWatch::Add($GLOBALS["USER"]->GetId(), 'UNICOMMENTS' . $arParams["ENTITY_XML_ID"]); ?> <script> BX.ready(function(){BX.PULL.extendWatch('UNICOMMENTS<?php echo CUtil::JSEscape($arParams["ENTITY_XML_ID"]); ?> ');}); </script> <?php }
$arAdditionalData['SCRIPTS'] = array(); $arHeadScriptsNew = array_unique($arHeadScriptsNew); foreach ($arHeadScriptsNew as $script) { $arAdditionalData["SCRIPTS"][] = CUtil::GetAdditionalFileURL($script); } $additional_data = '<script type="text/javascript" bxrunfirst="true">' . "\n"; $additional_data .= 'top.__logGetNextPageLinkEntities(' . CUtil::PhpToJSObject($component->arResult["ENTITIES_XML_ID"]) . ', ' . CUtil::PhpToJSObject($component->arResult["ENTITIES_CORRESPONDENCE"]) . ');'; $additional_data .= '</script>'; if ($arResult["AJAX_CALL"]) { $strText = ob_get_clean(); echo CUtil::PhpToJSObject(array("PROPS" => array("CONTENT" => $additional_data . $strText, "STRINGS" => array(), "JS" => $arAdditionalData["SCRIPTS"], "CSS" => $arAdditionalData["CSS"]), "LAST_TS" => $arResult["dateLastPageTS"] ? intval($arResult["dateLastPageTS"]) : 0)); } else { echo $additional_data; } if (CModule::IncludeModule("pull")) { CPullWatch::DeferredSql(); } die; } CUtil::InitJSCore(array("ajax")); $arParams["UID"] = randString(4); $arParams["FORM_ID"] = "sonetCommentForm" . $arParams["UID"]; $arParams["ALLOW_VIDEO"] = $arParams["ALLOW_VIDEO"] == "Y" ? "Y" : "N"; $arSmiles = array(); if (!empty($arResult["Smiles"])) { foreach ($arResult["Smiles"] as $arSmile) { $arSmiles[] = array('name' => $arSmile["NAME"], 'path' => $arSmile["IMAGE"], 'code' => str_replace("\\\\", "\\", $arSmile["TYPE"]), 'codes' => str_replace("\\\\", "\\", $arSmile["TYPING"]), 'width' => $arSmile["IMAGE_WIDTH"], 'height' => $arSmile["IMAGE_HEIGHT"]); } } $formParams = array("FORM_ID" => $arParams["FORM_ID"], "SHOW_MORE" => "Y", "PARSER" => array("Bold", "Italic", "Underline", "Strike", "ForeColor", "FontList", "FontSizeList", "RemoveFormat", "Quote", "Code", "CreateLink", "Image", "UploadFile", "InputVideo", "Table", "Justify", "InsertOrderedList", "InsertUnorderedList", "Source", "MentionUser", "Spoiler"), "BUTTONS" => array(in_array("UF_SONET_COM_FILE", $arParams["COMMENT_PROPERTY"]) || in_array("UF_SONET_COM_DOC", $arParams["COMMENT_PROPERTY"]) ? "UploadFile" : "", "CreateLink", "InputVideo", "Quote", "MentionUser"), "TEXT" => array("NAME" => "comment", "VALUE" => "", "HEIGHT" => "80px"), "UPLOAD_FILE" => isset($arResult["COMMENT_PROPERTIES"]["DATA"]["UF_SONET_COM_DOC"]) ? false : (is_array($arResult["COMMENT_PROPERTIES"]["DATA"]) ? $arResult["COMMENT_PROPERTIES"]["DATA"]["UF_SONET_COM_FILE"] : false), "UPLOAD_WEBDAV_ELEMENT" => $arResult["COMMENT_PROPERTIES"]["DATA"]["UF_SONET_COM_DOC"], "UPLOAD_FILE_PARAMS" => array("width" => 400, "height" => 400), "FILES" => array("VALUE" => array(), "DEL_LINK" => $arResult["urlToDelImage"], "SHOW" => "N"), "SMILES" => array("VALUE" => $arSmiles), "LHE" => array("id" => "id" . $arParams["FORM_ID"], "documentCSS" => "body {color:#434343;}", "ctrlEnterHandler" => "__logSubmitCommentForm" . $arParams["UID"], "fontFamily" => "'Helvetica Neue', Helvetica, Arial, sans-serif", "fontSize" => "12px", "bInitByJS" => true, "height" => 80)); ?>
public function addComment($authorId, array $data) { $return = null; if (($res = $this->getDataToShow($authorId)) && !empty($res) && ($res2 = $this->getDataToCheck($this->entityId)) && !empty($res2)) { list($message, $topic, $forum) = $res2; $messageFields = array("POST_MESSAGE" => $data["text"], "PARAM2" => $this->entityId, "APPROVED" => "Y", "PERMISSION_EXTERNAL" => "I", "PERMISSION" => "I"); if ($forum["DEDUPLICATION"] == "Y") { \CForumNew::update($forum["ID"], array("DEDUPLICATION" => "N"), false); } if (!empty($data['fileId'])) { $messageFields['UF_FORUM_MESSAGE_DOC'] = array($data['fileId']); $GLOBALS["UF_FORUM_MESSAGE_DOC"] = array($data['fileId']); } elseif (!empty($data['versionId'])) { $messageFields['UF_FORUM_MESSAGE_VER'] = $data['versionId']; $GLOBALS["UF_FORUM_MESSAGE_VER"] = $data['versionId']; } $comId = ForumAddMessage("REPLY", $message["FORUM_ID"], $message["TOPIC_ID"], 0, $messageFields, $strErrorMessage, $strOKMessage); if ($res['DUPLICATE_TO_SOCNET'] == "Y" && $comId > 0 && Loader::includeModule("socialnetwork")) { if ($res['DUPLICATE_TO_SOCNET'] == "Y") { $arFieldsForSocnet = array("USER_ID" => $authorId, '=LOG_DATE' => $GLOBALS['DB']->currentTimeFunction(), "ENTITY_TYPE" => $res["ENTITY_TYPE"], "ENTITY_ID" => $res["ENTITY_ID"], "EVENT_ID" => $res["EVENT_ID"], "MESSAGE" => $data["text"], "TEXT_MESSAGE" => $data["text"], "URL" => $res["DETAIL_URL"], "MODULE_ID" => $res["MODULE_ID"], "SOURCE_ID" => $comId, "LOG_ID" => $res["LOG_ID"], "RATING_TYPE_ID" => "FORUM_POST", "RATING_ENTITY_ID" => $comId); if (!empty($data['fileId'])) { $arFieldsForSocnet['UF_SONET_COM_DOC'] = array($data['fileId']); $GLOBALS["UF_SONET_COM_DOC"] = array($data['fileId']); } elseif (!empty($data['versionId'])) { $arFieldsForSocnet['UF_SONET_COM_VER'] = $data['versionId']; $GLOBALS["UF_SONET_COM_VER"] = $data['versionId']; } \CSocNetLogComments::add($arFieldsForSocnet, false, false, false); } } if ($comId > 0 && Loader::includeModule("pull") && \CPullOptions::getNginxStatus() && $res["DETAIL_URL"] !== null) { \CPullWatch::addToStack("UNICOMMENTS" . $topic["XML_ID"], array('module_id' => "unicomments", 'command' => "comment", 'params' => array("AUTHOR_ID" => $authorId, "ID" => $comId, "POST_ID" => $this->entityId, "TS" => time(), "ACTION" => "REPLY", "URL" => array("LINK" => str_replace("MID=" . $this->entityId, "MID=" . $comId, $res["DETAIL_URL"])), "ENTITY_XML_ID" => $topic["XML_ID"], "APPROVED" => "Y", "NEED_REQUEST" => "Y"))); } } }