[aur-dev] [PATCH] Move deletion proposal code from pkgfuncs.inc to pkgedit.php and add mechanism for dealing with reasons for deletion.
Peter Lewis
pete at muddygoat.org
Sun Sep 26 16:46:49 EDT 2010
---
web/html/pkgedit.php | 210 ++++++++++++++++++++++++++++++++++++++++++++++++++
web/lib/pkgfuncs.inc | 42 ++--------
2 files changed, 218 insertions(+), 34 deletions(-)
diff --git a/web/html/pkgedit.php b/web/html/pkgedit.php
index 0339d00..f04e816 100644
--- a/web/html/pkgedit.php
+++ b/web/html/pkgedit.php
@@ -103,6 +103,216 @@ if ($_REQUEST["change_Category"]) {
exit();
}
+# Propose deletion of package
+#
+# valid reasons are:
+# - sources no longer available [nosource],
+# - no longer builds on current systems (and cannot reasonably be patched) [wontbuild],
+# - duplicated elsewhere in the repos [dupe],
+# - name or source control system changed (e.g. from svn to git) [namechange]
+#
+if ($_REQUEST["propose_Deletion"]) {
+
+ if ($_REQUEST["CONFIRM"] && ($_REQUEST["NOSOURCE"] || $_REQUEST["WONTBUILD"] || $_REQUEST["DUPE"] || $_REQUEST["NAMECHANGE"]) ) {
+ # The user confirmed and we have at least one reason - go ahead and do it
+
+ $dbh = db_connect();
+
+ # Get details of the user who proposed the deletion
+ $f_name = username_from_sid($_COOKIE['AURSID']);
+ $f_email = email_from_sid($_COOKIE['AURSID']);
+ $f_uid = uid_from_sid($_COOKIE['AURSID']);
+
+ # Get package name
+ $q = "SELECT Packages.Name ";
+ $q.= "FROM Packages ";
+ $q.= "WHERE Packages.ID = " . $_REQUEST['ID'];
+
+ $result = db_query($q, $dbh);
+
+ # If this is false, then something has gone wrong (i.e. the package got deleted while you were doing this)
+ if (!mysql_num_rows($result)) {
+ print __("Oops, something went wrong and the package no longer seems to exist!");
+ exit();
+ }
+
+ $row = mysql_fetch_assoc($result);
+
+ # Send a message to aur-general
+ $body = "The AUR package " . $row['Name'] . " has been proposed for deletion by " . $f_name . " [1].\n\n";
+ $body.= "You may view the package at:\nhttp://aur.archlinux.org/packages.php?ID=" . $_REQUEST['ID'] . "\n\n";
+
+ $body.= "The reason(s) given were:\n";
+ if ($_REQUEST['NOSOURCE']) {
+ $body.= " - The sources are no longer available.\n";
+ }
+ if ($_REQUEST['WONTBUILD']) {
+ $body.= " - The package no longer builds on current systems.\n";
+ }
+ if ($_REQUEST['DUPE']) {
+ $body.= " - The package is duplicated elsewhere.\n";
+ }
+ if ($_REQUEST['NAMECHANGE']) {
+ $body.= " - The package's name has changed, and a new package replaces it.\n";
+ }
+
+ $body.= "\nThe proposer added the following details:\n";
+ $body.= $_REQUEST['REASONTEXT']."\n\n";
+
+
+ $body.= "[1] - http://aur.archlinux.org/account.php?Action=AccountInfo&ID=" . $f_uid;
+
+
+ $body = wordwrap($body, 70);
+ $headers = "Reply-to: nobody at archlinux.org\nFrom:aur-notify at archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n";
+
+ # TODO: add the real aur-general at archlinux.org address here when done with testing
+ @mail('aur-general at __REMOVE_ME__archlinux.org', "AUR Package Deletion Proposal for ".$row['Name'], $body, $headers);
+
+
+
+ # Notify maintainer of package by email
+ $q = "SELECT Packages.Name, Users.Email ";
+ $q.= "FROM Packages, Users ";
+ $q.= "WHERE Packages.ID = " . $_REQUEST['ID'] ." ";
+ $q.= "AND Users.ID = Packages.MaintainerUID";
+
+ $result = db_query($q, $dbh);
+
+ # If this is false, then the package has no maintainer, so there's no email to send
+ if (mysql_num_rows($result)) {
+ $row = mysql_fetch_assoc($result);
+
+ # construct email - maintainer
+ $body = "Your AUR package " . $row['Name'] . " has been proposed for deletion by " . $f_name . " [1].\n\n";
+ $body.= "You may view your package at:\nhttp://aur.archlinux.org/packages.php?ID=" . $_REQUEST['ID'] . "\n\n";
+
+ $body.= "The reason(s) given were:\n";
+ if ($_REQUEST['NOSOURCE']) {
+ $body.= " - The sources are no longer available.\n";
+ }
+ if ($_REQUEST['WONTBUILD']) {
+ $body.= " - The package no longer builds on current systems.\n";
+ }
+ if ($_REQUEST['DUPE']) {
+ $body.= " - The package is duplicated elsewhere.\n";
+ }
+ if ($_REQUEST['NAMECHANGE']) {
+ $body.= " - The package's name has changed, and a new package replaces it.\n";
+ }
+
+ $body.= "\nThe proposer added the following details:\n";
+ $body.= $_REQUEST['REASONTEXT']."\n\n";
+
+ $body.= "[1] - http://aur.archlinux.org/account.php?Action=AccountInfo&ID=" . $f_uid;
+
+ $body = wordwrap($body, 70);
+ $headers = "Reply-to: nobody at archlinux.org\nFrom:aur-notify at archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n";
+
+ @mail($row['Email'], "AUR Package Deletion Proposal for ".$row['Name'], $body, $headers);
+ }
+
+
+ # Send messages to those on the notify list as well (but not the maintainer again)
+
+ $q = "SELECT Packages.Name, Users.Email ";
+ $q.= "FROM Packages, Users ";
+ $q.= "WHERE Packages.ID = " . $_REQUEST['ID'] . " ";
+ $q.= "AND Packages.MaintainerUID != Users.ID";
+ $result = db_query($q, $dbh);
+
+ # If this is false, then the package has no-one to notify, so there's no email to send
+ if (mysql_num_rows($result)) {
+ while($row = mysql_fetch_assoc($result)) {
+
+ # construct email - maintainer
+ $body = "The AUR package " . $row['Name'] . " has been proposed for deletion by " . $f_name . " [1].\n\n";
+ $body.= "You may view the package at:\nhttp://aur.archlinux.org/packages.php?ID=" . $_REQUEST['ID'] . "\n\n";
+
+ $body.= "The reason(s) given were:\n";
+ if ($_REQUEST['NOSOURCE']) {
+ $body.= " - The sources are no longer available.\n";
+ }
+ if ($_REQUEST['WONTBUILD']) {
+ $body.= " - The package no longer builds on current systems.\n";
+ }
+ if ($_REQUEST['DUPE']) {
+ $body.= " - The package is duplicated elsewhere.\n";
+ }
+ if ($_REQUEST['NAMECHANGE']) {
+ $body.= " - The package's name has changed, and a new package replaces it.\n";
+ }
+
+ $body.= "\nThe proposer added the following details:\n";
+ $body.= $_REQUEST['REASONTEXT']."\n\n";
+
+
+ $body.= "[1] - http://aur.archlinux.org/account.php?Action=AccountInfo&ID=" . $f_uid;
+
+
+ $body = wordwrap($body, 70);
+ $headers = "Reply-to: nobody at archlinux.org\nFrom:aur-notify at archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n";
+
+ @mail($row['Email'], "AUR Package Deletion Proposal for ".$row['Name'], $body, $headers);
+ }
+ }
+
+
+
+ # Update the database to know that deletion has been proposed
+ $q = "UPDATE Packages SET DeletionProposed = 1";
+ $q.= " WHERE ID = " . $_REQUEST['ID'];
+ db_query($q, $dbh);
+
+
+ print __("Package successfully proposed for deletion. Check the aur-general list for this proposal's progress.")."<br />\n";
+ print "<a href='packages.php?ID=" . $_REQUEST["ID"] . ">" . __("Back to the package page") . "</a>";
+
+ } else {
+
+ # We can be here because both of these aren't true:
+
+ if (!$_REQUEST["CONFIRM"]) {
+ # The user gave a reason, but didn't hit confirm
+ print __("You must check the last box to confirm that you wish to propose the package for deletion.") . "<br /><br />";
+ }
+
+ if ($_REQUEST["CONFIRM"]) {
+ print __("You must give at least one valid reason when proposing a package deletion.") . "<br /><br />";
+ }
+
+
+
+ # Prompt visitor for reasons for the deletion
+
+ print "<form action='pkgedit.php' method='post'>\n";
+ print "<input type='hidden' name='propose_Deletion' value='1'>\n";
+ print "<input type='hidden' name='ID' value=\"".$_REQUEST["ID"]."\">\n";
+ print __("Please select the reason(s) why you think this package should be deleted.")."<br />\n";
+
+ print " <input type='checkbox' name='NOSOURCE' value='1' /> " .__("The sources are no longer available")."<br />\n";
+ print " <input type='checkbox' name='WONTBUILD' value='1' /> " .__("The package no longer builds on a current system")."<br />\n";
+ print " <input type='checkbox' name='DUPE' value='1' /> " .__("The package is duplicated in the AUR or another repository")."<br />\n";
+ print " <input type='checkbox' name='NAMECHANGE' value='1' /> " .__("The package's name has changed (including a -vcs suffix)")."<br />\n";
+ print "<br />\n";
+ print " ".__("Please give further details here. For example, if the package is duplicated, please post a link to where. If the name has changed, please say where the new package is.")."\n";
+ print " <textarea rows='10' cols='90' name='REASONTEXT'></textarea>";
+
+ print "<br /> <br />\n";
+
+ print " <input type='checkbox' name='CONFIRM' value='1' /> " .__("Check this box to confirm that you want to propose the deletion.")."<br />\n";
+
+ print "<br /> <br />\n";
+ print "<input type='submit' value=\"".__("Submit")."\">\n";
+ print "<input type='reset' value=\"".__("Reset")."\">\n";
+ print "</form>\n";
+
+ }
+ html_footer(AUR_VERSION);
+ exit();
+}
+
+
print __("You've found a bug if you see this....")."<br />\n";
html_footer(AUR_VERSION);
diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc
index 386662c..36fd13c 100644
--- a/web/lib/pkgfuncs.inc
+++ b/web/lib/pkgfuncs.inc
@@ -714,6 +714,11 @@ function pkg_propose_deletion ($atype, $ids, $action = True) {
}
}
+ # For now, we don't allow deletion proposals through this mechanism, since we require a reason
+ if ($action) {
+ return __("Deletion proposals are not currently allowed without giving a reason.");
+ }
+
$dbh = db_connect();
$first = 1;
@@ -730,45 +735,14 @@ function pkg_propose_deletion ($atype, $ids, $action = True) {
$q = "UPDATE Packages SET DeletionProposed = " . $ood;
$q.= " WHERE ID IN (" . $propose . ")";
- if (!$action) {
- echo "Undeleting!!!!";
- }
-
db_query($q, $dbh);
if ($action) {
- # Notify maintainer and aur-general of proposal by email
- $f_name = username_from_sid($_COOKIE['AURSID']);
- $f_email = email_from_sid($_COOKIE['AURSID']);
- $f_uid = uid_from_sid($_COOKIE['AURSID']);
- $q = "SELECT Packages.Name, Users.Email, Packages.ID ";
- $q.= "FROM Packages, Users ";
- $q.= "WHERE Packages.ID IN (" . $propose .") ";
- $q.= "AND Users.ID = Packages.MaintainerUID ";
- $q.= "AND Users.ID != " . $f_uid;
- $result = db_query($q, $dbh);
- if (mysql_num_rows($result)) {
- while ($row = mysql_fetch_assoc($result)) {
- # construct email - maintainer
- $body = "Your package " . $row['Name'] . " has been proposed for deletion by " . $f_name . " [1]. You may view your package at:\nhttp://aur.archlinux.org/packages.php?ID=" . $row['ID'] . "\n\n[1] - http://aur.archlinux.org/account.php?Action=AccountInfo&ID=" . $f_uid;
- $body = wordwrap($body, 70);
- $headers = "Reply-to: nobody at archlinux.org\nFrom:aur-notify at archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n";
- @mail($row['Email'], "AUR Package Deletion Proposal for ".$row['Name'], $body, $headers);
-
- # construct email - aur-general
- $body = "The AUR package " . $row['Name'] . " has been proposed for deletion by " . $f_name . " [1]. You may view the package at:\nhttp://aur.archlinux.org/packages.php?ID=" . $row['ID'] . "\n\n[1] - http://aur.archlinux.org/account.php?Action=AccountInfo&ID=" . $f_uid;
- $body = wordwrap($body, 70);
- $headers = "Reply-to: nobody at archlinux.org\nFrom:aur-notify at archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n";
- @mail('aur-general at archlinux.org', "AUR Package Deletion Proposal for ".$row['Name'], $body, $headers);
-
- }
- }
- }
-
- if ($action) {
+ # If we wanted to allow deletion propsals without reasons, we'd do it here.
+ # And we'd then say...
return __("The selected packages have been proposed for deletion.");
} else {
- return __("The deletion proposals have been cancelled for the selection packages.");
+ return __("The deletion proposals have been cancelled for the selected packages.");
}
}
--
1.7.3
More information about the aur-dev
mailing list