diff --git a/application/applicationextension.inc.php b/application/applicationextension.inc.php index 90aeb4f8e8..2b213c6e29 100644 --- a/application/applicationextension.inc.php +++ b/application/applicationextension.inc.php @@ -1095,12 +1095,13 @@ class RestUtils * * @param string $sClass Name of the class * @param mixed $key Either search criteria (substructure), or an object or an OQL string. - * @param int $limit The limit of results to return - * @param int $offset The offset of results to return + * @param int $iLimit The limit of results to return + * @param int $iOffset The offset of results to return + * * @return DBObjectSet The search result set * @throws Exception If the input structure is not valid */ - public static function GetObjectSetFromKey($sClass, $key, $limit = 0, $offset = 0) + public static function GetObjectSetFromKey($sClass, $key, $iLimit = 0, $iOffset = 0) { if (is_object($key)) { @@ -1134,7 +1135,7 @@ class RestUtils { throw new Exception("Wrong format for key"); } - $oObjectSet = new DBObjectSet($oSearch, array(), array(), null, $limit, $offset); + $oObjectSet = new DBObjectSet($oSearch, array(), array(), null, $iLimit, $iOffset); return $oObjectSet; } diff --git a/core/restservices.class.inc.php b/core/restservices.class.inc.php index 38852b7fe9..2ec01292c3 100644 --- a/core/restservices.class.inc.php +++ b/core/restservices.class.inc.php @@ -436,10 +436,10 @@ class CoreServices implements iRestServiceProvider $key = RestUtils::GetMandatoryParam($aParams, 'key'); $aShowFields = RestUtils::GetFieldList($sClass, $aParams, 'output_fields'); $bExtendedOutput = (RestUtils::GetOptionalParam($aParams, 'output_fields', '*') == '*+'); - $limit = (int) RestUtils::GetOptionalParam($aParams, 'limit', 0); - $page = (int) RestUtils::GetOptionalParam($aParams, 'page', 1); + $iLimit = (int)RestUtils::GetOptionalParam($aParams, 'limit', 0); + $iPage = (int)RestUtils::GetOptionalParam($aParams, 'page', 1); - $oObjectSet = RestUtils::GetObjectSetFromKey($sClass, $key, $limit, self::getOffsetFromLimitAndPage($limit, $page)); + $oObjectSet = RestUtils::GetObjectSetFromKey($sClass, $key, $iLimit, self::getOffsetFromLimitAndPage($iLimit, $iPage)); $sTargetClass = $oObjectSet->GetFilter()->GetClass(); if (UserRights::IsActionAllowed($sTargetClass, UR_ACTION_READ) != UR_ALLOWED_YES) @@ -452,7 +452,7 @@ class CoreServices implements iRestServiceProvider $oResult->code = RestResult::UNAUTHORIZED; $oResult->message = "The current user does not have enough permissions for exporting data of class $sTargetClass"; } - elseif ($page < 1) + elseif ($iPage < 1) { $oResult->code = RestResult::INVALID_PAGE; $oResult->message = "The request page number is not valid. It must be an integer greater than 0"; @@ -782,15 +782,14 @@ class CoreServices implements iRestServiceProvider } } - /** - * Returns the Offset for a given page number - * - * @param int $limit - * @param int $page - * @return int - */ - protected static function getOffsetFromLimitAndPage($limit, $page) - { - return $limit * max(0, $page - 1); - } + /** + * @param int $iLimit + * @param int $iPage + * + * @return int Offset for a given page number + */ + protected static function getOffsetFromLimitAndPage($iLimit, $iPage) + { + return $iLimit * max(0, $iPage - 1); + } }