• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/rest.php
  • Класс: BitrixImOpenLinesRest
  • Вызов: Rest::dialogUserDepersonalization
static function dialogUserDepersonalization($params, $n, CRestServer $server)
{
	$params = array_change_key_case($params, CASE_UPPER);

	if ($server->getAuthType() == SessionAuthAuth::AUTH_TYPE)
	{
		throw new RestException('Access for this method not allowed by session authorization.', 'WRONG_AUTH_TYPE', CRestServer::STATUS_WRONG_REQUEST);
	}

	if (!Loader::includeModule('im'))
	{
		throw new RestException('Messenger is not installed.', 'IM_NOT_INSTALLED', CRestServer::STATUS_WRONG_REQUEST);
	}

	global $USER;
	$userId = $USER->GetID();

	if (!(
		$USER->IsAdmin()
		|| (
			Loader::includeModule('bitrix24')
			&& CBitrix24::IsPortalAdmin($userId)
		)
	))
	{
		throw new RestException('You don't have access to this method', 'ACCESS_ERROR', CRestServer::STATUS_WRONG_REQUEST);
	}

	if (!isset($params['USER_CODE']) || empty($params['USER_CODE']))
	{
		throw new RestException('User code is not specified', 'USER_CODE_ERROR', CRestServer::STATUS_WRONG_REQUEST);
	}

	$guestUserId = Common::getUserIdByCode($params['USER_CODE']);
	if (!$guestUserId)
	{
		throw new RestException('The specified user is not a client of openlines module', 'USER_ERROR', CRestServer::STATUS_WRONG_REQUEST);
	}

	return Common::depersonalizationLinesUser($guestUserId);
}