From 00e37f06112778b0d98b03b67db4725a286ac824 Mon Sep 17 00:00:00 2001
From: Callan Barrett <wizzomafizzo@gmail.com>
Date: Wed, 26 Mar 2008 22:52:15 +0900
Subject: [PATCH] Remove references to AURMaintainerUID

This (should) get rid of anything to do with the unused column AURMaintainerUID
in the scripts and schema files

Signed-off-by: Callan Barrett <wizzomafizzo@gmail.com>
---
 support/schema/aur-schema.sql  |    5 +-
 support/schema/gendummydata.py |    2 +-
 web/html/packages.php          |  194 +++++++++++++++++-----------------------
 web/lang/en/acctfuncs_po.inc   |    1 -
 web/lib/pkgfuncs.inc           |    2 +-
 5 files changed, 85 insertions(+), 119 deletions(-)

diff --git a/support/schema/aur-schema.sql b/support/schema/aur-schema.sql
index d123595..2a2a1a7 100644
--- a/support/schema/aur-schema.sql
+++ b/support/schema/aur-schema.sql
@@ -122,7 +122,6 @@ CREATE TABLE Packages (
 	ModifiedTS BIGINT UNSIGNED NOT NULL,
 	SubmitterUID INTEGER UNSIGNED NOT NULL DEFAULT 0,     -- who submitted it?
 	MaintainerUID INTEGER UNSIGNED NOT NULL DEFAULT 0,    -- User
-	AURMaintainerUID INTEGER UNSIGNED NOT NULL DEFAULT 0, -- TU/Dev
 	FULLTEXT (Name,Description),
 	PRIMARY KEY (ID),
 	UNIQUE (Name),
@@ -133,12 +132,10 @@ CREATE TABLE Packages (
 	INDEX (NumVotes),
 	INDEX (SubmitterUID),
 	INDEX (MaintainerUID),
-	INDEX (AURMaintainerUID),
 	FOREIGN KEY (CategoryID) REFERENCES PackageCategories(ID) ON DELETE NO ACTION,
 	FOREIGN KEY (LocationID) REFERENCES PackageLocations(ID) ON DELETE NO ACTION,
 	FOREIGN KEY (SubmitterUID) REFERENCES Users(ID) ON DELETE NO ACTION,
-	FOREIGN KEY (MaintainerUID) REFERENCES Users(ID) ON DELETE NO ACTION,
-	FOREIGN KEY (AURMaintainerUID) REFERENCES Users(ID) ON DELETE NO ACTION
+	FOREIGN KEY (MaintainerUID) REFERENCES Users(ID) ON DELETE NO ACTION
 );
 
 
diff --git a/support/schema/gendummydata.py b/support/schema/gendummydata.py
index 94f037c..6a885f2 100755
--- a/support/schema/gendummydata.py
+++ b/support/schema/gendummydata.py
@@ -249,7 +249,7 @@ for p in seen_pkgs.keys():
 
 	uuid = genUID() # the submitter/user
 
-	s = "INSERT INTO Packages (ID, Name, Version, CategoryID, LocationID, SubmittedTS, SubmitterUID, MaintainerUID, AURMaintainerUID) VALUES (%d, '%s', '%s', %d, %d, %d, %d, %d, %d);\n" % (seen_pkgs[p], p, genVersion(location_id),
+	s = "INSERT INTO Packages (ID, Name, Version, CategoryID, LocationID, SubmittedTS, SubmitterUID, MaintainerUID) VALUES (%d, '%s', '%s', %d, %d, %d, %d, %d);\n" % (seen_pkgs[p], p, genVersion(location_id),
 			genCategory(), location_id, NOW, uuid, muid, muid)
 	out.write(s)
 	if count % 100 == 0:
diff --git a/web/html/packages.php b/web/html/packages.php
index cf8ad8c..91b3c30 100644
--- a/web/html/packages.php
+++ b/web/html/packages.php
@@ -159,26 +159,16 @@ if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) {
 					$disown .= ", ".$pid;
 				}
 			}
-			# Removed for now since we will have 1 maintainer
-			# PJM - 5 April 2005
-			#			if ($atype == "Trusted User" || $atype == "Developer") {
-			#				$field = "AURMaintainerUID";
-			#			} elseif ($atype == "User") {
-			#				$field = "MaintainerUID";
-			#			} else {
-			#				$field = "";
-			#			}
+			
 			$field = "MaintainerUID";
-			if ($field) {
-				$q = "UPDATE Packages ";
-				$q.= "SET ".$field." = 0 ";
-				$q.= "WHERE ID IN (" . $disown . ") ";
-				# If a user is a TU or dev they can disown any package
-        if ($atype == "User") {
-					$q.= "AND ".$field." = ".uid_from_sid($_COOKIE["AURSID"]);
-				}
-				db_query($q, $dbh);
+			$q = "UPDATE Packages ";
+			$q.= "SET ".$field." = 0 ";
+			$q.= "WHERE ID IN (" . $disown . ") ";
+			# If a user is a TU or dev they can disown any package
+      if ($atype == "User") {
+				$q.= "AND ".$field." = ".uid_from_sid($_COOKIE["AURSID"]);
 			}
+		  db_query($q, $dbh);
 
 			print "<p>\n";
 			print __("The selected packages have been disowned.");
@@ -214,83 +204,71 @@ if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) {
 					$delete .= ", ".$pid;
 				}
 			}
-			#			if ($atype == "Trusted User" || $atype == "Developer") {
-			#				$field = "AURMaintainerUID";
-			#			} elseif ($atype == "User") {
-			#				$field = "MaintainerUID";
-			#			} else {
-			#				$field = "";
-			#				}
+
 			$field = "MaintainerUID";
-			if ($field) {
-				# Only grab Unsupported packages that "we" own or are not owned at all
-				#
-				$ids_to_delete = array();
-				$q = "SELECT Packages.ID FROM Packages, PackageLocations ";
-				$q.= "WHERE Packages.ID IN (" . $delete . ") ";
-				$q.= "AND Packages.LocationID = PackageLocations.ID ";
-				$q.= "AND PackageLocations.Location = 'unsupported' ";
-				# If they're a TU or dev, can always delete, otherwise check ownership
+
+			# Only grab Unsupported packages that "we" own or are not owned at all
+			#
+			$ids_to_delete = array();
+			$q = "SELECT Packages.ID FROM Packages, PackageLocations ";
+			$q.= "WHERE Packages.ID IN (" . $delete . ") ";
+			$q.= "AND Packages.LocationID = PackageLocations.ID ";
+			$q.= "AND PackageLocations.Location = 'unsupported' ";
+			# If they're a TU or dev, can always delete, otherwise check ownership
+			#
+			if ($atype == "Trusted User" || $atype == "Developer") {
+				$result = db_query($q, $dbh);
+			} else {
+				$q.= "AND $field IN (0,  " . uid_from_sid($_COOKIE["AURSID"]) . ")";
+				$result = db_query($q, $dbh);
+			}
+			if ($result != Null && mysql_num_rows($result) > 0) {
+				while ($row = mysql_fetch_assoc($result)) {
+					$ids_to_delete[] = $row['ID'];
+				}
+			}
+			if (!empty($ids_to_delete)) {
+				# These are the packages that are safe to delete
 				#
-				if ($atype == "Trusted User" || $atype == "Developer") {
+			  foreach ($ids_to_delete as $id) {
+					# 1) delete from PackageVotes
+					$q = "DELETE FROM PackageVotes WHERE PackageID = " . $id;
 					$result = db_query($q, $dbh);
-				} else {
-					$q.= "AND $field IN (0,  " . uid_from_sid($_COOKIE["AURSID"]) . ")";
+
+					# 2) delete from PackageContents
+					$q = "DELETE FROM PackageContents WHERE PackageID = " . $id;
 					$result = db_query($q, $dbh);
-				}
-				if ($result != Null && mysql_num_rows($result) > 0) {
-					while ($row = mysql_fetch_assoc($result)) {
-						$ids_to_delete[] = $row['ID'];
-					}
-				}
-				if (!empty($ids_to_delete)) {
-					# These are the packages that are safe to delete
-					#
-				  foreach ($ids_to_delete as $id) {
-						# 1) delete from PackageVotes
-						$q = "DELETE FROM PackageVotes WHERE PackageID = " . $id;
-						$result = db_query($q, $dbh);
-
-						# 2) delete from PackageContents
-						$q = "DELETE FROM PackageContents WHERE PackageID = " . $id;
-						$result = db_query($q, $dbh);
-
-						# 3) delete from PackageDepends
-						$q = "DELETE FROM PackageDepends WHERE PackageID = " . $id;
-						$result = db_query($q, $dbh);
-
-						# 4) delete from PackageSources
-						$q = "DELETE FROM PackageSources WHERE PackageID = " . $id;
-						$result = db_query($q, $dbh);
-
-						# 5) delete from PackageComments
-						$q = "DELETE FROM PackageComments WHERE PackageID = " . $id;
-						$result = db_query($q, $dbh);
-
-						# 6) delete from Packages
-						$q = "DELETE FROM Packages WHERE ID = " . $id;
-						$result = db_query($q, $dbh);
-
-						# 7) delete from CommentNotify
-						$q = "DELETE FROM CommentNotify WHERE PkgID = " . $id;
-						$result = db_query($q, $dbh);
-
-						# TODO question: Now that the package as been deleted, does
-						#                the unsupported repo need to be regenerated?
-					  # ANSWER: No, there is no actual repo for unsupported, so no worries! (PJM)
-						# TODO question: What about regenerating the AUR repo? (EJ)
-
-						# Print the success message
-						print "<p>\n";
-			      print __("The selected packages have been deleted.");
-			      print "</p>\n";
-					}
-				} else {
+
+					# 3) delete from PackageDepends
+					$q = "DELETE FROM PackageDepends WHERE PackageID = " . $id;
+					$result = db_query($q, $dbh);
+
+					# 4) delete from PackageSources
+					$q = "DELETE FROM PackageSources WHERE PackageID = " . $id;
+					$result = db_query($q, $dbh);
+
+					# 5) delete from PackageComments
+					$q = "DELETE FROM PackageComments WHERE PackageID = " . $id;
+					$result = db_query($q, $dbh);
+
+					# 6) delete from Packages
+					$q = "DELETE FROM Packages WHERE ID = " . $id;
+					$result = db_query($q, $dbh);
+
+					# 7) delete from CommentNotify
+					$q = "DELETE FROM CommentNotify WHERE PkgID = " . $id;
+					$result = db_query($q, $dbh);
+
+					# Print the success message
 					print "<p>\n";
-					print __("None of the selected packages could be deleted.");
-					print "</p>\n";
-				} # end if (!empty($ids_to_delete))
-			} # end if ($field)
+		      print __("The selected packages have been deleted.");
+		      print "</p>\n";
+				}
+			} else {
+				print "<p>\n";
+				print __("None of the selected packages could be deleted.");
+				print "</p>\n";
+			} # end if (!empty($ids_to_delete))
 		} else {
 			print "<p>\n";
 			print __("You did not select any packages to delete.");
@@ -320,30 +298,22 @@ if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) {
 					$adopt .= ", ".$pid;
 				}
 			}
-			#			if ($atype == "Trusted User" || $atype == "Developer") {
-			#				$field = "AURMaintainerUID";
-			#			} elseif ($atype == "User") {
-			#$field = "MaintainerUID";
-			#} else {
-			#	$field = "";
-			#	}
+
 		  $field = "MaintainerUID";
-			if ($field) {
-				# NOTE: Only "orphaned" packages can be adopted at a particular
-				#       user class (TU/Dev or User).
-				#
-				$q = "UPDATE Packages ";
-				$q.= "SET ".$field." = ".uid_from_sid($_COOKIE["AURSID"])." ";
-				$q.= "WHERE ID IN (" . $adopt . ") ";
-				if ($atype == "User")
-				{
-					# Regular users may only adopt orphan packages from unsupported
-					# FIXME: We assume that LocationID for unsupported is "2"
-					$q.= "AND ".$field." = 0";
-					$q.= " AND LocationID = 2";
-				}
-				db_query($q, $dbh);
+			# NOTE: Only "orphaned" packages can be adopted at a particular
+			#       user class (TU/Dev or User).
+			#
+			$q = "UPDATE Packages ";
+			$q.= "SET ".$field." = ".uid_from_sid($_COOKIE["AURSID"])." ";
+			$q.= "WHERE ID IN (" . $adopt . ") ";
+			if ($atype == "User")
+			{
+				# Regular users may only adopt orphan packages from unsupported
+				# FIXME: We assume that LocationID for unsupported is "2"
+				$q.= "AND ".$field." = 0";
+				$q.= " AND LocationID = 2";
 			}
+			db_query($q, $dbh);
 
 			print "<p>\n";
 			print __("The selected packages have been adopted.");
diff --git a/web/lang/en/acctfuncs_po.inc b/web/lang/en/acctfuncs_po.inc
index c19bfdb..7550234 100644
--- a/web/lang/en/acctfuncs_po.inc
+++ b/web/lang/en/acctfuncs_po.inc
@@ -90,4 +90,3 @@ $_t["en"]["Developer"] = "Developer";
 $_t["en"]["View this user's packages"] = "View this user's packages";
 
 ?>
-
diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc
index 48d5239..1feceb6 100644
--- a/web/lib/pkgfuncs.inc
+++ b/web/lib/pkgfuncs.inc
@@ -500,7 +500,7 @@ function package_details($id=0, $SID="") {
                     echo " value='".__("Unflag Out-of-date")."'>\n";
 				}
 					
-                if ($row["AURMaintainerUID"] == 0 && $row["MaintainerUID"] == 0) {
+                if ($row["MaintainerUID"] == 0) {
                     echo "<input type='submit' class='button' name='do_Adopt'";
                     echo " value='".__("Adopt Packages")."'>\n";
                 }
-- 
1.5.3.8

