mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 09:43:03 +00:00
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:
parent
9c004010e3
commit
6adf639a34
18 changed files with 188 additions and 15 deletions
|
@ -198,3 +198,12 @@ CREATE TABLE PackageComments (
|
|||
FOREIGN KEY (PackageID) REFERENCES Packages(ID) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- Comment addition notifications
|
||||
--
|
||||
CREATE TABLE CommentNotify (
|
||||
PkgID INTEGER UNSIGNED NOT NULL,
|
||||
UserID INTEGER UNSIGNED NOT NULL,
|
||||
FOREIGN KEY (PkgID) REFERENCES Packages(ID) ON DELETE CASCADE,
|
||||
FOREIGN KEY (UserID) REFERENCES Users(ID) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
|
|
|
@ -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
|
||||
#
|
||||
|
|
|
@ -76,6 +76,30 @@ if ($_REQUEST["add_Comment"]) {
|
|||
print __("Comment has been added.")."<br /> <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
|
||||
#
|
||||
|
|
|
@ -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. <--";
|
||||
|
||||
?>
|
|
@ -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. <--";
|
||||
|
||||
?>
|
|
@ -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. <--";
|
||||
|
||||
?>
|
|
@ -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,6 +445,17 @@ function package_details($id=0, $SID="") {
|
|||
print "<input type='submit' class='button' name='do_UnVote'";
|
||||
print " value='".__("Un-Vote")."'>";
|
||||
}
|
||||
# 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";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue