Display package relations on the details page

This adds information from the following three fields to the package
details page:

* conflicts
* provides
* replaces

If either of these fields is empty, it is not displayed.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2014-04-26 13:17:28 +02:00
parent 92812050a0
commit 3720bdf6b2
2 changed files with 92 additions and 0 deletions

View file

@ -132,6 +132,34 @@ function pkg_dependencies($pkgid) {
return $deps;
}
/**
* Get package relations for a specific package
*
* @param int $pkgid The package to get relations for
*
* @return array All package relations for the package
*/
function pkg_relations($pkgid) {
$rels = array();
$pkgid = intval($pkgid);
if ($pkgid > 0) {
$dbh = DB::connect();
$q = "SELECT pr.RelName, rt.Name, pr.RelCondition, p.ID FROM PackageRelations pr ";
$q.= "LEFT JOIN Packages p ON pr.RelName = p.Name ";
$q.= "LEFT JOIN RelationTypes rt ON rt.ID = pr.RelTypeID ";
$q.= "WHERE pr.PackageID = ". $pkgid . " ";
$q.= "ORDER BY pr.RelName";
$result = $dbh->query($q);
if (!$result) {
return array();
}
while ($row = $result->fetch(PDO::FETCH_NUM)) {
$rels[] = $row;
}
}
return $rels;
}
/**
* Get the ID of a dependency type given its name
*