예제 #1
0
 public static function GetChatData($arParams = array())
 {
     global $DB;
     $arParams['PHOTO_SIZE'] = isset($arParams['PHOTO_SIZE']) ? intval($arParams['PHOTO_SIZE']) : 58;
     $from = "\n\t\t\tFROM b_im_relation R1\n\t\t\tINNER JOIN b_im_chat C ON C.ID = R1.CHAT_ID\n\t\t";
     if (isset($arParams['SKIP_PRIVATE']) && $arParams['SKIP_PRIVATE'] == 'Y') {
         $from .= " AND C.TYPE IN ('" . IM_MESSAGE_OPEN . "','" . IM_MESSAGE_CHAT . "')";
     }
     $innerJoin = $whereUser = "";
     if (isset($arParams['GET_LIST']) && $arParams['GET_LIST'] == 'Y') {
         if (!isset($arParams['USER_ID'])) {
             return false;
         }
         $innerJoin = "INNER JOIN b_im_relation R2 ON R2.CHAT_ID = C.ID";
         $whereGeneral = "WHERE R2.USER_ID = " . intval($arParams['USER_ID']);
     } else {
         $arFilter = array();
         if (isset($arParams['ID']) && is_array($arParams['ID'])) {
             foreach ($arParams['ID'] as $key => $value) {
                 $arFilter['ID'][$key] = intval($value);
             }
         } else {
             if (isset($arParams['ID']) && intval($arParams['ID']) > 0) {
                 $arFilter['ID'][] = intval($arParams['ID']);
             }
         }
         if (empty($arFilter['ID'])) {
             return false;
         }
         if (isset($arParams['USER_ID'])) {
             $innerJoin = "LEFT JOIN b_im_relation R2 ON R2.CHAT_ID = C.ID AND R2.USER_ID = " . intval($arParams['USER_ID']);
         }
         $whereGeneral = "WHERE R1.CHAT_ID IN (" . implode(',', $arFilter['ID']) . ") ";
     }
     $strSql = "\n\t\t\tSELECT\n\t\t\t\tC.ID CHAT_ID,\n\t\t\t\tC.TITLE CHAT_TITLE,\n\t\t\t\tC.CALL_TYPE CHAT_CALL_TYPE,\n\t\t\t\tC.AUTHOR_ID CHAT_OWNER_ID,\n\t\t\t\tC.CALL_NUMBER CHAT_CALL_NUMBER,\n\t\t\t\tC.EXTRANET CHAT_EXTRANET,\n\t\t\t\tC.COLOR CHAT_COLOR,\n\t\t\t\tC.TYPE CHAT_TYPE,\n\t\t\t\tC.AVATAR,\n\t\t\t\tC.ENTITY_TYPE,\n\t\t\t\tC.ENTITY_ID,\n\t\t\t\tR1.NOTIFY_BLOCK RELATION_BLOCK_NOTIFY,\n\t\t\t\tR1.USER_ID RELATION_USER_ID,\n\t\t\t\tR1.CALL_STATUS\n\t\t\t\t" . (isset($arParams['USER_ID']) ? ", R2.ID RID" : "") . "\n\t\t\t" . $from . "\n\t\t\t" . $innerJoin . "\n\t\t\t" . $whereGeneral . "\n\t\t";
     $arChat = array();
     $arUserInChat = array();
     $arUserCallStatus = array();
     $arUserChatBlockStatus = array();
     $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     while ($arRes = $dbRes->GetNext(true, false)) {
         if (isset($arParams['USER_ID'])) {
             if ($arRes['CHAT_TYPE'] == IM_MESSAGE_OPEN) {
                 if (intval($arRes['RID']) <= 0 && IM\User::getInstance($arParams['USER_ID'])->isExtranet()) {
                     continue;
                 }
             } else {
                 if (intval($arRes['RID']) <= 0) {
                     continue;
                 }
             }
         }
         if (!isset($arChat[$arRes["CHAT_ID"]])) {
             $avatar = '/bitrix/js/im/images/blank.gif';
             if (intval($arRes["AVATAR"]) > 0) {
                 $avatar = self::GetAvatarImage($arRes["AVATAR"], $arParams['PHOTO_SIZE']);
             }
             if ($arRes["CHAT_TYPE"] == IM_MESSAGE_PRIVATE) {
                 $chatType = 'private';
             } else {
                 if ($arRes["ENTITY_TYPE"] == 'CALL') {
                     $chatType = 'call';
                 } else {
                     $chatType = $arRes["CHAT_TYPE"] == IM_MESSAGE_OPEN ? 'open' : 'chat';
                 }
             }
             $arChat[$arRes["CHAT_ID"]] = array('id' => $arRes["CHAT_ID"], 'name' => $arRes["CHAT_TITLE"], 'owner' => $arRes["CHAT_OWNER_ID"], 'color' => $arRes["CHAT_COLOR"] == "" ? IM\Color::getColorByNumber($arRes['CHAT_ID']) : IM\Color::getColor($arRes['CHAT_COLOR']), 'extranet' => $arRes["CHAT_EXTRANET"] == "" ? "" : ($arRes["CHAT_EXTRANET"] == "Y" ? true : false), 'avatar' => $avatar, 'call' => trim($arRes["CHAT_CALL_TYPE"]), 'call_number' => trim($arRes["CHAT_CALL_NUMBER"]), 'call_entity_type' => trim($arRes["ENTITY_TYPE"]), 'call_entity_id' => trim($arRes["ENTITY_ID"]), 'type' => $chatType, 'messageType' => $arRes["CHAT_TYPE"]);
         }
         $arUserInChat[$arRes["CHAT_ID"]][] = $arRes["RELATION_USER_ID"];
         $arUserCallStatus[$arRes["CHAT_ID"]][$arRes["RELATION_USER_ID"]] = trim($arRes["CALL_STATUS"]);
         if ($arRes["RELATION_BLOCK_NOTIFY"] != 'N') {
             $arUserChatBlockStatus[$arRes["CHAT_ID"]][$arRes["RELATION_USER_ID"]] = $arRes["RELATION_BLOCK_NOTIFY"];
         }
     }
     $result = array('chat' => $arChat, 'userInChat' => $arUserInChat, 'userCallStatus' => $arUserCallStatus, 'userChatBlockStatus' => $arUserChatBlockStatus);
     return $result;
 }
예제 #2
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;
 }
예제 #3
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';
     $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\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'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'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'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;
 }
예제 #4
0
 public function Join($chatId)
 {
     $chatId = intval($chatId);
     if ($chatId <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_EMPTY_CHAT_ID"), "EMPTY_CHAT_ID");
         return false;
     }
     $orm = IM\ChatTable::getById($chatId);
     if (!($chatData = $orm->fetch())) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_CHAT_NOT_EXISTS"), "ERROR_CHAT_NOT_EXISTS");
         return false;
     }
     if ($chatData['TYPE'] != IM_MESSAGE_OPEN) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_ACCESS_JOIN"), "ACCESS_JOIN");
         return false;
     }
     if (IM\User::getInstance($this->user_id)->isExtranet()) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_ACCESS_JOIN"), "ACCESS_JOIN");
         return false;
     }
     $chat = new CIMChat(0);
     $chat->AddUser($chatId, $this->user_id);
     return true;
 }
예제 #5
0
 public static function PreparePushForPrivate($params)
 {
     if ($params['SYSTEM'] == 'Y') {
         $pushText = $params['MESSAGE'];
     } else {
         $userName = \Bitrix\Im\User::getInstance($params['FROM_USER_ID'])->getName();
         if (!$userName) {
             return false;
         }
         $pushText = $userName . ': ' . $params['MESSAGE'];
     }
     $pushText = self::PrepareMessageForPush(array('MESSAGE' => $pushText, 'FILES' => $params['FILES'], 'ATTACH' => empty($params['MESSAGE']) && $params['ATTACH']));
     if (!$pushText) {
         return false;
     }
     $result = array();
     $result['push']['params'] = array('TAG' => 'IM_MESS_' . $params['FROM_USER_ID'], 'CATEGORY' => 'ANSWER', 'URL' => SITE_DIR . 'mobile/ajax.php?mobile_action=im_answer', 'PARAMS' => array('RECIPIENT_ID' => $params['FROM_USER_ID']));
     $result['push']['tag'] = 'IM_MESS_' . $params['FROM_USER_ID'];
     $result['push']['sub_tag'] = 'IM_MESS';
     $result['push']['app_id'] = 'Bitrix24';
     $result['push']['message'] = $pushText;
     return $result;
 }