summaryrefslogtreecommitdiffstats
path: root/web/lib/pkgreqfuncs.inc.php
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2015-03-04 11:59:18 +0100
committerLukas Fleischer <archlinux@cryptocrack.de>2015-03-04 12:20:21 +0100
commita53241a2f1fe4ecafd86a97738a04e2fbfbb0b84 (patch)
treed8c5e2d153e5c118a8401fbb5808acf27ed2570a /web/lib/pkgreqfuncs.inc.php
parent5dca715c46669a2e1ed193c13aacff03e7e237ff (diff)
downloadaurweb-a53241a2f1fe4ecafd86a97738a04e2fbfbb0b84.tar.xz
Automatically close requests
Close requests automatically when a package is deleted or orphaned. Implements FS#43799. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/pkgreqfuncs.inc.php')
-rw-r--r--web/lib/pkgreqfuncs.inc.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/web/lib/pkgreqfuncs.inc.php b/web/lib/pkgreqfuncs.inc.php
index 0fab447..e4c63b5 100644
--- a/web/lib/pkgreqfuncs.inc.php
+++ b/web/lib/pkgreqfuncs.inc.php
@@ -42,6 +42,27 @@ function pkgreq_list($offset, $limit) {
}
/**
+ * Get a list of all open package requests belonging to a certain package base
+ *
+ * @param int $baseid The package base ID to retrieve requests for
+ * @param int $type The type of requests to obtain
+ *
+ * @return array List of package request IDs
+ */
+function pkgreq_by_pkgbase($baseid, $type) {
+ $dbh = DB::connect();
+
+ $q = "SELECT PackageRequests.ID ";
+ $q.= "FROM PackageRequests INNER JOIN RequestTypes ON ";
+ $q.= "RequestTypes.ID = PackageRequests.ReqTypeID ";
+ $q.= "WHERE PackageRequests.Status = 0 ";
+ $q.= "AND PackageRequests.PackageBaseID = " . intval($baseid) . " ";
+ $q.= "AND RequestTypes.Name = " . $dbh->quote($type);
+
+ return $dbh->query($q)->fetchAll(PDO::FETCH_COLUMN, 0);
+}
+
+/**
* Obtain the package base that belongs to a package request.
*
* @param int $id Package request ID to retrieve the package base for