kohabug 2437 Corrects LIMIT offset algorithm
authorChris Nighswonger <chris.nighswonger@liblime.com>
Mon, 4 Aug 2008 15:15:20 +0000 (10:15 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Mon, 4 Aug 2008 20:26:51 +0000 (15:26 -0500)
Because of a miscalculation in the offset algorithm, the LIMIT offset creeps
backwards by a magnitude for every page beyond page two. This patch corrects
the algorithm to behave as expected.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/VirtualShelves/Page.pm

index 4589aba..a81f1d0 100755 (executable)
@@ -66,9 +66,9 @@ sub shelfpage ($$$$$) {
        my ($shelflimit, $shelfoffset, $shelveslimit, $shelvesoffset);
        # FIXME: These limits should not be hardcoded...
        $shelflimit = 20;       # Limits number of items returned for a given query
-       $shelfoffset = (($itemoff == 1) ? 0 : ($itemoff * 10));         # Sets the offset to begin retrieving items at
+       $shelfoffset = ($itemoff - 1) * 20;             # Sets the offset to begin retrieving items at
        $shelveslimit = 20;     # Limits number of shelves returned for a given query (row_count)
-       $shelvesoffset = (($shelfoff == 1) ? 0 : ($shelfoff * 10));             # Sets the offset to begin retrieving shelves at (offset)
+       $shelvesoffset = ($shelfoff - 1) * 20;          # Sets the offset to begin retrieving shelves at (offset)
        # getting the Shelves list
        my $category = (($displaymode eq 'privateshelves') ? 1 : 2);
        my ($shelflist, $totshelves) = GetShelves( $category, $shelveslimit, $shelvesoffset, $loggedinuser );