mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Fix pkgbase_user_voted()
pkgbase_user_voted() should expect a package base ID, not a package ID. Change the SQL query accordingly. This fixes the vote status on package base pages. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
c004429023
commit
5b5a5f343e
1 changed files with 10 additions and 14 deletions
|
@ -703,28 +703,24 @@ function pkgbase_votes_from_name($pkgname) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if a user has already voted for a specific package
|
* Determine if a user has already voted for a specific package base
|
||||||
*
|
*
|
||||||
* @param string $uid The user ID to check for an existing vote
|
* @param string $uid The user ID to check for an existing vote
|
||||||
* @param string $pkgid The package ID to check for an existing vote
|
* @param string $base_id The package base ID to check for an existing vote
|
||||||
*
|
*
|
||||||
* @return bool True if the user has already voted, otherwise false
|
* @return bool True if the user has already voted, otherwise false
|
||||||
*/
|
*/
|
||||||
function pkgbase_user_voted($uid, $pkgid) {
|
function pkgbase_user_voted($uid, $base_id) {
|
||||||
$dbh = DB::connect();
|
$dbh = DB::connect();
|
||||||
|
$q = "SELECT COUNT(*) FROM PackageVotes WHERE ";
|
||||||
$q = "SELECT * FROM PackageVotes, Packages WHERE ";
|
$q.= "UsersID = ". $dbh->quote($uid) . " AND ";
|
||||||
$q.= "PackageVotes.UsersID = ". $dbh->quote($uid) . " AND ";
|
$q.= "PackageBaseID = " . $dbh->quote($base_id);
|
||||||
$q.= "PackageVotes.PackageBaseID = Packages.PackageBaseID AND ";
|
|
||||||
$q.= "Packages.ID = " . $dbh->quote($pkgid);
|
|
||||||
$result = $dbh->query($q);
|
$result = $dbh->query($q);
|
||||||
|
if (!$result) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if ($result->fetch(PDO::FETCH_NUM)) {
|
return ($result->fetch(PDO::FETCH_COLUMN, 0) > 0);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue