Re: [aur-dev] [PATCH] Move deletion proposal code from pkgfuncs.inc to pkgedit.php and add mechanism for dealing with reasons for deletion.

2010-10-07 Thread Loui Chang
On Sun 26 Sep 2010 21:46 +0100, Peter Lewis wrote:
 ---
  web/html/pkgedit.php |  210 
 ++
  web/lib/pkgfuncs.inc |   42 ++
  2 files changed, 218 insertions(+), 34 deletions(-)

Just a quick note:
There is a patch in my queue which removes all current code out of
pkgedit, which is something that I've been meaning to do.

I'd recommend altering the mechanism so that it doesn't reside in
pkgedit. Thanks Peter.



[aur-dev] [PATCH] Move deletion proposal code from pkgfuncs.inc to pkgedit.php and add mechanism for dealing with reasons for deletion.

2010-09-26 Thread Peter Lewis
---
 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=AccountInfoID=; . $f_uid;
+   
+   
+   $body = wordwrap($body, 70);
+   $headers = Reply-to: 
nob...@archlinux.org\nfrom:aur-not...@archlinux.org\nx-mailer: PHP\nX-MimeOLE: 
Produced By AUR\n;
+
+   # TODO: add the real aur-gene...@archlinux.org address here 
when done with testing
+   @mail('aur-gene...@__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.=   -