diff --git a/browse_by_rating.php b/browse_by_rating.php
new file mode 100644
index 0000000..267599f
--- /dev/null
+++ b/browse_by_rating.php
@@ -0,0 +1,182 @@
+Main";
+
+echo html_frame_start("", '98%', '', 2);
+
+if (empty($aClean['sRating']))
+{
+ echo "Rating: $sPathtrail";
+ echo html_frame_end();
+ echo html_frame_start("", '98%', '', 2);
+ echo "
\n";
+ echo " | Rating | \n";
+ echo " Description | \n";
+ echo " No. Apps | \n";
+ echo " \n";
+ html_tr_highlight_clickable("browse_by_rating.php?sRating=".PLATINUM_RATING, "platinum", "platinum", "platinum");
+ echo " Platinum | ";
+ echo " Applications that install and run out of the box | \n";
+ echo " ".Application::countWithRating(PLATINUM_RATING)." | \n";
+ echo " \n";
+ html_tr_highlight_clickable("browse_by_rating.php?sRating=".GOLD_RATING, "gold", "gold", "gold");
+ echo " Gold | ";
+ echo " Applications that work flawlessly with some DLL overrides or other settings, crack etc. | \n";
+ echo " ".Application::countWithRating(GOLD_RATING)." | \n";
+ echo " \n";
+ html_tr_highlight_clickable("browse_by_rating.php?sRating=".SILVER_RATING, "silver", "silver", "silver");
+ echo " Silver | ";
+ echo " Applications that work excellently for 'normal use' | \n";
+ echo " ".Application::countWithRating(SILVER_RATING)." | \n";
+ echo " \n";
+ html_tr_highlight_clickable("browse_by_rating.php?sRating=".BRONZE_RATING, "bronze", "bronze", "bronze");
+ echo " Bronze | ";
+ echo " Applications that work but have some issues, even for 'normal use' | \n";
+ echo " ".Application::countWithRating(BRONZE_RATING)." | \n";
+ echo " \n";
+ html_tr_highlight_clickable("browse_by_rating.php?sRating=".GARBAGE_RATING, "garbage", "garbage", "garbage");
+ echo " Garbage | ";
+ echo " Applications that don't work as intended, there should be at least one bug report if an app gets this rating | \n";
+ echo " ".Application::countWithRating(GARBAGE_RATING)." | \n";
+ echo " \n";
+ echo "
\n";
+
+ echo html_frame_end();
+} else
+{
+ /* display a range of 10 pages */
+ $iPageRange = 10;
+ $iItemsPerPage = 50;
+ $iCurrentPage = 1;
+
+ if($aClean['iItemsPerPage'])
+ $iItemsPerPage = $aClean['iItemsPerPage'];
+ if($aClean['iPage'])
+ $iCurrentPage = $aClean['iPage'];
+
+ $iItemsPerPage = min($iItemsPerPage,500);
+
+ switch($aClean['sRating'])
+ {
+ case PLATINUM_RATING:
+ $sPathtrail.=" > Platinum";
+ $iTotalPages = ceil(Application::countWithRating(PLATINUM_RATING)/$iItemsPerPage);
+ $sRating = PLATINUM_RATING;
+ break;
+
+ case GOLD_RATING:
+ $sPathtrail.=" > Gold";
+ $iTotalPages = ceil(Application::countWithRating(GOLD_RATING)/$iItemsPerPage);
+ $sRating = GOLD_RATING;
+ break;
+
+ case SILVER_RATING:
+ $sPathtrail.=" > Silver";
+ $iTotalPages = ceil(Application::countWithRating(SILVER_RATING)/$iItemsPerPage);
+ $sRating = SILVER_RATING;
+ break;
+ case BRONZE_RATING:
+ $sPathtrail.=" > Bronze";
+ $iTotalPages = ceil(Application::countWithRating(BRONZE_RATING)/$iItemsPerPage);
+ $sRating = BRONZE_RATING;
+ break;
+ case GARBAGE_RATING:
+ $sPathtrail.=" > Garbage";
+ $iTotalPages = ceil(Application::countWithRating(GARBAGE_RATING)/$iItemsPerPage);
+ $sRating=GARBAGE_RATING;
+ break;
+
+ }
+
+ $iCurrentPage = min($iCurrentPage,$iTotalPages);
+ $iOffset = (($iCurrentPage-1) * $iItemsPerPage);
+ $apps=Application::getWithRating($sRating, $iOffset, $iItemsPerPage);
+
+ echo "Rating: $sPathtrail";
+ echo html_frame_end();
+
+
+
+
+ /* display page selection links */
+ echo "
";
+ echo "Page $iCurrentPage of $iTotalPages
";
+ display_page_range($iCurrentPage, $iPageRange, $iTotalPages,
+ $_SERVER['PHP_SELF']."?sRating=".$aClean['sRating']."&iItemsPerPage=".$iItemsPerPage);
+ echo "
";
+ echo "
";
+
+ /* display the option to choose how many applications per-page to display */
+ echo '";
+ echo "";
+
+ echo html_frame_start("","98%","",0);
+ echo "\n\n";
+
+ echo "\n";
+ echo " | Application Name | \n";
+ echo " Description | \n";
+ echo " No. Versions | \n";
+ echo "
\n\n";
+
+ while(list($i, $iAppId) = each($apps))
+ {
+ $oApp = new Application($iAppId);
+
+ //set row color
+ $bgcolor = ($i % 2) ? "color0" : "color1";
+
+ //format desc
+ $desc = util_trim_description($oApp->sDescription);
+
+ //display row
+ echo "\n";
+ echo " | ".$oApp->sName." | \n";
+ echo " $desc | \n";
+ echo " ".sizeof($oApp->aVersionsIds)." | \n";
+ echo "
\n\n";
+ }
+
+ echo "
\n\n";
+
+ echo html_frame_end();
+ echo "";
+ display_page_range($iCurrentPage, $iPageRange, $iTotalPages,
+ $_SERVER['PHP_SELF']."?sRating=".$aClean['sRating']."&iItemsPerPage=".$iItemsPerPage);
+ echo "";
+}
+
+
+apidb_footer();
+
+?>
diff --git a/include/application.php b/include/application.php
index e8935a6..caf3c71 100644
--- a/include/application.php
+++ b/include/application.php
@@ -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
diff --git a/include/sidebar.php b/include/sidebar.php
index 949470a..abdc7f5 100644
--- a/include/sidebar.php
+++ b/include/sidebar.php
@@ -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/");
diff --git a/index.php b/index.php
index d2032e1..63606a5 100644
--- a/index.php
+++ b/index.php
@@ -88,7 +88,7 @@ If you have screenshots or links to contribute, please browse the database and u
This is a list of applications that are known to be working well and for which many AppDB users voted.
-The top-10 Platinum List
+
Only Applications which install and run flawless on a out-of-the-box Wine installation make it to the Platinum list:
@@ -100,7 +100,7 @@ If you have screenshots or links to contribute, please browse the database and u
-The top-10 Gold List
+The top-10 Gold List
Applications that work flawlessly with some DLL overrides or other settings, crack etc make it to the Gold list:
@@ -112,7 +112,7 @@ If you have screenshots or links to contribute, please browse the database and u
-The top-10 Silver List
+
The Silver list contains apps which we hope we can easily fix so they make it to Gold status:
diff --git a/unit_test/test_application.php b/unit_test/test_application.php
index b412072..b6a9420 100644
--- a/unit_test/test_application.php
+++ b/unit_test/test_application.php
@@ -17,39 +17,9 @@ function test_application_delete()
{
test_start(__FUNCTION__);
- global $test_email, $test_password;
-
- $oUser = new User();
-
- /* delete the user if they already exist */
- if($oUser->login($test_email, $test_password) == SUCCESS)
- {
- $oUser->delete();
- $oUser = new User();
- }
-
- /* create the user */
- $retval = $oUser->create("testemail@somesite.com", "password", "Test user", "20051020");
- if($retval != SUCCESS)
- {
- if($retval == USER_CREATE_EXISTS)
- echo "The user already exists!\n";
- else if($retval == USER_LOGIN_FAILED)
- echo "User login failed!\n";
- else
- echo "ERROR: UNKNOWN ERROR!!\n";
-
+ if(!$oUser = create_and_login_user())
return false;
- }
-
- /* login the user */
- $retval = $oUser->login($test_email, $test_password);
- if($retval != SUCCESS)
- {
- echo "Got '".$retval."' instead of SUCCESS(".SUCCESS.")\n";
- return false;
- }
-
+
/* make this user an admin so we can create applications without having them queued */
$hResult = query_parameters("INSERT into user_privs values ('?', '?')",
$oUser->iUserId, "admin");
@@ -67,16 +37,12 @@ function test_application_delete()
$iAppId = $oApp->iAppId; /* use the iAppId of the application we just created */
- $iVersionIdBase = 400000;
for($iVersionIdIndex = 0; $iVersionIdIndex < 10; $iVersionIdIndex++)
{
- $iVersionId = $iVersionIdBase + $iVersionIdIndex;
-
$oVersion = new Version();
- $oVersion->versionName = "Some Version".$iVersionId;
- $oVersion->description = "Some Version description".$iVersionId;
+ $oVersion->versionName = "Some Version".$iVersionIdIndex;
+ $oVersion->description = "Some Version description".$iVersionIdIndex;
$oVersion->iAppId = $oApp->iAppId;
- $oVersion->iVersionId = $iVersionId;
if(!$oVersion->create())
{
@@ -107,16 +73,145 @@ function test_application_delete()
}
+
+function test_application_getWithRating()
+{
+ test_start(__FUNCTION__);
+
+ if(!$oUser = create_and_login_user())
+ return false;
+
+ /* make this user an admin so we can create applications without having them queued */
+ $hResult = query_parameters("INSERT into user_privs values ('?', '?')",
+ $oUser->iUserId, "admin");
+
+ $oApp = new Application();
+ $oApp->sName = "Some application";
+ $oApp->sDescription = "some description";
+ $oApp->submitterId = $oUser->iUserId;
+ if(!$oApp->create())
+ {
+ $oUser->delete();
+ echo "Failed to create application!\n";
+ return false;
+ }
+
+ $iAppId = $oApp->iAppId; /* use the iAppId of the application we just created */
+
+
+ /* Create several versions of the new application to test uniqueness of getWithRating() results */
+
+ for($iVersionIdIndex = 0; $iVersionIdIndex < 10; $iVersionIdIndex++)
+ {
+ $oVersion = new Version();
+ $oVersion->versionName = "Some Version".$iVersionIdIndex;
+ $oVersion->description = "Some Version description".$iVersionIdIndex;
+ $oVersion->iAppId = $oApp->iAppId;
+
+
+ /* Create Several Ratings, some duplicate */
+ if ($iVersionIdIndex < 4)
+ {
+ $oVersion->sTestedRating = "Platinum";
+ }
+ elseif ($iVersionIdIndex < 8)
+ {
+ $oVersion->sTestedRating = "Gold";
+ }
+ else
+ {
+ $oVersion->sTestedRating = "Bronze";
+ }
+
+ if(!$oVersion->create())
+ {
+ delete_app_and_user($oApp, $oUser);
+ echo "Failed to create version!\n";
+ return false;
+ }
+ }
+
+
+ $iItemsPerPage = 50;
+ $iOffset = 0;
+ $sRating = 'Bronze';
+ $aApps=Application::getWithRating($sRating, $iOffset, $iItemsPerPage);
+ $aTest = array();//array to test the uniqueness our query results
+ while(list($i, $iId) = each($aApps)) //cycle through results returned by getWithRating
+ {
+ if ( in_array($iId, $aTest) ) //if the appId is already in our test results fail unique test
+ {
+ delete_app_and_user($oApp, $oUser);
+ echo "getWithRating failed to return a unique result set\n";
+ return false;
+ }
+
+ array_push($aTest, $iId); //push the appId on to our test array
+
+ }
+
+
+ delete_app_and_user($oApp, $oUser);
+
+ return true;
+}
+
+
function delete_app_and_user($oApp, $oUser)
{
$oApp->delete();
$oUser->delete();
}
+function create_and_login_user()
+{
+ global $test_email, $test_password;
+
+ $oUser = new User();
+
+ /* delete the user if they already exist */
+ if($oUser->login($test_email, $test_password) == SUCCESS)
+ {
+ $oUser->delete();
+ $oUser = new User();
+ }
+
+ /* create the user */
+ $retval = $oUser->create("$test_email", "$test_password", "Test user", "20051020");
+ if($retval != SUCCESS)
+ {
+ if($retval == USER_CREATE_EXISTS)
+ echo "The user already exists!\n";
+ else if($retval == USER_LOGIN_FAILED)
+ echo "User login failed!\n";
+ else
+ echo "ERROR: UNKNOWN ERROR!!\n";
+
+ return false;
+ }
+
+ /* login the user */
+ $retval = $oUser->login($test_email, $test_password);
+ if($retval != SUCCESS)
+ {
+ echo "Got '".$retval."' instead of SUCCESS(".SUCCESS.")\n";
+ return false;
+ }
+
+ return $oUser;
+
+}
+
if(!test_application_delete())
echo "test_application_delete() failed!\n";
else
echo "test_application_delete() passed!\n";
+
+if(!test_application_getWithRating())
+ echo "test_application_getWithRating() failed!\n";
+else
+ echo "test_application_getWithRating() passed!\n";
+
?>