Commit d03f7a89 authored by Lukas Fleischer's avatar Lukas Fleischer
Browse files

Fix pkgbase_votes_from_name()

In 676595f9

 (Prefix package functions with pkg_/pkgbase_, 2014-04-05),
votes_for_pkgname() was renamed to pkgbase_votes_from_name() without
changing the semantics. Slightly adapt the implementation and interpret
the argument as a package base name instead of a package name. Also fix
the call site.

Reported-by: default avatarFelix Yan <felixonmars@gmail.com>
Signed-off-by: default avatarLukas Fleischer <archlinux@cryptocrack.de>
parent e9b13cef
<?php <?php
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
include_once('aur.inc.php'); include_once('aur.inc.php');
include_once('pkgfuncs.inc.php'); include_once('pkgbasefuncs.inc.php');
$SID = $_COOKIE['AURSID']; $SID = $_COOKIE['AURSID'];
$pkgname = htmlspecialchars($_GET['N']); $pkgbase_name = htmlspecialchars($_GET['N']);
$votes = pkgbase_votes_from_name($pkgname); $votes = pkgbase_votes_from_name($pkgbase_name);
html_header(__("Voters")); html_header(__("Voters"));
...@@ -13,7 +13,7 @@ if (has_credential(CRED_PKGBASE_LIST_VOTERS)): ...@@ -13,7 +13,7 @@ if (has_credential(CRED_PKGBASE_LIST_VOTERS)):
?> ?>
<div class="box"> <div class="box">
<h2>Votes for <a href="<?= get_pkg_uri($pkgname); ?>"><?= $pkgname ?></a></h2> <h2>Votes for <a href="<?= get_pkgbase_uri($pkgbase_name); ?>"><?= $pkgbase_name ?></a></h2>
<div class="boxbody"> <div class="boxbody">
<ul> <ul>
<?php while (list($indx, $row) = each($votes)): ?> <?php while (list($indx, $row) = each($votes)): ?>
......
...@@ -683,19 +683,20 @@ function pkgbase_vote ($base_ids, $action=true) { ...@@ -683,19 +683,20 @@ function pkgbase_vote ($base_ids, $action=true) {
} }
/** /**
* Get all usernames and IDs that voted for a specific package * Get all usernames and IDs that voted for a specific package base
* *
* @param string $pkgname The name of the package to retrieve votes for * @param string $pkgbase_name The package base to retrieve votes for
* *
* @return array User IDs and usernames that voted for a specific package * @return array User IDs and usernames that voted for a specific package base
*/ */
function pkgbase_votes_from_name($pkgname) { function pkgbase_votes_from_name($pkgbase_name) {
$dbh = DB::connect(); $dbh = DB::connect();
$q = "SELECT UsersID,Username,Name FROM PackageVotes "; $q = "SELECT UsersID, Username, Name FROM PackageVotes ";
$q.= "LEFT JOIN Users on (UsersID = Users.ID) "; $q.= "LEFT JOIN Users ON UsersID = Users.ID ";
$q.= "LEFT JOIN Packages on (PackageVotes.PackageBaseID = Packages.PackageBaseID) "; $q.= "LEFT JOIN PackageBases ";
$q.= "WHERE Name = ". $dbh->quote($pkgname) . " "; $q.= "ON PackageVotes.PackageBaseID = PackageBases.ID ";
$q.= "WHERE PackageBases.Name = ". $dbh->quote($pkgbase_name) . " ";
$q.= "ORDER BY Username"; $q.= "ORDER BY Username";
$result = $dbh->query($q); $result = $dbh->query($q);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment