static function GetMobileDialogTemplateJS($arParams, $arTemplate)
{
global $USER;
$ppStatus = false;
$ppServerStatus = false;
$updateStateInterval = 'auto';
if (CModule::IncludeModule("pull"))
{
$ppStatus = (bool)CPullOptions::ModuleEnable();
$ppServerStatus = (bool)CPullOptions::GetNginxStatus();
$updateStateInterval = CPullOptions::GetNginxStatus()? self::GetSessionLifeTime(): 80;
if ($updateStateInterval > 100)
{
if ($updateStateInterval > 3600)
$updateStateInterval = 3600;
$updateStateInterval = $updateStateInterval-60;
}
}
$diskStatus = CIMDisk::Enabled();
$diskExternalLinkStatus = CIMDisk::EnabledExternalLink();
$chatExtendShowHistory = COption::GetOptionInt('im', 'chat_extend_show_history');
$phoneEnabled = self::CheckPhoneStatus() && CModule::IncludeModule('mobileapp') && BitrixMobileAppMobile::getInstance()->isWebRtcSupported();
$olConfig = Array();
$crmPath = Array();
$businessUsers = false;
if (BitrixMainLoader::includeModule('crm'))
{
$crmPath['LEAD'] = BitrixImIntegrationCrmCommon::getLink('LEAD');
$crmPath['CONTACT'] = BitrixImIntegrationCrmCommon::getLink('CONTACT');
$crmPath['COMPANY'] = BitrixImIntegrationCrmCommon::getLink('COMPANY');
$crmPath['DEAL'] = BitrixImIntegrationCrmCommon::getLink('DEAL');
}
if (CModule::IncludeModule('imopenlines'))
{
$olConfig['canDeleteMessage'] = str_replace('.', '_', BitrixImopenlinesConnector::getListCanDeleteMessage());
$olConfig['canDeleteOwnMessage'] = str_replace('.', '_', BitrixImopenlinesConnector::getListCanDeleteOwnMessage());
$olConfig['canUpdateOwnMessage'] = str_replace('.', '_', BitrixImopenlinesConnector::getListCanUpdateOwnMessage());
$olConfig['queue'] = Array();
foreach (BitrixImOpenLinesConfig::getQueueList($USER->GetID()) as $config)
{
$olConfig['queue'][] = array_change_key_case($config, CASE_LOWER);
}
}
$mobileAction = isset($arTemplate["ACTION"])? $arTemplate["ACTION"]: 'none';
$mobileCallMethod = isset($arTemplate["CALL_METHOD"])? $arTemplate["CALL_METHOD"]: 'device';
$counters = BitrixImCounter::get(null, ['JSON' => 'Y']);
$initConfig = [
'mobileAction' => $mobileAction,
'mobileCallMethod' => $mobileCallMethod,
'colors' => BitrixImColor::isEnabled()? BitrixImColor::getSafeColorNames(): false,
'chatCounters' => [
'notify' => intval($counters['TYPE']['NOTIFY']),
'dialog' => intval($counters['TYPE']['DIALOG']),
'chat' => intval($counters['TYPE']['CHAT']),
'lines' => intval($counters['TYPE']['LINES']),
'mail' => intval($arTemplate["MAIL_COUNTER"])
],
'counters' => empty($arTemplate['COUNTERS'])? false: $arTemplate['COUNTERS'],
'ppStatus' => $ppStatus,
'ppServerStatus' => $ppServerStatus,
'updateStateInterval' => $updateStateInterval,
'openChatEnable' => (bool)CIMMessenger::CheckEnableOpenChat(),
'xmppStatus' => (bool)CIMMessenger::CheckXmppStatusOnline(),
'isAdmin' => (bool)self::IsAdmin(),
'bitrixNetwork' => (bool)CIMMessenger::CheckNetwork(),
'bitrix24' => (bool)IsModuleInstalled('bitrix24'),
'bitrix24net' => (bool)IsModuleInstalled('b24network'),
'bitrixIntranet' => (bool)IsModuleInstalled('intranet'),
'bitrixXmpp' => (bool)IsModuleInstalled('xmpp'),
'bitrixMobile' => (bool)IsModuleInstalled('mobile'),
'bitrixOpenLines' => (bool)IsModuleInstalled('imopenlines'),
'bitrixCrm' => (bool)IsModuleInstalled('crm'),
'desktopStatus' => (bool)CIMMessenger::CheckDesktopStatusOnline(),
'desktopVersion' => (int)CIMMessenger::GetDesktopVersion(),
'language' => LANGUAGE_ID,
'bot' => empty($arTemplate['BOT'])? false: $arTemplate["BOT"],
'command' => empty($arTemplate['COMMAND'])? false: $arTemplate["COMMAND"],
'textareaIcon' => empty($arTemplate['TEXTAREA_ICON'])? false: $arTemplate["TEXTAREA_ICON"],
'smile' => empty($arTemplate['SMILE'])? false: $arTemplate["SMILE"],
'smileSet' => empty($arTemplate['SMILE_SET'])? false: $arTemplate["SMILE_SET"],
'settings' => empty($arTemplate['SETTINGS'])? false: $arTemplate['SETTINGS'],
'settingsNotifyBlocked' => empty($arTemplate['SETTINGS_NOTIFY_BLOCKED'])? false: $arTemplate['SETTINGS_NOTIFY_BLOCKED'],
'recent' => false,
'businessUsers' => $businessUsers === false? false: (empty($businessUsers)? null: $businessUsers),
'userChatOptions' => CIMChat::GetChatOptions(),
'history' => false,
'openMessenger' => false,
'openHistory' => false,
'openNotify' => false,
'openSettings' => false,
'generalChatId' => CIMChat::GetGeneralChatId(),
'canSendMessageGeneralChat' => (bool)CIMChat::CanSendMessageToGeneralChat($USER->GetID()),
'userId' => $USER->GetID(),
'userEmail' => $USER->GetEmail(),
'userColor' => BitrixImColor::getCode(BitrixImUser::getInstance()->getColor()),
'userGender' => BitrixImUser::getInstance()->getGender(),
'userExtranet' => (bool)BitrixImUser::getInstance()->isExtranet(),
'webrtc' => [
'turnServer' => empty($arTemplate['TURN_SERVER'])? '': $arTemplate['TURN_SERVER'],
'turnServerLogin' => empty($arTemplate['TURN_SERVER_LOGIN'])? '': $arTemplate['TURN_SERVER_LOGIN'],
'turnServerPassword' => empty($arTemplate['TURN_SERVER_PASSWORD'])? '': $arTemplate['TURN_SERVER_PASSWORD'],
'mobileSupport' => (bool)$arTemplate['WEBRTC_MOBILE_SUPPORT'],
'phoneEnabled' => (bool)$phoneEnabled,
],
'openlines' => $olConfig,
'options' => [
'chatExtendShowHistory' => (bool)$chatExtendShowHistory
],
'disk' => [
'enable' => (bool)$diskStatus,
'external' => (bool)$diskExternalLinkStatus
],
'path' => [
'lf' => empty($arTemplate['PATH_TO_LF'])? '/': $arTemplate['PATH_TO_LF'],
'profile' => empty($arTemplate['PATH_TO_USER_PROFILE'])? '': $arTemplate['PATH_TO_USER_PROFILE'],
'profileTemplate' => empty($arTemplate['PATH_TO_USER_PROFILE_TEMPLATE'])? '': $arTemplate['PATH_TO_USER_PROFILE_TEMPLATE'],
'mail' => empty($arTemplate['PATH_TO_USER_MAIL'])? '': $arTemplate['PATH_TO_USER_MAIL'],
'crm' => $crmPath
]
];
return $initConfig;
}