summaryrefslogtreecommitdiffstats
path: root/web/lib
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2014-04-17 19:49:26 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2014-04-17 21:09:16 +0200
commit73936002f7d5685a9063683f68d4e8c2e01be0ac (patch)
treec1f152f76be0399222a47cab2060998e41ce5688 /web/lib
parent32b5d466439b5c291472c68f6a732c5be4ca60cf (diff)
downloadaur-73936002f7d5685a9063683f68d4e8c2e01be0ac.tar.gz
aur-73936002f7d5685a9063683f68d4e8c2e01be0ac.tar.xz
Store {make,check,opt}depends in the database
In addition to parsing and storing dependencies of packages, store makedepends, checkdepends and optdepends. Every dependency (of any type) is displayed on the package details page. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib')
-rw-r--r--web/lib/pkgfuncs.inc.php29
1 files changed, 23 insertions, 6 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index c6b4a27f..153e2a83 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -132,6 +132,21 @@ function pkg_dependencies($pkgid) {
}
/**
+ * Get the ID of a dependency type given its name
+ *
+ * @param string $name The name of the dependency type
+ *
+ * @return int The ID of the dependency type
+ */
+function pkg_dependency_type_id_from_name($name) {
+ $dbh = DB::connect();
+ $q = "SELECT ID FROM DependencyTypes WHERE Name = ";
+ $q.= $dbh->quote($name);
+ $result = $dbh->query($q);
+ return $result->fetch(PDO::FETCH_COLUMN, 0);
+}
+
+/**
* Determine packages that depend on a package
*
* @param string $name The package name for the dependency search
@@ -653,18 +668,20 @@ function pkg_create($base_id, $pkgname, $license, $pkgver, $pkgdesc, $pkgurl) {
* Add a dependency for a specific package to the database
*
* @param int $pkgid The package ID to add the dependency for
+ * @param string $type The type of dependency to add
* @param string $depname The name of the dependency to add
* @param string $depcondition The type of dependency for the package
*
* @return void
*/
-function pkg_add_dep($pkgid, $depname, $depcondition) {
+function pkg_add_dep($pkgid, $type, $depname, $depcondition) {
$dbh = DB::connect();
- $q = sprintf("INSERT INTO PackageDepends (PackageID, DepName, DepCondition) VALUES (%d, %s, %s)",
- $pkgid,
- $dbh->quote($depname),
- $dbh->quote($depcondition));
-
+ $q = sprintf("INSERT INTO PackageDepends (PackageID, DepTypeID, DepName, DepCondition) VALUES (%d, %d, %s, %s)",
+ $pkgid,
+ pkg_dependency_type_id_from_name($type),
+ $dbh->quote($depname),
+ $dbh->quote($depcondition)
+ );
$dbh->exec($q);
}