Пример #1
0
	public static function Add($userId)
	{
		global $DB, $APPLICATION;

		$channelId = md5(uniqid().$_SERVER["REMOTE_ADDR"].$_SERVER["SERVER_NAME"].(is_object($APPLICATION)? $APPLICATION->GetServerUniqID(): ''));

		$arParams = Array(
			'USER_ID' => intval($userId),
			'CHANNEL_ID' => $channelId,
			'LAST_ID' => 0,
			'~DATE_CREATE' => $DB->CurrentTimeFunction(),
		);
		$result = IntVal($DB->Add("b_pull_channel", $arParams, Array()));

		if (CPullOptions::GetNginxStatus())
		{
			$result = false;
			$arData = Array(
				'module_id' => 'pull',
				'command' => 'open',
				'params' => Array(),
			);
			$CHTTP = new CHTTP();
			$CHTTP->http_timeout = 10;
			if ($CHTTP->HTTPQuery('POST', CPullOptions::GetPublishUrl($channelId), CUtil::PhpToJsObject(Array('MESSAGE' => Array($arData), 'ERROR' => ''))))
				$result = $CHTTP->result;
		}

		return ($result? $channelId: false);
	}
Пример #2
0
	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;
	}
Пример #3
0
 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;
 }
Пример #4
0
	public static function AddShared($arMessage)
	{
		if (!CPullOptions::GetNginxStatus())
			return false;

		$arChannel = CPullChannel::GetShared();
		return self::AddByChannel($arChannel['CHANNEL_ID'], $arMessage);
	}
Пример #5
0
 public static function GetMobileTemplateJS($arParams, $arTemplate)
 {
     global $USER;
     $ppStatus = 'false';
     $ppServerStatus = 'false';
     $updateStateInterval = 'auto';
     if (CModule::IncludeModule("pull")) {
         $ppStatus = CPullOptions::ModuleEnable() ? 'true' : 'false';
         $ppServerStatus = CPullOptions::GetNginxStatus() ? 'true' : 'false';
         $updateStateInterval = CPullOptions::GetNginxStatus() ? self::GetSessionLifeTime() : 80;
         if ($updateStateInterval > 100) {
             if ($updateStateInterval > 3600) {
                 $updateStateInterval = 3600;
             }
             $updateStateInterval = $updateStateInterval - 60;
         }
     }
     $diskStatus = CIMDisk::Enabled();
     $phoneSipAvailable = false;
     $phoneDeviceActive = false;
     $phoneEnabled = self::CheckPhoneStatus() && CModule::IncludeModule('mobileapp') && \Bitrix\MobileApp\Mobile::getInstance()->isWebRtcSupported();
     if ($phoneEnabled && CModule::IncludeModule('voximplant')) {
         $phoneSipAvailable = CVoxImplantConfig::GetModeStatus(CVoxImplantConfig::MODE_SIP);
         $phoneDeviceActive = CVoxImplantUser::GetPhoneActive($USER->GetId());
     }
     $mobileAction = isset($arTemplate["ACTION"]) ? $arTemplate["ACTION"] : 'none';
     $mobileCallMethod = isset($arTemplate["CALL_METHOD"]) ? $arTemplate["CALL_METHOD"] : 'device';
     $userColor = isset($arTemplate['CONTACT_LIST']['users'][$USER->GetID()]['color']) ? $arTemplate['CONTACT_LIST']['users'][$USER->GetID()]['color'] : '';
     $sJS = "\n\t\t\tBX.ready(function() {\n\t\t\t\tBXIM = new BX.ImMobile({\n\t\t\t\t\t'mobileAction': '" . $mobileAction . "',\n\t\t\t\t\t'mobileCallMethod': '" . $mobileCallMethod . "',\n\n\t\t\t\t\t'colors': " . (IM\Color::isEnabled() ? CUtil::PhpToJSObject(IM\Color::getSafeColorNames()) : 'false') . ",\n\t\t\t\t\t'mailCount': " . intval($arTemplate["MAIL_COUNTER"]) . ",\n\t\t\t\t\t'notifyCount': " . intval($arTemplate["NOTIFY_COUNTER"]) . ",\n\t\t\t\t\t'messageCount': " . intval($arTemplate["MESSAGE_COUNTER"]) . ",\n\t\t\t\t\t'counters': " . (empty($arTemplate['COUNTERS']) ? '{}' : CUtil::PhpToJSObject($arTemplate['COUNTERS'])) . ",\n\t\t\t\t\t'ppStatus': " . $ppStatus . ",\n\t\t\t\t\t'ppServerStatus': " . $ppServerStatus . ",\n\t\t\t\t\t'updateStateInterval': '" . $updateStateInterval . "',\n\t\t\t\t\t'openChatEnable': " . (CIMMessenger::CheckEnableOpenChat() ? 'true' : 'false') . ",\n\t\t\t\t\t'xmppStatus': " . (CIMMessenger::CheckXmppStatusOnline() ? 'true' : 'false') . ",\n\t\t\t\t\t'bitrixNetwork': " . (CIMMessenger::CheckNetwork() ? 'true' : 'false') . ",\n\t\t\t\t\t'bitrixNetwork2': " . (CIMMessenger::CheckNetwork2() ? 'true' : 'false') . ",\n\t\t\t\t\t'bitrix24': " . (IsModuleInstalled('bitrix24') ? 'true' : 'false') . ",\n\t\t\t\t\t'bitrix24Admin': " . (CModule::IncludeModule('bitrix24') && CBitrix24::IsPortalAdmin($USER->GetId()) ? 'true' : 'false') . ",\n\t\t\t\t\t'bitrix24net': " . (IsModuleInstalled('b24network') ? 'true' : 'false') . ",\n\t\t\t\t\t'bitrixIntranet': " . (IsModuleInstalled('intranet') ? 'true' : 'false') . ",\n\t\t\t\t\t'bitrixXmpp': " . (IsModuleInstalled('xmpp') ? 'true' : 'false') . ",\n\t\t\t\t\t'bitrixMobile': " . (IsModuleInstalled('mobile') ? 'true' : 'false') . ",\n\t\t\t\t\t'desktopStatus': " . (CIMMessenger::CheckDesktopStatusOnline() ? 'true' : 'false') . ",\n\t\t\t\t\t'desktopVersion': " . CIMMessenger::GetDesktopVersion() . ",\n\t\t\t\t\t'language': '" . LANGUAGE_ID . "',\n\n\t\t\t\t\t'smile': " . (empty($arTemplate['SMILE']) ? '{}' : CUtil::PhpToJSObject($arTemplate["SMILE"])) . ",\n\t\t\t\t\t'smileSet': " . (empty($arTemplate['SMILE_SET']) ? '{}' : CUtil::PhpToJSObject($arTemplate["SMILE_SET"])) . ",\n\t\t\t\t\t'settings': " . (empty($arTemplate['SETTINGS']) ? '{}' : CUtil::PhpToJSObject($arTemplate['SETTINGS'])) . ",\n\t\t\t\t\t'settingsNotifyBlocked': " . (empty($arTemplate['SETTINGS_NOTIFY_BLOCKED']) ? '{}' : CUtil::PhpToJSObject($arTemplate['SETTINGS_NOTIFY_BLOCKED'])) . ",\n\n\t\t\t\t\t'notify': " . (empty($arTemplate['NOTIFY']['notify']) ? '{}' : CUtil::PhpToJSObject($arTemplate['NOTIFY']['notify'])) . ",\n\t\t\t\t\t'unreadNotify' : " . (empty($arTemplate['NOTIFY']['unreadNotify']) ? '{}' : CUtil::PhpToJSObject($arTemplate['NOTIFY']['unreadNotify'])) . ",\n\t\t\t\t\t'flashNotify' : " . (empty($arTemplate['NOTIFY']['flashNotify']) ? '{}' : CUtil::PhpToJSObject($arTemplate['NOTIFY']['flashNotify'])) . ",\n\t\t\t\t\t'countNotify' : " . intval($arTemplate['NOTIFY']['countNotify']) . ",\n\t\t\t\t\t'loadNotify' : " . ($arTemplate['NOTIFY']['loadNotify'] ? 'true' : 'false') . ",\n\n\t\t\t\t\t'recent': " . (empty($arTemplate['RECENT']) && $arTemplate['RECENT'] !== false ? '[]' : CUtil::PhpToJSObject($arTemplate['RECENT'])) . ",\n\t\t\t\t\t'users': " . (empty($arTemplate['CONTACT_LIST']['users']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['users'])) . ",\n\t\t\t\t\t'groups': " . (empty($arTemplate['CONTACT_LIST']['groups']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['groups'])) . ",\n\t\t\t\t\t'userInGroup': " . (empty($arTemplate['CONTACT_LIST']['userInGroup']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['userInGroup'])) . ",\n\t\t\t\t\t'woGroups': " . (empty($arTemplate['CONTACT_LIST']['woGroups']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['woGroups'])) . ",\n\t\t\t\t\t'woUserInGroup': " . (empty($arTemplate['CONTACT_LIST']['woUserInGroup']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['woUserInGroup'])) . ",\n\t\t\t\t\t'chat': " . (empty($arTemplate['CHAT']['chat']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CHAT']['chat'])) . ",\n\t\t\t\t\t'userInChat': " . (empty($arTemplate['CHAT']['userInChat']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CHAT']['userInChat'])) . ",\n\t\t\t\t\t'userChatBlockStatus': " . (empty($arTemplate['CHAT']['userChatBlockStatus']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CHAT']['userChatBlockStatus'])) . ",\n\t\t\t\t\t'message' : " . (empty($arTemplate['MESSAGE']['message']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['message'])) . ",\n\t\t\t\t\t'files' : " . (empty($arTemplate['MESSAGE']['files']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['files'])) . ",\n\t\t\t\t\t'showMessage' : " . (empty($arTemplate['MESSAGE']['usersMessage']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['usersMessage'])) . ",\n\t\t\t\t\t'unreadMessage' : " . (empty($arTemplate['MESSAGE']['unreadMessage']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['unreadMessage'])) . ",\n\t\t\t\t\t'flashMessage' : " . (empty($arTemplate['MESSAGE']['flashMessage']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['flashMessage'])) . ",\n\t\t\t\t\t'history' : {},\n\t\t\t\t\t'openMessenger' : " . (isset($_GET['IM_DIALOG']) ? "'" . CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_DIALOG'])) . "'" : 'false') . ",\n\t\t\t\t\t'openHistory' : " . (isset($_GET['IM_HISTORY']) ? "'" . CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_HISTORY'])) . "'" : 'false') . ",\n\t\t\t\t\t'openNotify' : " . (isset($_GET['IM_NOTIFY']) && $_GET['IM_NOTIFY'] == 'Y' ? 'true' : 'false') . ",\n\t\t\t\t\t'openSettings' : " . (isset($_GET['IM_SETTINGS']) ? $_GET['IM_SETTINGS'] == 'Y' ? "'true'" : "'" . CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_SETTINGS'])) . "'" : 'false') . ",\n\n\t\t\t\t\t'currentTab' : '" . ($arTemplate['CURRENT_TAB'] ? CUtil::JSEscape($arTemplate['CURRENT_TAB']) : 0) . "',\n\t\t\t\t\t'generalChatId': " . CIMChat::GetGeneralChatId() . ",\n\t\t\t\t\t'canSendMessageGeneralChat': " . (CIMChat::CanSendMessageToGeneralChat($USER->GetID()) ? 'true' : 'false') . ",\n\t\t\t\t\t'userId': " . $USER->GetID() . ",\n\t\t\t\t\t'userEmail': '" . CUtil::JSEscape($USER->GetEmail()) . "',\n\t\t\t\t\t'userColor': '" . IM\Color::getCode($userColor) . "',\n\t\t\t\t\t'userGender': '" . IM\User::getInstance()->getGender() . "',\n\t\t\t\t\t'userExtranet': " . (IM\User::getInstance()->isExtranet() ? 'true' : 'false') . ",\n\t\t\t\t\t'webrtc': {'turnServer' : '" . (empty($arTemplate['TURN_SERVER']) ? '' : CUtil::JSEscape($arTemplate['TURN_SERVER'])) . "', 'turnServerLogin' : '" . (empty($arTemplate['TURN_SERVER_LOGIN']) ? '' : CUtil::JSEscape($arTemplate['TURN_SERVER_LOGIN'])) . "', 'turnServerPassword' : '" . (empty($arTemplate['TURN_SERVER_PASSWORD']) ? '' : CUtil::JSEscape($arTemplate['TURN_SERVER_PASSWORD'])) . "', 'mobileSupport': " . ($arTemplate['WEBRTC_MOBILE_SUPPORT'] ? 'true' : 'false') . ", 'phoneEnabled': " . ($phoneEnabled ? 'true' : 'false') . ", 'phoneSipAvailable': " . ($phoneSipAvailable ? 'true' : 'false') . "},\n\t\t\t\t\t'disk': {'enable' : " . ($diskStatus ? 'true' : 'false') . "},\n\t\t\t\t\t'path' : {'profile' : '" . (empty($arTemplate['PATH_TO_USER_PROFILE']) ? '' : CUtil::JSEscape($arTemplate['PATH_TO_USER_PROFILE'])) . "', 'profileTemplate' : '" . (empty($arTemplate['PATH_TO_USER_PROFILE_TEMPLATE']) ? '' : CUtil::JSEscape($arTemplate['PATH_TO_USER_PROFILE_TEMPLATE'])) . "', 'mail' : '" . (empty($arTemplate['PATH_TO_USER_MAIL']) ? '' : CUtil::JSEscape($arTemplate['PATH_TO_USER_MAIL'])) . "'}\n\t\t\t\t});\n\t\t\t});\n\t\t";
     return $sJS;
 }
Пример #6
0
	public static function GetMobileTemplateJS($arParams, $arTemplate)
	{
		global $USER;

		$ppStatus = 'false';
		$ppServerStatus = 'false';
		$updateStateInterval = 'auto';
		if (CModule::IncludeModule("pull"))
		{
			$ppStatus = CPullOptions::ModuleEnable()? 'true': 'false';
			$ppServerStatus = CPullOptions::GetNginxStatus()? 'true': 'false';
			$updateStateInterval = CPullOptions::GetNginxStatus()? self::GetSessionLifeTime(): 80;
			if ($updateStateInterval > 100)
			{
				if ($updateStateInterval > 3600)
					$updateStateInterval = 3600;

				$updateStateInterval = $updateStateInterval-60;
			}
		}

		$diskStatus = CIMDisk::Enabled();

		$phoneSipAvailable = 0;
		$phoneEnabled = false;

		$mobileAction = isset($arTemplate["ACTION"])? $arTemplate["ACTION"]: 'none';

		$sJS = "
			BX.ready(function() {
				BXIM = new BX.ImMobile({
					'mobileAction': '".$mobileAction."',

					'mailCount': ".intval($arTemplate["MAIL_COUNTER"]).",
					'notifyCount': ".intval($arTemplate["NOTIFY_COUNTER"]).",
					'messageCount': ".intval($arTemplate["MESSAGE_COUNTER"]).",
					'counters': ".(empty($arTemplate['COUNTERS'])? '{}': CUtil::PhpToJSObject($arTemplate['COUNTERS'])).",
					'ppStatus': ".$ppStatus.",
					'ppServerStatus': ".$ppServerStatus.",
					'updateStateInterval': '".$updateStateInterval."',
					'xmppStatus': ".(CIMMessenger::CheckXmppStatusOnline()? 'true': 'false').",
					'bitrixNetworkStatus': ".(CIMMessenger::CheckNetworkStatus()? 'true': 'false').",
					'bitrix24Status': ".(IsModuleInstalled('bitrix24')? 'true': 'false').",
					'bitrix24Admin': ".(CModule::IncludeModule('bitrix24') && CBitrix24::IsPortalAdmin($USER->GetId())? 'true': 'false').",
					'bitrix24net': ".(IsModuleInstalled('b24network')? 'true': 'false').",
					'bitrixIntranet': ".(IsModuleInstalled('intranet')? 'true': 'false').",
					'bitrixXmpp': ".(IsModuleInstalled('xmpp')? 'true': 'false').",
					'desktopStatus': ".(CIMMessenger::CheckDesktopStatusOnline()? 'true': 'false').",
					'desktopVersion': ".CIMMessenger::GetDesktopVersion().",
					'language': '".LANGUAGE_ID."',

					'smile': ".(empty($arTemplate['SMILE'])? '{}': CUtil::PhpToJSObject($arTemplate["SMILE"])).",
					'smileSet': ".(empty($arTemplate['SMILE_SET'])? '{}': CUtil::PhpToJSObject($arTemplate["SMILE_SET"])).",
					'settings': ".(empty($arTemplate['SETTINGS'])? '{}': CUtil::PhpToJSObject($arTemplate['SETTINGS'])).",
					'settingsNotifyBlocked': ".(empty($arTemplate['SETTINGS_NOTIFY_BLOCKED'])? '{}': CUtil::PhpToJSObject($arTemplate['SETTINGS_NOTIFY_BLOCKED'])).",

					'notify': ".(empty($arTemplate['NOTIFY']['notify'])? '{}': CUtil::PhpToJSObject($arTemplate['NOTIFY']['notify'])).",
					'unreadNotify' : ".(empty($arTemplate['NOTIFY']['unreadNotify'])? '{}': CUtil::PhpToJSObject($arTemplate['NOTIFY']['unreadNotify'])).",
					'flashNotify' : ".(empty($arTemplate['NOTIFY']['flashNotify'])? '{}': CUtil::PhpToJSObject($arTemplate['NOTIFY']['flashNotify'])).",
					'countNotify' : ".intval($arTemplate['NOTIFY']['countNotify']).",
					'loadNotify' : ".($arTemplate['NOTIFY']['loadNotify']? 'true': 'false').",

					'recent': ".(empty($arTemplate['RECENT'])? '{}': CUtil::PhpToJSObject($arTemplate['RECENT'])).",
					'users': ".(empty($arTemplate['CONTACT_LIST']['users'])? '{}': CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['users'])).",
					'groups': ".(empty($arTemplate['CONTACT_LIST']['groups'])? '{}': CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['groups'])).",
					'userInGroup': ".(empty($arTemplate['CONTACT_LIST']['userInGroup'])? '{}': CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['userInGroup'])).",
					'woGroups': ".(empty($arTemplate['CONTACT_LIST']['woGroups'])? '{}': CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['woGroups'])).",
					'woUserInGroup': ".(empty($arTemplate['CONTACT_LIST']['woUserInGroup'])? '{}': CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['woUserInGroup'])).",
					'chat': ".(empty($arTemplate['CHAT']['chat'])? '{}': CUtil::PhpToJSObject($arTemplate['CHAT']['chat'])).",
					'userInChat': ".(empty($arTemplate['CHAT']['userInChat'])? '{}': CUtil::PhpToJSObject($arTemplate['CHAT']['userInChat'])).",
					'userChatBlockStatus': ".(empty($arTemplate['CHAT']['userChatBlockStatus'])? '{}': CUtil::PhpToJSObject($arTemplate['CHAT']['userChatBlockStatus'])).",
					'message' : ".(empty($arTemplate['MESSAGE']['message'])? '{}': CUtil::PhpToJSObject($arTemplate['MESSAGE']['message'])).",
					'files' : ".(empty($arTemplate['MESSAGE']['files'])? '{}': CUtil::PhpToJSObject($arTemplate['MESSAGE']['files'])).",
					'showMessage' : ".(empty($arTemplate['MESSAGE']['usersMessage'])? '{}': CUtil::PhpToJSObject($arTemplate['MESSAGE']['usersMessage'])).",
					'unreadMessage' : ".(empty($arTemplate['MESSAGE']['unreadMessage'])? '{}': CUtil::PhpToJSObject($arTemplate['MESSAGE']['unreadMessage'])).",
					'flashMessage' : ".(empty($arTemplate['MESSAGE']['flashMessage'])? '{}': CUtil::PhpToJSObject($arTemplate['MESSAGE']['flashMessage'])).",
					'history' : {},
					'openMessenger' : ".(isset($_GET['IM_DIALOG'])? "'".CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_DIALOG']))."'": 'false').",
					'openHistory' : ".(isset($_GET['IM_HISTORY'])? "'".CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_HISTORY']))."'": 'false').",
					'openNotify' : ".(isset($_GET['IM_NOTIFY']) && $_GET['IM_NOTIFY'] == 'Y'? 'true': 'false').",
					'openSettings' : ".(isset($_GET['IM_SETTINGS'])? $_GET['IM_SETTINGS'] == 'Y'? "'true'": "'".CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_SETTINGS']))."'": 'false').",

					'currentTab' : '".($arTemplate['CURRENT_TAB']? CUtil::JSEscape($arTemplate['CURRENT_TAB']): 0)."',
					'userId': ".$USER->GetID().",
					'userEmail': '".CUtil::JSEscape($USER->GetEmail())."',
					'webrtc': {'turnServer' : '".(empty($arTemplate['TURN_SERVER'])? '': CUtil::JSEscape($arTemplate['TURN_SERVER']))."', 'turnServerLogin' : '".(empty($arTemplate['TURN_SERVER_LOGIN'])? '': CUtil::JSEscape($arTemplate['TURN_SERVER_LOGIN']))."', 'turnServerPassword' : '".(empty($arTemplate['TURN_SERVER_PASSWORD'])? '': CUtil::JSEscape($arTemplate['TURN_SERVER_PASSWORD']))."', 'mobileSupport': ".($arTemplate['WEBRTC_MOBILE_SUPPORT']? 'true': 'false').", 'phoneEnabled': ".($phoneEnabled? 'true': 'false').", 'phoneSipAvailable': ".($phoneSipAvailable? 'true': 'false')."},
					'disk': {'enable' : ".($diskStatus? 'true': 'false')."},
					'path' : {'profile' : '".(empty($arTemplate['PATH_TO_USER_PROFILE'])? '': CUtil::JSEscape($arTemplate['PATH_TO_USER_PROFILE']))."', 'profileTemplate' : '".(empty($arTemplate['PATH_TO_USER_PROFILE_TEMPLATE'])? '': CUtil::JSEscape($arTemplate['PATH_TO_USER_PROFILE_TEMPLATE']))."', 'mail' : '".(empty($arTemplate['PATH_TO_USER_MAIL'])? '': CUtil::JSEscape($arTemplate['PATH_TO_USER_MAIL']))."'}
				});
			});
		";

		return $sJS;
	}
Пример #7
0
	protected static function CheckLiveMode()
	{
		return CModule::IncludeModule('pull') && CPullOptions::GetNginxStatus();
	}
Пример #8
0
                 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');
Пример #9
0
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
/**
 * Bitrix vars
 * @global CUser $GLOBALS["USER"]
 * @global CMain $APPLICATION
 * @var array $arParams
 */
$arParams = array();
$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";
$sign = new \Bitrix\Main\Security\Sign\Signer();
$arParams["SIGN"] = $sign->unsign($_REQUEST["sign"], "main.post.list");
if (!is_array($_SESSION["UC_LAST_ACTIVITY"])) {
    $_SESSION["UC_LAST_ACTIVITY"] = array("TIME" => 0, "ENTITY_XML_ID" => $_REQUEST["ENTITY_XML_ID"]);
}
if (check_bitrix_sessid() && $_REQUEST["MODE"] == "PUSH&PULL" && $GLOBALS["USER"]->IsAuthorized() && $arParams["SIGN"] == $_REQUEST["ENTITY_XML_ID"] && ($_SESSION["UC_ACTIVITY"]["ENTITY_XML_ID"] != $_REQUEST["ENTITY_XML_ID"] || time() - $_SESSION["UC_ACTIVITY"]["TIME"] > 10) && CModule::IncludeModule("pull") && CPullOptions::GetNginxStatus()) {
    $_SESSION["UC_ACTIVITY"]["TIME"] = time();
    $_SESSION["UC_ACTIVITY"]["ENTITY_XML_ID"] = $_REQUEST["ENTITY_XML_ID"];
    $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;
}
Пример #10
0
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,
Пример #11
0
	public static function GetTemplateJS($arParams, $arTemplate)
	{
		global $USER;

		$ppStatus = 'false';
		$ppServerStatus = 'false';
		$updateStateInterval = 'auto';
		if (CModule::IncludeModule("pull"))
		{
			$ppStatus = CPullOptions::ModuleEnable()? 'true': 'false';
			$ppServerStatus = CPullOptions::GetNginxStatus()? 'true': 'false';
			$updateStateInterval = CPullOptions::GetNginxStatus()? self::GetSessionLifeTime(): 80;
			if ($updateStateInterval > 100)
			{
				if ($arTemplate['DESKTOP'] == 'true')
					$updateStateInterval = intval($updateStateInterval/2);
				else
					$updateStateInterval = $updateStateInterval-20;
			}
		}

		if ($arTemplate['INIT'] == 'Y')
		{
			$sJS = "
				BX.ready(function() {
					BXIM = new BX.IM(BX('bx-notifier-panel'), {
						'mailCount': ".$arTemplate["MAIL_COUNTER"].",
						'notifyCount': ".$arTemplate["NOTIFY_COUNTER"].",
						'messageCount': ".$arTemplate["MESSAGE_COUNTER"].",
						'counters': ".(empty($arTemplate['COUNTERS'])? '{}': CUtil::PhpToJSObject($arTemplate['COUNTERS'])).",
						'ppStatus': ".$ppStatus.",
						'ppServerStatus': ".$ppServerStatus.",
						'updateStateInterval': '".$updateStateInterval."',
						'xmppStatus': ".(CIMMessenger::CheckXmppStatusOnline()? 'true': 'false').",
						'bitrix24Status': ".(IsModuleInstalled('bitrix24')? 'true': 'false').",
						'bitrixIntranet': ".(IsModuleInstalled('intranet')? 'true': 'false').",
						'bitrixXmpp': ".(IsModuleInstalled('xmpp')? 'true': 'false').",
						'desktop': ".$arTemplate["DESKTOP"].",
						'desktopStatus': ".(CIMMessenger::CheckDesktopStatusOnline()? 'true': 'false').",
						'desktopLinkOpen': ".$arTemplate["DESKTOP_LINK_OPEN"].",
						'language': '".LANGUAGE_ID."',

						'smile': ".CUtil::PhpToJSObject($arTemplate["SMILE"]).",
						'smileSet': ".CUtil::PhpToJSObject($arTemplate["SMILE_SET"]).",
						'settings': ".CUtil::PhpToJSObject($arTemplate['SETTINGS']).",
						'settingsNotifyBlocked': ".(empty($arTemplate['SETTINGS_NOTIFY_BLOCKED'])? '{}': CUtil::PhpToJSObject($arTemplate['SETTINGS_NOTIFY_BLOCKED'])).",

						'notify': ".(empty($arTemplate['NOTIFY']['notify'])? '{}': CUtil::PhpToJSObject($arTemplate['NOTIFY']['notify'])).",
						'unreadNotify' : ".(empty($arTemplate['NOTIFY']['unreadNotify'])? '{}': CUtil::PhpToJSObject($arTemplate['NOTIFY']['unreadNotify'])).",
						'flashNotify' : ".(empty($arTemplate['NOTIFY']['flashNotify'])? '{}': CUtil::PhpToJSObject($arTemplate['NOTIFY']['flashNotify'])).",
						'countNotify' : ".intval($arTemplate['NOTIFY']['countNotify']).",
						'loadNotify' : ".($arTemplate['NOTIFY']['loadNotify']? 'true': 'false').",

						'recent': ".CUtil::PhpToJSObject($arTemplate['RECENT']).",
						'users': ".(empty($arTemplate['CONTACT_LIST']['users'])? '{}': CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['users'])).",
						'groups': ".(empty($arTemplate['CONTACT_LIST']['groups'])? '{}': CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['groups'])).",
						'userInGroup': ".(empty($arTemplate['CONTACT_LIST']['userInGroup'])? '{}': CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['userInGroup'])).",
						'woGroups': ".(empty($arTemplate['CONTACT_LIST']['woGroups'])? '{}': CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['woGroups'])).",
						'woUserInGroup': ".(empty($arTemplate['CONTACT_LIST']['woUserInGroup'])? '{}': CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['woUserInGroup'])).",
						'chat': ".(empty($arTemplate['CHAT']['chat'])? '{}': CUtil::PhpToJSObject($arTemplate['CHAT']['chat'])).",
						'userInChat': ".(empty($arTemplate['CHAT']['userInChat'])? '{}': CUtil::PhpToJSObject($arTemplate['CHAT']['userInChat'])).",
						'message' : ".(empty($arTemplate['MESSAGE']['message'])? '{}': CUtil::PhpToJSObject($arTemplate['MESSAGE']['message'])).",
						'showMessage' : ".(empty($arTemplate['MESSAGE']['usersMessage'])? '{}': CUtil::PhpToJSObject($arTemplate['MESSAGE']['usersMessage'])).",
						'unreadMessage' : ".(empty($arTemplate['MESSAGE']['unreadMessage'])? '{}': CUtil::PhpToJSObject($arTemplate['MESSAGE']['unreadMessage'])).",
						'flashMessage' : ".(empty($arTemplate['MESSAGE']['flashMessage'])? '{}': CUtil::PhpToJSObject($arTemplate['MESSAGE']['flashMessage'])).",
						'history' : {},
						'openMessenger' : ".(isset($_GET['IM_DIALOG'])? "'".CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_DIALOG']))."'": 'false').",
						'openHistory' : ".(isset($_GET['IM_HISTORY'])? "'".CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_HISTORY']))."'": 'false').",
						'openSettings' : ".(isset($_GET['IM_SETTINGS']) && $_GET['IM_SETTINGS'] == 'Y'? "'true'": 'false').",
						'currentTab' : '".CUtil::JSEscape($arTemplate['CURRENT_TAB'])."',
						'userId': ".$USER->GetID().",
						'userEmail': '".CUtil::JSEscape($USER->GetEmail())."',
						'webrtc': {'turnServer' : '".CUtil::JSEscape($arTemplate['TURN_SERVER'])."', 'turnServerFirefox' : '".CUtil::JSEscape($arTemplate['TURN_SERVER_FIREFOX'])."', 'turnServerLogin' : '".CUtil::JSEscape($arTemplate['TURN_SERVER_LOGIN'])."', 'turnServerPassword' : '".CUtil::JSEscape($arTemplate['TURN_SERVER_PASSWORD'])."'},
						'path' : {'profile' : '".CUtil::JSEscape($arTemplate['PATH_TO_USER_PROFILE'])."', 'profileTemplate' : '".CUtil::JSEscape($arTemplate['PATH_TO_USER_PROFILE_TEMPLATE'])."', 'mail' : '".CUtil::JSEscape($arTemplate['PATH_TO_USER_MAIL'])."'}
					});
				});
			";
		}
		else
		{
			$sJS = "
				BX.ready(function() {
					BXIM = new BX.IM(BX('bx-notifier-panel'), {
						'init': false,
						'settings': ".CUtil::PhpToJSObject($arTemplate['SETTINGS']).",
						'updateStateInterval': '".$updateStateInterval."',
						'desktop': ".$arTemplate["DESKTOP"].",
						'ppStatus': ".$ppStatus.",
						'ppServerStatus': ".$ppServerStatus.",
						'xmppStatus': ".(CIMMessenger::CheckXmppStatusOnline()? 'true': 'false').",
						'bitrix24Status': ".(IsModuleInstalled('bitrix24')? 'true': 'false').",
						'bitrixIntranet': ".(IsModuleInstalled('intranet')? 'true': 'false').",
						'bitrixXmpp': ".(IsModuleInstalled('xmpp')? 'true': 'false').",
						'notify' : {},
						'users' : {},
						'userId': ".$USER->GetID().",
						'userEmail': '".CUtil::JSEscape($USER->GetEmail())."',

						'openMessenger' : ".(isset($_GET['IM_DIALOG'])? "'".CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_DIALOG']))."'": 'false').",
						'openHistory' : ".(isset($_GET['IM_HISTORY'])? "'".CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_HISTORY']))."'": 'false').",
						'openSettings' : ".(isset($_GET['IM_SETTINGS']) && $_GET['IM_SETTINGS'] == 'Y'? "'true'": 'false').",

						'path' : {'profile' : '".$arTemplate['PATH_TO_USER_PROFILE']."', 'profileTemplate' : '".$arTemplate['PATH_TO_USER_PROFILE_TEMPLATE']."', 'mail' : '".$arTemplate['PATH_TO_USER_MAIL']."'}
					});
				});
			";
		}

		return $sJS;
	}
Пример #12
0
	public static function CheckOnlineChannel()
	{
		if (!CPullOptions::GetNginxStatus())
			return false;

		global $DB;
		$arUser = Array();

		$sqlDateFunction = null;
		$dbType = strtolower($DB->type);
		if ($dbType == "mysql")
			$sqlDateFunction = "DATE_SUB(NOW(), INTERVAL 13 HOUR)";
		else if ($dbType == "mssql")
			$sqlDateFunction = "dateadd(HOUR, -13, getdate())";
		else if ($dbType == "oracle")
			$sqlDateFunction = "SYSDATE-1/13";

		if (!is_null($sqlDateFunction))
		{
			$strSql = "
					SELECT USER_ID, CHANNEL_ID
					FROM b_pull_channel
					WHERE DATE_CREATE >= ".$sqlDateFunction;
			$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
			while ($arRes = $dbRes->Fetch())
				$arUser[$arRes['USER_ID']] = $arRes['CHANNEL_ID'];
		}
		if (count($arUser) > 0)
		{
			$arOnline = Array();
			$arOffline = Array();

			global $USER;
			$agentUserId = 0;
			if (is_object($USER) && $USER->GetId() > 0)
			{
				$agentUserId = $USER->GetId();
				$arOnline[$agentUserId] = $agentUserId;
			}

			foreach ($arUser as $userId => $channelId)
			{
				if ($userId <= 0 || $agentUserId == $userId)
					continue;

				$result = self::Send($channelId, 'ping', 'GET', 5, false);
				$result = json_decode($result);
				if (is_object($result))
				{
					if ($result->subscribers > 0)
						$arOnline[$userId] = $userId;
					else
						$arOffline[$userId] = $userId;
				}
			}

			if (count($arOnline) > 0)
			{
				ksort($arOnline);
				CUser::SetLastActivityDateByArray($arOnline);
			}
		}

		$arSend = Array();
		$dbUsers = CUser::GetList(($sort_by = 'ID'), ($sort_dir = 'asc'), array('LAST_ACTIVITY' => '180'), array('FIELDS' => array("ID")));
		while ($arUser = $dbUsers->Fetch())
		{
			$arSend[$arUser["ID"]] = Array(
				'id' => $arUser["ID"],
				'status' => 'online',
			);
		}

		CPullStack::AddShared(Array(
			'module_id' => 'main',
			'command' => 'online_list',
			'params' => Array(
				'USERS' => $arSend
			),
		));

		return "CPullChannel::CheckOnlineChannel();";
	}
Пример #13
0
 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())));
             }
         }
     }
 }
Пример #14
0
?>
" name="path_to_listener" <?php 
echo CPullOptions::GetNginxStatus() ? '' : 'disabled="true"';
?>
></td>
	</tr>
	<tr>
		<td><?php 
echo GetMessage("PULL_OPTIONS_PATH_TO_PUBLISH");
?>
:</td>
		<td><input id="config_path_to_publish" type="text" size="40" value="<?php 
echo CPullOptions::GetPublishUrl();
?>
" name="path_to_publish" <?php 
echo CPullOptions::GetNginxStatus() ? '' : 'disabled="true"';
?>
></td>
	</tr>
<?php 
if (IsModuleInstalled('mobileapp')) {
    ?>
	<tr>
		<td align="right" width="50%"><?php 
    echo GetMessage("PULL_OPTIONS_PUSH");
    ?>
:</td>
		<td><input type="checkbox" size="40" value="Y" <?php 
    echo CPullOptions::GetPushStatus() ? ' checked' : '';
    ?>
 name="push"></td>
Пример #15
0
    /**
     * Use component main.post.list to work with LiveFeed
     * @param int $commentId Comment ID which needs to send.
     * @param array $arParams Array of settings (DATE_TIME_FORMAT, SHOW_RATING, PATH_TO_USER, AVATAR_SIZE, NAME_TEMPLATE, SHOW_LOGIN)
     * @return string
     */
    public static function addLiveComment($commentId = 0, $arParams = array())
    {
        $res = "";
        if ($commentId > 0 && CModule::IncludeModule("pull") && \CPullOptions::GetNginxStatus() && ($comment = CBlogComment::GetByID($commentId)) && ($arPost = CBlogPost::GetByID($comment["POST_ID"]))) {
            global $DB, $APPLICATION;
            $arParams["DATE_TIME_FORMAT"] = isset($arParams["DATE_TIME_FORMAT"]) ? $arParams["DATE_TIME_FORMAT"] : $DB->DateFormatToPHP(CSite::GetDateFormat("FULL"));
            $arParams["SHOW_RATING"] = $arParams["SHOW_RATING"] == "N" ? "N" : "Y";
            $arParams["PATH_TO_USER"] = isset($arParams["PATH_TO_USER"]) ? $arParams["PATH_TO_USER"] : '';
            $arParams["AVATAR_SIZE_COMMENT"] = $arParams["AVATAR_SIZE_COMMENT"] > 0 ? $arParams["AVATAR_SIZE_COMMENT"] : ($arParams["AVATAR_SIZE"] > $arParams["AVATAR_SIZE"] ? $arParams["AVATAR_SIZE"] : 58);
            $arParams["NAME_TEMPLATE"] = isset($arParams["NAME_TEMPLATE"]) ? $arParams["NAME_TEMPLATE"] : CSite::GetNameFormat();
            $arParams["SHOW_LOGIN"] = $arParams["SHOW_LOGIN"] == "N" ? "N" : "Y";
            $comment["DateFormated"] = FormatDateFromDB($comment["DATE_CREATE"], $arParams["DATE_TIME_FORMAT"], true);
            $timestamp = MakeTimeStamp($comment["DATE_CREATE"]);
            if (strcasecmp(LANGUAGE_ID, 'EN') !== 0 && strcasecmp(LANGUAGE_ID, 'DE') !== 0) {
                $comment["DateFormated"] = ToLower($comment["DateFormated"]);
            }
            $comment["UF"] = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("BLOG_COMMENT", $commentId, LANGUAGE_ID);
            $arAuthor = CBlogUser::GetUserInfo($comment["AUTHOR_ID"], $arParams["PATH_TO_USER"], array("AVATAR_SIZE_COMMENT" => $arParams["AVATAR_SIZE_COMMENT"]));
            if (intval($arAuthor["PERSONAL_PHOTO"]) > 0) {
                $image_resize = CFile::ResizeImageGet($arAuthor["PERSONAL_PHOTO"], array("width" => $arParams["AVATAR_SIZE_COMMENT"], "height" => $arParams["AVATAR_SIZE_COMMENT"]), BX_RESIZE_IMAGE_EXACT);
                $arAuthor["PERSONAL_PHOTO_RESIZED"] = array("src" => $image_resize["src"]);
            }
            $p = new blogTextParser(false, '');
            $ufCode = "UF_BLOG_COMMENT_FILE";
            if (is_array($comment["UF"][$ufCode])) {
                $p->arUserfields = array($ufCode => array_merge($comment["UF"][$ufCode], array("TAG" => "DOCUMENT ID")));
            }
            $arAllow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "SHORT_ANCHOR" => "Y");
            $arParserParams = array("imageWidth" => 800, "imageHeight" => 800);
            $comment["TextFormated"] = $p->convert($comment["POST_TEXT"], false, array(), $arAllow, $arParserParams);
            $p->bMobile = true;
            $comment["TextFormatedMobile"] = $p->convert($comment["POST_TEXT"], false, array(), $arAllow, $arParserParams);
            $comment["TextFormatedJS"] = CUtil::JSEscape(htmlspecialcharsBack($comment["POST_TEXT"]));
            $comment["TITLE"] = CUtil::JSEscape(htmlspecialcharsBack($comment["TITLE"]));
            $eventHandlerID = AddEventHandler("main", "system.field.view.file", array("CSocNetLogTools", "logUFfileShow"));
            $res = $APPLICATION->IncludeComponent("bitrix:main.post.list", "", array("TEMPLATE_ID" => 'BLOG_COMMENT_BG_', "RATING_TYPE_ID" => $arParams["SHOW_RATING"] == "Y" ? "BLOG_COMMENT" : "", "ENTITY_XML_ID" => "BLOG_" . $arPost["ID"], "RECORDS" => array($commentId => array("ID" => $comment["ID"], "NEW" => $arParams["FOLLOW"] != "N" && $comment["NEW"] == "Y" ? "Y" : "N", "APPROVED" => $comment["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH ? "Y" : "N", "POST_TIMESTAMP" => $timestamp, "POST_TIME" => $comment["DATE_CREATE_TIME"], "POST_DATE" => $comment["DateFormated"], "AUTHOR" => array("ID" => $arAuthor["ID"], "NAME" => $arAuthor["~NAME"], "LAST_NAME" => $arAuthor["~LAST_NAME"], "SECOND_NAME" => $arAuthor["~SECOND_NAME"], "AVATAR" => $arAuthor["PERSONAL_PHOTO_resized"]["src"]), "FILES" => false, "UF" => $comment["UF"], "~POST_MESSAGE_TEXT" => $comment["POST_TEXT"], "WEB" => array("POST_TIME" => $comment["DATE_CREATE_TIME"], "POST_DATE" => $comment["DateFormated"], "CLASSNAME" => "", "POST_MESSAGE_TEXT" => $comment["TextFormated"], "AFTER" => <<<HTML
<script>top.text{$commentId} = text{$commentId} = '{$comment["TextFormatedJS"]}';top.title{$commentId} = title{$commentId} = '{$comment["TITLE"]}';top.arComFiles{$commentId} = [];</script>
HTML
), "MOBILE" => array("POST_TIME" => $comment["DATE_CREATE_TIME"], "POST_DATE" => $comment["DateFormated"], "CLASSNAME" => "", "POST_MESSAGE_TEXT" => $comment["TextFormatedMobile"]))), "NAV_STRING" => "", "NAV_RESULT" => "", "PREORDER" => "N", "RIGHTS" => array("MODERATE" => "N", "EDIT" => "N", "DELETE" => "N"), "VISIBLE_RECORDS_COUNT" => 1, "ERROR_MESSAGE" => "", "OK_MESSAGE" => "", "RESULT" => $commentId, "PUSH&PULL" => array("ACTION" => "REPLY", "ID" => $commentId), "MODE" => "PULL_MESSAGE", "VIEW_URL" => "", "EDIT_URL" => "", "MODERATE_URL" => "", "DELETE_URL" => "", "AUTHOR_URL" => "", "AVATAR_SIZE" => $arParams["AVATAR_SIZE_COMMENT"], "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"], "SHOW_LOGIN" => $arParams["SHOW_LOGIN"], "DATE_TIME_FORMAT" => "", "LAZYLOAD" => "", "NOTIFY_TAG" => "", "NOTIFY_TEXT" => "", "SHOW_MINIMIZED" => "Y", "SHOW_POST_FORM" => "", "IMAGE_SIZE" => "", "mfi" => ""), array(), null);
            if ($eventHandlerID !== false && intval($eventHandlerID) > 0) {
                RemoveEventHandler('main', 'system.field.view.file', $eventHandlerID);
            }
        }
        return $res;
    }
Пример #16
0
				$arUnread['chat'.$data['recipientId']]['CHAT'] = $arMessage['chat'][$data['recipientId']];
			}

			uasort($arUnread, create_function('$a, $b', 'if($a["MESSAGE"]["date"] < $b["MESSAGE"]["date"] ) return 1; elseif($a["MESSAGE"]["date"]  > $b["MESSAGE"]["date"] ) return -1; else return 0;'));
			$arResult['COUNTER_UNREAD_MESSAGES'] = $arUnread;
		}

		$arOnline = CIMStatus::GetList();
		$arResult['ONLINE'] = !empty($arOnline)? $arOnline['users']: Array();

		if (CModule::IncludeModule('pull'))
		{
			$arChannel = CPullChannel::Get($USER->GetId());
			if (is_array($arChannel))
			{
				$nginxStatus = CPullOptions::GetNginxStatus();
				$webSocketStatus = CPullOptions::GetWebSocketStatus();

				$arChannels = Array($arChannel['CHANNEL_ID']);
				if ($nginxStatus)
				{
					$arChannelShared = CPullChannel::GetShared();
					$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');
Пример #17
0
 $arTmpCommentEvent = array("LOG_DATE" => $arComment["LOG_DATE"], "LOG_DATE_FORMAT" => $arComment["LOG_DATE_FORMAT"], "LOG_DATE_DAY" => ConvertTimeStamp(MakeTimeStamp($arComment["LOG_DATE"]), "SHORT"), "LOG_TIME_FORMAT" => $timeFormated, "MESSAGE" => $arComment["MESSAGE"], "MESSAGE_FORMAT" => $arComment["~MESSAGE"], "CREATED_BY" => $arCreatedBy, "AVATAR_SRC" => CSocNetLogTools::FormatEvent_CreateAvatar($arUser, $arParams, ""), "USER_ID" => $arComment["USER_ID"]);
 $arEventTmp = CSocNetLogTools::FindLogCommentEventByID($arComment["EVENT_ID"]);
 if ($arEventTmp && array_key_exists("CLASS_FORMAT", $arEventTmp) && array_key_exists("METHOD_FORMAT", $arEventTmp)) {
     $arFIELDS_FORMATTED = call_user_func(array($arEventTmp["CLASS_FORMAT"], $arEventTmp["METHOD_FORMAT"]), $arComment, $arParams);
     $arTmpCommentEvent["MESSAGE_FORMAT"] = htmlspecialcharsback($arFIELDS_FORMATTED["EVENT_FORMATTED"]["MESSAGE"]);
 } else {
     $arTmpCommentEvent["MESSAGE_FORMAT"] = $arComment["MESSAGE"];
 }
 if ($arEventTmp && array_key_exists("CLASS_FORMAT", $arEventTmp) && array_key_exists("METHOD_FORMAT", $arEventTmp)) {
     $arFIELDS_FORMATTED = call_user_func(array($arEventTmp["CLASS_FORMAT"], $arEventTmp["METHOD_FORMAT"]), $arComment, array_merge($arParams, array("MOBILE" => "Y")));
     $strMessageMobile = htmlspecialcharsback($arFIELDS_FORMATTED["EVENT_FORMATTED"]["MESSAGE"]);
 } else {
     $strMessageMobile = $arComment["MESSAGE"];
 }
 $arResult["arCommentFormatted"] = $arTmpCommentEvent;
 if ($_REQUEST["pull"] == "Y" && CModule::IncludeModule("pull") && CPullOptions::GetNginxStatus()) {
     $arForumMetaData = CSocNetLogTools::GetForumCommentMetaData($arLog["EVENT_ID"]);
     if ($arLog["ENTITY_TYPE"] == "CRMACTIVITY" && CModule::IncludeModule('crm') && ($arActivity = CCrmActivity::GetByID($arLog["ENTITY_ID"], false)) && $arActivity["TYPE_ID"] == CCrmActivityType::Task) {
         $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 ($arForumMetaData && $arLog["SOURCE_ID"] > 0) {
         $entity_xml_id = $arForumMetaData[0] . "_" . $arLog["SOURCE_ID"];
     } else {
         $entity_xml_id = strtoupper($arLog["EVENT_ID"]) . "_" . $arLog["ID"];
     }
     $commentId = !!$arComment["SOURCE_ID"] ? $arComment["SOURCE_ID"] : $arComment["ID"];
     $eventHandlerID = AddEventHandler("main", "system.field.view.file", array("CSocNetLogTools", "logUFfileShow"));
     $rights = CSocNetLogComponent::getCommentRights(array("EVENT_ID" => $arLog["EVENT_ID"], "SOURCE_ID" => $arLog["SOURCE_ID"]));
     $res = $APPLICATION->IncludeComponent("bitrix:main.post.list", "", array("TEMPLATE_ID" => '', "RATING_TYPE_ID" => $arComment["RATING_TYPE_ID"], "ENTITY_XML_ID" => $entity_xml_id, "RECORDS" => array($commentId => array("ID" => $commentId, "NEW" => "Y", "APPROVED" => "Y", "POST_TIMESTAMP" => $arResult["timestamp"], "AUTHOR" => array("ID" => $arUser["ID"], "NAME" => $arUser["NAME"], "LAST_NAME" => $arUser["LAST_NAME"], "SECOND_NAME" => $arUser["SECOND_NAME"], "AVATAR" => $arTmpCommentEvent["AVATAR_SRC"]), "FILES" => false, "UF" => $arComment["UF"], "~POST_MESSAGE_TEXT" => $arComment["~MESSAGE"], "WEB" => array("CLASSNAME" => "", "POST_MESSAGE_TEXT" => $arTmpCommentEvent["MESSAGE_FORMAT"], "AFTER" => $arTmpCommentEvent["UF"]), "MOBILE" => array("CLASSNAME" => "", "POST_MESSAGE_TEXT" => $strMessageMobile))), "NAV_STRING" => "", "NAV_RESULT" => "", "PREORDER" => "N", "RIGHTS" => array("MODERATE" => "N", "EDIT" => $rights["COMMENT_RIGHTS_EDIT"], "DELETE" => $rights["COMMENT_RIGHTS_DELETE"]), "VISIBLE_RECORDS_COUNT" => 1, "ERROR_MESSAGE" => "", "OK_MESSAGE" => "", "RESULT" => $commentId, "PUSH&PULL" => array("ACTION" => "REPLY", "ID" => $commentId), "MODE" => "PULL_MESSAGE", "VIEW_URL" => isset($arComment["EVENT"]["URL"]) && strlen($arComment["EVENT"]["URL"]) > 0 ? $arComment["EVENT"]["URL"] : (isset($arParams["PATH_TO_LOG_ENTRY"]) && strlen($arParams["PATH_TO_LOG_ENTRY"]) > 0 ? CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_LOG_ENTRY"], array("log_id" => $arLog["ID"])) . "?commentId=#ID#" : ""), "EDIT_URL" => "__logEditComment('" . $entity_xml_id . "', '#ID#', '" . $arLog["ID"] . "');", "MODERATE_URL" => "", "DELETE_URL" => '/bitrix/components/bitrix/socialnetwork.log.entry/ajax.php?lang=' . LANGUAGE_ID . '&action=delete_comment&delete_comment_id=#ID#&post_id=' . $arLog["ID"] . '&site=' . SITE_ID, "AUTHOR_URL" => "", "AVATAR_SIZE" => $arParams["AVATAR_SIZE_COMMENT"], "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"], "SHOW_LOGIN" => $arParams["SHOW_LOGIN"], "DATE_TIME_FORMAT" => $arParams["DATE_TIME_FORMAT"], "LAZYLOAD" => "Y", "NOTIFY_TAG" => "", "NOTIFY_TEXT" => "", "SHOW_MINIMIZED" => "Y", "SHOW_POST_FORM" => "Y", "IMAGE_SIZE" => "", "mfi" => ""), array(), null);
     if ($eventHandlerID > 0) {
Пример #18
0
 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;
 }
Пример #19
0
<?endif;?>
	<tr>
		<td width="40%"></td>
		<td width="60%"></td>
	</tr>
	<tr>
		<td width="40%"><nobr><?=GetMessage("PULL_OPTIONS_NGINX")?></nobr>:</td>
		<td width="60%"><input id="config_nginx" type="checkbox" size="40" value="Y" <?=(CPullOptions::GetNginxStatus()?' checked':'')?> name="nginx"></td>
	</tr>
	<tr>
		<td><?=GetMessage("PULL_OPTIONS_PATH_TO_PUBLISH")?>:</td>
		<td><input id="config_path_to_publish" type="text" size="40" value="<?=htmlspecialcharsbx(CPullOptions::GetPublishUrl())?>" name="path_to_publish" <?=(CPullOptions::GetNginxStatus()? '':'disabled="true"')?>></td>
	</tr>
	<tr>
		<td ><?=GetMessage("PULL_OPTIONS_PATH_TO_LISTENER")?>:</td>
		<td><input id="config_path_to_listener" type="text" size="40" value="<?=htmlspecialcharsbx(CPullOptions::GetListenUrl())?>" name="path_to_listener" <?=(CPullOptions::GetNginxStatus()? '':'disabled="true"')?>></td>
	</tr>
	<?/*
	<tr>
		<td width="40%"><nobr><?=GetMessage("PULL_OPTIONS_WEBSOCKET")?></nobr>:</td>
		<td width="60%"><input id="config_websocket" type="checkbox" size="40" value="Y" <?=(CPullOptions::GetWebSocketStatus()?' checked':'')?> name="websocket" <?=(CPullOptions::GetNginxStatus()? '':'disabled="true"')?>></td>
	</tr>
	<tr>
		<td ><?=GetMessage("PULL_OPTIONS_PATH_TO_WEBSOCKET")?>:</td>
		<td><input id="config_path_to_websocket" type="text" size="40" value="<?=htmlspecialcharsbx(CPullOptions::GetWebSocketUrl())?>" name="path_to_websocket" <?=(!CPullOptions::GetNginxStatus() || !CPullOptions::GetWebSocketStatus() ? 'disabled="true"': '')?></td>
	</tr>
	*/?>
<?if (IsModuleInstalled('mobileapp')):?>
	<tr>
		<td align="right" width="50%"><?=GetMessage("PULL_OPTIONS_PUSH")?>:</td>
		<td><input type="checkbox" size="40" value="Y" <?=(CPullOptions::GetPushStatus()?' checked':'')?> name="push"></td>
Пример #20
0
    function AddLiveComment($commentId = 0, $path = "", $arParams = array())
    {
        if (IntVal($commentId) <= 0) {
            return;
        }
        if (CModule::IncludeModule("pull") && CPullOptions::GetNginxStatus() && ($arComment = CBlogComment::GetByID($commentId)) && ($arPost = CBlogPost::GetByID($arComment["POST_ID"]))) {
            if (strlen($path) <= 0 && strlen($arComment["PATH"]) > 0) {
                $path = CComponentEngine::MakePathFromTemplate($arComment["PATH"], array("post_id" => $arComment["POST_ID"], "comment_id" => $commentId));
            }
            if (strlen($path) <= 0) {
                $path = CComponentEngine::MakePathFromTemplate($arPost["PATH"], array("post_id" => $arComment["POST_ID"], "comment_id" => $commentId)) . "?commentId=" . $commentId;
            }
            $arFormatParams = array("PATH_TO_USER" => isset($arParams["PATH_TO_USER"]) ? $arParams["PATH_TO_USER"] : '', "PATH_TO_POST" => $path, "NAME_TEMPLATE" => isset($arParams["NAME_TEMPLATE"]) ? $arParams["NAME_TEMPLATE"] : CSite::GetNameFormat(), "SHOW_LOGIN" => isset($arParams["SHOW_LOGIN"]) ? $arParams["SHOW_LOGIN"] : true, "AVATAR_SIZE_COMMENT" => isset($arParams["AVATAR_SIZE_COMMENT"]) ? $arParams["AVATAR_SIZE_COMMENT"] : 58, "PATH_TO_SMILE" => isset($arParams["PATH_TO_SMILE"]) ? $arParams["PATH_TO_SMILE"] : '', "DATE_TIME_FORMAT" => isset($arParams["DATE_TIME_FORMAT"]) ? $arParams["DATE_TIME_FORMAT"] : '', "SHOW_RATING" => isset($arParams["SHOW_RATING"]) ? $arParams["SHOW_RATING"] : '', "RATING_TYPE" => "like");
            $arComment["DateFormated"] = FormatDateFromDB($arComment["DATE_CREATE"], $arFormatParams["DATE_TIME_FORMAT"], true);
            if (strcasecmp(LANGUAGE_ID, 'EN') !== 0 && strcasecmp(LANGUAGE_ID, 'DE') !== 0) {
                $arComment["DateFormated"] = ToLower($arComment["DateFormated"]);
            }
            $arComment["UF"] = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("BLOG_COMMENT", $commentId, LANGUAGE_ID);
            $arAuthor = CBlogUser::GetUserInfo($arComment["AUTHOR_ID"], $arFormatParams["PATH_TO_USER"], array("AVATAR_SIZE_COMMENT" => $arFormatParams["AVATAR_SIZE_COMMENT"]));
            if (IsModuleInstalled('extranet') && CModule::IncludeModule('socialnetwork')) {
                CSocNetTools::InitGlobalExtranetArrays();
            }
            $arTmpUser = array("NAME" => $arAuthor["~NAME"], "LAST_NAME" => $arAuthor["~LAST_NAME"], "SECOND_NAME" => $arAuthor["~SECOND_NAME"], "LOGIN" => $arAuthor["~LOGIN"], "NAME_LIST_FORMATTED" => "");
            $arAuthor["NAME_FORMATED"] = CUser::FormatName($arFormatParams["NAME_TEMPLATE"], $arTmpUser, $arFormatParams["SHOW_LOGIN"] != "N");
            if (intval($arAuthor["PERSONAL_PHOTO"]) > 0) {
                $image_resize = CFile::ResizeImageGet($arAuthor["PERSONAL_PHOTO"], array("width" => $arFormatParams["AVATAR_SIZE_COMMENT"], "height" => $arFormatParams["AVATAR_SIZE_COMMENT"]), BX_RESIZE_IMAGE_EXACT);
                $arAuthor["PERSONAL_PHOTO_RESIZED"] = array("src" => $image_resize["src"]);
            }
            $p = new blogTextParser(false, '');
            $ufCode = "UF_BLOG_COMMENT_FILE";
            if (is_array($arComment["UF"][$ufCode])) {
                $p->arUserfields = array($ufCode => array_merge($arComment["UF"][$ufCode], array("TAG" => "DOCUMENT ID")));
            }
            $arAllow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "SHORT_ANCHOR" => "Y");
            $arParserParams = array("imageWidth" => 800, "imageHeight" => 800);
            $arComment["TextFormated"] = $p->convert($arComment["POST_TEXT"], false, array(), $arAllow, $arParserParams);
            $p->bMobile = true;
            $arComment["TextFormatedMobile"] = $p->convert($arComment["POST_TEXT"], false, array(), $arAllow, $arParserParams);
            if ($perm >= BLOG_PERMS_MODERATE) {
                if ($arComment["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) {
                    $arComment["CAN_HIDE"] = "Y";
                } else {
                    $arComment["CAN_SHOW"] = "Y";
                }
            } else {
                $arComment["CAN_SHOW"] = $arComment["CAN_HIDE"] = "N";
            }
            $urlToPost = CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arFormatParams["PATH_TO_POST"]), array("post_id" => "#source_post_id#", "user_id" => $arPost["AUTHOR_ID"]));
            $urlToPost .= strpos($urlToPost, "?") !== false ? "&" : "?";
            $arUrl = array("LINK" => $urlToPost, "SHOW" => $urlToPost . "show_comment_id=#comment_id#&comment_post_id=#post_id#&" . bitrix_sessid_get(), "HIDE" => $urlToPost . "hide_comment_id=#comment_id#&comment_post_id=#post_id#&" . bitrix_sessid_get(), "DELETE" => $urlToPost . "delete_comment_id=#comment_id#&comment_post_id=#post_id#&" . bitrix_sessid_get(), "USER" => htmlspecialcharsback($arFormatParams["PATH_TO_USER"]));
            CRatingsComponentsMain::GetShowRating($arFormatParams);
            if ($arFormatParams["SHOW_RATING"] == "Y") {
                $arRating = CRatings::GetRatingVoteResult('BLOG_COMMENT', array($arComment["ID"]));
            }
            $arCommentParams = array("ID" => $commentId, "ENTITY_XML_ID" => "BLOG_" . $arPost["ID"], "FULL_ID" => array("BLOG_" . $arPost["ID"], $commentId), "ACTION" => "REPLY", "APPROVED" => "Y", "PANELS" => array("EDIT" => "N", "MODERATE" => "N", "DELETE" => "N"), "NEW" => "Y", "AUTHOR" => array("ID" => $GLOBALS["USER"]->GetID(), "NAME" => $arAuthor["NAME_FORMATED"], "URL" => $arAuthor["url"], "E-MAIL" => $arComment["AuthorEmail"], "AVATAR" => $arAuthor["PERSONAL_PHOTO_resized"]["src"], "IS_EXTRANET" => is_array($GLOBALS["arExtranetUserID"]) && in_array($GLOBALS["USER"]->GetID(), $GLOBALS["arExtranetUserID"])), "POST_TIMESTAMP" => $arComment["DATE_CREATE_TS"], "POST_TIME" => $arComment["DATE_CREATE_TIME"], "POST_DATE" => $arComment["DateFormated"], "POST_MESSAGE_TEXT" => $arComment["TextFormated"], "POST_MESSAGE_TEXT_MOBILE" => $arComment["TextFormatedMobile"], "URL" => array("LINK" => str_replace(array("##comment_id#", "#comment_id#"), array("", $commentId), $arUrl["LINK"]), "EDIT" => "__blogEditComment('" . $commentId . "', '" . $arPost["ID"] . "');", "MODERATE" => str_replace(array("#source_post_id#", "#post_id#", "#comment_id#", "&" . bitrix_sessid_get()), array($arPost["ID"], $arPost["ID"], $commentId, ""), $arComment["CAN_SHOW"] == "Y" ? $arUrl["SHOW"] : ($arComment["CAN_HIDE"] == "Y" ? $arUrl["HIDE"] : "")), "DELETE" => str_replace(array("#source_post_id#", "#post_id#", "#comment_id#", "&" . bitrix_sessid_get()), array($arPost["ID"], $arPost["ID"], $commentId, ""), $arUrl["DELETE"])), "AFTER" => "", "BEFORE_ACTIONS_MOBILE" => "", "AFTER_MOBILE" => "");
            if ($arFormatParams["SHOW_RATING"] == "Y") {
                $arRatingData = array("ENTITY_TYPE_ID" => "BLOG_COMMENT", "ENTITY_ID" => $commentId, "OWNER_ID" => $arComment["AUTHOR_ID"], "USER_VOTE" => $arRating[$commentId]["USER_VOTE"], "USER_HAS_VOTED" => $arRating[$commentId]["USER_HAS_VOTED"], "TOTAL_VOTES" => $arRating[$commentId]["TOTAL_VOTES"], "TOTAL_POSITIVE_VOTES" => $arRating[$commentId]["TOTAL_POSITIVE_VOTES"], "TOTAL_NEGATIVE_VOTES" => $arRating[$commentId]["TOTAL_NEGATIVE_VOTES"], "TOTAL_VALUE" => $arRating[$commentId]["TOTAL_VALUE"], "PATH_TO_USER_PROFILE" => $arUrl["USER"]);
                ob_start();
                $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:rating.vote", $arFormatParams["RATING_TYPE"], $arRatingData, false, array("HIDE_ICONS" => "Y"));
                $arCommentParams["BEFORE_ACTIONS"] = ob_get_clean();
                ob_start();
                $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:rating.vote", "mobile_comment_" . $arFormatParams["RATING_TYPE"], $arRatingData, false, array("HIDE_ICONS" => "Y"));
                $arCommentParams["BEFORE_ACTIONS_MOBILE"] = ob_get_clean();
            }
            $arUFResult = self::BuildUFFields($arComment["UF"]);
            $arCommentParams["AFTER"] .= $arUFResult["AFTER"];
            $arCommentParams["AFTER_MOBILE"] .= $arUFResult["AFTER_MOBILE"];
            if ($arComment["CAN_EDIT"] == "Y") {
                ob_start();
                ?>
<script>
					top.text<?php 
                echo $commentId;
                ?>
 = text<?php 
                echo $commentId;
                ?>
 = '<?php 
                echo CUtil::JSEscape(htmlspecialcharsBack($arComment["POST_TEXT"]));
                ?>
';
					top.title<?php 
                echo $commentId;
                ?>
 = title<?php 
                echo $commentId;
                ?>
 = '<?php 
                echo isset($arComment["TITLE"]) ? CUtil::JSEscape($arComment["TITLE"]) : '';
                ?>
';
					top.arComFiles<?php 
                echo $commentId;
                ?>
 = [];<?php 
                ?>
</script><?php 
                $arCommentParams["AFTER"] .= ob_get_clean();
            }
            CPullWatch::AddToStack('UNICOMMENTSBLOG_' . $arPost["ID"], array('module_id' => 'unicomments', 'command' => 'comment', 'params' => $arCommentParams));
        }
    }
Пример #21
0
 public static function GetTemplateJS($arParams, $arTemplate)
 {
     global $USER;
     $ppStatus = 'false';
     $ppServerStatus = 'false';
     if (CModule::IncludeModule("pull")) {
         $ppStatus = CPullOptions::ModuleEnable() ? 'true' : 'false';
         $ppServerStatus = CPullOptions::GetNginxStatus() ? 'true' : 'false';
     }
     if ($arTemplate['INIT'] == 'Y') {
         $sJS = "\n\t\t\t\tBX.ready(function() {\n\t\t\t\t\tBXIM = new BX.IM(BX('bx-notifier-panel'), {\n\t\t\t\t\t\t'panelPosition': {'horizontal' : '" . $arTemplate['PANEL_POSTION_HORIZONTAL'] . "', 'vertical' : '" . $arTemplate['PANEL_POSTION_VERTICAL'] . "'},\n\t\t\t\t\t\t'userStatus': '" . $arTemplate['STATUS'] . "',\n\t\t\t\t\t\t'mailCount': " . $arTemplate["MAIL_COUNTER"] . ",\n\t\t\t\t\t\t'notifyCount': " . $arTemplate["NOTIFY_COUNTER"] . ",\n\t\t\t\t\t\t'messageCount': " . $arTemplate["MESSAGE_COUNTER"] . ",\n\t\t\t\t\t\t'counters': " . (empty($arTemplate['COUNTERS']) ? '{}' : CUtil::PhpToJSObject($arTemplate['COUNTERS'])) . ",\n\t\t\t\t\t\t'ppStatus': " . $ppStatus . ",\n\t\t\t\t\t\t'ppServerStatus': " . $ppServerStatus . ",\n\t\t\t\t\t\t'xmppStatus': " . (CIMMessenger::CheckXmppStatusOnline() ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrix24Status': " . (IsModuleInstalled('bitrix24') ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrixIntranet': " . (IsModuleInstalled('intranet') ? 'true' : 'false') . ",\n\t\t\t\t\t\t'desktop': " . $arTemplate["DESKTOP"] . ",\n\t\t\t\t\t\t'desktopStatus': " . (CIMMessenger::CheckDesktopStatusOnline() ? 'true' : 'false') . ",\n\t\t\t\t\t\t'desktopLinkOpen': " . $arTemplate["DESKTOP_LINK_OPEN"] . ",\n\n\t\t\t\t\t\t'notify': " . (empty($arTemplate['NOTIFY']['notify']) ? '{}' : CUtil::PhpToJSObject($arTemplate['NOTIFY']['notify'])) . ",\n\t\t\t\t\t\t'unreadNotify' : " . (empty($arTemplate['NOTIFY']['unreadNotify']) ? '{}' : CUtil::PhpToJSObject($arTemplate['NOTIFY']['unreadNotify'])) . ",\n\t\t\t\t\t\t'flashNotify' : " . (empty($arTemplate['NOTIFY']['flashNotify']) ? '{}' : CUtil::PhpToJSObject($arTemplate['NOTIFY']['flashNotify'])) . ",\n\t\t\t\t\t\t'countNotify' : " . intval($arTemplate['NOTIFY']['countNotify']) . ",\n\t\t\t\t\t\t'loadNotify' : " . ($arTemplate['NOTIFY']['loadNotify'] ? 'true' : 'false') . ",\n\n\t\t\t\t\t\t'recent': " . CUtil::PhpToJSObject($arTemplate['RECENT']) . ",\n\t\t\t\t\t\t'users': " . (empty($arTemplate['CONTACT_LIST']['users']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['users'])) . ",\n\t\t\t\t\t\t'groups': " . (empty($arTemplate['CONTACT_LIST']['groups']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['groups'])) . ",\n\t\t\t\t\t\t'userInGroup': " . (empty($arTemplate['CONTACT_LIST']['userInGroup']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['userInGroup'])) . ",\n\t\t\t\t\t\t'woGroups': " . (empty($arTemplate['CONTACT_LIST']['woGroups']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['woGroups'])) . ",\n\t\t\t\t\t\t'woUserInGroup': " . (empty($arTemplate['CONTACT_LIST']['woUserInGroup']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['woUserInGroup'])) . ",\n\t\t\t\t\t\t'chat': " . (empty($arTemplate['CHAT']['chat']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CHAT']['chat'])) . ",\n\t\t\t\t\t\t'userInChat': " . (empty($arTemplate['CHAT']['userInChat']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CHAT']['userInChat'])) . ",\n\t\t\t\t\t\t'message' : " . (empty($arTemplate['MESSAGE']['message']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['message'])) . ",\n\t\t\t\t\t\t'showMessage' : " . (empty($arTemplate['MESSAGE']['usersMessage']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['usersMessage'])) . ",\n\t\t\t\t\t\t'unreadMessage' : " . (empty($arTemplate['MESSAGE']['unreadMessage']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['unreadMessage'])) . ",\n\t\t\t\t\t\t'flashMessage' : " . (empty($arTemplate['MESSAGE']['flashMessage']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['flashMessage'])) . ",\n\t\t\t\t\t\t'history' : {},\n\t\t\t\t\t\t'openMessenger' : " . (isset($_GET['IM_DIALOG']) ? "'" . htmlspecialcharsbx($_GET['IM_DIALOG']) . "'" : 'false') . ",\n\t\t\t\t\t\t'openHistory' : " . (isset($_GET['IM_HISTORY']) ? "'" . htmlspecialcharsbx($_GET['IM_HISTORY']) . "'" : 'false') . ",\n\t\t\t\t\t\t'viewOffline': " . $arTemplate['VIEW_OFFLINE'] . ",\n\t\t\t\t\t\t'viewGroup': " . $arTemplate['VIEW_GROUP'] . ",\n\t\t\t\t\t\t'enableSound': " . $arTemplate['ENABLE_SOUND'] . ",\n\t\t\t\t\t\t'sendByEnter': " . $arTemplate['SEND_BY_ENTER'] . ",\n\t\t\t\t\t\t'currentTab' : " . ($arTemplate['CURRENT_TAB'] > 0 ? $arTemplate['CURRENT_TAB'] : '0') . ",\n\t\t\t\t\t\t'userId': " . $USER->GetID() . ",\n\t\t\t\t\t\t'path' : {'profile' : '" . $arTemplate['PATH_TO_USER_PROFILE'] . "', 'profileTemplate' : '" . $arTemplate['PATH_TO_USER_PROFILE_TEMPLATE'] . "', 'mail' : '" . $arTemplate['PATH_TO_USER_MAIL'] . "'}\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t";
     } else {
         $sJS = "\n\t\t\t\tBX.ready(function() {\n\t\t\t\t\tBXIM = new BX.IM(BX('bx-notifier-panel'), {\n\t\t\t\t\t\t'init': false,\n\n\t\t\t\t\t\t'desktop': " . $arTemplate["DESKTOP"] . ",\n\t\t\t\t\t\t'desktopStatus': " . (CIMMessenger::CheckDesktopStatusOnline() ? 'true' : 'false') . ",\n\t\t\t\t\t\t'desktopLinkOpen': " . $arTemplate["DESKTOP_LINK_OPEN"] . ",\n\n\t\t\t\t\t\t'userStatus': '" . $arTemplate['STATUS'] . "',\n\t\t\t\t\t\t'ppStatus': " . $ppStatus . ",\n\t\t\t\t\t\t'ppServerStatus': " . $ppServerStatus . ",\n\t\t\t\t\t\t'xmppStatus': " . (CIMMessenger::CheckXmppStatusOnline() ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrix24Status': " . (IsModuleInstalled('bitrix24') ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrixIntranet': " . (IsModuleInstalled('intranet') ? 'true' : 'false') . ",\n\t\t\t\t\t\t'enableSound': " . $arTemplate['ENABLE_SOUND'] . ",\n\t\t\t\t\t\t'notify' : {},\n\t\t\t\t\t\t'users' : {},\n\t\t\t\t\t\t'userId': " . $USER->GetID() . ",\n\n\t\t\t\t\t\t'openMessenger' : " . (isset($_GET['IM_DIALOG']) ? intval($_GET['IM_DIALOG']) : 'false') . ",\n\t\t\t\t\t\t'openHistory' : " . (isset($_GET['IM_HISTORY']) ? intval($_GET['IM_HISTORY']) : 'false') . ",\n\n\t\t\t\t\t\t'path' : {'profile' : '" . $arTemplate['PATH_TO_USER_PROFILE'] . "', 'profileTemplate' : '" . $arTemplate['PATH_TO_USER_PROFILE_TEMPLATE'] . "', 'mail' : '" . $arTemplate['PATH_TO_USER_MAIL'] . "'}\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t";
     }
     return $sJS;
 }
Пример #22
0
	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",
						),
					)
				);
			}
		}
	}
Пример #23
0
 public static function Enable()
 {
     return CModule::IncludeModule('pull') && CPullOptions::GetNginxStatus() ? true : false;
 }
Пример #24
0
<?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;
}
Пример #25
0
 public static function SetLastActivityDate($userId, $lastActivityDate = null, $sendPull = false)
 {
     if (is_null($lastActivityDate)) {
         $lastActivityDate = time();
     }
     CUserOptions::SetOption('xmpp', 'LastActivityDate', intval($lastActivityDate), false, $userId);
     if ($sendPull) {
         if (CModule::IncludeModule('pull') && CPullOptions::GetNginxStatus()) {
             CPullStack::AddByUser($userId, array('module_id' => 'xmpp', 'command' => 'lastActivityDate', 'params' => array('timestamp' => intval($lastActivityDate))));
         }
     }
     return true;
 }
Пример #26
0
    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>
Пример #27
0
 public static function GetTemplateJS($arParams, $arTemplate)
 {
     global $USER;
     $ppStatus = 'false';
     $ppServerStatus = 'false';
     $updateStateInterval = 'auto';
     if (CModule::IncludeModule("pull")) {
         $ppStatus = CPullOptions::ModuleEnable() ? 'true' : 'false';
         $ppServerStatus = CPullOptions::GetNginxStatus() ? 'true' : 'false';
         $updateStateInterval = CPullOptions::GetNginxStatus() ? self::GetSessionLifeTime() : 80;
         if ($updateStateInterval > 100) {
             if ($updateStateInterval > 3600) {
                 $updateStateInterval = 3600;
             }
             if ($arTemplate['DESKTOP'] == 'true') {
                 $updateStateInterval = intval($updateStateInterval / 2);
             } else {
                 $updateStateInterval = $updateStateInterval - 60;
             }
         }
     }
     $diskStatus = CIMDisk::Enabled();
     if ($arTemplate['INIT'] == 'Y') {
         $phoneAvailable = 0;
         $phoneSipAvailable = 0;
         $phoneEnabled = self::CheckPhoneStatus();
         if ($phoneEnabled && CModule::IncludeModule('voximplant')) {
             $phoneBalance = COption::GetOptionString("voximplant", "account_balance", 0);
             if (floatval($phoneBalance) >= 0) {
                 $phoneAvailable = floatval($phoneBalance) > 0 ? 2 : 1;
             }
             $phoneSipAvailable = CVoxImplantConfig::GetModeStatus(CVoxImplantConfig::MODE_SIP);
         }
         $pathToIm = isset($arTemplate['PATH_TO_IM']) ? $arTemplate['PATH_TO_IM'] : '';
         $pathToCall = isset($arTemplate['PATH_TO_CALL']) ? $arTemplate['PATH_TO_CALL'] : '';
         $pathToFile = isset($arTemplate['PATH_TO_FILE']) ? $arTemplate['PATH_TO_FILE'] : '';
         $sJS = "\n\t\t\t\tBX.ready(function() {\n\t\t\t\t\tBXIM = new BX.IM(BX('bx-notifier-panel'), {\n\t\t\t\t\t\t'mailCount': " . $arTemplate["MAIL_COUNTER"] . ",\n\t\t\t\t\t\t'notifyCount': " . $arTemplate["NOTIFY_COUNTER"] . ",\n\t\t\t\t\t\t'messageCount': " . $arTemplate["MESSAGE_COUNTER"] . ",\n\t\t\t\t\t\t'counters': " . (empty($arTemplate['COUNTERS']) ? '{}' : CUtil::PhpToJSObject($arTemplate['COUNTERS'])) . ",\n\t\t\t\t\t\t'ppStatus': " . $ppStatus . ",\n\t\t\t\t\t\t'ppServerStatus': " . $ppServerStatus . ",\n\t\t\t\t\t\t'updateStateInterval': '" . $updateStateInterval . "',\n\t\t\t\t\t\t'xmppStatus': " . (CIMMessenger::CheckXmppStatusOnline() ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrixNetworkStatus': " . (CIMMessenger::CheckNetworkStatus() ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrix24Status': " . (IsModuleInstalled('bitrix24') ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrix24Admin': " . (CModule::IncludeModule('bitrix24') && CBitrix24::IsPortalAdmin($USER->GetId()) ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrix24net': " . (IsModuleInstalled('b24network') ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrixIntranet': " . (IsModuleInstalled('intranet') ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrixXmpp': " . (IsModuleInstalled('xmpp') ? 'true' : 'false') . ",\n\t\t\t\t\t\t'desktop': " . $arTemplate["DESKTOP"] . ",\n\t\t\t\t\t\t'desktopStatus': " . (CIMMessenger::CheckDesktopStatusOnline() ? 'true' : 'false') . ",\n\t\t\t\t\t\t'desktopVersion': " . CIMMessenger::GetDesktopVersion() . ",\n\t\t\t\t\t\t'desktopLinkOpen': " . $arTemplate["DESKTOP_LINK_OPEN"] . ",\n\t\t\t\t\t\t'language': '" . LANGUAGE_ID . "',\n\n\t\t\t\t\t\t'smile': " . CUtil::PhpToJSObject($arTemplate["SMILE"]) . ",\n\t\t\t\t\t\t'smileSet': " . CUtil::PhpToJSObject($arTemplate["SMILE_SET"]) . ",\n\t\t\t\t\t\t'settings': " . CUtil::PhpToJSObject($arTemplate['SETTINGS']) . ",\n\t\t\t\t\t\t'settingsNotifyBlocked': " . (empty($arTemplate['SETTINGS_NOTIFY_BLOCKED']) ? '{}' : CUtil::PhpToJSObject($arTemplate['SETTINGS_NOTIFY_BLOCKED'])) . ",\n\n\t\t\t\t\t\t'notify': " . (empty($arTemplate['NOTIFY']['notify']) ? '{}' : CUtil::PhpToJSObject($arTemplate['NOTIFY']['notify'])) . ",\n\t\t\t\t\t\t'unreadNotify' : " . (empty($arTemplate['NOTIFY']['unreadNotify']) ? '{}' : CUtil::PhpToJSObject($arTemplate['NOTIFY']['unreadNotify'])) . ",\n\t\t\t\t\t\t'flashNotify' : " . (empty($arTemplate['NOTIFY']['flashNotify']) ? '{}' : CUtil::PhpToJSObject($arTemplate['NOTIFY']['flashNotify'])) . ",\n\t\t\t\t\t\t'countNotify' : " . intval($arTemplate['NOTIFY']['countNotify']) . ",\n\t\t\t\t\t\t'loadNotify' : " . ($arTemplate['NOTIFY']['loadNotify'] ? 'true' : 'false') . ",\n\n\t\t\t\t\t\t'recent': " . CUtil::PhpToJSObject($arTemplate['RECENT']) . ",\n\t\t\t\t\t\t'users': " . (empty($arTemplate['CONTACT_LIST']['users']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['users'])) . ",\n\t\t\t\t\t\t'groups': " . (empty($arTemplate['CONTACT_LIST']['groups']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['groups'])) . ",\n\t\t\t\t\t\t'userInGroup': " . (empty($arTemplate['CONTACT_LIST']['userInGroup']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['userInGroup'])) . ",\n\t\t\t\t\t\t'woGroups': " . (empty($arTemplate['CONTACT_LIST']['woGroups']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['woGroups'])) . ",\n\t\t\t\t\t\t'woUserInGroup': " . (empty($arTemplate['CONTACT_LIST']['woUserInGroup']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CONTACT_LIST']['woUserInGroup'])) . ",\n\t\t\t\t\t\t'chat': " . (empty($arTemplate['CHAT']['chat']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CHAT']['chat'])) . ",\n\t\t\t\t\t\t'userInChat': " . (empty($arTemplate['CHAT']['userInChat']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CHAT']['userInChat'])) . ",\n\t\t\t\t\t\t'userChatBlockStatus': " . (empty($arTemplate['CHAT']['userChatBlockStatus']) ? '{}' : CUtil::PhpToJSObject($arTemplate['CHAT']['userChatBlockStatus'])) . ",\n\t\t\t\t\t\t'message' : " . (empty($arTemplate['MESSAGE']['message']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['message'])) . ",\n\t\t\t\t\t\t'files' : " . (empty($arTemplate['MESSAGE']['files']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['files'])) . ",\n\t\t\t\t\t\t'showMessage' : " . (empty($arTemplate['MESSAGE']['usersMessage']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['usersMessage'])) . ",\n\t\t\t\t\t\t'unreadMessage' : " . (empty($arTemplate['MESSAGE']['unreadMessage']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['unreadMessage'])) . ",\n\t\t\t\t\t\t'flashMessage' : " . (empty($arTemplate['MESSAGE']['flashMessage']) ? '{}' : CUtil::PhpToJSObject($arTemplate['MESSAGE']['flashMessage'])) . ",\n\t\t\t\t\t\t'history' : {},\n\t\t\t\t\t\t'openMessenger' : " . (isset($_GET['IM_DIALOG']) ? "'" . CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_DIALOG'])) . "'" : 'false') . ",\n\t\t\t\t\t\t'openHistory' : " . (isset($_GET['IM_HISTORY']) ? "'" . CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_HISTORY'])) . "'" : 'false') . ",\n\t\t\t\t\t\t'openNotify' : " . (isset($_GET['IM_NOTIFY']) && $_GET['IM_NOTIFY'] == 'Y' ? 'true' : 'false') . ",\n\t\t\t\t\t\t'openSettings' : " . (isset($_GET['IM_SETTINGS']) ? $_GET['IM_SETTINGS'] == 'Y' ? "'true'" : "'" . CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_SETTINGS'])) . "'" : 'false') . ",\n\t\t\t\t\t\t'currentTab' : '" . CUtil::JSEscape($arTemplate['CURRENT_TAB']) . "',\n\t\t\t\t\t\t'userId': " . $USER->GetID() . ",\n\t\t\t\t\t\t'userEmail': '" . CUtil::JSEscape($USER->GetEmail()) . "',\n\t\t\t\t\t\t'webrtc': {'turnServer' : '" . CUtil::JSEscape($arTemplate['TURN_SERVER']) . "', 'turnServerFirefox' : '" . CUtil::JSEscape($arTemplate['TURN_SERVER_FIREFOX']) . "', 'turnServerLogin' : '" . CUtil::JSEscape($arTemplate['TURN_SERVER_LOGIN']) . "', 'turnServerPassword' : '" . CUtil::JSEscape($arTemplate['TURN_SERVER_PASSWORD']) . "', 'phoneEnabled': " . ($phoneEnabled ? 'true' : 'false') . ", 'phoneAvailable': " . $phoneAvailable . ", 'phoneSipAvailable': " . ($phoneSipAvailable ? 'true' : 'false') . "},\n\t\t\t\t\t\t'disk': {'enable' : " . ($diskStatus ? 'true' : 'false') . "},\n\t\t\t\t\t\t'path' : {'profile' : '" . CUtil::JSEscape($arTemplate['PATH_TO_USER_PROFILE']) . "', 'profileTemplate' : '" . CUtil::JSEscape($arTemplate['PATH_TO_USER_PROFILE_TEMPLATE']) . "', 'mail' : '" . CUtil::JSEscape($arTemplate['PATH_TO_USER_MAIL']) . "', 'im': '" . CUtil::JSEscape($pathToIm) . "', 'call': '" . CUtil::JSEscape($pathToCall) . "', 'file': '" . CUtil::JSEscape($pathToFile) . "'}\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t";
     } else {
         $sJS = "\n\t\t\t\tBX.ready(function() {\n\t\t\t\t\tBXIM = new BX.IM(BX('bx-notifier-panel'), {\n\t\t\t\t\t\t'init': false,\n\t\t\t\t\t\t'settings': " . CUtil::PhpToJSObject($arTemplate['SETTINGS']) . ",\n\t\t\t\t\t\t'updateStateInterval': '" . $updateStateInterval . "',\n\t\t\t\t\t\t'desktop': " . $arTemplate["DESKTOP"] . ",\n\t\t\t\t\t\t'ppStatus': " . $ppStatus . ",\n\t\t\t\t\t\t'ppServerStatus': " . $ppServerStatus . ",\n\t\t\t\t\t\t'xmppStatus': " . (CIMMessenger::CheckXmppStatusOnline() ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrix24Status': " . (IsModuleInstalled('bitrix24') ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrixIntranet': " . (IsModuleInstalled('intranet') ? 'true' : 'false') . ",\n\t\t\t\t\t\t'bitrixXmpp': " . (IsModuleInstalled('xmpp') ? 'true' : 'false') . ",\n\t\t\t\t\t\t'notify' : {},\n\t\t\t\t\t\t'users' : {},\n\t\t\t\t\t\t'userId': " . $USER->GetID() . ",\n\t\t\t\t\t\t'userEmail': '" . CUtil::JSEscape($USER->GetEmail()) . "',\n\n\t\t\t\t\t\t'openMessenger' : " . (isset($_GET['IM_DIALOG']) ? "'" . CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_DIALOG'])) . "'" : 'false') . ",\n\t\t\t\t\t\t'openHistory' : " . (isset($_GET['IM_HISTORY']) ? "'" . CUtil::JSEscape(htmlspecialcharsbx($_GET['IM_HISTORY'])) . "'" : 'false') . ",\n\t\t\t\t\t\t'openSettings' : " . (isset($_GET['IM_SETTINGS']) && $_GET['IM_SETTINGS'] == 'Y' ? "'true'" : 'false') . ",\n\n\t\t\t\t\t\t'disk': {'enable' : '" . ($diskStatus ? 'true' : 'false') . "'},\n\t\t\t\t\t\t'path' : {'profile' : '" . $arTemplate['PATH_TO_USER_PROFILE'] . "', 'profileTemplate' : '" . $arTemplate['PATH_TO_USER_PROFILE_TEMPLATE'] . "', 'mail' : '" . $arTemplate['PATH_TO_USER_MAIL'] . "'}\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t";
     }
     return $sJS;
 }