示例#1
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;
 }
示例#2
0
}
if (!$USER->IsAuthorized()) {
    $USER->LoginByCookies();
}
if (intval($USER->GetID()) <= 0) {
    // TODO need change AUTHORIZE ERROR callbacks
    //header("HTTP/1.0 401 Not Authorized");
    //header("Content-Type: application/x-javascript");
    //header("BX-Authorize: ".bitrix_sessid());
    echo CUtil::PhpToJsObject(array('ERROR' => 'AUTHORIZE_ERROR', 'BITRIX_SESSID' => bitrix_sessid()));
    CMain::FinalActions();
    die;
}
if (check_bitrix_sessid()) {
    if (isset($_REQUEST["mobile_action"]) && $_POST['FOCUS'] == 'Y' && CModule::IncludeModule('mobile')) {
        Bitrix\Mobile\User::setOnline();
    }
    if ($_POST['IM_AVATAR_UPDATE'] == 'Y') {
        $userId = $USER->GetId();
        if (CIMChat::GetGeneralChatId() != intval($_POST['CHAT_ID'])) {
            $CFileUploader = new CFileUploader(array("allowUpload" => "I", "events" => array("onFileIsUploaded" => array("CIMDisk", "UploadAvatar"))));
            if (!$CFileUploader->checkPost()) {
                echo CUtil::PhpToJsObject(array('ERROR' => 'UPLOAD_ERROR'));
            }
        } else {
            echo CUtil::PhpToJsObject(array('ERROR' => 'UPLOAD_ERROR'));
        }
    } else {
        if ($_POST['IM_FILE_UPLOAD'] == 'Y') {
            CUtil::decodeURIComponent($_POST);
            $CFileUploader = new CFileUploader(array("allowUpload" => "A", "events" => array("onFileIsUploaded" => array("CIMDisk", "UploadFile"))));