Add the ability to browse applications by rating and a unit test for the added Application::getWithRating()
This commit is contained in:
@@ -9,6 +9,14 @@ require_once(BASE."include/category.php");
|
||||
require_once(BASE."include/url.php");
|
||||
require_once(BASE."include/util.php");
|
||||
require_once(BASE."include/mail.php");
|
||||
|
||||
define("PLATINUM_RATING", "Platinum");
|
||||
define("GOLD_RATING", "Gold");
|
||||
define("SILVER_RATING", "Silver");
|
||||
define("BRONZE_RATING", "Bronze");
|
||||
define("GARBAGE_RATING", "Garbage");
|
||||
|
||||
|
||||
/**
|
||||
* Application class for handling applications.
|
||||
*/
|
||||
@@ -358,6 +366,38 @@ class Application {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function countWithRating($sRating)
|
||||
{
|
||||
$sQuery = "SELECT DISTINCT count(appId) as total
|
||||
FROM appVersion
|
||||
WHERE maintainer_rating = '?'";
|
||||
|
||||
if($hResult = query_parameters($sQuery, $sRating))
|
||||
{
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
}
|
||||
return $oRow->total;
|
||||
}
|
||||
|
||||
function getWithRating($sRating, $iOffset, $iItemsPerPage)
|
||||
{
|
||||
$aApps = array();
|
||||
$sQuery = "SELECT DISTINCT appId
|
||||
FROM appVersion
|
||||
WHERE maintainer_rating = '?'
|
||||
ORDER BY appId ASC LIMIT ?, ?";
|
||||
|
||||
if($hResult = query_parameters($sQuery, $sRating, $iOffset, $iItemsPerPage))
|
||||
{
|
||||
while($aRow = mysql_fetch_row($hResult))
|
||||
{
|
||||
array_push($aApps, $aRow[0]);
|
||||
}
|
||||
}
|
||||
return $aApps;
|
||||
}
|
||||
|
||||
function SendNotificationMail($sAction="add",$sMsg=null)
|
||||
{
|
||||
$aClean = array(); //array of filtered user input
|
||||
|
||||
@@ -23,6 +23,7 @@ function global_sidebar_menu() {
|
||||
$g->add("AppDB Home", BASE);
|
||||
$g->add("Screenshots", BASE."viewScreenshots.php");
|
||||
$g->add("Browse Apps", BASE."appbrowse.php");
|
||||
$g->add("Browse Apps by Rating", BASE."browse_by_rating.php");
|
||||
$g->add("Top 25", BASE."votestats.php");
|
||||
$g->add("Submit Application", BASE."appsubmit.php?sSub=view&sAppType=application");
|
||||
$g->add("Help & Documentation", BASE."help/");
|
||||
|
||||
Reference in New Issue
Block a user