[aur-dev] [PATCH] Add support for TU ninja edits

Lukas Fleischer archlinux at cryptocrack.de
Sat May 31 06:04:45 EDT 2014


Trusted Users now have the ability to overwrite packages without
changing ownership. This allows for adding small fixes to PKGBUILDs
without disowning the package.

Implements FS#32807.

Signed-off-by: Lukas Fleischer <archlinux at cryptocrack.de>
---
 web/html/pkgsubmit.php       | 10 ++++++++--
 web/lib/aur.inc.php          |  5 +++++
 web/lib/pkgbasefuncs.inc.php |  7 ++++---
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php
index f07580b..969eb35 100644
--- a/web/html/pkgsubmit.php
+++ b/web/html/pkgsubmit.php
@@ -346,9 +346,15 @@ if ($uid):
 				 * base, the database ID needs to be preserved
 				 * so that any votes are retained.
 				 */
-				$was_orphan = (pkgbase_maintainer_uid($base_id) === NULL);
+				$maintainer_uid = pkgbase_maintainer_uid($base_id);
+				$was_orphan = ($maintainer_uid === NULL);
 
-				pkgbase_update($base_id, $pkgbase_info['pkgbase'], $uid);
+				if ($was_orphan) {
+					/* Adopt orphan packages. */
+					$maintainer_uid = $uid;
+				}
+
+				pkgbase_update($base_id, $pkgbase_info['pkgbase'], $maintainer_uid, $uid);
 
 				if ($category_id > 1) {
 					pkgbase_update_category($base_id, $category_id);
diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php
index ff46455..9fc3378 100644
--- a/web/lib/aur.inc.php
+++ b/web/lib/aur.inc.php
@@ -293,6 +293,11 @@ function html_footer($ver="") {
  * @return int 0 if the user can't submit, 1 if the user can submit
  */
 function can_submit_pkgbase($name="", $sid="") {
+	$atype = account_from_sid($_COOKIE["AURSID"]);
+	if ($atype == "Trusted User" || $atype == "Developer") {
+		return 1;
+	}
+
 	if (!$name || !$sid) {return 0;}
 	$dbh = DB::connect();
 	$q = "SELECT MaintainerUID ";
diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php
index 9f80ef2..9dbdff6 100644
--- a/web/lib/pkgbasefuncs.inc.php
+++ b/web/lib/pkgbasefuncs.inc.php
@@ -934,17 +934,18 @@ function pkgbase_create($name, $category_id, $uid) {
  *
  * @param string $name Name of the updated package base
  * @param int $base_id The package base ID of the affected package
- * @param int $uid User ID of the package uploader
+ * @param int $maintainer_uid User ID of the package mainainer
+ * @param int $packager_uid User ID of the package uploader
  *
  * @return void
  */
-function pkgbase_update($base_id, $name, $uid) {
+function pkgbase_update($base_id, $name, $maintainer_uid, $packager_uid) {
 	$dbh = DB::connect();
 	$q = sprintf("UPDATE PackageBases SET  " .
 		"Name = %s, ModifiedTS = UNIX_TIMESTAMP(), " .
 		"MaintainerUID = %d, PackagerUID = %d, OutOfDateTS = NULL " .
 		"WHERE ID = %d",
-		$dbh->quote($name), $uid, $uid, $base_id);
+		$dbh->quote($name), $maintainer_uid, $packager_uid, $base_id);
 	$dbh->exec($q);
 }
 
-- 
1.9.3



More information about the aur-dev mailing list