From 5eb7354e7d67833ec3ef582bb9ef74550f60f318 Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Sat, 20 Jun 2015 12:44:36 +0200 Subject: Add functions for getting arrays of maintainer and co-maintainer UIDs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Johannes Löthberg Signed-off-by: Lukas Fleischer --- web/lib/pkgbasefuncs.inc.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'web/lib') diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php index c8c99ebb..d12a2286 100644 --- a/web/lib/pkgbasefuncs.inc.php +++ b/web/lib/pkgbasefuncs.inc.php @@ -318,6 +318,19 @@ function pkgbase_maintainer_uid($base_id) { return $result->fetch(PDO::FETCH_COLUMN, 0); } +/** + * Retrieve the maintainers of an array of package bases given by their ID + * + * @param int $base_ids The array of IDs of the package bases to query + * + * @return int The user ID of the current package maintainer + */ +function pkgbase_maintainer_uids($base_ids) { + $dbh = DB::connect(); + $q = "SELECT MaintainerUID FROM PackageBases WHERE ID IN (" . implode(",", $base_ids) . ")"; + $result = $dbh->query($q); + return $result->fetchAll(PDO::FETCH_COLUMN, 0); +} /** * Flag package(s) as out-of-date @@ -992,6 +1005,28 @@ function pkgbase_get_comaintainers($base_id) { } } +/** + * Get a list of package base co-maintainer IDs + * + * @param int $base_id The package base ID to retrieve the co-maintainers for + * + * @return array An array of co-maintainer user UDs + */ +function pkgbase_get_comaintainer_uids($base_ids) { + $dbh = DB::connect(); + $q = "SELECT UsersID FROM PackageComaintainers "; + $q .= "INNER JOIN Users ON Users.ID = PackageComaintainers.UsersID "; + $q .= "WHERE PackageComaintainers.PackageBaseID IN (" . implode(",", $base_ids) . ") "; + $q .= "ORDER BY Priority ASC"; + $result = $dbh->query($q); + + if ($result) { + return $result->fetchAll(PDO::FETCH_COLUMN, 0); + } else { + return array(); + } +} + /** * Update the list of co-maintainers of a package base * -- cgit v1.2.3-24-g4f1b