• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/rest/user.php
  • Класс: BitrixMainRestUser
  • Вызов: User::getHistoryList
static function getHistoryList($query, $nav = 0, CRestServer $server)
{
	global $USER;

	$query = array_change_key_case($query, CASE_LOWER);

	$filter = ($query['filter'] ?? array());
	$order = ($query['order'] ?? array('ID' => 'DESC'));

	static $filterFields = array("USER_ID", "DATE_INSERT", "EVENT_TYPE", "REMOTE_ADDR", "USER_AGENT", "REQUEST_URI", "FIELD");
	static $orderFields = array("ID");

	$queryFilter = static::sanitizeFilter(
		$filter,
		$filterFields,
		function($field, $value, $operation)
		{
			switch($field)
			{
				case 'DATE_INSERT':
					return MainTypeDateTime::createFromUserTime(CRestUtil::unConvertDateTime($value));
					break;
				case 'USER_ID':
				case 'FIELD':
					if($operation <> '=')
					{
						throw new RestRestException("Only '=' operation is allowed for the filter field {$field}.", RestRestException::ERROR_ARGUMENT, CRestServer::STATUS_WRONG_REQUEST);
					}
					break;

			}
			return $value;
		}
	);

	if(!isset($queryFilter["=USER_ID"]))
	{
		throw new RestRestException("USER_ID filter field is required.", RestRestException::ERROR_ARGUMENT, CRestServer::STATUS_WRONG_REQUEST);
	}

	if(!$USER->CanDoOperation('edit_all_users') && $queryFilter["=USER_ID"] <> $USER->GetID())
	{
		throw new RestAccessException();
	}

	if(isset($queryFilter["=FIELD"]))
	{
		$queryFilter['=BitrixMainUserProfileRecordTable:HISTORY.FIELD'] = $queryFilter["=FIELD"];
		unset($queryFilter["=FIELD"]);
	}

	$order = static::sanitizeOrder($order, $orderFields);

	$navParams = static::getNavData($nav, true);

	$dbRes = MainUserProfileHistoryTable::getList(array(
		'filter' => $queryFilter,
		'limit' => $navParams['limit'],
		'offset' => $navParams['offset'],
		'count_total' => true,
		'order' => $order,
	));

	$result = array();
	while($event = $dbRes->fetch())
	{
		/** @var MainTypeDateTime $ts */
		$ts = $event['DATE_INSERT'];
		$event['DATE_INSERT'] = CRestUtil::convertDateTime($ts->toString());

		$result[] = $event;
	}

	return static::setNavData($result, array(
		"count" => $dbRes->getCount(),
		"offset" => $navParams['offset']
	));
}