started working on package delete support

This commit is contained in:
eric 2005-01-25 22:52:32 +00:00
parent 9641fdc735
commit a54ca6bfaf
11 changed files with 363 additions and 243 deletions

View file

@ -126,5 +126,5 @@ if (isset($_COOKIE["AURSID"])) {
}
html_footer("\$Id$");
# vim: ts=2 sw=2 et ft=php
# vim: ts=2 sw=2 noet ft=php
?>

View file

@ -10,5 +10,5 @@ print __("If this problem persists, please contact the site administrator.");
print "</p>\n";
html_footer("\$Id$");
# vim: ts=2 sw=2 et ft=php
# vim: ts=2 sw=2 noet ft=php
?>

View file

@ -120,5 +120,5 @@ print "</table>\n";
html_footer("\$Id$");
# vim: ts=2 sw=2 et ft=php
# vim: ts=2 sw=2 noet ft=php
?>

View file

@ -20,5 +20,5 @@ print __("You have been successfully logged out.")."<br />\n";
html_footer("\$Id$");
# vim: ts=2 sw=2 et ft=php
# vim: ts=2 sw=2 noet ft=php
?>

View file

@ -155,7 +155,85 @@ if (isset($_REQUEST["do_Flag"])) {
print "</p>\n";
} else {
print "<p>\n";
print __("You did not select any packages to disowned.");
print __("You did not select any packages to disown.");
print "</p>\n";
}
pkgsearch_results_link();
}
} elseif (isset($_REQUEST["do_Delete"])) {
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)
#
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 "<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";
} else {
print "<p>\n";
print __("You did not select any packages to delete.");
print "</p>\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
?>

View file

@ -15,5 +15,5 @@ print __("Manage package ID: %s", array($_REQUEST["ID"])) . "<br />\n";
html_footer("\$Id$");
# vim: ts=2 sw=2 et ft=php
# vim: ts=2 sw=2 noet ft=php
?>

View file

@ -159,7 +159,9 @@ if ($_COOKIE["AURSID"]) {
}
}
@exec("/bin/sh -c 'mv ".$upload_file." ".$INCOMING_DIR.$pkg_name."/".$_FILES["pfile"]["name"]."'");
$shcmd = "/bin/sh -c 'mv ".$upload_file." ".$INCOMING_DIR.$pkg_name;
$shcmd.= "/".$_FILES["pfile"]["name"]."'");
@exec($shcmd);
# if no error, get list of directory contents and process PKGBUILD
#
@ -323,14 +325,25 @@ if ($_COOKIE["AURSID"]) {
# update package data
#
$q = "UPDATE Packages SET Name='".mysql_escape_string($new_pkgbuild['pkgname'])."', Version='".mysql_escape_string($new_pkgbuild['pkgver'])."', CategoryID=".mysql_escape_string($_REQUEST['category']).", Description='".mysql_escape_string($new_pkgbuild['pkgdesc'])."', URL='".mysql_escape_string($new_pkgbuild['url'])."', LocationID=2, FSPath='".mysql_escape_string($INCOMING_DIR.$pkg_name."/".$_FILES["pfile"]["name"])."', URLPath='".mysql_escape_string($URL_DIR.$pkg_name."/".$_FILES["pfile"]["name"])."' ";
$q .= "WHERE ID = " . $pdata["ID"];
$q = "UPDATE Packages SET ";
$q.="Name='".mysql_escape_string($new_pkgbuild['pkgname'])."', ";
$q.="Version='".mysql_escape_string($new_pkgbuild['pkgver'])."',";
$q.="CategoryID=".mysql_escape_string($_REQUEST['category']).", ";
$q.="Description='".mysql_escape_string($new_pkgbuild['pkgdesc'])."', ";
$q.="URL='".mysql_escape_string($new_pkgbuild['url'])."', ";
$q.="LocationID=2, ";
$fspath=$INCOMING_DIR.$pkg_name."/".$_FILES["pfile"]["name"];
$q.="FSPath='".mysql_escape_string($fspath)."', ";
$urlpath=$URL_DIR.$pkg_name."/".$_FILES["pfile"]["name"];
$q.="URLPath='".mysql_escape_string($urlpath)."' ";
$q.="WHERE ID = " . $pdata["ID"];
$result = db_query($q, $dbh);
# update package contents
#
while (list($k, $v) = each($pkg_contents)) {
$q = "INSERT INTO PackageContents (PackageID, FSPath, URLPath, FileSize) VALUES (";
$q = "INSERT INTO PackageContents ";
$q.= "(PackageID, FSPath, URLPath, FileSize) VALUES (";
$q.= $pdata['ID'].", ";
$q.= "'".$INCOMING_DIR.$pkg_name."/".$pkg_name."/".$k."', ";
$q.= "'".$URL_DIR.$pkg_name."/".$pkg_name."/".$k."', ";
@ -358,15 +371,32 @@ if ($_COOKIE["AURSID"]) {
# add upload history
#
$q = "INSERT INTO PackageUploadHistory (PackageID, UsersID, Comments, UploadTS) VALUES (";
$q .= $pdata["ID"] . ", " . uid_from_sid($_COOKIE['AURSID']) . ", '" . mysql_escape_string($_REQUEST["comments"]) . "', UNIX_TIMESTAMP())";
$q = "INSERT INTO PackageUploadHistory ";
$q.= "(PackageID, UsersID, Comments, UploadTS) VALUES (";
$q.= $pdata["ID"] . ", " . uid_from_sid($_COOKIE['AURSID']);
$q.= ", '" . mysql_escape_string($_REQUEST["comments"]);
$q.= "', UNIX_TIMESTAMP())";
db_query($q);
} else {
# this is a brand new package
#
$q = "INSERT INTO Packages (Name, Version, CategoryID, Description, URL, LocationID, SubmittedTS, SubmitterUID, MaintainerUID, FSPath, URLPath) ";
$q .= "VALUES ('".mysql_escape_string($new_pkgbuild['pkgname'])."', '".mysql_escape_string($new_pkgbuild['pkgver'])."', ".mysql_escape_string($_REQUEST['category']).", '".mysql_escape_string($new_pkgbuild['pkgdesc'])."', '".mysql_escape_string($new_pkgbuild['url'])."', 2, UNIX_TIMESTAMP(), ".uid_from_sid($_COOKIE["AURSID"]).", ".uid_from_sid($_COOKIE["AURSID"]).", '".mysql_escape_string($INCOMING_DIR.$pkg_name."/".$_FILES["pfile"]["name"])."', '".mysql_escape_string($URL_DIR.$pkg_name."/".$_FILES["pfile"]["name"])."')";
$q = "INSERT INTO Packages ";
$q.= " (Name, Version, CategoryID, Description, URL, LocationID, ";
$q.= " SubmittedTS, SubmitterUID, MaintainerUID, FSPath, URLPath) ";
$q.= "VALUES ('";
$q.= mysql_escape_string($new_pkgbuild['pkgname'])."', '";
$q.= mysql_escape_string($new_pkgbuild['pkgver'])."', ";
$q.= mysql_escape_string($_REQUEST['category']).", '";
$q.= mysql_escape_string($new_pkgbuild['pkgdesc'])."', '";
$q.= mysql_escape_string($new_pkgbuild['url']);
$q.= "', 2, UNIX_TIMESTAMP(), ";
$q.= uid_from_sid($_COOKIE["AURSID"]).", ";
$q.= uid_from_sid($_COOKIE["AURSID"]).", '";
$fspath=$INCOMING_DIR.$pkg_name."/".$_FILES["pfile"]["name"];
$q.= mysql_escape_string($fspath)."', '";
$urlpath=$URL_DIR.$pkg_name."/".$_FILES["pfile"]["name"];
$q.= mysql_escape_string($urlpath)."')";
$result = db_query($q, $dbh);
# print $result . "<br>";
@ -375,7 +405,8 @@ if ($_COOKIE["AURSID"]) {
# update package contents
#
while (list($k, $v) = each($pkg_contents)) {
$q = "INSERT INTO PackageContents (PackageID, FSPath, URLPath, FileSize) VALUES (";
$q = "INSERT INTO PackageContents ";
$q.= "(PackageID, FSPath, URLPath, FileSize) VALUES (";
$q.= $packageID.", ";
$q.= "'".$INCOMING_DIR.$pkg_name."/".$pkg_name."/".$k."', ";
$q.= "'".$URL_DIR.$pkg_name."/".$pkg_name."/".$k."', ";
@ -403,8 +434,11 @@ if ($_COOKIE["AURSID"]) {
# add upload history
#
$q = "INSERT INTO PackageUploadHistory (PackageID, UsersID, Comments, UploadTS) VALUES (";
$q .= $packageID . ", " . uid_from_sid($_COOKIE["AURSID"]) . ", '" . mysql_escape_string($_REQUEST["comments"]) . "', UNIX_TIMESTAMP())";
$q = "INSERT INTO PackageUploadHistory ";
$q.= "(PackageID, UsersID, Comments, UploadTS) VALUES (";
$q.= $packageID . ", " . uid_from_sid($_COOKIE["AURSID"]) . ", '";
$q.= mysql_escape_string($_REQUEST["comments"]);
$q.= "', UNIX_TIMESTAMP())";
db_query($q, $dbh);
}
}
@ -512,5 +546,5 @@ if ($_COOKIE["AURSID"]) {
print "</center>\n";
html_footer("\$Id$");
# vim: ts=2 sw=2 et ft=php
# vim: ts=2 sw=2 noet ft=php
?>

View file

@ -10,5 +10,5 @@ print __("Click on the Home link above to log in.");
print "</p>\n";
html_footer("\$Id$");
# vim: ts=2 sw=2 et ft=php
# vim: ts=2 sw=2 noet ft=php
?>

View file

@ -3,4 +3,6 @@
$UPLOAD_DIR = "/aur/temp/";
$INCOMING_DIR = "/aur/incoming/";
$URL_DIR = "/packages/";
# vim: ts=2 sw=2 noet ft=php
?>

View file

@ -576,6 +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_Vote'";
print " value='".__("Vote")."'></td>\n";