summaryrefslogtreecommitdiffstats
path: root/web/lib/pkgfuncs.inc.php
diff options
context:
space:
mode:
authorcanyonknight <canyonknight@gmail.com>2014-01-21 02:42:44 +0100
committerLukas Fleischer <archlinux@cryptocrack.de>2014-01-22 18:27:42 +0100
commit1e9d539acfb609dd7a6f085295f0d068d69cb077 (patch)
tree3be78a61115771818f3284bbb632245119ff2c73 /web/lib/pkgfuncs.inc.php
parent81d4cc13dcae2f159ed937d4ce41e1df7d3c82b0 (diff)
downloadaur-1e9d539acfb609dd7a6f085295f0d068d69cb077.tar.gz
aur-1e9d539acfb609dd7a6f085295f0d068d69cb077.tar.xz
Further optimize voters.php to only need the package name
* Extends changes in 81d4cc13dcae2f159ed937d4ce41e1df7d3c82b0 * Modify getvotes() to use the package name rather than package ID * Rename getvotes() to votes_for_pkgname() for clarity with new changes * Modify routing framework and links to now use package names for voters.php Signed-off-by: canyonknight <canyonknight@gmail.com> Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/pkgfuncs.inc.php')
-rw-r--r--web/lib/pkgfuncs.inc.php11
1 files changed, 6 insertions, 5 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index a4deee6d..c1a64f76 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -1075,16 +1075,17 @@ function pkg_vote ($atype, $ids, $action=true) {
/**
* Get all usernames and IDs that voted for a specific package
*
- * @param string $pkgid The package ID to get all votes for
+ * @param string $pkgname The name of the package to retrieve votes for
*
* @return array User IDs and usernames that voted for a specific package
*/
-function getvotes($pkgid) {
+function votes_for_pkgname($pkgname) {
$dbh = DB::connect();
- $q = "SELECT UsersID,Username FROM PackageVotes ";
- $q.= "LEFT JOIN Users on (UsersID = ID) ";
- $q.= "WHERE PackageID = ". $dbh->quote($pkgid) . " ";
+ $q = "SELECT UsersID,Username,Name FROM PackageVotes ";
+ $q.= "LEFT JOIN Users on (UsersID = Users.ID) ";
+ $q.= "LEFT JOIN Packages on (PackageID = Packages.ID) ";
+ $q.= "WHERE Name = ". $dbh->quote($pkgname) . " ";
$q.= "ORDER BY Username";
$result = $dbh->query($q);