From 7ca7f7a584406f8ea4d93a0d10524e35b7a1dc07 Mon Sep 17 00:00:00 2001 From: pjmattal Date: Wed, 2 Feb 2005 05:19:08 +0000 Subject: first working delete testing is not FULLY done, but it's fairly good --- web/html/packages.php | 71 ++++++++++++++++++++++++++++++------------------ web/lang/pkgfuncs_po.inc | 13 ++++++++- web/lib/pkgfuncs.inc | 6 ++-- 3 files changed, 59 insertions(+), 31 deletions(-) diff --git a/web/html/packages.php b/web/html/packages.php index 4d8a49e9..b2dabefb 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -168,7 +168,6 @@ if (isset($_REQUEST["do_Flag"])) { 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) # @@ -194,53 +193,71 @@ if (isset($_REQUEST["do_Flag"])) { } 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 Packages.LocationID = PackageLocations.ID "; $q.= "AND PackageLocations.Location = 'Unsupported' "; - $q.= "AND (".$field." = ".uid_from_sid($_COOKIE["AURSID"]); - $q.= "OR (AURMaintainerUID = 0 AND MaintainerUID = 0))"; + $q.= "AND AURMaintainerUID IN (0, " . uid_from_sid($_COOKIE["AURSID"]) . ")"; $result = db_query($q, $dbh); - while ($row = mysql_fetch_assoc($result)) { - $ids_to_delete[] = $row['ID']; + if ($result != Null && mysql_num_rows($result) > 0) { + 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? + 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 PackageUploadHistory + $q = "DELETE FROM PackageUploadHistory WHERE PackageID = " . $id; + $result = db_query($q, $dbh); + + # 6) delete from Packages + $q = "DELETE FROM Packages WHERE ID = " . $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) + + # Print the success message + print "

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

\n"; + } } 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"; + } # end if (!empty($ids_to_delete)) + } # end if ($field) } else { print "

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

\n"; - } - + } # end if (!empty($ids)) pkgsearch_results_link(); - - } - + } # end if (!atype) } elseif (isset($_REQUEST["do_Adopt"])) { if (!$atype) { diff --git a/web/lang/pkgfuncs_po.inc b/web/lang/pkgfuncs_po.inc index 054ad917..33d109b2 100644 --- a/web/lang/pkgfuncs_po.inc +++ b/web/lang/pkgfuncs_po.inc @@ -111,6 +111,17 @@ $_t["en"]["Disown Packages"] = "Disown Packages"; # $_t["fr"]["Disown Packages"] = "--> Traduction française ici. <--"; # $_t["de"]["Disown Packages"] = "--> Deutsche Übersetzung hier. <--"; +$_t["en"]["Delete Packages"] = "Delete Packages"; +# $_t["es"]["Delete Packages"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Delete Packages"] = "--> Traduction française ici. <--"; +# $_t["de"]["Delete Packages"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["You did not select any packages to delete."] = "You did not select any packages to delete."; + +$_t["en"]["None of the selected packages could be deleted."] = "None of the selected packages could be deleted."; + +$_t["en"]["The selected packages have been deleted."] = "The selected packages have been deleted."; + $_t["en"]["Vote"] = "Vote"; # $_t["es"]["Vote"] = "--> Traducción española aquí. <--"; # $_t["fr"]["Vote"] = "--> Traduction française ici. <--"; @@ -161,4 +172,4 @@ $_t["en"]["Yes"] = "Yes"; # $_t["fr"]["Yes"] = "--> Traduction française ici. <--"; # $_t["de"]["Yes"] = "--> Deutsche Übersetzung hier. <--"; -?> \ No newline at end of file +?> diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index da948fd4..4c21702b 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -576,9 +576,9 @@ function pkg_search_page($SID="") { print " "; print "\n"; - #print " "; - #print "\n"; + print " "; + print "\n"; print " "; print "\n"; -- cgit v1.2.3-24-g4f1b