Пример #1
0
 /**
  * Checks online status of IM.
  * @return bool
  */
 public static function isDesktopImOnline()
 {
     if (!Loader::includeModule('im')) {
         return false;
     }
     return \CIMMessenger::checkDesktopStatusOnline();
 }
Пример #2
0
 public static function SetRecent($entityId, $messageId, $isChat = false, $userId = false)
 {
     $entityId = intval($entityId);
     $messageId = intval($messageId);
     if ($entityId <= 0 || $messageId <= 0) {
         return false;
     }
     $userId = intval($userId);
     if ($userId <= 0) {
         $userId = $GLOBALS['USER']->GetID();
     }
     if (!$isChat && $userId == $entityId) {
         return false;
     }
     global $DB;
     $strSQL = "\n\t\t\tINSERT INTO b_im_recent (USER_ID, ITEM_TYPE, ITEM_ID, ITEM_MID)\n\t\t\tVALUES (" . $userId . ", '" . ($isChat ? IM_MESSAGE_GROUP : IM_MESSAGE_PRIVATE) . "', " . $entityId . ", " . $messageId . ")\n\t\t\tON DUPLICATE KEY UPDATE ITEM_MID = " . $messageId;
     $DB->Query($strSQL, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     $obCache = new CPHPCache();
     $obCache->CleanDir('/bx/im/rec' . CIMMessenger::GetCachePath($userId));
     if ($isChat) {
         CIMMessenger::SpeedFileDelete($userId, IM_SPEED_GROUP);
     } else {
         CIMMessenger::SpeedFileDelete($userId, IM_SPEED_MESSAGE);
     }
     return true;
 }
Пример #3
0
 function Add($arFields)
 {
     global $DB;
     if (IsModuleInstalled("im") && CModule::IncludeModule("im")) {
         if ($arFields["MESSAGE_TYPE"] == SONET_MESSAGE_SYSTEM) {
             if (!(isset($arFields["EMAIL_TEMPLATE"]) && strlen($arFields["EMAIL_TEMPLATE"]) > 0)) {
                 $arFields["EMAIL_TEMPLATE"] = "SONET_NEW_MESSAGE";
             }
             $ID = CIMNotify::Add($arFields);
             return $ID;
         } else {
             CIMMessenger::SpeedFileDelete($arFields['TO_USER_ID'], IM_SPEED_MESSAGE);
         }
     }
     if (defined("INTASK_SKIP_SOCNET_MESSAGES1") && INTASK_SKIP_SOCNET_MESSAGES1) {
         $arFields["=DATE_VIEW"] = $DB->CurrentTimeFunction();
     }
     $arFields1 = array();
     foreach ($arFields as $key => $value) {
         if (substr($key, 0, 1) == "=") {
             $arFields1[substr($key, 1)] = $value;
             unset($arFields[$key]);
         }
     }
     if (!CSocNetMessages::CheckFields("ADD", $arFields)) {
         return false;
     }
     $db_events = GetModuleEvents("socialnetwork", "OnBeforeSocNetMessagesAdd");
     while ($arEvent = $db_events->Fetch()) {
         if (ExecuteModuleEventEx($arEvent, array(&$arFields)) === false) {
             return false;
         }
     }
     $arInsert = $DB->PrepareInsert("b_sonet_messages", $arFields);
     foreach ($arFields1 as $key => $value) {
         if (strlen($arInsert[0]) > 0) {
             $arInsert[0] .= ", ";
         }
         $arInsert[0] .= $key;
         if (strlen($arInsert[1]) > 0) {
             $arInsert[1] .= ", ";
         }
         $arInsert[1] .= $value;
     }
     $ID = false;
     if (strlen($arInsert[0]) > 0) {
         $strSql = "INSERT INTO b_sonet_messages(" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")";
         $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $ID = IntVal($DB->LastID());
         $events = GetModuleEvents("socialnetwork", "OnSocNetMessagesAdd");
         while ($arEvent = $events->Fetch()) {
             ExecuteModuleEventEx($arEvent, array($ID, $arFields));
         }
         //CSocNetMessages::SendEvent($ID, "SONET_NEW_MESSAGE");
         CSocNetMessages::__SpeedFileCreate($arFields["TO_USER_ID"]);
     }
     return $ID;
 }
Пример #4
0
 public static function OnFileDelete($params)
 {
     $result = IM\ChatTable::getList(array('select' => array('ID', 'AUTHOR_ID'), 'filter' => array('=AVATAR' => $params['ID'])));
     while ($row = $result->fetch()) {
         IM\ChatTable::update($row['ID'], array('AVATAR' => ''));
         $obCache = new CPHPCache();
         $arRel = CIMChat::GetRelationById($row['ID']);
         foreach ($arRel as $rel) {
             $obCache->CleanDir('/bx/imc/recent' . CIMMessenger::GetCachePath($rel['USER_ID']));
         }
     }
 }
Пример #5
0
 /**
  * Method will be invoked after new database record inserted.
  *
  * @param array $newRecord All fields of inserted record.
  *
  * @return void
  */
 public function afterInsertTrigger(array $newRecord)
 {
     $id = intval($newRecord['MESSAGE_ID']);
     if (!\Bitrix\Main\Loader::includeModule('pull')) {
         return;
     }
     $message = \CIMMessenger::GetById($id, array('WITH_FILES' => 'Y'));
     if (!$message) {
         return;
     }
     if ($newRecord['PARAM_NAME'] === 'LIKE' && $newRecord["PARAM_VALUE"]) {
         $like = $message['PARAMS']['LIKE'];
         $result = \Bitrix\IM\ChatTable::getList(array('filter' => array('=ID' => $message['CHAT_ID'])));
         $chat = $result->fetch();
         $relations = \CIMMessenger::GetRelationById($id);
         if (!isset($relations[$newRecord["PARAM_VALUE"]])) {
             return;
         }
         if ($message['AUTHOR_ID'] > 0 && $message['AUTHOR_ID'] != $newRecord["PARAM_VALUE"]) {
             $CCTP = new \CTextParser();
             $CCTP->MaxStringLen = 200;
             $CCTP->allow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N");
             $message['MESSAGE'] = str_replace('<br />', ' ', $CCTP->convertText($message['MESSAGE']));
             $message['MESSAGE'] = preg_replace("/\\[s\\].*?\\[\\/s\\]/i", "", $message['MESSAGE']);
             $message['MESSAGE'] = preg_replace("/\\[[bui]\\](.*?)\\[\\/[bui]\\]/i", "\$1", $message['MESSAGE']);
             $message['MESSAGE'] = preg_replace("/\\[USER=([0-9]{1,})\\](.*?)\\[\\/USER\\]/i", "\$2", $message['MESSAGE']);
             $message['MESSAGE'] = preg_replace("/------------------------------------------------------(.*)------------------------------------------------------/mi", " [" . GetMessage('IM_QUOTE') . "] ", str_replace(array("#BR#"), array(" "), $message['MESSAGE']));
             if (count($message['FILES']) > 0 && strlen($message['MESSAGE']) < 200) {
                 foreach ($message['FILES'] as $file) {
                     $file = " [" . GetMessage('IM_MESSAGE_FILE') . ": " . $file['name'] . "]";
                     if (strlen($message['MESSAGE'] . $file) > 200) {
                         break;
                     }
                     $message['MESSAGE'] .= $file;
                 }
                 $message['MESSAGE'] = trim($message['MESSAGE']);
             }
             $isChat = $chat && strlen($chat['TITLE']) > 0;
             $dot = strlen($message['MESSAGE']) >= 200 ? '...' : '';
             $message['MESSAGE'] = substr($message['MESSAGE'], 0, 199) . $dot;
             $message['MESSAGE'] = strlen($message['MESSAGE']) > 0 ? $message['MESSAGE'] : '-';
             $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => $message['AUTHOR_ID'], "FROM_USER_ID" => $newRecord["PARAM_VALUE"], "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "main", "NOTIFY_EVENT" => "rating_vote", "NOTIFY_TAG" => "RATING|IM|" . ($isChat ? 'G' : 'P') . "|" . ($isChat ? $chat['ID'] : $newRecord["PARAM_VALUE"]) . "|" . $id, "NOTIFY_MESSAGE" => GetMessage($isChat ? 'IM_MESSAGE_LIKE' : 'IM_MESSAGE_LIKE_PRIVATE', array('#MESSAGE#' => $message['MESSAGE'], '#TITLE#' => $chat['TITLE'])));
             \CIMNotify::Add($arMessageFields);
         }
         $arPullMessage = array('id' => $id, 'chatId' => $relations[$newRecord["PARAM_VALUE"]]['CHAT_ID'], 'senderId' => $newRecord["PARAM_VALUE"], 'users' => $like);
         foreach ($relations as $rel) {
             \CPullStack::AddByUser($rel['USER_ID'], array('module_id' => 'im', 'command' => 'messageLike', 'params' => $arPullMessage));
         }
     }
 }
Пример #6
0
 public static function SetRecent($arParams)
 {
     $itemId = intval($arParams['ENTITY_ID']);
     $messageId = intval($arParams['MESSAGE_ID']);
     if ($itemId <= 0) {
         return false;
     }
     $userId = intval($arParams['USER_ID']);
     if ($userId <= 0) {
         $userId = (int) $GLOBALS['USER']->GetID();
     }
     $chatType = IM_MESSAGE_PRIVATE;
     if (isset($arParams['CHAT_TYPE']) && in_array($arParams['CHAT_TYPE'], array(IM_MESSAGE_OPEN, IM_MESSAGE_CHAT))) {
         $chatType = $arParams['CHAT_TYPE'];
     } else {
         if (isset($arParams['CHAT_ID'])) {
             $orm = IM\ChatTable::getById($arParams['CHAT_ID']);
             if ($chatData = $orm->fetch()) {
                 $chatType = $chatData['TYPE'];
             }
         }
     }
     $isChat = in_array($chatType, array(IM_MESSAGE_OPEN, IM_MESSAGE_CHAT));
     if (!$isChat && $userId == $itemId) {
         return false;
     }
     global $DB;
     $strSQL = "\n\t\t\tINSERT INTO b_im_recent (USER_ID, ITEM_TYPE, ITEM_ID, ITEM_MID)\n\t\t\tVALUES (" . $userId . ", '" . $chatType . "', " . $itemId . ", " . $messageId . ")\n\t\t\tON DUPLICATE KEY UPDATE ITEM_MID = " . $messageId . "\n\t\t";
     $DB->Query($strSQL, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     $obCache = new CPHPCache();
     $obCache->CleanDir('/bx/imc/recent' . CIMMessenger::GetCachePath($userId));
     if ($isChat) {
         CIMMessenger::SpeedFileDelete($userId, IM_SPEED_GROUP);
     } else {
         CIMMessenger::SpeedFileDelete($userId, IM_SPEED_MESSAGE);
     }
     return true;
 }
Пример #7
0
 public function GetNotifyCounter($arNotify = array())
 {
     $count = 0;
     if (isset($arNotify['unreadNotify']) && !empty($arNotify['unreadNotify']) && isset($arNotify['notify'])) {
         $arGroupNotify = array();
         foreach ($arNotify['unreadNotify'] as $key => $value) {
             if (!isset($arNotify['notify'][$key])) {
                 continue;
             }
             $notify = $arNotify['notify'][$key];
             if ($notify['type'] == 2 && $notify['tag'] != '') {
                 if (!isset($arGroupNotify[$notify['tag']])) {
                     $arGroupNotify[$notify['tag']] = true;
                     $count++;
                 }
             } else {
                 $count++;
             }
         }
     } else {
         $count = CIMMessenger::SpeedFileGet($this->user_id, IM_SPEED_NOTIFY);
     }
     return intval($count);
 }
Пример #8
0
 public static function GetSendMode($userId)
 {
     $result = self::SEND_IMMEDIATELY;
     $isMobile = false;
     if (CModule::IncludeModule('mobile')) {
         $isMobile = Bitrix\Mobile\User::checkOnline($userId);
     }
     $isDesktop = false;
     $isDesktopIdle = false;
     if (CModule::IncludeModule('im')) {
         $arOnline = CIMStatus::GetList(array('ID' => $userId, 'SKIP_CHECK' => 'Y'));
         $isOnline = isset($arOnline['users'][$userId]) && $arOnline['users'][$userId]['status'] != 'offline';
         $isDesktop = CIMMessenger::CheckDesktopStatusOnline($userId);
         if ($isDesktop && intval($arOnline['users'][$userId]['idle']) > 0) {
             $isDesktopIdle = true;
         }
     } else {
         $isOnline = CUser::IsOnLine($userId, 120);
     }
     if ($isMobile) {
         $result = self::SEND_IMMEDIATELY;
     } else {
         if ($isOnline) {
             $result = self::SEND_DEFERRED;
             if ($isDesktop) {
                 $result = self::SEND_SKIP;
                 if ($isDesktopIdle) {
                     $result = self::SEND_IMMEDIATELY;
                 }
             }
         }
     }
     return $result;
 }
Пример #9
0
 public static function UploadFile($hash, &$file, &$package, &$upload, &$error)
 {
     $post = \Bitrix\Main\Context::getCurrent()->getRequest()->getPostList()->toArray();
     $post['PARAMS'] = CUtil::JsObjectToPhp($post['REG_PARAMS']);
     $chatId = intval($post['REG_CHAT_ID']);
     if (intval($chatId) <= 0) {
         $error = GetMessage('IM_DISK_ERR_UPLOAD');
         return false;
     }
     $chatRelation = CIMChat::GetRelationById($chatId);
     if (!$chatRelation[self::GetUserId()]) {
         $error = GetMessage('IM_DISK_ERR_UPLOAD');
         return false;
     }
     $folderModel = self::GetFolderModel($chatId);
     if (!$folderModel) {
         $error = GetMessage('IM_DISK_ERR_UPLOAD');
         return false;
     }
     $fileId = $post['PARAMS'][$file["id"]];
     if (!$fileId) {
         $error = GetMessage('IM_DISK_ERR_UPLOAD');
         return false;
     }
     if (!$file["files"]["default"]) {
         $error = GetMessage('IM_DISK_ERR_UPLOAD');
         return false;
     }
     /** @var $fileModel \Bitrix\Disk\File */
     $fileModel = \Bitrix\Disk\File::getById($fileId);
     if (!$fileModel || $fileModel->getParentId() != $folderModel->getId()) {
         $error = GetMessage('IM_DISK_ERR_UPLOAD');
         return false;
     }
     $resultUpdate = $fileModel->uploadVersion($file["files"]["default"], self::GetUserId());
     if (!$resultUpdate) {
         $errors = $fileModel->getErrors();
         $message = '';
         foreach ($errors as $errorCode) {
             $message = $message . ' ' . $errorCode->getMessage();
         }
         $message = trim($message);
         if (strlen($message) > 0) {
             $error = $message;
         }
         return false;
     }
     $messageId = intval($post['REG_MESSAGE_ID']);
     $file['fileId'] = $fileId;
     $file['fileTmpId'] = $file["id"];
     $file['fileMessageId'] = $messageId;
     $file['fileChatId'] = $chatId;
     $file['fileParams'] = self::GetFileParams($chatId, $fileModel);
     foreach ($chatRelation as $relation) {
         if ($relation['MESSAGE_TYPE'] != IM_MESSAGE_PRIVATE) {
             break;
         }
         if (self::GetUserId() == $relation['USER_ID']) {
             continue;
         }
         \Bitrix\Disk\Driver::getInstance()->getRecentlyUsedManager()->push($relation['USER_ID'], $fileId);
     }
     if (CModule::IncludeModule('pull')) {
         $pullMessage = array('module_id' => 'im', 'command' => 'fileUpload', 'params' => array('fileChatId' => $file['fileChatId'], 'fileId' => $file['fileId'], 'fileTmpId' => $file["id"], 'fileMessageId' => $file["fileMessageId"], 'fileParams' => $file['fileParams']));
         CPullStack::AddByUsers(array_keys($chatRelation), $pullMessage);
         $orm = \Bitrix\Im\ChatTable::getById($chatId);
         $chat = $orm->fetch();
         if ($chat['TYPE'] == IM_MESSAGE_OPEN) {
             CPullWatch::AddToStack('IM_PUBLIC_' . $chat['ID'], $pullMessage);
         }
     }
     $arFiles[$fileId] = $file['fileParams'];
     $file['fileMessageOut'] = CIMMessenger::GetFormatFilesMessageOut($arFiles);
     CIMMessage::UpdateMessageOut($messageId, $file['fileMessageOut']);
     foreach (GetModuleEvents("im", "OnAfterFileUpload", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array(array('CHAT_ID' => $file['fileChatId'], 'FILE_ID' => $file['fileId'], 'MESSAGE_ID' => $file['fileMessageId'], 'MESSAGE_OUT' => $file['fileMessageOut'], 'FILE' => $file['fileParams'])));
     }
     return true;
 }
Пример #10
0
 public static function UploadFile($hash, &$file, &$package, &$upload, &$error)
 {
     $post = \Bitrix\Main\Context::getCurrent()->getRequest()->getPostList()->toArray();
     $post['PARAMS'] = CUtil::JsObjectToPhp($post['REG_PARAMS']);
     $chatId = intval($post['REG_CHAT_ID']);
     if (intval($chatId) <= 0) {
         return false;
     }
     $chatRelation = CIMChat::GetRelationById($chatId);
     if (!$chatRelation[self::GetUserId()]) {
         $error = GetMessage('IM_DISK_ERR_UPLOAD');
         return false;
     }
     $folderModel = self::GetFolderModel($chatId);
     if (!$folderModel) {
         $error = GetMessage('IM_DISK_ERR_UPLOAD');
         return false;
     }
     $fileId = $post['PARAMS'][$file["id"]];
     if (!$fileId) {
         return false;
     }
     $fileModel = \Bitrix\Disk\File::getById($fileId);
     if (!$fileModel || $fileModel->getParentId() != $folderModel->getId()) {
         $error = GetMessage('IM_DISK_ERR_UPLOAD');
         return false;
     }
     $resultUpdate = $fileModel->uploadVersion($file["files"]["default"], self::GetUserId());
     if (!$resultUpdate) {
         return false;
     }
     $file['fileId'] = $fileId;
     $file['fileTmpId'] = $file["id"];
     $file['fileMessageId'] = $messageId;
     $file['fileChatId'] = $chatId;
     $file['fileParams'] = self::GetFileParams($chatId, $fileModel);
     $messageId = intval($post['REG_MESSAGE_ID']);
     if (CModule::IncludeModule('pull')) {
         foreach ($chatRelation as $relation) {
             CPullStack::AddByUser($relation['USER_ID'], array('module_id' => 'im', 'command' => 'fileUpload', 'params' => array('fileChatId' => $file['fileChatId'], 'fileId' => $file['fileId'], 'fileTmpId' => $file["id"], 'fileMessageId' => $file["fileMessageId"], 'fileParams' => $file['fileParams'])));
         }
     }
     $arFiles[$fileId] = $file['fileParams'];
     $file['fileMessageOut'] = CIMMessenger::GetFormatFilesMessageOut($arFiles);
     CIMMessage::UpdateMessageOut($messageId, $file['fileMessageOut']);
     foreach (GetModuleEvents("im", "OnAfterFileUpload", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array(array('CHAT_ID' => $file['fileChatId'], 'FILE_ID' => $file['fileId'], 'MESSAGE_ID' => $file['fileMessageId'], 'MESSAGE_OUT' => $file['fileMessageOut'], 'FILE' => $file['fileParams'])));
     }
     return true;
 }
Пример #11
0
 public static function isDesktopImOnline()
 {
     if (!CModule::IncludeModule('im')) {
         return false;
     }
     return CIMMessenger::CheckDesktopStatusOnline();
 }
Пример #12
0
 public static function AddMessage($arFields)
 {
     $arFields['MESSAGE_TYPE'] = isset($arParams['MESSAGE_TYPE']) && in_array($arParams['MESSAGE_TYPE'], array(IM_MESSAGE_OPEN, IM_MESSAGE_CHAT)) ? $arParams['MESSAGE_TYPE'] : IM_MESSAGE_CHAT;
     return CIMMessenger::Add($arFields);
 }
Пример #13
0
	public static function InitCounters($userId, $check = true)
	{
		return false;
		
		if (intval($userId) <= 0)
			return false;

		$send = false;
		if (!$check || !CUserOptions::GetOption('im', 'initCounterNotify2', false, $userId))
		{
			CIMNotify::SetUnreadCounter($userId);
			CUserOptions::SetOption('im', 'initCounterNotify2', true, $userId);
			$send = true;
		}
		if (!$check || !CUserOptions::GetOption('im', 'initCounterChat2', false, $userId))
		{
			CIMChat::SetUnreadCounter($userId);
			CUserOptions::SetOption('im', 'initCounterChat2', true, $userId);
			$send = true;
		}
		if (!$check || !CUserOptions::GetOption('im', 'initCounterMessage2', false, $userId))
		{
			CIMMessage::SetUnreadCounter($userId);
			CUserOptions::SetOption('im', 'initCounterMessage2', true, $userId);
			$send = true;
		}
		if ($send)
			CIMMessenger::SendBadges($userId);

		return true;
	}
Пример #14
0
	public function GetNotifyCounter($arNotify = Array())
	{
		$count = 0;
		if (isset($arNotify['unreadNotify']) && !empty($arNotify['unreadNotify']) && isset($arNotify['notify']))
		{
			foreach ($arNotify['unreadNotify'] as $key => $value)
			{
				if (!isset($arNotify['notify'][$key]))
					continue;

				$count++;
			}
		}
		else
		{
			$count = CIMMessenger::SpeedFileGet($this->user_id, IM_SPEED_NOTIFY);
		}
		return intval($count);
	}
Пример #15
0
 public static function AddMessage($arFields)
 {
     $arFields['MESSAGE_TYPE'] = IM_MESSAGE_GROUP;
     return CIMMessenger::Add($arFields);
 }
Пример #16
0
 /**
  * Method will be invoked after an database record updated.
  *
  * @param array $oldRecord All fields before update.
  * @param array $newRecord All fields after update.
  *
  * @return void
  */
 public function afterUpdateTrigger(array $oldRecord, array $newRecord)
 {
     if (!\Bitrix\Main\Loader::includeModule('pull')) {
         return;
     }
     $arFields = \CIMMessenger::GetById($newRecord['ID'], array('WITH_FILES' => 'Y'));
     if (!$arFields) {
         return;
     }
     $arFields['DATE_MODIFY'] = time() + \CTimeZone::GetOffset();
     $CCTP = new \CTextParser();
     $CCTP->MaxStringLen = 200;
     $CCTP->allow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "Y", "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N");
     $pullMessage = $CCTP->convertText(htmlspecialcharsbx($arFields['MESSAGE']));
     $relations = \CIMChat::GetRelationById($arFields['CHAT_ID']);
     $arPullMessage = array('id' => $arFields['ID'], 'type' => $arFields['MESSAGE_TYPE'] == IM_MESSAGE_PRIVATE ? 'private' : 'chat', 'text' => $pullMessage, 'date' => $arFields['DATE_MODIFY']);
     if ($arFields['MESSAGE_TYPE'] == IM_MESSAGE_PRIVATE) {
         $arFields['FROM_USER_ID'] = $arFields['AUTHOR_ID'];
         foreach ($relations as $rel) {
             if ($rel['USER_ID'] != $arFields['AUTHOR_ID']) {
                 $arFields['TO_USER_ID'] = $rel['USER_ID'];
             }
         }
         $arPullMessage['fromUserId'] = $arFields['FROM_USER_ID'];
         $arPullMessage['toUserId'] = $arFields['TO_USER_ID'];
     } else {
         $arPullMessage['chatId'] = $arFields['CHAT_ID'];
         $arPullMessage['senderId'] = $arFields['AUTHOR_ID'];
     }
     \CPullStack::AddByUsers(array_keys($relations), $p = array('module_id' => 'im', 'command' => $arFields['PARAMS']['IS_DELETED'] === 'Y' ? 'messageDelete' : 'messageUpdate', 'params' => $arPullMessage));
     foreach ($relations as $rel) {
         $obCache = new \CPHPCache();
         $obCache->CleanDir('/bx/imc/recent' . \CIMMessenger::GetCachePath($rel['USER_ID']));
     }
     if ($newRecord['MESSAGE_TYPE'] == IM_MESSAGE_OPEN) {
         \CPullWatch::AddToStack('IM_PUBLIC_' . $arFields['CHAT_ID'], array('module_id' => 'im', 'command' => $arFields['PARAMS']['IS_DELETED'] === 'Y' ? 'messageDelete' : 'messageUpdate', 'params' => $arPullMessage));
     }
     foreach (\GetModuleEvents("im", "OnAfterMessagesUpdate", true) as $arEvent) {
         \ExecuteModuleEventEx($arEvent, array(intval($newRecord['ID']), $arFields));
     }
 }
Пример #17
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;
 }
Пример #18
0
	}
	if (!isset($arResult['CONTACT_LIST']['users'][$USER->GetID()]))
	{
		$arUsers = CIMContactList::GetUserData(array(
			'ID' => $USER->GetID(),
			'DEPARTMENT' => 'N',
			'USE_CACHE' => 'Y',
			'SHOW_ONLINE' => 'N'
		));
		$arResult['CONTACT_LIST']['users'][$USER->GetID()] = $arUsers['users'][$USER->GetID()];
	}

	$arResult['OPEN_TAB'] = CIMMessenger::GetOpenTabs();
	$arResult['CURRENT_TAB'] = CIMMessenger::GetCurrentTab();

	$arSettings = CIMMessenger::GetSettings();
	$arResult['STATUS'] = isset($arSettings['status'])? $arSettings['status']: 'online';
	$arResult['VIEW_OFFLINE'] = isset($arSettings['viewOffline']) && $arSettings['viewOffline'] == 'N'? 'false': 'true';
	$arResult['VIEW_GROUP'] = isset($arSettings['viewGroup']) && $arSettings['viewGroup'] == 'N'? 'false': 'true';
	$arResult['ENABLE_SOUND'] = isset($arSettings['enableSound']) && $arSettings['enableSound'] == 'N'? 'false': 'true';
	$arResult['SEND_BY_ENTER'] = isset($arSettings['sendByEnter']) && $arSettings['sendByEnter'] == 'Y'? 'true': 'false';
	$arResult['PANEL_POSTION_HORIZONTAL'] = isset($arSettings['panelPositionHorizontal']) && in_array($arSettings['panelPositionHorizontal'], Array('left', 'center', 'right'))? $arSettings['panelPositionHorizontal']: 'right';
	$arResult['PANEL_POSTION_VERTICAL'] = isset($arSettings['panelPositionVertical']) && in_array($arSettings['panelPositionVertical'], Array('top', 'bottom'))? $arSettings['panelPositionVertical']: 'bottom';
	$arResult['TRY_NATIVE_NOTIFY'] = isset($arSettings['tryNativeNotify']) && $arSettings['tryNativeNotify'] == 'N'? 'false': 'true';

}
else
{
	$arResult['STATUS'] = 'online';
	$arResult['ENABLE_SOUND'] = 'false';
}
Пример #19
0
                }
            }
        }
    }
    if (!isset($arResult['CONTACT_LIST']['users'][$USER->GetID()])) {
        $arUsers = CIMContactList::GetUserData(array('ID' => $USER->GetID(), 'DEPARTMENT' => 'N', 'USE_CACHE' => 'Y', 'SHOW_ONLINE' => 'N'));
        $arResult['CONTACT_LIST']['users'][$USER->GetID()] = $arUsers['users'][$USER->GetID()];
    }
    $arResult['CURRENT_TAB'] = CIMMessenger::GetCurrentTab();
} else {
    $arResult['SETTINGS_NOTIFY_BLOCKED'] = CIMSettings::GetSimpleNotifyBlocked();
}
$arResult['DESKTOP'] = $arParams['DESKTOP'] == 'Y' ? 'true' : 'false';
$arResult["INIT"] = $arParams['INIT'];
$arResult['DESKTOP_LINK_OPEN'] = $arParams['DESKTOP_LINK_OPEN'] == 'Y' ? 'true' : 'false';
$arResult['PATH_TO_USER_PROFILE_TEMPLATE'] = CIMContactList::GetUserPath();
$arResult['PATH_TO_USER_PROFILE'] = CIMContactList::GetUserPath($USER->GetId());
$arResult['TURN_SERVER'] = COption::GetOptionString('im', 'turn_server');
$arResult['TURN_SERVER_FIREFOX'] = COption::GetOptionString('im', 'turn_server_firefox');
$arResult['TURN_SERVER_LOGIN'] = COption::GetOptionString('im', 'turn_server_login');
$arResult['TURN_SERVER_PASSWORD'] = COption::GetOptionString('im', 'turn_server_password');
CIMMessenger::InitCounters($USER->GetID());
$jsInit = array('im');
if (defined('LANGUAGE_ID') && LANGUAGE_ID == 'ru') {
    $jsInit[] = 'translit';
}
CJSCore::Init($jsInit);
if (!(isset($arParams['TEMPLATE_HIDE']) && $arParams['TEMPLATE_HIDE'] == 'Y')) {
    $this->IncludeComponentTemplate();
}
return $arResult;
Пример #20
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;
	}
Пример #21
0
                                         if ($_POST['COMMAND'] == 'signaling') {
                                             CIMMessenger::CallCommand($_POST['RECIPIENT_ID'], $_POST['COMMAND'], array('peer' => $_POST['PEER']));
                                         } else {
                                             CIMMessenger::CallCommand($_POST['RECIPIENT_ID'], $_POST['COMMAND']);
                                         }
                                     }
                                     echo CUtil::PhpToJsObject(array('ERROR' => $errorMessage));
                                 } else {
                                     if ($_POST['IM_START_WRITING'] == 'Y') {
                                         $errorMessage = "";
                                         CIMMessenger::StartWriting($_POST['RECIPIENT_ID']);
                                         echo CUtil::PhpToJsObject(array('ERROR' => $errorMessage));
                                     } else {
                                         if ($_POST['IM_DESKTOP_LOGOUT'] == 'Y') {
                                             $errorMessage = "";
                                             CIMMessenger::RemoveDesktopStatusOnline();
                                             CIMContactList::SetOffline();
                                             echo CUtil::PhpToJsObject(array('ERROR' => $errorMessage));
                                         } else {
                                             echo CUtil::PhpToJsObject(array('ERROR' => 'UNKNOWN_ERROR'));
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Пример #22
0
 public static function GetDeviceInfo($userId, $appId = 'Bitrix24')
 {
     $result = array();
     if (is_array($userId)) {
         foreach ($userId as $key => $id) {
             $id = intval($id);
             if ($id > 0) {
                 $result[$id] = array('mode' => self::RECORD_NOT_FOUND, 'device' => array());
             }
         }
     } else {
         if (intval($userId) > 0) {
             $result[intval($userId)] = array('mode' => self::RECORD_NOT_FOUND, 'device' => array());
         }
     }
     if (empty($result)) {
         return false;
     }
     $imInclude = false;
     if (CModule::IncludeModule('im')) {
         $imInclude = true;
     }
     $query = new \Bitrix\Main\Entity\Query(\Bitrix\Main\UserTable::getEntity());
     $sago = Bitrix\Main\Application::getConnection()->getSqlHelper()->addSecondsToDateTime('-180');
     $query->registerRuntimeField('', new \Bitrix\Main\Entity\ExpressionField('IS_ONLINE_CUSTOM', 'CASE WHEN LAST_ACTIVITY_DATE > ' . $sago . ' THEN \'Y\' ELSE \'N\' END'));
     $query->addSelect('ID')->addSelect('EMAIL')->addSelect('IS_ONLINE_CUSTOM');
     if ($imInclude) {
         $query->registerRuntimeField('', new \Bitrix\Main\Entity\ReferenceField('im', 'Bitrix\\Im\\StatusTable', array('=this.ID' => 'ref.USER_ID')));
         $query->addSelect('im.IDLE', 'IDLE')->addSelect('im.MOBILE_LAST_DATE', 'MOBILE_LAST_DATE');
     }
     $query->registerRuntimeField('', new \Bitrix\Main\Entity\ReferenceField('push', 'Bitrix\\Pull\\PushTable', array('=this.ID' => 'ref.USER_ID')));
     $query->registerRuntimeField('', new \Bitrix\Main\Entity\ExpressionField('HAS_MOBILE', 'CASE WHEN main_user_push.USER_ID > 0 THEN \'Y\' ELSE \'N\' END'));
     $query->addSelect('HAS_MOBILE')->addSelect('push.APP_ID', 'APP_ID')->addSelect('push.UNIQUE_HASH', 'UNIQUE_HASH')->addSelect('push.DEVICE_TYPE', 'DEVICE_TYPE')->addSelect('push.DEVICE_TOKEN', 'DEVICE_TOKEN');
     $query->addFilter('=ID', array_keys($result));
     $queryResult = $query->exec();
     while ($user = $queryResult->fetch()) {
         $uniqueHashes[] = CPullPush::getUniqueHash($user["ID"], $appId);
         $uniqueHashes[] = CPullPush::getUniqueHash($user["ID"], $appId . "_bxdev");
         if (in_array($user['UNIQUE_HASH'], $uniqueHashes)) {
             $result[$user['ID']]['device'][] = array('APP_ID' => $user['APP_ID'], 'USER_ID' => $user['ID'], 'DEVICE_TYPE' => $user['DEVICE_TYPE'], 'DEVICE_TOKEN' => $user['DEVICE_TOKEN']);
             //$result[$user['ID']]['email'] = $user['EMAIL'];
         } else {
             continue;
         }
         if ($result[$user['ID']]['mode'] != self::RECORD_NOT_FOUND) {
             continue;
         }
         $isMobile = false;
         $isOnline = false;
         $isDesktop = false;
         $isDesktopIdle = false;
         if ($user['HAS_MOBILE'] == 'N') {
             $result[$user['ID']]['mode'] = self::RECORD_NOT_FOUND;
             $result[$user['ID']]['device'] = array();
             continue;
         }
         if ($user['IS_ONLINE_CUSTOM'] == 'Y') {
             $isOnline = true;
         }
         if ($imInclude) {
             $mobileLastDate = 0;
             if (is_object($user['MOBILE_LAST_DATE'])) {
                 $mobileLastDate = $user['MOBILE_LAST_DATE']->getTimestamp();
             }
             if ($mobileLastDate > 0 && $mobileLastDate + 180 > time()) {
                 $isMobile = true;
             }
             $isDesktop = CIMMessenger::CheckDesktopStatusOnline($user['ID']);
             if ($isDesktop && $isOnline && is_object($user['IDLE'])) {
                 if ($user['IDLE']->getTimestamp() > 0) {
                     $isDesktopIdle = true;
                 }
             }
         }
         $status = self::SEND_IMMEDIATELY;
         if ($isMobile) {
             $status = self::SEND_IMMEDIATELY;
         } else {
             if ($isOnline) {
                 $status = self::SEND_DEFERRED;
                 if ($isDesktop) {
                     $status = self::SEND_SKIP;
                     if ($isDesktopIdle) {
                         $status = self::SEND_IMMEDIATELY;
                     } else {
                         $result[$user['ID']]['device'] = array();
                     }
                 } else {
                     $result[$user['ID']]['device'] = array();
                 }
             }
         }
         $result[$user['ID']]['mode'] = $status;
     }
     return $result;
 }
Пример #23
0
 function HideAllChatMessage($chatId)
 {
     global $DB;
     $chatId = intval($chatId);
     $limitById = '';
     $ar = \CIMChat::GetRelationById($chatId, $this->user_id);
     if ($ar && $ar['START_ID'] > 0) {
         $limitById = 'AND M.ID >= ' . intval($ar['START_ID']);
     }
     $strSql = "\n\t\t\tSELECT\n\t\t\t\tMAX(M.ID)+1 MAX_ID,\n\t\t\t\tR1.ID R1_ID\n\t\t\tFROM b_im_relation R1\n\t\t\tINNER JOIN b_im_message M ON M.CHAT_ID = R1.CHAT_ID\n\t\t\tWHERE\n\t\t\t\tR1.USER_ID = " . $this->user_id . "\n\t\t\tAND R1.MESSAGE_TYPE <> '" . IM_MESSAGE_PRIVATE . "'\n\t\t\tAND R1.CHAT_ID = " . $chatId . "\n\t\t\t\t" . $limitById . "\n\t\t\tGROUP BY M.CHAT_ID, R1.ID\n\t\t";
     $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     if ($arRes = $dbRes->Fetch()) {
         $strSql = "UPDATE b_im_relation SET START_ID = " . intval($arRes['MAX_ID']) . ", LAST_ID = " . (intval($arRes['MAX_ID']) - 1) . " WHERE ID = " . intval($arRes['R1_ID']);
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $obCache = new CPHPCache();
         $obCache->CleanDir('/bx/imc/recent' . CIMMessenger::GetCachePath($this->user_id));
     }
     return true;
 }
Пример #24
0
 public static function AddGeneralMessage($arFields)
 {
     $arFields['MESSAGE_TYPE'] = IM_MESSAGE_OPEN;
     $arFields['TO_CHAT_ID'] = self::GetGeneralChatId();
     return CIMMessenger::Add($arFields);
 }
Пример #25
0
	public static function SetReadMessageAll($fromUserId)
	{
		global $DB;

		$fromUserId = intval($fromUserId);
		if ($fromUserId <= 0)
			return false;

		$strSql = "
			SELECT RT.ID, RT.USER_ID, RT.CHAT_ID
			FROM b_im_relation RF
			INNER JOIN b_im_relation RT on RF.CHAT_ID = RT.CHAT_ID AND RT.ID != RF.ID
			WHERE RF.USER_ID = ".$fromUserId."
			AND RT.MESSAGE_TYPE = '".IM_MESSAGE_PRIVATE."' AND RT.STATUS < ".IM_STATUS_READ;
		$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
		if ($arRes = $dbRes->Fetch())
		{
			self::SetLastId(intval($arRes['CHAT_ID']), $arRes['USER_ID']);
			//CUserCounter::Clear($arRes['USER_ID'], 'im_message_v2', '**', false);
			CIMMessenger::SpeedFileDelete($arRes['USER_ID'], IM_SPEED_MESSAGE);
		}

		return true;
	}
Пример #26
0
		));
	}
	else if ($_POST['IM_START_WRITING'] == 'Y')
	{
		$errorMessage = "";
		CIMMessenger::StartWriting($_POST['DIALOG_ID']);

		echo CUtil::PhpToJsObject(Array(
			'ERROR' => $errorMessage
		));
	}
	else if ($_POST['IM_DESKTOP_LOGOUT'] == 'Y')
	{
		$errorMessage = "";

		CIMMessenger::SetDesktopStatusOffline();
		CIMContactList::SetOffline();

		echo CUtil::PhpToJsObject(Array(
			'ERROR' => $errorMessage
		));
	}
	else if ($_POST['IM_SETTING_SAVE'] == 'Y')
	{
		$errorMessage = "";

		$arSettings = CUtil::JsObjectToPhp($_POST['SETTINGS']);

		CIMSettings::SetSetting(CIMSettings::SETTINGS, $arSettings);

		echo CUtil::PhpToJsObject(Array(
Пример #27
0
	public static function GetRecentList($arParams = Array())
	{
		global $DB, $USER;

		$bLoadUnreadMessage = isset($arParams['LOAD_UNREAD_MESSAGE']) && $arParams['LOAD_UNREAD_MESSAGE'] == 'Y'? true: false;
		$bTimeZone = isset($arParams['USE_TIME_ZONE']) && $arParams['USE_TIME_ZONE'] == 'N'? false: true;
		$bSmiles = isset($arParams['USE_SMILES']) && $arParams['USE_SMILES'] == 'N'? false: true;

		$nameTemplate = COption::GetOptionString("im", "user_name_template", "#LAST_NAME# #NAME#", SITE_ID);
		$nameTemplateSite = CSite::GetNameFormat(false);
		$nameOfSite = CModule::IncludeModule('extranet') && !CExtranet::IsIntranetUser()? "ex": false;
		$bIntranetEnable = IsModuleInstalled('intranet') && CModule::IncludeModule('intranet')? true: false;

		$arRecent = Array();
		$arUsers = Array();

		$cache_ttl = 2592000;
		$cache_id = $GLOBALS['USER']->GetID();
		$cache_dir = '/bx/imc/rec'.CIMMessenger::GetCachePath($cache_id);
		$obCache = new CPHPCache();
		if($obCache->InitCache($cache_ttl, $cache_id, $cache_dir))
		{
			$ar = $obCache->GetVars();
			$arRecent = $ar['recent'];
			$arUsers = $ar['users'];
		}
		else
		{
			if (!$bTimeZone)
				CTimeZone::Disable();
			$strSql = "
				SELECT
					R.ITEM_TYPE, R.ITEM_ID,
					R.ITEM_MID M_ID, M.AUTHOR_ID M_AUTHOR_ID, M.MESSAGE M_MESSAGE, ".$DB->DatetimeToTimestampFunction('M.DATE_CREATE')." M_DATE_CREATE,
					C.TITLE C_TITLE, C.AUTHOR_ID C_OWNER_ID,
					U.LOGIN, U.NAME, U.LAST_NAME, U.PERSONAL_PHOTO, U.SECOND_NAME, U.PERSONAL_BIRTHDAY, U.PERSONAL_GENDER
				FROM
				b_im_recent R
				LEFT JOIN b_user U ON R.ITEM_TYPE = '".IM_MESSAGE_PRIVATE."' AND R.ITEM_ID = U.ID
				LEFT JOIN b_im_chat C ON R.ITEM_TYPE = '".IM_MESSAGE_GROUP."' AND R.ITEM_ID = C.ID
				LEFT JOIN b_im_message M ON R.ITEM_MID = M.ID
				WHERE R.USER_ID = ".$USER->GetId();
			if (!$bTimeZone)
				CTimeZone::Enable();

			$toDelete = Array();
			$CCTP = new CTextParser();
			$CCTP->MaxStringLen = 255;
			$CCTP->allow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => ($bSmiles? "Y": "N"), "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N");
			$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
			while ($arRes = $dbRes->GetNext(true, false))
			{
				$arRes['ITEM_TYPE'] = trim($arRes['ITEM_TYPE']);
				if ($arRes['M_DATE_CREATE']+2592000 < time())
				{
					$toDelete[$arRes['ITEM_TYPE']][] = $arRes['ITEM_ID'];
					continue;
				}

				$itemId = $arRes['ITEM_ID'];
				$item = Array(
					'TYPE' => $arRes['ITEM_TYPE'],
					'MESSAGE' => Array(
						'id' => $arRes['M_ID'],
						'senderId' => $arRes['M_AUTHOR_ID'],
						'date' => $arRes['M_DATE_CREATE'],
						'text' => $CCTP->convertText(preg_replace("/\[s\].*?\[\/s\]/i", "", $arRes['M_MESSAGE']))
					)
				);
				$item['MESSAGE']['text'] = preg_replace("/------------------------------------------------------(.*)------------------------------------------------------/mi", " [".GetMessage('IM_QUOTE')."] ", strip_tags(str_replace(array("<br>","<br/>","<br />", "#BR#"), Array(" "," ", " ", " "), $item['MESSAGE']['text']), "<img>"));
				if ($arRes['ITEM_TYPE'] == IM_MESSAGE_PRIVATE)
				{
					$arUsers[] = $arRes['ITEM_ID'];
					$arFileTmp = CFile::ResizeImageGet(
						$arRes["PERSONAL_PHOTO"],
						array('width' => 58, 'height' => 58),
						BX_RESIZE_IMAGE_EXACT,
						false
					);

					$item['USER'] = Array(
						'id' => $arRes['ITEM_ID'],
						'name' => CUser::FormatName($nameTemplateSite, $arRes, true, false),
						'nameList' => CUser::FormatName($nameTemplate, $arRes, true, false),
						'avatar' => empty($arFileTmp['src'])? '/bitrix/js/im/images/blank.gif': $arFileTmp['src'],
						'gender' => $arRes['PERSONAL_GENDER'] == 'F'? 'F': 'M',
						'status' => 'offline',
						'birthday' => $arRes['PERSONAL_BIRTHDAY'],
						'profile' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('im', 'path_to_user_profile', "", $nameOfSite), array("user_id" => $arRes["ITEM_ID"]))
					);
				}
				else
				{
					$itemId = 'chat'.$itemId;
					$item['CHAT'] = Array(
						'id' => $arRes['ITEM_ID'],
						'name' => $arRes["C_TITLE"],
						'owner' => $arRes["C_OWNER_ID"],
					);
				}
				$arRecent[$itemId] = $item;
			}
			// remove old entity
			if (!empty($toDelete))
			{
				if (isset($toDelete[IM_MESSAGE_PRIVATE]))
					self::DeleteRecent($toDelete[IM_MESSAGE_PRIVATE]);
				if (isset($toDelete[IM_MESSAGE_GROUP]))
					self::DeleteRecent($toDelete[IM_MESSAGE_GROUP], true);
			}
			if($obCache->StartDataCache())
				$obCache->EndDataCache(Array('recent' => $arRecent, 'users' => $arUsers));
		}

		$arOnline = self::GetStatus(Array('ID' => array_values($arUsers)));
		foreach ($arRecent as $key => $value)
		{
			if ($value['TYPE'] != IM_MESSAGE_PRIVATE)
				continue;

			$arRecent[$key]['USER']['birthday'] = $bIntranetEnable? CIntranetUtils::IsToday($value['USER']['birthday']): false;
			$arRecent[$key]['USER']['status'] = isset($arOnline['users'][$value['USER']['id']])? 'online': 'offline';
		}

		if ($bLoadUnreadMessage)
		{
			$CIMMessage = new CIMMessage(false, Array(
				'hide_link' => true
			));

			$ar = $CIMMessage->GetUnreadMessage(Array(
				'LOAD_DEPARTMENT' => 'N',
				'ORDER' => 'ASC',
				'GROUP_BY_CHAT' => 'Y',
				'USE_TIME_ZONE' => $bTimeZone? 'Y': 'N',
				'USE_SMILES' => $bSmiles? 'Y': 'N'
			));
			foreach ($ar['message'] as $data)
			{
				if (!isset($arRecent[$data['senderId']]))
				{
					$arRecent[$data['senderId']] = Array(
						'TYPE' => IM_MESSAGE_PRIVATE,
						'USER' => $ar['users'][$data['senderId']]
					);
				}
				$arRecent[$data['senderId']]['MESSAGE'] = Array(
					'id' => $data['id'],
					'senderId' => $data['senderId'],
					'date' => $data['date'],
					'text' => preg_replace("/------------------------------------------------------(.*)------------------------------------------------------/mi", " [".GetMessage('IM_QUOTE')."] ", strip_tags(str_replace(array("<br>","<br/>","<br />", "#BR#"), Array(" ", " ", " ", " "), $data['text']), "<img>"))
				);

				$arRecent[$data['senderId']]['COUNTER'] = $data['counter'];
			}

			$CIMChat = new CIMChat(false, Array(
				'hide_link' => true
			));

			$ar = $CIMChat->GetUnreadMessage(Array(
				'ORDER' => 'ASC',
				'GROUP_BY_CHAT' => 'Y',
				'USER_LOAD' => 'N',
				'USE_SMILES' => $bSmiles? 'Y': 'N',
				'USE_TIME_ZONE' => $bTimeZone? 'Y': 'N'
			));
			foreach ($ar['message'] as $data)
			{
				if (!isset($arRecent['chat'.$data['recipientId']]))
				{
					$arRecent['chat'.$data['recipientId']] = Array(
						'TYPE' => IM_MESSAGE_GROUP,
						'CHAT' => $ar['chat']
					);
				}
				$arRecent['chat'.$data['recipientId']]['MESSAGE'] = Array(
					'id' => $data['id'],
					'senderId' => $data['senderId'],
					'date' => $data['date'],
					'text' => $data['text']
				);
				$arRecent['chat'.$data['recipientId']]['COUNTER'] = $data['counter'];
			}
		}

		if (!empty($arRecent))
		{
			sortByColumn(
				$arRecent,
				array(
					'COUNTER' => array(SORT_NUMERIC, SORT_DESC),
					'MESSAGE' => array(SORT_NUMERIC, SORT_DESC)
				),
				array(
					'COUNTER' => function($counter){ return !is_null($counter); },
					'MESSAGE' => function($recent){ return $recent['date']; }
				),
				null, true
			);
		}

		return $arRecent;
	}
Пример #28
0
 public static function GetRecentList($arParams = array())
 {
     global $DB, $USER;
     $bLoadUnreadMessage = isset($arParams['LOAD_UNREAD_MESSAGE']) && $arParams['LOAD_UNREAD_MESSAGE'] == 'Y' ? true : false;
     $bTimeZone = isset($arParams['USE_TIME_ZONE']) && $arParams['USE_TIME_ZONE'] == 'N' ? false : true;
     $bSmiles = isset($arParams['USE_SMILES']) && $arParams['USE_SMILES'] == 'N' ? false : true;
     $userId = isset($arParams['USER_ID']) ? $arParams['USER_ID'] : $USER->GetId();
     $nameTemplate = self::GetUserNameTemplate(SITE_ID);
     $nameTemplateSite = CSite::GetNameFormat(false);
     $bIntranetEnable = IsModuleInstalled('intranet') && CModule::IncludeModule('intranet') ? true : false;
     $arRecent = array();
     $arUsers = array();
     $bColorEnabled = IM\Color::isEnabled();
     $cache_ttl = 2592000;
     $cache_id = 'im_recent_v8_' . $userId . '_' . $bColorEnabled;
     $cache_dir = '/bx/imc/recent' . CIMMessenger::GetCachePath($userId);
     $obCache = new CPHPCache();
     if ($obCache->InitCache($cache_ttl, $cache_id, $cache_dir)) {
         $ar = $obCache->GetVars();
         $arRecent = $ar['recent'];
         $arUsers = $ar['users'];
     } else {
         if (!$bTimeZone) {
             CTimeZone::Disable();
         }
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tR.ITEM_TYPE, R.ITEM_ID,\n\t\t\t\t\tR.ITEM_MID M_ID, M.AUTHOR_ID M_AUTHOR_ID, M.ID M_ID, M.CHAT_ID M_CHAT_ID, M.MESSAGE M_MESSAGE, " . $DB->DatetimeToTimestampFunction('M.DATE_CREATE') . " M_DATE_CREATE,\n\t\t\t\t\tC.TITLE C_TITLE, C.AUTHOR_ID C_OWNER_ID, C.ENTITY_TYPE C_ENTITY_TYPE, C.AVATAR C_AVATAR, C.CALL_NUMBER C_CALL_NUMBER, C.EXTRANET CHAT_EXTRANET, C.COLOR CHAT_COLOR, C.TYPE CHAT_TYPE,\n\t\t\t\t\tU.LOGIN, U.NAME, U.LAST_NAME, U.PERSONAL_PHOTO, U.SECOND_NAME, U.PERSONAL_BIRTHDAY, U.PERSONAL_GENDER, U.EXTERNAL_AUTH_ID, U.WORK_POSITION,\n\t\t\t\t\tC1.USER_ID RID\n\t\t\t\tFROM\n\t\t\t\tb_im_recent R\n\t\t\t\tLEFT JOIN b_user U ON R.ITEM_TYPE = '" . IM_MESSAGE_PRIVATE . "' AND R.ITEM_ID = U.ID\n\t\t\t\tLEFT JOIN b_im_chat C ON R.ITEM_TYPE != '" . IM_MESSAGE_PRIVATE . "' AND R.ITEM_ID = C.ID\n\t\t\t\tLEFT JOIN b_im_message M ON R.ITEM_MID = M.ID\n\t\t\t\tLEFT JOIN b_im_relation C1 ON C1.CHAT_ID = C.ID AND C1.USER_ID = " . $userId . "\n\t\t\t\tWHERE R.USER_ID = " . $userId;
         if (!$bTimeZone) {
             CTimeZone::Enable();
         }
         $toDelete = array();
         $arMessageId = array();
         $CCTP = new CTextParser();
         $CCTP->MaxStringLen = 255;
         $CCTP->allow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => $bSmiles ? "Y" : "N", "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N");
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         while ($arRes = $dbRes->GetNext(true, false)) {
             $arRes['ITEM_TYPE'] = trim($arRes['ITEM_TYPE']);
             if ($arRes['ITEM_TYPE'] == IM_MESSAGE_OPEN) {
                 if (intval($arRes['RID']) <= 0 && IM\User::getInstance($userId)->isExtranet()) {
                     continue;
                 }
             } else {
                 if ($arRes['ITEM_TYPE'] == IM_MESSAGE_CHAT) {
                     if (intval($arRes['RID']) <= 0) {
                         continue;
                     }
                 }
             }
             $arMessageId[] = $arRes['M_ID'];
             if ($arRes['M_DATE_CREATE'] + 2592000 < time()) {
                 $toDelete[$arRes['ITEM_TYPE']][] = $arRes['ITEM_ID'];
                 continue;
             }
             $itemId = $arRes['ITEM_ID'];
             $item = array('TYPE' => $arRes['ITEM_TYPE'], 'MESSAGE' => array('id' => $arRes['M_ID'], 'chatId' => $arRes['M_CHAT_ID'], 'senderId' => $arRes['M_AUTHOR_ID'], 'date' => $arRes['M_DATE_CREATE'], 'text' => $CCTP->convertText(preg_replace("/\\[s\\].*?\\[\\/s\\]/i", "", $arRes['M_MESSAGE']))));
             $item['MESSAGE']['text'] = preg_replace('#\\-{54}.+?\\-{54}#s', " [" . GetMessage('IM_QUOTE') . "] ", strip_tags(str_replace(array("<br>", "<br/>", "<br />", "#BR#"), array(" ", " ", " ", " "), $item['MESSAGE']['text']), "<img>"));
             if ($arRes['ITEM_TYPE'] == IM_MESSAGE_PRIVATE) {
                 $arUsers[] = $arRes['ITEM_ID'];
                 $arFileTmp = CFile::ResizeImageGet($arRes["PERSONAL_PHOTO"], array('width' => 58, 'height' => 58), BX_RESIZE_IMAGE_EXACT, false, false, true);
                 $item['USER'] = array('id' => $arRes['ITEM_ID'], 'name' => CUser::FormatName($nameTemplateSite, $arRes, true, false), 'nameList' => CUser::FormatName($nameTemplate, $arRes, true, false), 'workPosition' => $arRes['WORK_POSITION'], 'color' => self::GetUserColor($arRes["ID"], $arRes['PERSONAL_GENDER'] == 'M' ? 'M' : 'F'), 'avatar' => empty($arFileTmp['src']) ? '/bitrix/js/im/images/blank.gif' : $arFileTmp['src'], 'status' => 'offline', 'birthday' => $arRes['PERSONAL_BIRTHDAY'], 'gender' => $arRes['PERSONAL_GENDER'] == 'F' ? 'F' : 'M', 'extranet' => false, 'network' => $arRes['EXTERNAL_AUTH_ID'] == self::NETWORK_AUTH_ID, 'phoneDevice' => false, 'profile' => CIMContactList::GetUserPath($arRes["ITEM_ID"]));
             } else {
                 $chatType = $arRes["ITEM_TYPE"] == IM_MESSAGE_OPEN ? 'open' : 'chat';
                 if ($arRes["C_ENTITY_TYPE"] == 'CALL') {
                     $chatType = 'call';
                 }
                 $itemId = 'chat' . $itemId;
                 $item['CHAT'] = array('id' => $arRes['ITEM_ID'], 'name' => $arRes["C_TITLE"], 'color' => $arRes["CHAT_COLOR"] == "" ? IM\Color::getColorByNumber($arRes['ITEM_ID']) : IM\Color::getColor($arRes['CHAT_COLOR']), 'avatar' => CIMChat::GetAvatarImage($arRes["C_AVATAR"]), 'extranet' => $arRes["CHAT_EXTRANET"] == "" ? "" : ($arRes["CHAT_EXTRANET"] == "Y" ? true : false), 'owner' => $arRes["C_OWNER_ID"], 'type' => $chatType, 'messageType' => $arRes['CHAT_TYPE'], 'call_number' => $arRes["C_CALL_NUMBER"]);
             }
             $arRecent[$itemId] = $item;
         }
         $params = CIMMessageParam::Get($arMessageId);
         foreach ($arRecent as $key => $value) {
             if (isset($params[$value['MESSAGE']['id']])) {
                 if (count($params[$value['MESSAGE']['id']]['FILE_ID']) > 0 && strlen(trim($arRecent[$key]['MESSAGE']['text'])) <= 0) {
                     $arRecent[$key]['MESSAGE']['text'] = "[" . GetMessage('IM_FILE') . "]";
                 }
                 $arRecent[$key]['MESSAGE']['params'] = $params[$value['MESSAGE']['id']];
             }
         }
         if (!empty($toDelete)) {
             if (isset($toDelete[IM_MESSAGE_PRIVATE])) {
                 self::DeleteRecent($toDelete[IM_MESSAGE_PRIVATE]);
             }
             if (isset($toDelete[IM_MESSAGE_CHAT])) {
                 self::DeleteRecent($toDelete[IM_MESSAGE_CHAT], true);
             }
             if (isset($toDelete[IM_MESSAGE_OPEN])) {
                 self::DeleteRecent($toDelete[IM_MESSAGE_OPEN], true);
             }
         }
         $bExtranetEnable = IsModuleInstalled('extranet');
         $bVoximplantEnable = IsModuleInstalled('voximplant');
         if ($bExtranetEnable || $bVoximplantEnable) {
             $arUserPhone = array();
             $arUserDepartment = array();
             $arSelectParams = array();
             if ($bExtranetEnable) {
                 $arSelectParams[] = 'UF_DEPARTMENT';
             }
             if ($bVoximplantEnable) {
                 $arSelectParams[] = 'UF_VI_PHONE';
             }
             $dbUsers = CUser::GetList($sort_by = array('last_name' => 'asc'), $dummy = '', array('ID' => $userId . "|" . implode('|', $arUsers)), array('FIELDS' => array("ID"), 'SELECT' => $arSelectParams));
             while ($arUser = $dbUsers->GetNext(true, false)) {
                 $arUserPhone[$arUser['ID']] = $arUser['UF_VI_PHONE'] == 'Y';
                 $arUserDepartment[$arUser['ID']] = self::IsExtranet($arUser);
             }
             foreach ($arRecent as $key => $value) {
                 if (isset($value['USER'])) {
                     $arRecent[$key]['USER']['extranet'] = $arUserDepartment[$value['USER']['id']];
                     $arRecent[$key]['USER']['phoneDevice'] = $arUserPhone[$value['USER']['id']];
                 }
             }
         }
         if ($obCache->StartDataCache()) {
             $obCache->EndDataCache(array('recent' => $arRecent, 'users' => $arUsers));
         }
     }
     $arOnline = CIMStatus::GetList(array('ID' => array_values($arUsers), 'GET_OFFLINE' => 'Y'));
     foreach ($arRecent as $key => $value) {
         if ($value['TYPE'] != IM_MESSAGE_PRIVATE) {
             continue;
         }
         $arRecent[$key]['USER']['birthday'] = $bIntranetEnable ? CIntranetUtils::IsToday($value['USER']['birthday']) : false;
         $arRecent[$key]['USER']['status'] = isset($arOnline['users'][$value['USER']['id']]) ? $arOnline['users'][$value['USER']['id']]['status'] : 'offline';
         $arRecent[$key]['USER']['idle'] = isset($arOnline['users'][$value['USER']['id']]) ? $arOnline['users'][$value['USER']['id']]['idle'] : 0;
         $arRecent[$key]['USER']['mobileLastDate'] = isset($arOnline['users'][$value['USER']['id']]) ? $arOnline['users'][$value['USER']['id']]['mobileLastDate'] : 0;
         if ($arOnline['users'][$value['USER']['id']]['color']) {
             $arRecent[$key]['USER']['color'] = $arOnline['users'][$value['USER']['id']]['color'];
         }
     }
     if ($bLoadUnreadMessage) {
         $CIMMessage = new CIMMessage(false, array('HIDE_LINK' => 'Y'));
         $ar = $CIMMessage->GetUnreadMessage(array('LOAD_DEPARTMENT' => 'N', 'ORDER' => 'ASC', 'GROUP_BY_CHAT' => 'Y', 'USE_TIME_ZONE' => $bTimeZone ? 'Y' : 'N', 'USE_SMILES' => $bSmiles ? 'Y' : 'N'));
         foreach ($ar['message'] as $data) {
             if (!isset($arRecent[$data['senderId']])) {
                 $arRecent[$data['senderId']] = array('TYPE' => IM_MESSAGE_PRIVATE, 'USER' => $ar['users'][$data['senderId']]);
             }
             $arRecent[$data['senderId']]['MESSAGE'] = array('id' => $data['id'], 'senderId' => $data['senderId'], 'date' => $data['date'], 'text' => preg_replace('#\\-{54}.+?\\-{54}#s', " [" . GetMessage('IM_QUOTE') . "] ", strip_tags(str_replace(array("<br>", "<br/>", "<br />", "#BR#"), array(" ", " ", " ", " "), $data['text']), "<img>")));
             $arRecent[$data['senderId']]['COUNTER'] = $data['counter'];
         }
         $CIMChat = new CIMChat(false, array('HIDE_LINK' => 'Y'));
         $ar = $CIMChat->GetUnreadMessage(array('ORDER' => 'ASC', 'GROUP_BY_CHAT' => 'Y', 'USER_LOAD' => 'N', 'FILE_LOAD' => 'N', 'USE_SMILES' => $bSmiles ? 'Y' : 'N', 'USE_TIME_ZONE' => $bTimeZone ? 'Y' : 'N'));
         foreach ($ar['message'] as $data) {
             if (!isset($arRecent['chat' . $data['recipientId']])) {
                 $arRecent['chat' . $data['recipientId']] = array('TYPE' => $ar['messageType'] ? $ar['messageType'] : IM_MESSAGE_CHAT, 'CHAT' => $ar['chat']);
             }
             $arRecent['chat' . $data['recipientId']]['MESSAGE'] = array('id' => $data['id'], 'senderId' => $data['senderId'], 'date' => $data['date'], 'text' => $data['text']);
             $arRecent['chat' . $data['recipientId']]['COUNTER'] = $data['counter'];
         }
     }
     if (!empty($arRecent)) {
         sortByColumn($arRecent, array('COUNTER' => array(SORT_NUMERIC, SORT_DESC), 'MESSAGE' => array(SORT_NUMERIC, SORT_DESC)), array('COUNTER' => array(__CLASS__, 'GetRecentListSortCounter'), 'MESSAGE' => array(__CLASS__, 'GetRecentListSortMessage')), null, true);
     }
     return $arRecent;
 }
Пример #29
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
$composite = \Bitrix\Main\Page\Frame::getInstance();
$composite->setEnable();
$composite->setUseAppCache();
?>
<div id="im-contact-list-search"></div>
<div id="im-contact-list-wrap"></div>
<?php 
$frame = $this->createFrame("im_component_recent_v2_" . $USER->GetId())->begin();
$frame->setBrowserStorage(true);
?>
<script type="text/javascript">
	<?php 
echo CIMMessenger::GetMobileTemplateJS(array(), $arResult);
?>
</script>
<?php 
$frame->beginStub();
?>
<div class="bx-messenger-cl-item-load"><?php 
echo GetMessage('IM_RESENT_LOADING');
?>
</div>
<?php 
$frame->end();
Пример #30
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;
 }