Make votes version specific
This commit is contained in:
committed by
WineHQ
parent
625a8e2842
commit
f3dae72762
@@ -3,18 +3,18 @@
|
||||
<h3>Application Voting System Help</h3>
|
||||
|
||||
<p>
|
||||
The Application Database features a voting system that allows you to pick which <b>3</b> applications
|
||||
The Application Database features a voting system that allows you to pick which <b>3</b> application verions
|
||||
you would MOST like to see running in Wine.
|
||||
</p>
|
||||
|
||||
<p><b>Step by Step help on Voting</b></p>
|
||||
<p><b>Step by Step Help on Voting</b></p>
|
||||
<ol>
|
||||
|
||||
<li>Log into the Application Database.</li><p>
|
||||
|
||||
<li>Browse to the Application you wish to add to your vote list.</li><p>
|
||||
<li>Browse to the application version you wish to add to your vote list.</li><p>
|
||||
|
||||
<li>In the sidebar, Click one of the 3 available slots, and click Vote.</li><p>
|
||||
<li>In the sidebar, click one of the 3 available slots, and click Vote.</li><p>
|
||||
|
||||
<li>Done!</li></p>
|
||||
|
||||
@@ -25,14 +25,12 @@ you would MOST like to see running in Wine.
|
||||
|
||||
<ul>
|
||||
|
||||
<li><i>Please</i> seriously only vote for applications which will benefit the community. Don't
|
||||
vote for applications that are known to work well. We know Solitaire works. Voting for it
|
||||
would not make much sense.</li>
|
||||
<li><i>Please</i> seriously only vote for applications which will benefit the
|
||||
community. Don’t vote for applications that are known to be working well.
|
||||
We know Solitaire works. Voting for it would not make much sense.</li>
|
||||
|
||||
<li>When voting for an application, you are voting for <b>ALL</b> its various versions.</li>
|
||||
|
||||
<li>You can clear your vote at anytime. Simply browse to any application
|
||||
in the database, select the slot you want to clear, and click the Clear
|
||||
version in the database, select the slot you want to clear, and click the Clear
|
||||
button.</li>
|
||||
|
||||
</ul>
|
||||
|
||||
@@ -613,10 +613,6 @@ class Application {
|
||||
if(!$_SESSION['current']->canViewApplication($this))
|
||||
util_show_error_page_and_exit("Something went wrong with the application or version id");
|
||||
|
||||
// show Vote Menu
|
||||
if($_SESSION['current']->isLoggedIn())
|
||||
apidb_sidebar_add("vote_menu");
|
||||
|
||||
// header
|
||||
apidb_header("Viewing App - ".$this->sName);
|
||||
|
||||
@@ -640,12 +636,10 @@ class Application {
|
||||
echo " <tr class=color0 valign=top><td width=\"100\"><b>Name</b></td><td width='100%'> ".$this->sName." </td>\n";
|
||||
echo " <tr class=\"color1\"><td><b>Vendor</b></td><td> ".
|
||||
" <a href='vendorview.php?iVendorId=$oVendor->iVendorId'> ".$oVendor->sName." </a> \n";
|
||||
echo " <tr class=\"color0\"><td><b>Votes</b></td><td> ";
|
||||
echo vote_count_app_total($this->iAppId);
|
||||
echo " </td></tr>\n";
|
||||
|
||||
// main URL
|
||||
echo " <tr class=\"color1\"><td><b>URL</b></td><td>".$appLinkURL."</td></tr>\n";
|
||||
echo " <tr class=\"color0\"><td><b>URL</b></td><td>".$appLinkURL."</td></tr>\n";
|
||||
|
||||
// optional links
|
||||
if($sUrls = url::display(NULL, $this->iAppId))
|
||||
|
||||
@@ -279,11 +279,11 @@ function outputTopXRowAppsFromRating($rating, $iNum_apps)
|
||||
/* them again when filling in any empty spots in the list */
|
||||
$appIdArray = array();
|
||||
|
||||
$sQuery = "SELECT appVotes.appId AS appId, appVersion.versionId, COUNT( appVotes.appId ) AS c
|
||||
$sQuery = "SELECT appVotes.versionId, COUNT( appVotes.versionId ) AS c
|
||||
FROM appVotes, appVersion
|
||||
WHERE appVersion.maintainer_rating = '?'
|
||||
AND appVersion.appId = appVotes.appId
|
||||
GROUP BY appVotes.appId
|
||||
AND appVersion.versionId = appVotes.versionId
|
||||
GROUP BY appVotes.versionId
|
||||
ORDER BY c DESC
|
||||
LIMIT ?";
|
||||
$hResult = query_parameters($sQuery, $rating, $iNum_apps);
|
||||
@@ -298,7 +298,7 @@ function outputTopXRowAppsFromRating($rating, $iNum_apps)
|
||||
if(!$iNum_apps) return;
|
||||
|
||||
/* if we have any empty spots in the list, get these from applications with images */
|
||||
$sQuery = "SELECT DISTINCT appVersion.appId as appId, appVersion.versionId
|
||||
$sQuery = "SELECT DISTINCT appVersion.versionId
|
||||
FROM appVersion, appData
|
||||
WHERE appVersion.maintainer_rating = '$rating'
|
||||
AND appVersion.versionId = appData.versionId
|
||||
@@ -307,7 +307,7 @@ function outputTopXRowAppsFromRating($rating, $iNum_apps)
|
||||
|
||||
/* make sure we exclude any apps we've already output */
|
||||
foreach($appIdArray as $key=>$value)
|
||||
$sQuery.="AND appVersion.appId != '".$value."' ";
|
||||
$sQuery.="AND appVersion.versionId != '".$value."' ";
|
||||
|
||||
$sQuery.=" LIMIT $iNum_apps";
|
||||
|
||||
|
||||
@@ -668,8 +668,8 @@ class Version {
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/* retrieves values from $aValues that were output by OutputEditor() */
|
||||
/* $aValues can be $_REQUEST or any array with the values from OutputEditor() */
|
||||
/* retrieves values from $aValues that were output by outputEditor() */
|
||||
/* $aValues can be $_REQUEST or any array with the values from outputEditor() */
|
||||
function GetOutputEditorValues($aValues)
|
||||
{
|
||||
$this->iAppId = $aValues['iAppId'];
|
||||
@@ -930,6 +930,24 @@ class Version {
|
||||
return $ob->versionName;
|
||||
}
|
||||
|
||||
function fullName($iVersionId)
|
||||
{
|
||||
if(!$iVersionId)
|
||||
return FALSE;
|
||||
|
||||
$hResult = query_parameters(
|
||||
"SELECT appFamily.appName, appVersion.versionName
|
||||
FROM appVersion, appFamily WHERE appVersion.appId = appFamily.appId
|
||||
AND versionId = '?'",
|
||||
$iVersionId);
|
||||
|
||||
if(!$hResult || !mysql_num_rows($hResult))
|
||||
return FALSE;
|
||||
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
return "$oRow->appName $oRow->versionName";
|
||||
}
|
||||
|
||||
function showList($hResult)
|
||||
{
|
||||
//show applist
|
||||
|
||||
@@ -3,11 +3,10 @@ require_once(BASE."include/util.php");
|
||||
/* max votes per user */
|
||||
define('MAX_VOTES',3);
|
||||
|
||||
|
||||
/**
|
||||
* count the number of votes for appId by userId
|
||||
*/
|
||||
function vote_count($iAppId, $iUserId = null)
|
||||
function vote_count($iVersionId, $iUserId = null)
|
||||
{
|
||||
if(!$iUserId)
|
||||
{
|
||||
@@ -16,8 +15,8 @@ function vote_count($iAppId, $iUserId = null)
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
$hResult = query_parameters("SELECT * FROM appVotes WHERE appId = '?' AND userId = '?'",
|
||||
$iAppId, $iUserId);
|
||||
$hResult = query_parameters("SELECT * FROM appVotes WHERE versionId = '?' AND userId = '?'",
|
||||
$iVersionId, $iUserId);
|
||||
return mysql_num_rows($hResult);
|
||||
}
|
||||
|
||||
@@ -40,11 +39,12 @@ function vote_count_user_total($iUserId = null)
|
||||
|
||||
|
||||
/*
|
||||
* total votes for appId
|
||||
* total votes for versionId
|
||||
*/
|
||||
function vote_count_app_total($iAppId)
|
||||
function vote_count_version_total($iVersionId)
|
||||
{
|
||||
$hResult = query_parameters("SELECT * FROM appVotes WHERE appId = '?'", $iAppId);
|
||||
$hResult = query_parameters("SELECT * FROM appVotes WHERE versionId = '?'",
|
||||
$iVersionId);
|
||||
return mysql_num_rows($hResult);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ function vote_count_app_total($iAppId)
|
||||
/**
|
||||
* add a vote for appId
|
||||
*/
|
||||
function vote_add($iAppId, $iSlot, $iUserId = null)
|
||||
function vote_add($iVersionId, $iSlot, $iUserId = null)
|
||||
{
|
||||
if(!$iUserId)
|
||||
{
|
||||
@@ -67,8 +67,9 @@ function vote_add($iAppId, $iSlot, $iUserId = null)
|
||||
|
||||
vote_remove($iSlot, $iUserId);
|
||||
|
||||
query_parameters("INSERT INTO appVotes (id, time, appId, userId, slot)
|
||||
VALUES (?, ?, '?', '?', '?')", "null", "null", $iAppId, $iUserId, $iSlot);
|
||||
query_parameters("INSERT INTO appVotes (id, time, versionId, userId, slot)
|
||||
VALUES (?, ?, '?', '?', '?')", "null", "null",
|
||||
$iVersionId, $iUserId, $iSlot);
|
||||
}
|
||||
|
||||
|
||||
@@ -115,19 +116,21 @@ function vote_menu()
|
||||
global $aClean;
|
||||
|
||||
$m = new htmlmenu("Votes","updatevote.php");
|
||||
|
||||
|
||||
$votes = vote_get_user_votes();
|
||||
|
||||
for($i = 1;$i <= MAX_VOTES; $i++)
|
||||
{
|
||||
if(isset($votes[$i]))
|
||||
{
|
||||
$sAppName = Application::lookup_name($votes[$i]->appId);
|
||||
$str = "<a href='appview.php?iAppId=".$votes[$i]->appId."'> $sAppName</a>";
|
||||
$m->add("<input type=radio name=iSlot value='$i'> ".$str);
|
||||
$sName = Version::fullName($votes[$i]->versionId);
|
||||
$str = "<a href='appview.php?iVersionId=".$votes[$i]->versionId."'>".
|
||||
"$sName</a>";
|
||||
}
|
||||
else
|
||||
$m->add("<input type=radio name=iSlot value='$i'> No App Selected");
|
||||
$str = "No App Selected";
|
||||
|
||||
$m->add("<input type=radio name=iSlot value='$i'> $str");
|
||||
}
|
||||
|
||||
$m->addmisc(" ");
|
||||
@@ -135,7 +138,7 @@ function vote_menu()
|
||||
$m->add("<input type=submit name=sClear value=' Clear Vote ' class=votebutton>");
|
||||
$m->add("<input type=submit name=sVote value='Vote for App' class=votebutton>");
|
||||
|
||||
$m->addmisc("<input type=hidden name=iAppId value={$aClean['iAppId']}>");
|
||||
$m->addmisc("<input type=hidden name=iVersionId value={$aClean['iVersionId']}>");
|
||||
|
||||
$m->add("View Results", BASE."votestats.php");
|
||||
$m->add("Voting Help", BASE."help/?sTopic=voting");
|
||||
@@ -149,10 +152,11 @@ function vote_update($vars)
|
||||
if(!$_SESSION['current']->isLoggedIn())
|
||||
util_show_error_page_and_exit("You must be logged in to vote");
|
||||
|
||||
if( !is_numeric($vars['iAppId']) OR !is_numeric($vars['iSlot']))
|
||||
if( !is_numeric($vars['iVersionId']) OR !is_numeric($vars['iSlot']))
|
||||
{
|
||||
if(is_numeric($vars['iAppId']))
|
||||
util_redirect_and_exit(apidb_fullurl("appview.php?iAppId=".$vars['iAppId']));
|
||||
if(is_numeric($vars['iVersionId']))
|
||||
util_redirect_and_exit(apidb_fullurl(
|
||||
"appview.php?iVersionId=".$vars['iVersionId']));
|
||||
else
|
||||
util_redirect_and_exit(apidb_fullurl("index.php"));
|
||||
|
||||
@@ -161,8 +165,8 @@ function vote_update($vars)
|
||||
|
||||
if($vars["sVote"])
|
||||
{
|
||||
addmsg("Registered vote for App #".$vars['iAppId'], "green");
|
||||
vote_add($vars['iAppId'], $vars['iSlot']);
|
||||
addmsg("Registered vote for App #".$vars['iVersionId'], "green");
|
||||
vote_add($vars['iVersionId'], $vars['iSlot']);
|
||||
} else if($vars['sClear'])
|
||||
{
|
||||
/* see if we have a vote in this slot, if we don't there is */
|
||||
@@ -170,11 +174,12 @@ function vote_update($vars)
|
||||
if(is_vote_in_slot($vars['iSlot']))
|
||||
{
|
||||
vote_remove($vars['iSlot']);
|
||||
addmsg("Removed vote for App #".$vars['iAppId'], "green");
|
||||
addmsg("Removed vote for App #".$vars['iVersionId'], "green");
|
||||
}
|
||||
}
|
||||
|
||||
util_redirect_and_exit(apidb_fullurl("appview.php?iAppId=".$vars['iAppId']));
|
||||
util_redirect_and_exit(apidb_fullurl(
|
||||
"appview.php?iVersionId=".$vars['iVersionId']));
|
||||
}
|
||||
|
||||
// tell us if there is a vote in a given slot so we don't
|
||||
|
||||
15
index.php
15
index.php
@@ -59,21 +59,20 @@ If you have screenshots or links to contribute, please browse the database and u
|
||||
|
||||
$numApps = getNumberOfVersions();
|
||||
|
||||
$voteQuery = "SELECT appVotes.appId, appName, count(userId) as count ".
|
||||
"FROM appVotes, appFamily ".
|
||||
"WHERE appVotes.appId = appFamily.appId ".
|
||||
"GROUP BY appId ORDER BY count DESC LIMIT 1";
|
||||
$voteQuery = "SELECT appVotes.versionId, count(userId) as count ".
|
||||
"FROM appVotes ".
|
||||
"GROUP BY versionId ORDER BY count DESC LIMIT 1";
|
||||
$hResult = query_parameters($voteQuery);
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
|
||||
$voteAppId = $oRow->appId;
|
||||
$voteAppName = $oRow->appName;
|
||||
$sVoteVersionId = $oRow->versionId;
|
||||
$sVoteAppName = version::fullName($oRow->versionId);
|
||||
|
||||
// don't mention the top application if there are no votes yet
|
||||
if($voteAppId != "")
|
||||
if($sVoteVersionId != "")
|
||||
{
|
||||
echo "There are <b>$numApps</b> applications currently in the database with\n";
|
||||
echo "<a href='appview.php?iAppId=$voteAppId'>$voteAppName</a> being the\n";
|
||||
echo "<a href='appview.php?iVersionId=$sVoteVersionId'>$sVoteAppName</a> being the\n";
|
||||
echo "top <a href='votestats.php'>voted</a> application.\n";
|
||||
} else
|
||||
{
|
||||
|
||||
@@ -152,11 +152,11 @@ create table appData (
|
||||
create table appVotes (
|
||||
id int not null auto_increment,
|
||||
time timestamp,
|
||||
appId int not null,
|
||||
versionId int not null,
|
||||
userId int not null,
|
||||
slot int not null,
|
||||
key(id),
|
||||
index(appId),
|
||||
index(versionId),
|
||||
index(userId)
|
||||
);
|
||||
|
||||
|
||||
@@ -125,10 +125,13 @@ echo '<br />';
|
||||
if(empty($aClean['iCategoryId']))
|
||||
{
|
||||
/* leave out the appFamily.catId = '$aClean['iCategoryId']' */
|
||||
$hResult = query_parameters("SELECT appVotes.appId, appName, count(userId) as count ".
|
||||
"FROM appVotes, appFamily ".
|
||||
"WHERE appVotes.appId = appFamily.appId ".
|
||||
"GROUP BY appId ORDER BY count DESC LIMIT ?", $aClean['iTopNumber']);
|
||||
$hResult = query_parameters("SELECT appVotes.versionId, appName, count(userId) as
|
||||
count
|
||||
FROM appVotes, appFamily, appVersion
|
||||
WHERE appVotes.versionId = appVersion.versionId AND
|
||||
appFamily.appId = appVersion.appId
|
||||
GROUP BY appVotes.versionId ORDER BY count DESC LIMIT ?",
|
||||
$aClean['iTopNumber']);
|
||||
} else
|
||||
{
|
||||
/* Display all application for a given category (including sub categories)
|
||||
@@ -139,15 +142,16 @@ if(empty($aClean['iCategoryId']))
|
||||
c.catId =29
|
||||
OR c.catParent =29)*/
|
||||
|
||||
$hResult = query_parameters("SELECT v.appId, f.appName, count( v.appId ) AS count
|
||||
FROM appFamily AS f, appCategory AS c, appVotes AS v
|
||||
WHERE v.appId = f.appId
|
||||
$hResult = query_parameters("SELECT v.versionId, f.appName, count( v.versionId ) AS count
|
||||
FROM appFamily AS f, appCategory AS c, appVotes AS v, appVersion
|
||||
WHERE appVersion.appId = f.appId
|
||||
AND appVersion.versionId = v.versionId
|
||||
AND f.catId = c.catId
|
||||
AND (
|
||||
c.catId = '?'
|
||||
OR c.catParent = '?'
|
||||
)
|
||||
GROUP BY appId
|
||||
GROUP BY v.versionId
|
||||
ORDER BY count DESC LIMIT ?", $aClean['iCategoryId'], $aClean['iCategoryId'], $aClean['iTopNumber']);
|
||||
}
|
||||
|
||||
@@ -162,7 +166,7 @@ if($hResult)
|
||||
while($row = mysql_fetch_object($hResult))
|
||||
{
|
||||
$bgcolor = ($c % 2) ? "color0" : "color1";
|
||||
$link = "<a href='appview.php?iAppId=$row->appId'>$row->appName</a>";
|
||||
$link = "<a href='appview.php?iVersionId=$row->versionId'>$row->appName</a>";
|
||||
echo "<tr class=$bgcolor><td width='90%'>$c. $link </td> <td> $row->count </td></tr>\n";
|
||||
$c++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user