[aur-dev] [PATCH] send emails when delteing packages
Florian Pritz
bluewind at xinu.at
Thu Sep 8 04:45:33 EDT 2011
Signed-off-by: Florian Pritz <bluewind at xinu.at>
---
web/lib/pkgfuncs.inc.php | 43 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index 3e89fa3..b6d4d08 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -710,6 +710,49 @@ function pkg_delete ($atype, $ids, $mergepkgid, $dbh=NULL) {
}
if ($mergepkgid) {
+ $mergepkgname = pkgname_from_id($mergepkgid, $dbh);
+ }
+
+ # Send email notifications
+ foreach ($ids as $pkgid) {
+ $q = 'SELECT CommentNotify.*, Users.Email ';
+ $q.= 'FROM CommentNotify, Users ';
+ $q.= 'WHERE Users.ID = CommentNotify.UserID ';
+ $q.= 'AND CommentNotify.UserID != ' . uid_from_sid($_COOKIE['AURSID']) . ' ';
+ $q.= 'AND CommentNotify.PkgID = ' . intval($pkgid);
+ $result = db_query($q, $dbh);
+ $bcc = array();
+
+ if (mysql_num_rows($result)) {
+ while ($row = mysql_fetch_assoc($result)) {
+ array_push($bcc, $row['Email']);
+ }
+
+ $q = 'SELECT Packages.* ';
+ $q.= 'FROM Packages ';
+ $q.= 'WHERE Packages.ID = ' . intval($pkgid);
+ $result = db_query($q, $dbh);
+ $row = mysql_fetch_assoc($result);
+
+ # TODO: native language emails for users, based on their prefs
+ # Simply making these strings translatable won't work, users would be
+ # getting emails in the language that the user who posted the comment was in
+ $body = "";
+ if ($mergepkgid) {
+ $body .= username_from_sid($_COOKIE['AURSID']) . " merged \"".$row["Name"]."\" into \"$mergepkgname\".\n\n";
+ $body .= "\n\n---\nYou will no longer receive notifications about this package, please go to https://aur.archlinux.org/packages.php?ID=".$mergepkgid." and click the Notify button if you wish to recieve them again.";
+ } else {
+ $body .= username_from_sid($_COOKIE['AURSID']) . " deleted \"".$row["Name"]."\".\n\n";
+ $body .= "\n\n---\nYou will no longer receive notifications about this package.";
+ }
+ $body = wordwrap($body, 70);
+ $bcc = implode(', ', $bcc);
+ $headers = "Bcc: $bcc\nReply-to: nobody at archlinux.org\nFrom: aur-notify at archlinux.org\nX-Mailer: AUR\n";
+ @mail(' ', "AUR Package deleted: " . $row['Name'], $body, $headers);
+ }
+ }
+
+ if ($mergepkgid) {
/* Merge comments */
$q = "UPDATE PackageComments ";
$q.= "SET PackageID = " . intval($mergepkgid) . " ";
--
1.7.6.1
More information about the aur-dev
mailing list