- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/classes/general/im_rest.php
- Класс: CIMRestService
- Вызов: CIMRestService::messageUserGet
static function messageUserGet($arParams, $offset, CRestServer $server)
{
$arParams = array_change_key_case($arParams, CASE_UPPER);
if (
$server->getAuthType() != BitrixRestOAuthAuth::AUTH_TYPE
&& !self::isDebugEnabled()
)
{
throw new BitrixRestRestException("Access for this method allowed only by OAuth authorization.", "WRONG_AUTH_TYPE", CRestServer::STATUS_WRONG_REQUEST);
}
global $USER;
$userId = $USER->GetID();
if ($userId <= 0)
{
throw new BitrixRestRestException("User ID can't be empty", "ID_EMPTY", CRestServer::STATUS_WRONG_REQUEST);
}
if (isset($arParams['FIRST_ID']))
{
$options['FIRST_ID'] = intval($arParams['FIRST_ID']);
}
else
{
$options['LAST_ID'] = isset($arParams['LAST_ID']) && intval($arParams['LAST_ID']) > 0? intval($arParams['LAST_ID']): 0;
}
$options['LIMIT'] = isset($arParams['LIMIT'])? (intval($arParams['LIMIT']) > 500? 500: intval($arParams['LIMIT'])): 50;
$options['JSON'] = 'Y';
$forUser = $userId;
if (isset($arParams['USER_ID']) && intval($arParams['USER_ID']) > 0 && $arParams['USER_ID'] != $userId)
{
if (
(
!BitrixImUser::getInstance($arParams['USER_ID'])->isActive() && !BitrixImUser::getInstance($arParams['USER_ID'])->isExtranet()
|| BitrixImUser::getInstance($arParams['USER_ID'])->isConnector()
)
&&
(
$USER->IsAdmin()
|| BitrixMainLoader::includeModule('bitrix24') && CBitrix24::IsPortalAdmin($userId)
)
)
{
$forUser = intval($arParams['USER_ID']);
$options['SKIP_MESSAGE'] = 'Y';
}
else
{
throw new BitrixRestRestException("You don't have access to this user", "ACCESS_ERROR", CRestServer::STATUS_WRONG_REQUEST);
}
}
return BitrixImUser::getMessages($forUser, $options);
}