From 38eb8d2a3ab0b7f35618d151613211d45f6ec4d8 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sat, 26 Apr 2014 14:21:43 +0200 Subject: Display package groups on the details page The groups field is hidden if a package doesn't belong to any group. Signed-off-by: Lukas Fleischer --- web/lib/pkgfuncs.inc.php | 26 ++++++++++++++++++++++++++ web/template/pkg_details.php | 18 ++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index f80d4b4b..6811767f 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -104,6 +104,32 @@ function pkg_from_name($name="") { return $row[0]; } +/** + * Get package groups for a specific package + * + * @param int $pkgid The package to get groups for + * + * @return array All package groups for the package + */ +function pkg_groups($pkgid) { + $grps = array(); + $pkgid = intval($pkgid); + if ($pkgid > 0) { + $dbh = DB::connect(); + $q = "SELECT g.Name FROM Groups g "; + $q.= "INNER JOIN PackageGroups pg ON pg.GroupID = g.ID "; + $q.= "WHERE pg.PackageID = ". $pkgid; + $result = $dbh->query($q); + if (!$result) { + return array(); + } + while ($row = $result->fetch(PDO::FETCH_COLUMN, 0)) { + $grps[] = $row; + } + } + return $grps; +} + /** * Get package dependencies for a specific package * diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php index da90c9d7..ff3f710a 100644 --- a/web/template/pkg_details.php +++ b/web/template/pkg_details.php @@ -22,6 +22,8 @@ $out_of_date_time = ($row["OutOfDateTS"] == 0) ? $msg : gmdate("Y-m-d", intval($ $urlpath = URL_DIR . substr($row['BaseName'], 0, 2) . "/" . $row['BaseName']; +$grps = pkg_groups($row["ID"]); + $deps = pkg_dependencies($row["ID"]); $requiredby = pkg_required($row["Name"]); @@ -172,6 +174,22 @@ if ($SID && ($uid == $row["MaintainerUID"] || + 0): ?> + + + + + + + , + + + + + + + + 0): ?> -- cgit v1.2.3-24-g4f1b