From 31b0b68b479aff1f85feb89010ed3fcf40a95673 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Mon, 21 Feb 2011 17:56:12 +0100 Subject: Automatically adopt when updating an orphan package (fixes FS#22992). Signed-off-by: Lukas Fleischer --- web/html/pkgsubmit.php | 12 +++++++----- web/lib/aur.inc | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index b55a720..ccbd35e 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -255,15 +255,14 @@ if ($_COOKIE["AURSID"]): $dbh = db_connect(); - # This is an overwrite of an existing package, the database ID - # needs to be preserved so that any votes are retained. However, - # PackageDepends and PackageSources can be purged. - $q = "SELECT * FROM Packages WHERE Name = '" . mysql_real_escape_string($new_pkgbuild['pkgname']) . "'"; $result = db_query($q, $dbh); $pdata = mysql_fetch_assoc($result); if ($pdata) { + # This is an overwrite of an existing package, the database ID + # needs to be preserved so that any votes are retained. However, + # PackageDepends and PackageSources can be purged. # Flush out old data that will be replaced with new data $q = "DELETE FROM PackageDepends WHERE PackageID = " . $pdata["ID"]; @@ -291,13 +290,14 @@ if ($_COOKIE["AURSID"]): } # Update package data - $q = sprintf("UPDATE Packages SET ModifiedTS = UNIX_TIMESTAMP(), Name = '%s', Version = '%s-%s', License = '%s', Description = '%s', URL = '%s', OutOfDateTS = NULL WHERE ID = %d", + $q = sprintf("UPDATE Packages SET ModifiedTS = UNIX_TIMESTAMP(), Name = '%s', Version = '%s-%s', License = '%s', Description = '%s', URL = '%s', OutOfDateTS = NULL, MaintainerUID = '%d' WHERE ID = %d", mysql_real_escape_string($new_pkgbuild['pkgname']), mysql_real_escape_string($new_pkgbuild['pkgver']), mysql_real_escape_string($new_pkgbuild['pkgrel']), mysql_real_escape_string($new_pkgbuild['license']), mysql_real_escape_string($new_pkgbuild['pkgdesc']), mysql_real_escape_string($new_pkgbuild['url']), + uid_from_sid($_COOKIE["AURSID"]), $pdata["ID"]); db_query($q, $dbh); @@ -329,6 +329,8 @@ if ($_COOKIE["AURSID"]): } } + if (!$pdata["MaintainerUID"]) pkg_notify(account_from_sid($_COOKIE["AURSID"]), array($pdata["ID"])); + header('Location: packages.php?ID=' . $pdata['ID']); } else { diff --git a/web/lib/aur.inc b/web/lib/aur.inc index 835b8a8..5a60c4c 100644 --- a/web/lib/aur.inc +++ b/web/lib/aur.inc @@ -339,7 +339,7 @@ function can_submit_pkg($name="", $sid="") { if ($row[1] == "1") { return 1; } $my_uid = uid_from_sid($sid); - if ($row[0] == $my_uid) { + if (!$row[0] || $row[0] == $my_uid) { return 1; } -- cgit v1.2.3-70-g09d2