summaryrefslogtreecommitdiffstats
path: root/web/lib/pkgfuncs.inc.php
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2014-04-26 13:17:28 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2014-04-26 13:34:17 +0200
commit3720bdf6b264cb4bb603e4199f2758598c260ed4 (patch)
tree9dee586a6aace9e5f1b4e02838aee91a7e1f14f9 /web/lib/pkgfuncs.inc.php
parent92812050a059a651357f772b58e967154ea8428c (diff)
downloadaurweb-3720bdf6b264cb4bb603e4199f2758598c260ed4.tar.xz
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>
Diffstat (limited to 'web/lib/pkgfuncs.inc.php')
-rw-r--r--web/lib/pkgfuncs.inc.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index 2eb0be4..a04f525 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -133,6 +133,34 @@ function pkg_dependencies($pkgid) {
}
/**
+ * 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
*
* @param string $name The name of the dependency type