SQL CHANGES: New table CommentNotify with fields:

PkgID
	UserID
This implements emailing comment notifications, including a user option to
enable/disable it on the package page. It uses php's mail() function to do
it and sends to everyone on the notify list as BCC.

This needs some more testing before public consumption.
This commit is contained in:
simo 2005-06-08 01:07:55 +00:00
parent 9c004010e3
commit 6adf639a34
18 changed files with 188 additions and 15 deletions

View file

@ -243,6 +243,10 @@ if (isset($_REQUEST["do_Flag"])) {
$q = "DELETE FROM Packages WHERE ID = " . $id;
$result = db_query($q, $dbh);
# 7) delete from CommentNotify
$q = "DELETE FROM CommentNotify 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)
@ -458,6 +462,59 @@ if (isset($_REQUEST["do_Flag"])) {
pkgsearch_results_link();
} elseif (isset($_REQUEST["do_Notify"])) {
# I realize that the implementation here seems a bit convoluted, but we want to
# ensure that everything happens as it should, even if someone called this page
# without having clicked a button somewhere (naughty naughty). This also leaves
# room to someday expand and allow to add oneself to multiple lists at once. -SL
if (!$atype) {
print __("You must be logged in before you can get notifications on comments.");
print "<br />\n";
} else {
if (!empty($ids)) {
$dbh = db_connect();
$uid = uid_from_sid($_COOKIE["AURSID"]);
# There currently shouldn't be multiple requests here, but the format in which
# it's sent requires this
while (list($pid, $v) = each($ids)) {
$q = "INSERT INTO CommentNotify (PkgID, UserID) VALUES (".$pid.', '.$uid.')';
db_query($q, $dbh);
print '<p>';
print __("You have been added to the comment notification list.");
print '<br /></p>';
pkgdetails_link($pid);
}
} else {
print '<p>';
print __("Couldn't add to notification list.");
print '<br /></p>';
}
}
} elseif (isset($_REQUEST["do_UnNotify"])) {
if (!$atype) {
print __("You must be logged in before you can cancel notification on comments.");
print "<br />\n";
} else {
if (!empty($ids)) {
$dbh = db_connect();
$uid = uid_from_sid($_COOKIE["AURSID"]);
# There currently shouldn't be multiple requests here, but the format in which
# it's sent requires this
while (list($pid, $v) = each($ids)) {
$q = "DELETE FROM CommentNotify WHERE PkgID = ".$pid;
$q.= " AND UserID = ".$uid;
db_query($q, $dbh);
print '<p>';
print __("You have been removed from the comment notification list.");
print '<br /></p>';
pkgdetails_link($pid);
}
} else {
print '<p>';
print __("Couldn't remove from notification list.");
print '<br /></p>';
}
}
} else {
# do_More/do_Less/do_Search/do_MyPackages - just do a search
#

View file

@ -76,6 +76,30 @@ if ($_REQUEST["add_Comment"]) {
print __("Comment has been added.")."<br />&nbsp;<br />\n";
pkgdetails_link($_REQUEST["ID"]);
# Send email notifications
#
$q = "SELECT CommentNotify.*, Users.Email ";
$q.= "FROM CommentNotify, Users ";
$q.= "WHERE Users.ID = CommentNotify.UserID ";
$q.= "AND CommentNotify.PkgID = ".intval($_REQUEST["ID"]);
$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.Name ";
$q.= "FROM Packages ";
$q.= "WHERE Packages.ID = ".intval($_REQUEST["ID"]);
$result = db_query($q, $dbh);
$row = mysql_fetch_assoc($result);
$body = __("A comment has been added to %s, you may view it at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=%s\n\nYou recieved this e-mail because you chose to recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the appropriate control.",array($row['Name'],$_REQUEST["ID"]));
$body = wordwrap($body, 70);
$bcc = implode(', ', $bcc);
$headers = "Bcc: $bcc\nReply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n";
@mail(' ', __("AUR Comment Notification for %s",array($row['Name'])), $body, $headers);
}
} else {
# Prompt visitor for comment
#

View file

@ -327,4 +327,4 @@ $_t["en"]["You do not have permission to edit this account."] = "You do not have
$_t["de"]["You do not have permission to edit this account."] = "Zugriff für das Bearbeiten dieses Benutzerkontos verweigert.";
$_t["pl"]["You do not have permission to edit this account."] = "Nie masz uprawnień do edycji tego konta.";
?>
?>

View file

@ -233,4 +233,4 @@ $_t["en"]["A Trusted User cannot assign Developer status."] = "A Trusted User ca
# $_t["de"]["A Trusted User cannot assign Developer status."] = "--> Deutsche Übersetzung hier. <--";
$_t["pl"]["A Trusted User cannot assign Developer status."] = "Zaufany użytkownik nie może nadać statusu developera.";
?>
?>

View file

@ -89,4 +89,4 @@ $_t["en"]["Developer"] = "Developer";
$_t["de"]["Developer"] = "Entwickler";
$_t["pl"]["Developer"] = "Developer";
?>
?>

View file

@ -77,4 +77,4 @@ $_t["en"]["Username"] = "Username";
$_t["de"]["Username"] = "Benutzername";
$_t["pl"]["Username"] = "Użytkownik";
?>
?>

View file

@ -23,4 +23,4 @@ $_t["en"]["If this problem persists, please contact the site administrator."] =
# $_t["de"]["If this problem persists, please contact the site administrator."] = "--> Deutsche Übersetzung hier. <--";
$_t["pl"]["If this problem persists, please contact the site administrator."] = "Jeżeli ten problem się powtarza, skontaktuj się z administratorem strony.";
?>
?>

View file

@ -155,4 +155,4 @@ $_t["en"]["Though we can't vouch for their contents, we provide a %hlist of user
# $_t["de"]["Though we can't vouch for their contents, we provide a %hlist of user repositories%h for your convenience."] = "--> Deutsche Übersetzung hier. <--";
$_t["pl"]["Though we can't vouch for their contents, we provide a %hlist of user repositories%h for your convenience."] = "Dla Twojej wygody podajemy %hlistę repozytoriów użytkowników%h, ale uwaga - nie odpowiadamy za ich zawartość.";
?>
?>

View file

@ -23,4 +23,4 @@ $_t["en"]["You have been successfully logged out."] = "You have been successfull
# $_t["de"]["You have been successfully logged out."] = "--> Deutsche Übersetzung hier. <--";
$_t["pl"]["You have been successfully logged out."] = "Zostałeś pomyślnie wylogowany.";
?>
?>

View file

@ -89,4 +89,14 @@ $_t["en"]["You've found a bug if you see this...."] = "You've found a bug if you
# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--";
$_t["pl"]["You've found a bug if you see this...."] = "Jeżeli to widzisz, to znalazłeś błąd...";
?>
$_t["en"]["A comment has been added to %s, you may view it at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=%s\n\nYou recieved this e-mail because you chose to recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the appropriate control."] = "A comment has been added to %s, you may view it at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=%s\n\nYou recieved this e-mail because you chose to have recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the appropriate control.";
# $_t["es"]["A comment has been added to %s, you may view it at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=%s\n\nYou recieved this e-mail because you chose to have recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the appropriate control."] = "--> Traducción española aquí. <--";
# $_t["fr"]["A comment has been added to %s, you may view it at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=%s\n\nYou recieved this e-mail because you chose to have recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the appropriate control."] = "--> Traduction française ici. <--";
# $_t["de"]["A comment has been added to %s, you may view it at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=%s\n\nYou recieved this e-mail because you chose to have recieve notifications of new comments on this package, if you no longer wish to recieve notifications about this package, please go the the above package page and click the appropriate control."] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["AUR Comment Notification for %s"] = "AUR Comment Notification for %s";
# $_t["es"]["AUR Comment Notification for %s"] = "--> Traducción española aquí. <--";
# $_t["fr"]["AUR Comment Notification for %s"] = "--> Traduction française ici. <--";
# $_t["de"]["AUR Comment Notification for %s"] = "--> Deutsche Übersetzung hier. <--";
?>

View file

@ -308,4 +308,14 @@ $_t["en"]["Package Listing"] = "Package Listing";
# $_t["de"]["Package Listing"] = "--> Deutsche Übersetzung hier. <--";
$_t["pl"]["Package Listing"] = "Lista pakietów";
?>
$_t["en"]["UnNotify"] = "UnNotify";
# $_t["es"]["UnNotify"] = "--> Traducción española aquí. <--";
# $_t["fr"]["UnNotify"] = "--> Traduction française ici. <--";
# $_t["de"]["UnNotify"] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["Notify"] = "Notify";
# $_t["es"]["Notify"] = "--> Traducción española aquí. <--";
# $_t["fr"]["Notify"] = "--> Traduction française ici. <--";
# $_t["de"]["Notify"] = "--> Deutsche Übersetzung hier. <--";
?>

View file

@ -143,4 +143,54 @@ $_t["en"]["Your votes have been cast for the selected packages."] = "Your votes
# $_t["de"]["Your votes have been cast for the selected packages."] = "--> Deutsche Übersetzung hier. <--";
$_t["pl"]["Your votes have been cast for the selected packages."] = "Twoje głosy zostały przyznane wybranym pakietom.";
?>
$_t["en"]["None of the selected packages could be deleted."] = "None of the selected packages could be deleted.";
# $_t["es"]["None of the selected packages could be deleted."] = "--> Traducción española aquí. <--";
# $_t["fr"]["None of the selected packages could be deleted."] = "--> Traduction française ici. <--";
# $_t["de"]["None of the selected packages could be deleted."] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["You must be logged in before you can get notifications on comments."] = "You must be logged in before you can get notifications on comments.";
# $_t["es"]["You must be logged in before you can get notifications on comments."] = "--> Traducción española aquí. <--";
# $_t["fr"]["You must be logged in before you can get notifications on comments."] = "--> Traduction française ici. <--";
# $_t["de"]["You must be logged in before you can get notifications on comments."] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["The selected packages have been deleted."] = "The selected packages have been deleted.";
# $_t["es"]["The selected packages have been deleted."] = "--> Traducción española aquí. <--";
# $_t["fr"]["The selected packages have been deleted."] = "--> Traduction française ici. <--";
# $_t["de"]["The selected packages have been deleted."] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["You have been removed from the comment notification list."] = "You have been removed from the comment notification list.";
# $_t["es"]["You have been removed from the comment notification list."] = "--> Traducción española aquí. <--";
# $_t["fr"]["You have been removed from the comment notification list."] = "--> Traduction française ici. <--";
# $_t["de"]["You have been removed from the comment notification list."] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["You must be logged in before you can cancel notification on comments."] = "You must be logged in before you can cancel notification on comments.";
# $_t["es"]["You must be logged in before you can cancel notification on comments."] = "--> Traducción española aquí. <--";
# $_t["fr"]["You must be logged in before you can cancel notification on comments."] = "--> Traduction française ici. <--";
# $_t["de"]["You must be logged in before you can cancel notification on comments."] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["You have been added to the comment notification list."] = "You have been added to the comment notification list.";
# $_t["es"]["You have been added to the comment notification list."] = "--> Traducción española aquí. <--";
# $_t["fr"]["You have been added to the comment notification list."] = "--> Traduction française ici. <--";
# $_t["de"]["You have been added to the comment notification list."] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["You did not select any packages to disown."] = "You did not select any packages to disown.";
# $_t["es"]["You did not select any packages to disown."] = "--> Traducción española aquí. <--";
# $_t["fr"]["You did not select any packages to disown."] = "--> Traduction française ici. <--";
# $_t["de"]["You did not select any packages to disown."] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["You did not select any packages to delete."] = "You did not select any packages to delete.";
# $_t["es"]["You did not select any packages to delete."] = "--> Traducción española aquí. <--";
# $_t["fr"]["You did not select any packages to delete."] = "--> Traduction française ici. <--";
# $_t["de"]["You did not select any packages to delete."] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["Couldn't add to notification list."] = "Couldn't add to notification list.";
# $_t["es"]["Couldn't add to notification list."] = "--> Traducción española aquí. <--";
# $_t["fr"]["Couldn't add to notification list."] = "--> Traduction française ici. <--";
# $_t["de"]["Couldn't add to notification list."] = "--> Deutsche Übersetzung hier. <--";
$_t["en"]["Couldn't remove from notification list."] = "Couldn't remove from notification list.";
# $_t["es"]["Couldn't remove from notification list."] = "--> Traducción española aquí. <--";
# $_t["fr"]["Couldn't remove from notification list."] = "--> Traduction française ici. <--";
# $_t["de"]["Couldn't remove from notification list."] = "--> Deutsche Übersetzung hier. <--";
?>

View file

@ -244,4 +244,4 @@ $_t["en"]["Error - No file uploaded"] = "Error - No file uploaded";
# $_t["fr"]["Package upload successful"] = "--> Traduction française ici. <--";
# $_t["de"]["Package upload successful"] = "--> Deutsche Übersetzung hier. <--";
?>
?>

View file

@ -17,4 +17,4 @@ $_t["en"]["Hi, this is worth reading!"] = "Hi, this is worth reading!";
# $_t["de"]["Hi, this is worth reading!"] = "--> Deutsche Übersetzung hier. <--";
$_t["pl"]["Hi, this is worth reading!"] = "Witaj, warto to przeczytać!";
?>
?>

View file

@ -35,4 +35,4 @@ $_t["fr"]["My current language tag is: '%s'."] = "Ma étiquette de langue couran
$_t["de"]["My current language tag is: '%s'."] = "Meine gegenwärtige Sprachflagge ist: '%s'.";
$_t["pl"]["My current language tag is: '%s'."] = "Etykieta mojego obecnego języka to: '%s'.";
?>
?>

View file

@ -23,4 +23,4 @@ $_t["en"]["Your session has timed out. You must log in again."] = "Your session
# $_t["de"]["Your session has timed out. You must log in again."] = "--> Deutsche Übersetzung hier. <--";
$_t["pl"]["Your session has timed out. You must log in again."] = "Twoja sesja wygasła. Musisz zalogować się ponownie.";
?>
?>

View file

@ -434,6 +434,8 @@ function package_details($id=0, $SID="") {
print "<td><form action='/packages.php' method='post'>\n";
print "<input type='hidden' name='IDs[".$row["ID"]."]' value='1'>\n";
print "<input type='hidden' name='ID' value='".$row["ID"]."'>\n";
# Voting Button
#
$q = "SELECT * FROM PackageVotes WHERE UsersID = ".uid_from_sid($SID);
$q.= " AND PackageID = ".$row["ID"];
if (!mysql_num_rows(db_query($q, $dbh))) {
@ -443,7 +445,18 @@ function package_details($id=0, $SID="") {
print "<input type='submit' class='button' name='do_UnVote'";
print " value='".__("Un-Vote")."'>";
}
print "</form></td>\n";
# Comment Nofify Button
#
$q = "SELECT * FROM CommentNotify WHERE UserID = ".uid_from_sid($SID);
$q.= " AND PkgID = ".$row["ID"];
if (!mysql_num_rows(db_query($q, $dbh))) {
print "<input type='submit' class='button' name='do_Notify'";
print " value='".__("Notify")."'>";
} else {
print "<input type='submit' class='button' name='do_UnNotify'";
print " value='".__("UnNotify")."'>";
}
print "</form></td>\n";
}
print "</tr>\n";