From a54ca6bfaf72832e0ca98278c037b7a1bc75fa16 Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 25 Jan 2005 22:52:32 +0000 Subject: started working on package delete support --- web/html/packages.php | 85 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 2 deletions(-) (limited to 'web/html/packages.php') diff --git a/web/html/packages.php b/web/html/packages.php index 07123a96..4d8a49e9 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -155,7 +155,85 @@ if (isset($_REQUEST["do_Flag"])) { print "

\n"; } else { print "

\n"; - print __("You did not select any packages to disowned."); + print __("You did not select any packages to disown."); + print "

\n"; + } + + pkgsearch_results_link(); + + } + + +} elseif (isset($_REQUEST["do_Delete"])) { + if (!$atype) { + print __("You must be logged in before you can disown packages."); + print "
\n"; + + } else { + # Delete the packages in $ids array (but only if they are Unsupported) + # + if (!empty($ids)) { + $dbh = db_connect(); + + # Delete the packages in $ids array + # + $first = 1; + while (list($pid, $v) = each($ids)) { + if ($first) { + $first = 0; + $delete = $pid; + } else { + $delete .= ", ".$pid; + } + } + $atype = account_from_sid($_COOKIE["AURSID"]); + if ($atype == "Trusted User" || $atype == "Developer") { + $field = "AURMaintainerUID"; + } elseif ($atype == "User") { + $field = "MaintainerUID"; + } else { + $field = ""; + } + + 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.LocationsID = PackageLocations.ID "; + $q.= "AND PackageLocations.Location = 'Unsupported' "; + $q.= "AND (".$field." = ".uid_from_sid($_COOKIE["AURSID"]); + $q.= "OR (AURMaintainerUID = 0 AND MaintainerUID = 0))"; + $result = db_query($q, $dbh); + while ($row = mysql_fetch_assoc($result)) { + $ids_to_delete[] = $row['ID']; + } + + if (!empty($ids_to_delete)) { + # TODO These are the packages that are safe to delete + # + # 1) delete from PackageVotes + # 2) delete from PackageContents + # 3) delete from PackageDepends + # 4) delete from PackageSources + # 5) delete from PackageUploadHistory + # 6) delete from Packages + # TODO question: Now that the package as been deleted, does + # the unsupported repo need to be regenerated? + } else { + print "

\n"; + print __("None of the selected packages could be deleted."); + print "

\n"; + } + } + + print "

\n"; + print __("The selected packages have been deleted."); + print "

\n"; + } else { + print "

\n"; + print __("You did not select any packages to delete."); print "

\n"; } @@ -196,6 +274,9 @@ if (isset($_REQUEST["do_Flag"])) { } 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 . ") "; @@ -346,5 +427,5 @@ if (isset($_REQUEST["do_Flag"])) { } html_footer("\$Id$"); -# vim: ts=2 sw=2 et ft=php +# vim: ts=2 sw=2 noet ft=php ?> -- cgit v1.2.3-24-g4f1b