- Модуль: imopenlines
- Путь к файлу: ~/bitrix/modules/imopenlines/lib/rest.php
- Класс: BitrixImOpenLinesRest
- Вызов: Rest::getSoftPauseHistory
static function getSoftPauseHistory($arParams, $n, CRestServer $server): array
{
$permission = Permissions::createWithCurrentUser();
if(!$permission->canPerform(Permissions::ENTITY_SOFT_PAUSE_LIST, Permissions::ACTION_VIEW))
{
throw new RestException('You dont have access to this action', 'ACCESS_DENIED', CRestServer::STATUS_WRONG_REQUEST);
}
if (!isset($arParams['DATE_START']))
{
throw new RestException('Empty DATE_START parameter', 'DATE_START_EMPTY', CRestServer::STATUS_WRONG_REQUEST);
}
$matches = [];
if (
preg_match("/^(d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2]d|3[0-1])$/", $arParams['DATE_START'], $matches)
&& checkdate($matches[2], $matches[3], $matches[1])
)
{
$arParams['DATE_START'] .= 'T00:00:00' . date('P');
}
if (
!preg_match("/^(d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2]d|3[0-1])T[0-2]d:[0-5]d:[0-5]d[+-][0-2]d:[0-5]d$/", $arParams['DATE_START'], $matches)
|| !checkdate($matches[2], $matches[3], $matches[1])
|| !$dateStart = DateTime::createFromPhp(DateTime::createFromFormat(DATE_ATOM, $arParams['DATE_START']))
)
{
throw new RestException("DATE_START parameter not in 'Y-m-dTH:i:sP' or 'Y-m-d' format", 'DATE_START_WRONG_FORMAT', CRestServer::STATUS_WRONG_REQUEST);
}
if (isset($arParams['DATE_END']))
{
if (
preg_match("/^(d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2]d|3[0-1])$/", $arParams['DATE_END'], $matches)
&& checkdate($matches[2], $matches[3], $matches[1])
)
{
$arParams['DATE_END'] .= 'T23:59:59' . date('P');
}
if (
!preg_match("/^(d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2]d|3[0-1])T[0-2]d:[0-5]d:[0-5]d[+-][0-2]d:[0-5]d$/", $arParams['DATE_END'], $matches)
|| !checkdate($matches[2], $matches[3], $matches[1])
|| !$dateEnd = DateTime::createFromPhp(DateTime::createFromFormat(DATE_ATOM, $arParams['DATE_END']))
)
{
throw new RestException("DATE_END parameter not in 'Y-m-dTH:i:sP' or 'Y-m-d' format", 'DATE_END_WRONG_FORMAT', CRestServer::STATUS_WRONG_REQUEST);
}
}
return UserPause::getHistory(
$dateStart,
$dateEnd ?? null,
(int)$arParams['CONFIG_ID'] ?? 0,
(int)$arParams['USER_ID'] ?? 0
);
}