mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
voters.php: Pull out DB code
* Create new function in pkgfuncs.inc.php with SQL queries from voters.php * Centralization of DB code important in a future transition to PDO interface Signed-off-by: canyonknight <canyonknight@gmail.com> Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
091c2b5f55
commit
09e50568e4
2 changed files with 27 additions and 13 deletions
|
@ -3,14 +3,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
|
||||||
include('aur.inc.php');
|
include('aur.inc.php');
|
||||||
include('pkgfuncs.inc.php');
|
include('pkgfuncs.inc.php');
|
||||||
|
|
||||||
function getvotes($pkgid) {
|
|
||||||
$dbh = db_connect();
|
|
||||||
$pkgid = db_escape_string($pkgid);
|
|
||||||
|
|
||||||
$result = db_query("SELECT UsersID,Username FROM PackageVotes LEFT JOIN Users on (UsersID = ID) WHERE PackageID = $pkgid ORDER BY Username", $dbh);
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
$SID = $_COOKIE['AURSID'];
|
$SID = $_COOKIE['AURSID'];
|
||||||
|
|
||||||
$pkgid = intval($_GET['ID']);
|
$pkgid = intval($_GET['ID']);
|
||||||
|
@ -27,11 +19,8 @@ if ($atype == 'Trusted User' || $atype== 'Developer'):
|
||||||
<div class="boxbody">
|
<div class="boxbody">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
while ($row = mysql_fetch_assoc($votes)):
|
while (list($indx, $row) = each($votes)): ?>
|
||||||
$uid = $row['UsersID'];
|
<a href="account.php?Action=AccountInfo&ID=<?php echo $row['UsersID'] ?>"><?php echo htmlspecialchars($row['Username']) ?></a><br />
|
||||||
$username = $row['Username'];
|
|
||||||
?>
|
|
||||||
<a href="account.php?Action=AccountInfo&ID=<?php echo $uid ?>"><?php echo htmlspecialchars($username) ?></a><br />
|
|
||||||
<?php endwhile; ?>
|
<?php endwhile; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -948,6 +948,31 @@ function pkg_vote ($atype, $ids, $action=true, $dbh=NULL) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Get all usernames and ids for a specifc package id
|
||||||
|
function getvotes($pkgid, $dbh=NULL) {
|
||||||
|
if(!$dbh) {
|
||||||
|
$dbh = db_connect();
|
||||||
|
}
|
||||||
|
|
||||||
|
$pkgid = db_escape_string($pkgid);
|
||||||
|
|
||||||
|
$q = "SELECT UsersID,Username FROM PackageVotes ";
|
||||||
|
$q.= "LEFT JOIN Users on (UsersID = ID) ";
|
||||||
|
$q.= "WHERE PackageID = ". $pkgid . " ";
|
||||||
|
$q.= "ORDER BY Username";
|
||||||
|
$result = db_query($q, $dbh);
|
||||||
|
|
||||||
|
if (!$result) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ($row = mysql_fetch_assoc($result)) {
|
||||||
|
$votes[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $votes;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle notification of packages
|
* Toggle notification of packages
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue