summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpjmattal <pjmattal>2005-02-02 05:19:08 +0000
committerpjmattal <pjmattal>2005-02-02 05:19:08 +0000
commit7ca7f7a584406f8ea4d93a0d10524e35b7a1dc07 (patch)
tree1534bc6ef1dc9966726a6a2a407c9a33fbc00d4e
parente0b54676c7c9d6229e8ed8147a885d13e1f35571 (diff)
downloadaurweb-7ca7f7a584406f8ea4d93a0d10524e35b7a1dc07.tar.xz
first working delete
testing is not FULLY done, but it's fairly good
-rw-r--r--web/html/packages.php71
-rw-r--r--web/lang/pkgfuncs_po.inc13
-rw-r--r--web/lib/pkgfuncs.inc6
3 files changed, 59 insertions, 31 deletions
diff --git a/web/html/packages.php b/web/html/packages.php
index 4d8a49e..b2dabef 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 "<br />\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 "<p>\n";
+ 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";
- }
- }
-
- print "<p>\n";
- print __("The selected packages have been deleted.");
- print "</p>\n";
+ } # end if (!empty($ids_to_delete))
+ } # end if ($field)
} else {
print "<p>\n";
print __("You did not select any packages to delete.");
print "</p>\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 054ad91..33d109b 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 da948fd..4c21702 100644
--- a/web/lib/pkgfuncs.inc
+++ b/web/lib/pkgfuncs.inc
@@ -576,9 +576,9 @@ function pkg_search_page($SID="") {
print " <td align='center'>";
print "<input type='submit' class='button' name='do_Disown'";
print " value='".__("Disown Packages")."'></td>\n";
- #print " <td align='center'>";
- #print "<input type='submit' class='button' name='do_Delete'";
- #print " value='".__("Delete Packages")."'></td>\n";
+ print " <td align='center'>";
+ print "<input type='submit' class='button' name='do_Delete'";
+ print " value='".__("Delete Packages")."'></td>\n";
print " <td align='center'>";
print "<input type='submit' class='button' name='do_Vote'";
print " value='".__("Vote")."'></td>\n";