diff --git a/include/application.php b/include/application.php index 7a4d6d4..a91e503 100644 --- a/include/application.php +++ b/include/application.php @@ -343,6 +343,14 @@ class Application { addmsg("The application has been rejected.", "green"); } } + + function objectGetItemsPerPage($bQueued = false) + { + $aItemsPerPage = array(25, 50, 100, 200); + $iDefaultPerPage = 25; + return array($aItemsPerPage, $iDefaultPerPage); + } + function ReQueue() { if(!$_SESSION['current']->canRequeueApplication($this)) @@ -818,8 +826,21 @@ class Application { return $sLink; } - function objectGetEntries($bQueued, $bRejected, $sOrderBy = "appId") + function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0, $sOrderBy = "appId") { + $sLimit = ""; + + /* Should we add a limit clause to the query? */ + if($iRows || $iStart) + { + $sLimit = " LIMIT ?,?"; + + /* Selecting 0 rows makes no sense, so we assume the user wants to select all of them + after an offset given by iStart */ + if(!$iRows) + $iRows = maintainer::objectGetEntriesCount($bQueued, $bRejected); + } + $sQuery = "SELECT * FROM appFamily WHERE appFamily.queued = '?'"; @@ -831,13 +852,28 @@ class Application { if(!$bRejected) return FALSE; - $sQuery .= " AND appFamily.submitterId = '?' ORDER BY '?'"; - $hResult = query_parameters($sQuery, $sQueued, - $_SESSION['current']->iUserId, $sOrderBy); + $sQuery .= " AND appFamily.submitterId = '?' ORDER BY '?'$sLimit"; + if($sLimit) + { + $hResult = query_parameters($sQuery, $sQueued, + $_SESSION['current']->iUserId, $sOrderBy, + $iStart, $iRows); + } else + { + $hResult = query_parameters($sQuery, $sQueued, + $_SESSION['current']->iUserId, $sOrderBy); + } } else { - $sQuery .= " ORDER BY '?'"; - $hResult = query_parameters($sQuery, $sQueued, $sOrderBy); + $sQuery .= " ORDER BY '?'$sLimit"; + if($sLimit) + { + $hResult = query_parameters($sQuery, $sQueued, $sOrderBy, + $iStart, $iRows); + } else + { + $hResult = query_parameters($sQuery, $sQueued, $sOrderBy); + } } if(!$hResult) diff --git a/include/application_queue.php b/include/application_queue.php index f33e4b3..5a503c2 100644 --- a/include/application_queue.php +++ b/include/application_queue.php @@ -292,9 +292,20 @@ class application_queue return TRUE; } - function objectGetEntries($bQueued, $bRejected) + function objectGetItemsPerPage($bQueued = false) { - return $this->oApp->objectGetEntries($bQueued, $bRejected); + return $this->oApp->objectGetItemsPerPage($bQueued); + } + + function objectGetEntriesCount($bQueued, $bRejected) + { + return $this->oApp->objectGetEntriesCount($bQueued, $bRejected); + } + + function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0, $sOrderBy = "appId") + { + return $this->oApp->objectGetEntries($bQueued, $bRejected, $iRows, $iStart, + $sOrderBy); } function objectGetHeader()