public static function CheckExpireAgent() { global $DB; if (!CPullOptions::ModuleEnable()) { return false; } $sqlDateFunction = null; $dbType = strtolower($DB->type); if ($dbType == "mysql") { $sqlDateFunction = "DATE_SUB(NOW(), INTERVAL 12 HOUR)"; } else { if ($dbType == "mssql") { $sqlDateFunction = "dateadd(HOUR, -12, getdate())"; } else { if ($dbType == "oracle") { $sqlDateFunction = "SYSDATE-1/12"; } } } if (!is_null($sqlDateFunction)) { $strSql = "\n\t\t\t\t\tSELECT CHANNEL_ID\n\t\t\t\t\tFROM b_pull_channel\n\t\t\t\t\tWHERE DATE_CREATE < " . $sqlDateFunction; $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); while ($arRes = $dbRes->Fetch()) { self::Delete($arRes['CHANNEL_ID']); } } return "CPullChannel::CheckExpireAgent();"; }
public static function CheckExpireAgent() { global $DB; if (!CPullOptions::ModuleEnable()) return false; CAgent::RemoveAgent("CPullWatch::CheckExpireAgent();", "pull"); $strSql = "SELECT count(ID) CNT FROM b_pull_watch WHERE DATE_CREATE < DATE_SUB(NOW(), INTERVAL 30 MINUTE)"; $dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__); if ($arRes = $dbRes->Fetch()) { $strSql = "DELETE FROM b_pull_watch WHERE DATE_CREATE < DATE_SUB(NOW(), INTERVAL 30 MINUTE) LIMIT 1000"; $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__); if ($arRes['CNT'] > 1000) { CAgent::AddAgent("CPullWatch::CheckExpireAgent();", "pull", "N", 180, "", "Y", ConvertTimeStamp(time()+CTimeZone::GetOffset()+180, "FULL")); return false; } } CAgent::AddAgent("CPullWatch::CheckExpireAgent();", "pull", "N", 600, "", "Y", ConvertTimeStamp(time()+CTimeZone::GetOffset()+600, "FULL")); return false; }
function CheckModules() { global $APPLICATION; if (!CModule::IncludeModule('pull') || !CPullOptions::GetQueueServerStatus()) { $this->errors[] = GetMessage('VI_CHECK_PULL'); } if (!IsModuleInstalled('im')) { $this->errors[] = GetMessage('VI_CHECK_IM'); } include $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/version.php"; if (version_compare("14.9.2", SM_VERSION) == 1) { $this->errors[] = GetMessage('VI_CHECK_MAIN'); } if (IsModuleInstalled('intranet')) { include $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/intranet/install/version.php"; if (version_compare("14.5.6", $arModuleVersion["VERSION"]) == 1) { $this->errors[] = GetMessage('VI_CHECK_INTRANET'); } } else { $this->errors[] = GetMessage('VI_CHECK_INTRANET_INSTALL'); } if (is_array($this->errors) && !empty($this->errors)) { $APPLICATION->ThrowException(implode("<br>", $this->errors)); return false; } else { return true; } }
public static function AddShared($arMessage, $channelType = 'shared') { if (!CPullOptions::GetQueueServerStatus()) { return false; } $arChannel = CPullChannel::GetChannelShared($channelType); return self::AddByChannel($arChannel['CHANNEL_ID'], $arMessage); }
public static function AddByChannel($channelId, $arMessage) { global $DB; if (strlen($arMessage['module_id'])<=0 || strlen($arMessage['command'])<=0) return false; $arData = Array( 'module_id' => $arMessage['module_id'], 'command' => $arMessage['command'], 'params' => is_array($arMessage['params'])?$arMessage['params']: Array(), ); if (CPullOptions::GetNginxStatus()) { $message = CUtil::PhpToJsObject(Array('CHANNEL_ID' => $channelId, 'MESSAGE' => Array($arData), 'ERROR' => '')); if (!defined('BX_UTF') || !BX_UTF) $message = $GLOBALS['APPLICATION']->ConvertCharset($message, SITE_CHARSET,'utf-8'); $CHTTP = new CHTTP(); $CHTTP->http_timeout = 10; if ($CHTTP->HTTPQuery('POST', CPullOptions::GetPublishUrl($channelId), str_replace("\n", " ", $message))) $result = $CHTTP->result; } else { $arParams = Array( 'CHANNEL_ID' => $channelId, 'MESSAGE' => str_replace("\n", " ", serialize($arData)), '~DATE_CREATE' => $DB->CurrentTimeFunction(), ); $id = IntVal($DB->Add("b_pull_stack", $arParams, Array("MESSAGE"))); $result = $id? '{"channel": "'.$channelId.'", "id": "'.$id.'"}': false; } if (isset($arMessage['push_text']) && strlen($arMessage['push_text'])>0 && isset($arMessage['push_user']) && intval($arMessage['push_user'])>0) { $CPushManager = new CPushManager(); $CPushManager->AddQueue(Array( 'USER_ID' => $arMessage['push_user'], 'MESSAGE' => str_replace("\n", " ", $arMessage['push_text']), 'PARAMS' => $arMessage['push_params'], 'TAG' => isset($arMessage['push_tag'])? $arMessage['push_tag']: '', )); } return $result; }
public static function SendPullEvent($params) { // TODO check params if (!CModule::IncludeModule('pull') || !CPullOptions::GetQueueServerStatus() || $params['USER_ID'] <= 0) { return false; } $config = array(); if ($params['COMMAND'] == 'outgoing') { $config = array("callId" => $params['CALL_ID'], "callIdTmp" => $params['CALL_ID_TMP'] ? $params['CALL_ID_TMP'] : '', "callDevice" => $params['CALL_DEVICE'] == 'PHONE' ? 'PHONE' : 'WEBRTC', "phoneNumber" => $params['PHONE_NUMBER'], "external" => $params['EXTERNAL'] ? true : false, "CRM" => $params['CRM'] ? $params['CRM'] : array()); } else { if ($params['COMMAND'] == 'timeout') { $config = array("callId" => $params['CALL_ID'], "failedCode" => intval($params['FAILED_CODE'])); } } CPullStack::AddByUser($params['USER_ID'], array('module_id' => 'voximplant', 'command' => $params['COMMAND'], 'params' => $config)); return true; }
public static function CheckExpireAgent() { global $DB, $pPERIOD; if (!CPullOptions::ModuleEnable()) { return "CPullWatch::CheckExpireAgent();"; } $pPERIOD = 1200; $strSql = "SELECT count(ID) CNT FROM b_pull_watch WHERE DATE_CREATE < DATE_SUB(NOW(), INTERVAL 32 MINUTE)"; $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); if ($arRes = $dbRes->Fetch()) { $strSql = "DELETE FROM b_pull_watch WHERE DATE_CREATE < DATE_SUB(NOW(), INTERVAL 32 MINUTE) LIMIT 1000"; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); if ($arRes['CNT'] > 1000) { $pPERIOD = 180; } } return "CPullWatch::CheckExpireAgent();"; }
public static function CheckNeedRun($bGetSectionStatus = true) { $arExcludeSites = CPullOptions::GetExcludeSites(); if (isset($arExcludeSites[SITE_ID])) return false; global $CACHE_MANAGER; $bAdminSection = false; if(defined("ADMIN_SECTION") && ADMIN_SECTION == true) $bAdminSection = true; $arResult = Array(); $res = $CACHE_MANAGER->Read(2592000, "pull_cnr"); if ($res) $arResult = $CACHE_MANAGER->Get("pull_cnr"); if(!$res) { $arResult = Array( 'ADMIN_SECTION' => false, 'PUBLIC_SECTION' => false ); $arModule = self::GetDependentModule(); foreach ($arModule as $moduleId => $options) { if (isset($options['ADMIN_SECTION']) && $options['ADMIN_SECTION'] == 'Y') $arResult['ADMIN_SECTION'] = true; if (isset($options['PUBLIC_SECTION']) && $options['PUBLIC_SECTION'] == 'Y') $arResult['PUBLIC_SECTION'] = true; } $CACHE_MANAGER->Set("pull_cnr", $arResult); } return $bGetSectionStatus? $arResult[$bAdminSection? 'ADMIN_SECTION': 'PUBLIC_SECTION']: $arResult; }
public static function AddByChannel($channelId, $arMessage) { global $DB; if (strlen($arMessage['module_id']) <= 0 || strlen($arMessage['command']) <= 0) { return false; } $arData = array('module_id' => $arMessage['module_id'], 'command' => $arMessage['command'], 'params' => is_array($arMessage['params']) ? $arMessage['params'] : array()); if (CPullOptions::GetNginxStatus()) { $CHTTP = new CHTTP(); $CHTTP->http_timeout = 10; if ($CHTTP->HTTPQuery('POST', CPullOptions::GetPublishUrl($channelId), str_replace("\n", " ", CUtil::PhpToJsObject(array('CHANNEL_ID' => $channelId, 'MESSAGE' => array($arData), 'ERROR' => ''))))) { $result = $CHTTP->result; } } else { $arParams = array('CHANNEL_ID' => $channelId, 'MESSAGE' => str_replace("\n", " ", serialize($arData)), '~DATE_CREATE' => $DB->CurrentTimeFunction()); $id = IntVal($DB->Add("b_pull_stack", $arParams, array("MESSAGE"))); $result = $id ? '{"channel": "' . $channelId . '", "id": "' . $id . '"}' : false; } if (isset($arMessage['push_text']) && strlen($arMessage['push_text']) > 0 && isset($arMessage['push_user']) && intval($arMessage['push_user']) > 0) { $CPushManager = new CPushManager(); $CPushManager->AddQueue(array('USER_ID' => $arMessage['push_user'], 'MESSAGE' => str_replace("\n", " ", $arMessage['push_text']), 'PARAMS' => $arMessage['push_params'], 'TAG' => isset($arMessage['push_tag']) ? $arMessage['push_tag'] : '')); } return $result; }
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", ), ) ); } } }
<?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; }
/** * Method will be invoked after new database record inserted. * * @param array $newRecord All fields of inserted record. * * @return void */ public function afterInsertTrigger(array $newRecord) { $arParams = array(); $chatId = $newRecord['CHAT_ID']; $arRel = \CIMChat::GetRelationById($chatId); $arFields['MESSAGE_TYPE'] = ''; foreach ($arRel as $rel) { $arFields['MESSAGE_TYPE'] = $rel["MESSAGE_TYPE"]; break; } $arFields['PARAMS'] = array(); $arFields['FILES'] = array(); //CUserCounter::Increment($arFields['TO_USER_ID'], 'im_message_v2', '**', false); if ($arFields['MESSAGE_TYPE'] == IM_MESSAGE_PRIVATE) { foreach ($arRel as $rel) { if ($rel['USER_ID'] == $newRecord['AUTHOR_ID']) { $arFields['FROM_USER_ID'] = $rel['USER_ID']; } else { $arFields['TO_USER_ID'] = $rel['USER_ID']; } } \CIMContactList::SetRecent(array('ENTITY_ID' => $arFields['TO_USER_ID'], 'MESSAGE_ID' => $newRecord['ID'], 'CHAT_TYPE' => IM_MESSAGE_PRIVATE, 'USER_ID' => $arFields['FROM_USER_ID'])); \CIMContactList::SetRecent(array('ENTITY_ID' => $arFields['FROM_USER_ID'], 'MESSAGE_ID' => $newRecord['ID'], 'CHAT_TYPE' => IM_MESSAGE_PRIVATE, 'USER_ID' => $arFields['TO_USER_ID'])); if (\CModule::IncludeModule('pull')) { $pullMessage = array('module_id' => 'im', 'command' => 'message', 'params' => \CIMMessage::GetFormatMessage(array('ID' => $newRecord['ID'], 'CHAT_ID' => $chatId, 'TO_USER_ID' => $arFields['TO_USER_ID'], 'FROM_USER_ID' => $arFields['FROM_USER_ID'], 'SYSTEM' => $newRecord['NOTIFY_EVENT'] == 'private_system' ? 'Y' : 'N', 'MESSAGE' => $newRecord['MESSAGE'], 'DATE_CREATE' => time(), 'PARAMS' => $arFields['PARAMS'], 'FILES' => $arFields['FILES']))); $pullMessageTo = $pullMessage; if (\CPullOptions::GetPushStatus()) { if (\CIMSettings::GetNotifyAccess($arFields["TO_USER_ID"], 'im', 'message', \CIMSettings::CLIENT_PUSH)) { $pushParams = \CIMMessenger::PreparePushForPrivate(array('FROM_USER_ID' => $arFields['FROM_USER_ID'], 'MESSAGE' => $newRecord['MESSAGE'], 'SYSTEM' => $arFields['SYSTEM'], 'FILES' => $arFields['FILES'])); $pullMessageTo = array_merge($pullMessage, $pushParams); } } \CPullStack::AddByUser($arFields['TO_USER_ID'], $pullMessageTo); \CPullStack::AddByUser($arFields['FROM_USER_ID'], $pullMessage); \CPushManager::DeleteFromQueueBySubTag($arFields['FROM_USER_ID'], 'IM_MESS'); //self::SendBadges($arFields['TO_USER_ID']); } } else { if ($arFields['MESSAGE_TYPE'] == IM_MESSAGE_CHAT || $arFields['MESSAGE_TYPE'] == IM_MESSAGE_OPEN) { foreach ($arRel as $relation) { \CIMContactList::SetRecent(array('ENTITY_ID' => $relation['CHAT_ID'], 'MESSAGE_ID' => $newRecord['ID'], 'CHAT_TYPE' => $relation['MESSAGE_TYPE'], 'USER_ID' => $relation['USER_ID'])); } if (\CModule::IncludeModule('pull')) { $pullMessage = array('module_id' => 'im', 'command' => 'messageChat', 'params' => \CIMMessage::GetFormatMessage(array('ID' => $newRecord['ID'], 'CHAT_ID' => $chatId, 'TO_CHAT_ID' => $chatId, 'FROM_USER_ID' => $newRecord['AUTHOR_ID'], 'MESSAGE' => $newRecord['MESSAGE'], 'SYSTEM' => $newRecord['AUTHOR_ID'] > 0 ? 'N' : 'Y', 'DATE_CREATE' => time(), 'PARAMS' => $arFields['PARAMS'], 'FILES' => $arFields['FILES']))); $chat = \Bitrix\Im\ChatTable::getById($chatId); $chatData = $chat->fetch(); if ($chatData && \CPullOptions::GetPushStatus()) { $pushParams = \CIMMessenger::PreparePushForChat(array('CHAT_ID' => $chatId, 'CHAT_TITLE' => $chatData['TITLE'], 'FROM_USER_ID' => $newRecord['AUTHOR_ID'], 'MESSAGE' => $newRecord['MESSAGE'], 'SYSTEM' => $newRecord['AUTHOR_ID'] > 0 ? 'N' : 'Y', 'FILES' => $arFields['FILES'])); $pullMessage = array_merge($pullMessage, $pushParams); } $pullUsers = array(); $pullUsersSkip = array(); foreach ($arRel as $rel) { $pullUsers[] = $rel['USER_ID']; if ($rel['USER_ID'] == $newRecord['AUTHOR_ID']) { $pullUsersSkip[] = $rel['USER_ID']; \CPushManager::DeleteFromQueueBySubTag($newRecord['AUTHOR_ID'], 'IM_MESS'); } else { if ($rel['NOTIFY_BLOCK'] == 'Y' || !\CIMSettings::GetNotifyAccess($rel['USER_ID'], 'im', $arFields['MESSAGE_TYPE'] == IM_MESSAGE_OPEN ? 'openChat' : 'chat', \CIMSettings::CLIENT_PUSH)) { $pullUsersSkip[] = $rel['USER_ID']; } } } $pullMessage['push']['skip_users'] = $pullUsersSkip; \CPullStack::AddByUsers($pullUsers, $pullMessage); if ($arFields['MESSAGE_TYPE'] == IM_MESSAGE_OPEN) { \CPullWatch::AddToStack('IM_PUBLIC_' . $chatId, $pullMessage); } /* TODO uncomment after fix mantis:66363 \CIMMessenger::SendMention(Array( 'CHAT_ID' => $chatId, 'CHAT_TITLE' => $chatData['TITLE'], 'CHAT_RELATION' => $arRel, 'CHAT_TYPE' => $chatData['TYPE'], 'MESSAGE' => $newRecord['MESSAGE'], 'FILES' => $arFields['FILES'], 'FROM_USER_ID' => $newRecord['AUTHOR_ID'], )); */ //\CIMMessenger::SendBadges($usersForBadges); foreach (\GetModuleEvents("im", "OnAfterMessagesAdd", true) as $arEvent) { \ExecuteModuleEventEx($arEvent, array($newRecord['ID'], $newRecord)); } } } } }
protected static function CheckLiveMode() { return CModule::IncludeModule('pull') && CPullOptions::GetNginxStatus(); }
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)); } }
/** * Return some information about P&P, such as publish url * * @since 14.5.4 * @return array */ protected static function getPullingInfo() { $result = array('enabled' => CModule::IncludeModule('pull') && CPullOptions::ModuleEnable()); if ($result['enabled']) { $result['nginx_used'] = CPullOptions::GetQueueServerStatus(); if ($result['nginx_used']) { $result['server_protocol'] = CPullOptions::GetQueueServerVersion(); $result['publish_url'] = CPullOptions::GetPublishUrl(); $result['pulling_url'] = CPullOptions::GetListenUrl(); $result['pulling_url_secure'] = CPullOptions::GetListenSecureUrl(); $result['websocket_url'] = CPullOptions::GetWebSocketUrl(); $result['websocket_url_secure'] = CPullOptions::GetWebSocketSecureUrl(); } } return $result; }
$arChannels[] = $arChannelShared['CHANNEL_ID']; if ($arChannel['CHANNEL_DT'] > $arChannelShared['CHANNEL_DT']) $arChannel['CHANNEL_DT'] = $arChannelShared['CHANNEL_DT']; } } if ($_POST['MOBILE'] == 'Y') $pullPath = ($nginxStatus? (CMain::IsHTTPS()? CPullOptions::GetListenSecureUrl($arChannels, true): CPullOptions::GetListenUrl($arChannels, true)): '/bitrix/components/bitrix/pull.request/ajax.php?UPDATE_STATE'); else $pullPath = ($nginxStatus? (CMain::IsHTTPS()? CPullOptions::GetListenSecureUrl($arChannels): CPullOptions::GetListenUrl($arChannels)): '/bitrix/components/bitrix/pull.request/ajax.php?UPDATE_STATE'); echo CUtil::PhpToJsObject(Array( 'CHANNEL_ID' => implode('/', $arChannels), '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' => '')); }
die; } if (isset($_REQUEST['AJAX_CALL']) && $_REQUEST['AJAX_CALL'] == 'Y') { return; } if (!CModule::IncludeModule('pull')) { return; } if (defined('BX_PULL_SKIP_INIT')) { return; } $userId = 0; if (defined('PULL_USER_ID')) { $userId = PULL_USER_ID; } else { if ($GLOBALS['USER'] && intval($GLOBALS['USER']->GetID()) > 0) { $userId = intval($GLOBALS['USER']->GetID()); } } if ($userId == 0) { return; } if (CPullOptions::CheckNeedRun()) { CJSCore::Init(array('pull')); $arResult = CPullChannel::GetConfig($userId); if (!(isset($arParams['TEMPLATE_HIDE']) && $arParams['TEMPLATE_HIDE'] == 'Y')) { define("BX_PULL_SKIP_INIT", true); $this->IncludeComponentTemplate(); } } return $arResult;
public static function OnEpilog() { if (!defined('BX_PULL_SKIP_INIT') && !(isset($_REQUEST['AJAX_CALL']) && $_REQUEST['AJAX_CALL'] == 'Y') && $GLOBALS['USER'] && intval($GLOBALS['USER']->GetID()) > 0 && CModule::IncludeModule('pull')) { define("BX_PULL_SKIP_INIT", true); if (CPullOptions::CheckNeedRun()) { CJSCore::Init(array('pull')); $pullConfig = CPullChannel::GetConfig($GLOBALS['USER']->GetID()); global $APPLICATION; $APPLICATION->AddAdditionalJS('<script type="text/javascript">BX.bind(window, "load", function() { BX.PULL.start(' . (empty($pullConfig) ? '' : CUtil::PhpToJsObject($pullConfig)) . '); });</script>'); /* if(!defined("BX_DESKTOP") && !defined("BX_MOBILE") && !defined("ADMIN_SECTION") && !IsModuleInstalled('b24network') && IsModuleInstalled('bitrix24') && (COption::GetOptionString('bitrix24', 'network', 'N') == 'Y')) { CJSCore::Init(array('npull')); $APPLICATION->AddAdditionalJS('<script type="text/javascript">BX.bind(window, "load", function() { BX.NPULL.start(); });</script>'); } */ } } }
public static function Invite($arParams) { $arConfig['CHAT_ID'] = intval($arParams['CHAT_ID']); if ($arConfig['CHAT_ID'] <= 0) { return false; } global $DB, $USER; $arConfig['RECIPIENT_ID'] = intval($arParams['RECIPIENT_ID']); $arConfig['USER_ID'] = intval($arParams['USER_ID']) > 0 ? intval($arParams['USER_ID']) : IntVal($USER->GetID()); $arConfig['VIDEO'] = isset($arParams['VIDEO']) && $arParams['VIDEO'] == 'N' ? 'N' : 'Y'; $arChat = CIMChat::GetChatData(array('ID' => $arConfig['CHAT_ID'])); if (empty($arChat['chat'])) { return false; } $arConfig['CALL_TO_GROUP'] = $arChat['chat'][$arConfig['CHAT_ID']]['type'] == IM_MESSAGE_GROUP; $arConfig['STATUS_TYPE'] = intval($arChat['chat'][$arConfig['CHAT_ID']]['call']); if (!$arConfig['CALL_TO_GROUP'] && !IsModuleInstalled('intranet') && CIMSettings::GetPrivacy(CIMSettings::PRIVACY_CALL, $arConfig['RECIPIENT_ID']) == CIMSettings::PRIVACY_RESULT_CONTACT && CModule::IncludeModule('socialnetwork') && CSocNetUser::IsFriendsAllowed() && !CSocNetUserRelations::IsFriends($arConfig['USER_ID'], $arConfig['RECIPIENT_ID'])) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage('IM_ERROR_CALL_PRIVACY'), "ERROR_FROM_PRIVACY"); return false; } if ($arConfig['STATUS_TYPE'] != IM_CALL_NONE) { if ($arConfig['CALL_TO_GROUP']) { self::MessageToChat($arConfig['CHAT_ID'], "IM_CALL_CHAT_START_", $arConfig['USER_ID'], true); } $strSql = "UPDATE b_im_relation SET CALL_STATUS = " . IM_CALL_STATUS_ANSWER . " WHERE CHAT_ID = " . $arConfig['CHAT_ID'] . " AND USER_ID = " . $arConfig['USER_ID']; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); $arUserData = CIMContactList::GetUserData(array('ID' => $arChat['userInChat'][$arConfig['CHAT_ID']], 'DEPARTMENT' => 'N', 'HR_PHOTO' => 'Y')); $arConfig['USER_DATA']['USERS'] = $arUserData['users']; $arConfig['USER_DATA']['HR_PHOTO'] = $arUserData['hrphoto']; foreach ($arChat['userCallStatus'][$arConfig['CHAT_ID']] as $userId => $callStatus) { if ($userId != $arConfig['USER_ID'] && in_array($callStatus, array(IM_CALL_STATUS_WAIT, IM_CALL_STATUS_ANSWER))) { $arUserToConnect[$userId] = $callStatus; } } $arConfig['USERS_CONNECT'] = $arUserToConnect; $arSend['users'] = $arUserData['users']; $arSend['hrphoto'] = $arUserData['hrphoto']; $arSend['video'] = $arConfig['VIDEO'] == 'Y' ? true : false; $arSend['callToGroup'] = $arConfig['CALL_TO_GROUP']; $arSend['chat'] = $arChat['chat']; $arSend['userChatBlockStatus'] = $arChat['userChatBlockStatus']; $arSend['userInChat'] = $arChat['userInChat']; foreach ($arChat['userCallStatus'][$arConfig['CHAT_ID']] as $userId => $callStatus) { if ($userId != $arConfig['USER_ID'] && !in_array($callStatus, array(IM_CALL_STATUS_DECLINE))) { self::Command($arConfig['CHAT_ID'], $userId, 'invite_join', $arSend); } } } else { if ($arConfig['CALL_TO_GROUP']) { self::MessageToChat($arConfig['CHAT_ID'], "IM_CALL_CHAT_INIT_", $arConfig['USER_ID'], true); } $strSql = "UPDATE b_im_chat SET CALL_TYPE = " . ($arConfig['VIDEO'] == 'Y' ? IM_CALL_VIDEO : IM_CALL_AUDIO) . " WHERE ID = " . $arConfig['CHAT_ID']; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); $strSql = "UPDATE b_im_relation SET CALL_STATUS = " . IM_CALL_STATUS_ANSWER . " WHERE CHAT_ID = " . $arConfig['CHAT_ID'] . " AND USER_ID = " . $arConfig['USER_ID']; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); $arUserToConnect = array(); foreach ($arChat['userCallStatus'][$arConfig['CHAT_ID']] as $userId => $callStatus) { if ($userId != $arConfig['USER_ID']) { $arUserToConnect[$userId] = $callStatus; } } $arUserData = CIMContactList::GetUserData(array('ID' => $arChat['userInChat'][$arConfig['CHAT_ID']], 'DEPARTMENT' => 'N', 'HR_PHOTO' => 'Y')); $arSend['users'] = $arUserData['users']; $arSend['hrphoto'] = $arUserData['hrphoto']; $arSend['video'] = $arConfig['VIDEO'] == 'Y' ? true : false; $arSend['callToGroup'] = $arConfig['CALL_TO_GROUP']; $arSend['chat'] = $arChat['chat']; $arSend['userChatBlockStatus'] = $arChat['userChatBlockStatus']; $arSend['userInChat'] = $arChat['userInChat']; foreach ($arUserToConnect as $userId => $callStatus) { self::Command($arConfig['CHAT_ID'], $userId, 'invite', $arSend); } $arConfig['USER_DATA']['USERS'] = $arUserData['users']; $arConfig['USER_DATA']['HR_PHOTO'] = $arUserData['hrphoto']; if (!$arConfig['CALL_TO_GROUP'] && CModule::IncludeModule('pull') && CPullOptions::GetPushStatus()) { $arSelect = array("ID", "LAST_NAME", "NAME", "LOGIN", "SECOND_NAME"); $dbUsers = CUser::GetList($sort_by = false, $dummy = '', array('ID' => $USER->GetID()), array('FIELDS' => $arSelect)); if ($arUser = $dbUsers->GetNext(true, false)) { $sName = CUser::FormatName(CSite::GetNameFormat(false), $arUser, true, false); $pushText = GetMessage('IM_CALL_INVITE', array('#USER_NAME#' => $sName)); } else { $pushText = GetMessage('IM_CALL_INVITE', array('#USER_NAME#' => GetMessage('IM_CALL_INVITE_NA'))); } $CPushManager = new CPushManager(); foreach ($arUserToConnect as $sendTouserId => $callStatus) { $CPushManager->AddQueue(array('USER_ID' => $sendTouserId, 'MESSAGE' => $pushText, 'EXPIRY' => 0, 'PARAMS' => 'IMINV_' . $USER->GetID() . "_" . time(), 'APP_ID' => 'Bitrix24', 'SOUND' => 'call.aif', 'SEND_IMMEDIATELY' => 'Y')); } } } foreach (GetModuleEvents("im", "OnCallStart", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($arConfig)); } return $arConfig; }
public static function GetConfig($userId, $cache = true, $reopen = false, $mobile = false) { $pullConfig = Array(); if (defined('BX_PULL_SKIP_LS')) $pullConfig['LOCAL_STORAGE'] = 'N'; if (IsModuleInstalled('bitrix24')) $pullConfig['BITRIX24'] = 'Y'; $arChannel = CPullChannel::Get($userId, $cache, $reopen); if (is_array($arChannel)) { $nginxStatus = CPullOptions::GetQueueServerStatus(); $webSocketStatus = false; $arChannels = Array($arChannel['CHANNEL_ID']); if ($nginxStatus) { if (defined('BX_PULL_SKIP_WEBSOCKET')) { $pullConfig['WEBSOCKET'] = 'N'; } else { $webSocketStatus = CPullOptions::GetWebSocketStatus(); } $arChannelShared = CPullChannel::GetShared($cache, $reopen); if (is_array($arChannelShared)) { $arChannels[] = $arChannelShared['CHANNEL_ID']; $arChannel['CHANNEL_DT'] = $arChannel['CHANNEL_DT'].'/'.$arChannelShared['CHANNEL_DT']; } } if ($mobile || defined('BX_MOBILE') || defined('BX_PULL_MOBILE')) { $pullConfig['MOBILE'] = 'Y'; $pullPath = ($nginxStatus? (CMain::IsHTTPS()? CPullOptions::GetListenSecureUrl($arChannels, true): CPullOptions::GetListenUrl($arChannels, true)): '/bitrix/components/bitrix/pull.request/ajax.php?UPDATE_STATE'); } else { $pullPath = ($nginxStatus? (CMain::IsHTTPS()? CPullOptions::GetListenSecureUrl($arChannels): CPullOptions::GetListenUrl($arChannels)): '/bitrix/components/bitrix/pull.request/ajax.php?UPDATE_STATE'); } $pullPathWs = ($nginxStatus && $webSocketStatus? (CMain::IsHTTPS()? CPullOptions::GetWebSocketSecureUrl($arChannels): CPullOptions::GetWebSocketUrl($arChannels)): ''); return $pullConfig+Array( 'CHANNEL_ID' => implode('/', $arChannels), 'CHANNEL_DT' => $arChannel['CHANNEL_DT'], 'LAST_ID' => $arChannel['LAST_ID'], 'PATH' => $pullPath, 'PATH_WS' => $pullPathWs, 'PATH_COMMAND' => defined('BX_PULL_COMMAND_PATH')? BX_PULL_COMMAND_PATH: '', 'METHOD' => ($nginxStatus? 'LONG': 'PULL'), 'REVISION' => PULL_REVISION, 'ERROR' => '', ); } return false; }
public static function SendAgent() { global $DB; if (!CPullOptions::GetPushStatus()) { return false; } $count = 0; $maxId = 0; $pushLimit = 70; $arPush = array(); $sqlDate = ""; $dbType = strtolower($DB->type); if ($dbType == "mysql") { $sqlDate = " WHERE DATE_CREATE < DATE_SUB(NOW(), INTERVAL 15 SECOND) "; } else { if ($dbType == "mssql") { $sqlDate = " WHERE DATE_CREATE < dateadd(SECOND, -15, getdate()) "; } else { if ($dbType == "oracle") { $sqlDate = " WHERE DATE_CREATE < SYSDATE-(1/24/60/60*15) "; } } } $strSql = $DB->TopSql("SELECT ID, USER_ID, MESSAGE, PARAMS FROM b_pull_push_queue" . $sqlDate, 280); $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); while ($arRes = $dbRes->Fetch()) { $arPush[$count][] = $arRes; if ($pushLimit <= count($arPush[$count])) { $count++; } $maxId = $maxId < $arRes['ID'] ? $arRes['ID'] : $maxId; } foreach ($arPush as $arStack) { $CPushManager = new CPushManager(); $CPushManager->SendMessage($arStack, defined('PULL_PUSH_SANDBOX') ? true : false); } if ($maxId > 0) { $strSql = "DELETE FROM b_pull_push_queue WHERE ID <= " . $maxId; $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); } $strSql = "SELECT COUNT(ID) CNT FROM b_pull_push_queue"; $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); if ($arRes = $dbRes->Fetch()) { if ($arRes['CNT'] > 280) { CAgent::RemoveAgent("CPushManager::SendAgent();", "pull"); CAgent::AddAgent("CPushManager::SendAgent();", "pull", "N", 15, "", "Y", ConvertTimeStamp(time() + CTimeZone::GetOffset() + 15, "FULL")); } else { if ($arRes['CNT'] > 0) { return "CPushManager::SendAgent();"; } } } return false; }
public static function SendPullEvent($params) { if (!CModule::IncludeModule('pull') || !CPullOptions::GetQueueServerStatus() || $params['USER_ID'] <= 0) { return false; } $config = array(); $push = array(); if ($params['COMMAND'] == 'start') { $config = array("callId" => $params['CALL_ID'], "callDevice" => $params['CALL_DEVICE'] == 'PHONE' ? 'PHONE' : 'WEBRTC', "external" => $params['EXTERNAL'] ? true : false, "CRM" => $params['CRM'] ? $params['CRM'] : false); } else { if ($params['COMMAND'] == 'hold' || $params['COMMAND'] == 'unhold') { $config = array("callId" => $params['CALL_ID']); } else { if ($params['COMMAND'] == 'timeout') { $config = array("callId" => $params['CALL_ID']); $push['send_immediately'] = 'Y'; $push['advanced_params'] = array("notificationsToCancel" => array('VI_CALL_' . $params['CALL_ID'])); } } } if (isset($params['MARK'])) { $config['mark'] = $params['MARK']; } CPullStack::AddByUser($params['USER_ID'], array('module_id' => 'voximplant', 'command' => $params['COMMAND'], 'params' => $config, 'push' => $push)); return true; }
"> <?php echo bitrix_sessid_post(); ?> <input type="hidden" name="lang" value="<?php echo LANG; ?> "> <input type="hidden" name="id" value="pull"> <input type="hidden" name="uninstall" value="Y"> <input type="hidden" name="step" value="2"> <?php CPullOptions::ClearCheckCache(); $arDependentModule = array(); $ar = CPullOptions::GetDependentModule(); foreach ($ar as $key => $value) { $arDependentModule[] = $value['MODULE_ID']; } if (empty($arDependentModule)) { ?> <?php echo CAdminMessage::ShowMessage(GetMessage("MOD_UNINST_WARN")); ?> <?php } else { ?> <?php echo CAdminMessage::ShowMessage(GetMessage("PULL_WARNING_MODULE", array('#BR#' => '<br />', '#MODULE#' => implode(", ", $arDependentModule)))); ?> <?php
if ($type == "U" && IntVal($id) > 0) { $arNewRightsName[] = "[user="******"]" . htmlspecialcharsback($name) . "[/user]"; } else { $arNewRightsName[] = "[url=" . $link . "]" . htmlspecialcharsback($name) . "[/url]"; } } else { $arNewRightsName[] = htmlspecialcharsback($name); } } } } $UserIP = CBlogUser::GetUserIP(); $arComFields = array("POST_ID" => $arParams["ID"], "BLOG_ID" => $arPost["BLOG_ID"], "POST_TEXT" => (count($arNewRightsName) > 1 ? GetMessage("B_B_SHARE") : GetMessage("B_B_SHARE_1")) . implode(", ", $arNewRightsName), "DATE_CREATE" => ConvertTimeStamp(time() + $arResult["TZ_OFFSET"], "FULL"), "AUTHOR_IP" => $UserIP[0], "AUTHOR_IP1" => $UserIP[1], "PARENT_ID" => false, "AUTHOR_ID" => $user_id, "SHARE_DEST" => implode(",", $arNewRights)); if ($comId = CBlogComment::Add($arComFields)) { BXClearCache(true, "/blog/comment/" . intval($arParams["ID"] / 100) . "/" . $arParams["ID"] . "/"); if (CModule::IncludeModule("pull") && CPullOptions::GetNginxStatus() && ($arComment = CBlogComment::GetByID($comId))) { $arAuthor = CBlogUser::GetUserInfo($arComment["AUTHOR_ID"], $arParams["PATH_TO_USER"], array("AVATAR_SIZE" => isset($arParams["AVATAR_SIZE_COMMON"]) ? $arParams["AVATAR_SIZE_COMMON"] : $arParams["AVATAR_SIZE"], "AVATAR_SIZE_COMMENT" => $arParams["AVATAR_SIZE_COMMENT"])); $arPullFields = array("ID" => $arComment["ID"], "ENTITY_XML_ID" => "BLOG_" . $arComment["POST_ID"], "FULL_ID" => array("BLOG_" . $arComment["POST_ID"], $arComment["ID"]), "NEW" => "N", "APPROVED" => "Y", "POST_TIMESTAMP" => time() + $arResult["TZ_OFFSET"], "PANELS" => array("EDIT" => "N", "MODERATE" => "N", "DELETE" => "N"), "URL" => array("LINK" => $arResult['urlToPost'] . (strpos($arResult['urlToPost'], "?") !== false ? "&" : "?") . "commentId=" . $arComment["ID"] . "#com" . $arComment["ID"]), "AUTHOR" => array("ID" => $arComment["AUTHOR_ID"], "NAME" => CUser::FormatName($arParams["NAME_TEMPLATE"], $arAuthor, $arParams["SHOW_LOGIN"] != "N" ? true : false), "URL" => $arAuthor["url"], "AVATAR" => $arAuthor["PERSONAL_PHOTO_resized"]["src"], "IS_EXTRANET" => is_array($GLOBALS["arExtranetUserID"]) && in_array($arComment["AUTHOR_ID"], $GLOBALS["arExtranetUserID"])), "ACTION" => "REPLY"); $p = new blogTextParser(false, ""); $arPullFields["POST_MESSAGE_TEXT"] = $p->convert($arComment["POST_TEXT"], false, array(), array("HTML" => "N"), array("pathToUser" => $arParams["PATH_TO_USER"])); if (IsModuleInstalled("mobile")) { $p->bMobile = true; $arPullFields["POST_MESSAGE_TEXT_MOBILE"] = $p->convert($arComment["POST_TEXT"], false, array(), array("HTML" => "N"), array("pathToUser" => "/mobile/users/?user_id=#user_id#")); } $arPullFields["POST_TIME"] = FormatDateFromDB($arComment["DATE_CREATE"], strpos($arParams["DATE_TIME_FORMAT_S"], 'a') !== false || ($arParams["DATE_TIME_FORMAT_S"] == 'FULL' && IsAmPmMode()) !== false ? strpos(FORMAT_DATETIME, 'TT') !== false ? 'G:MI TT' : 'G:MI T' : 'GG:MI'); $arPullFields["POST_DATE"] = FormatDateFromDB($arComment["DATE_CREATE"], $arParams["DATE_TIME_FORMAT"], true); if (strcasecmp(LANGUAGE_ID, 'EN') !== 0 && strcasecmp(LANGUAGE_ID, 'DE') !== 0) { $arPullFields["POST_DATE"] = ToLower($arPullFields["POST_DATE"]); } if (!empty($arParams['DATE_TIME_FORMAT_S']) && ($arParams['DATE_TIME_FORMAT_S'] == 'j F Y G:i' || $arParams['DATE_TIME_FORMAT_S'] == 'j F Y g:i a')) { $arPullFields["POST_DATE"] = ltrim($arPullFields["POST_DATE"], '0');
public static function SendBadges($userID) { return false; if (!(CModule::IncludeModule('pull') && CPullOptions::GetPushStatus())) return false; $arPush = Array(); if (!is_array($userID)) $userID = Array(intval($userID)); global $DB; if (empty($userID)) return false; foreach ($userID as $key => $userId) $userID[$key] = intval($userId); $CPushManager = new CPushManager(); $sql = "SELECT SUM(CNT) CNT, USER_ID FROM b_user_counter WHERE USER_ID IN (".implode(',', $userID).") and SITE_ID = '**' and CODE IN ('im_notify_v2', 'im_message_v2', 'im_chat_v2') GROUP BY USER_ID"; $res = $DB->Query($sql); while($row = $res->Fetch()) { $CPushManager->AddQueue(Array('USER_ID' => $row['USER_ID'], 'BADGE' => $row['CNT'], 'SEND_IMMEDIATELY' => 'Y')); } return true; }
public static function SendPullEvent($params) { // TODO check $params if (!CModule::IncludeModule('pull') || !CPullOptions::GetQueueServerStatus() || $params['USER_ID'] <= 0) { return false; } $config = array(); $push = array(); if ($params['COMMAND'] == 'invite') { $config = array("callId" => $params['CALL_ID'], "callerId" => $params['CALLER_ID'], "phoneNumber" => $params['PHONE_NAME'], "chatId" => 0, "chat" => array(), "typeConnect" => $params['TYPE_CONNECT'], "portalCall" => $params['PORTAL_CALL'] == 'Y' ? true : false, "portalCallUserId" => $params['PORTAL_CALL'] == 'Y' ? $params['PORTAL_CALL_USER_ID'] : 0, "portalCallData" => $params['PORTAL_CALL'] == 'Y' ? $params['PORTAL_CALL_DATA'] : array(), "config" => $params['CONFIG'] ? $params['CONFIG'] : array(), "CRM" => $params['CRM']); $callName = $params['CALLER_ID']; if (isset($params['CRM']['CONTACT']['NAME']) && strlen($params['CRM']['CONTACT']['NAME']) > 0) { $callName = $params['CRM']['CONTACT']['NAME']; } if (isset($params['CRM']['COMPANY']) && strlen($params['CRM']['COMPANY']) > 0) { $callName .= ' (' . $params['CRM']['COMPANY'] . ')'; } else { if (isset($params['CRM']['CONTACT']['POST']) && strlen($params['CRM']['CONTACT']['POST']) > 0) { $callName .= ' (' . $params['CRM']['CONTACT']['POST'] . ')'; } } $push['sub_tag'] = 'VI_CALL_' . $params['CALL_ID']; $push['send_immediately'] = 'Y'; $push['sound'] = 'call.aif'; $push['advanced_params'] = array("notificationsToCancel" => array('VI_CALL_' . $params['CALL_ID']), "androidHighPriority" => true); if ($params['PORTAL_CALL'] == 'Y') { $push['message'] = GetMessage('INCOMING_CALL', array('#NAME#' => $params['PORTAL_CALL_DATA']['users'][$params['PORTAL_CALL_USER_ID']]['name'])); } else { $push['message'] = GetMessage('INCOMING_CALL', array('#NAME#' => $callName)); $push['message'] = $push['message'] . ' ' . GetMessage('CALL_FOR_NUMBER', array('#NUMBER#' => $params['PHONE_NAME'])); } $push['params'] = array('ACTION' => 'VI_CALL_' . $params['CALL_ID'], 'PARAMS' => $config); } else { if ($params['COMMAND'] == 'update_crm') { $config = array("callId" => $params['CALL_ID'], "CRM" => $params['CRM']); } else { if ($params['COMMAND'] == 'timeout' || $params['COMMAND'] == 'answer_self') { $config = array("callId" => $params['CALL_ID']); $push['send_immediately'] = 'Y'; $push['advanced_params'] = array("notificationsToCancel" => array('VI_CALL_' . $params['CALL_ID'])); } } } if (isset($params['MARK'])) { $config['mark'] = $params['MARK']; } CPullStack::AddByUser($params['USER_ID'], array('module_id' => 'voximplant', 'command' => $params['COMMAND'], 'params' => $config, 'push' => $push)); return true; }
echo $arResult["Post"]["ID"]; ?> ')}); BX.addCustomEvent(window, 'OnUCAfterRecordAdd', function(ENTITY_XML_ID, response) { if (ENTITY_XML_ID == '<?php echo $arParams["ENTITY_XML_ID"]; ?> ') { __blogOnUCAfterRecordAdd(ENTITY_XML_ID, response); } }); } ); </script><?php if ($GLOBALS["USER"]->IsAuthorized() && CModule::IncludeModule("pull") && CPullOptions::GetNginxStatus()) { ?> <script type="text/javascript"> BX.addCustomEvent("onPullEvent-unicomments", function(command, params) { if (params["ENTITY_XML_ID"] == '<?php echo $arParams["ENTITY_XML_ID"]; ?> ') { BX.show(BX('blg-comment-<?php echo $arParams["ID"]; ?> ')); } } ); </script> <?php } if ($arResult["CanUserComment"]) { ?> <script>
public static function Enabled() { if (!CModule::IncludeModule('pull') || !CPullOptions::GetNginxStatus()) { return false; } if (!CModule::IncludeModule('disk')) { return false; } if (!\Bitrix\Disk\Driver::isSuccessfullyConverted()) { return false; } return true; }
public static function SendPullEvent($params) { if (!CModule::IncludeModule('pull') || !CPullOptions::GetQueueServerStatus() || $params['USER_ID'] <= 0) { return false; } if (empty($params['COMMAND'])) { return false; } $config = array(); if ($params['COMMAND'] == 'inviteTransfer') { $config = array("callId" => $params['CALL_ID'], "callerId" => $params['CALLER_ID'], "phoneNumber" => $params['PHONE_NAME'], "chatId" => 0, "chat" => array(), "application" => $params['APPLICATION'], "CRM" => $params['CRM']); } else { if ($params['COMMAND'] == 'completeTransfer') { $config = array("callId" => $params['CALL_ID'], "transferUserId" => $params['TRANSFER_USER_ID'], "callDevice" => $params['CALL_DEVICE'], "CRM" => $params['CRM'] ? $params['CRM'] : false); } else { $config["callId"] = $params['CALL_ID']; } } if (isset($params['MARK'])) { $config['mark'] = $params['MARK']; } CPullStack::AddByUser($params['USER_ID'], array('module_id' => 'voximplant', 'command' => $params['COMMAND'], 'params' => $config)); return true; }
public static function SendAgent() { global $DB; if (!CPullOptions::GetPushStatus()) { return false; } $count = 0; $maxId = 0; $pushLimit = 70; $arPush = array(); $sqlDate = ""; $dbType = strtolower($DB->type); if ($dbType == "mysql") { $sqlDate = " WHERE DATE_CREATE < DATE_SUB(NOW(), INTERVAL 15 SECOND) "; } else { if ($dbType == "mssql") { $sqlDate = " WHERE DATE_CREATE < dateadd(SECOND, -15, getdate()) "; } else { if ($dbType == "oracle") { $sqlDate = " WHERE DATE_CREATE < SYSDATE-(1/24/60/60*15) "; } } } $strSql = $DB->TopSql("SELECT ID, USER_ID, MESSAGE, PARAMS, BADGE, APP_ID FROM b_pull_push_queue" . $sqlDate, 280); $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); while ($arRes = $dbRes->Fetch()) { if ($arRes['BADGE'] == '') { unset($arRes['BADGE']); } $arPush[$count][] = $arRes; if ($pushLimit <= count($arPush[$count])) { $count++; } $maxId = $maxId < $arRes['ID'] ? $arRes['ID'] : $maxId; } if ($maxId > 0) { $strSql = "DELETE FROM b_pull_push_queue WHERE ID <= " . $maxId; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); } $CPushManager = new CPushManager(); foreach ($arPush as $arStack) { $CPushManager->SendMessage($arStack); } $strSql = "SELECT COUNT(ID) CNT FROM b_pull_push_queue"; $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); if ($arRes = $dbRes->Fetch()) { global $pPERIOD; if ($arRes['CNT'] > 280) { $pPERIOD = 10; return "CPushManager::SendAgent();"; } else { if ($arRes['CNT'] > 0) { $pPERIOD = 30; return "CPushManager::SendAgent();"; } } } return false; }