summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsimo <simo>2005-06-08 01:07:55 +0000
committersimo <simo>2005-06-08 01:07:55 +0000
commit6adf639a341b8954e911fce2d2bd3e7443a1426c (patch)
tree5e4c0d686db1569ec4c64784e0be5f05c4b68d22
parent9c004010e3251d8d1b4f7430db22d3d721623577 (diff)
downloadaurweb-6adf639a341b8954e911fce2d2bd3e7443a1426c.tar.xz
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.
-rw-r--r--support/schema/aur-schema.sql9
-rw-r--r--web/html/packages.php57
-rw-r--r--web/html/pkgedit.php24
-rw-r--r--web/lang/account_po.inc2
-rw-r--r--web/lang/acctfuncs_po.inc2
-rw-r--r--web/lang/aur_po.inc2
-rw-r--r--web/lang/common_po.inc2
-rw-r--r--web/lang/hacker_po.inc2
-rw-r--r--web/lang/index_po.inc2
-rw-r--r--web/lang/logout_po.inc2
-rw-r--r--web/lang/pkgedit_po.inc12
-rw-r--r--web/lang/pkgfuncs_po.inc12
-rw-r--r--web/lang/search_po.inc52
-rw-r--r--web/lang/submit_po.inc2
-rw-r--r--web/lang/template_po.inc2
-rw-r--r--web/lang/test_po.inc2
-rw-r--r--web/lang/timeout_po.inc2
-rw-r--r--web/lib/pkgfuncs.inc15
18 files changed, 188 insertions, 15 deletions
diff --git a/support/schema/aur-schema.sql b/support/schema/aur-schema.sql
index 0b6d5e5..490a5ed 100644
--- a/support/schema/aur-schema.sql
+++ b/support/schema/aur-schema.sql
@@ -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
+);
+
diff --git a/web/html/packages.php b/web/html/packages.php
index 4ea4b01..791837f 100644
--- a/web/html/packages.php
+++ b/web/html/packages.php
@@ -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
#
diff --git a/web/html/pkgedit.php b/web/html/pkgedit.php
index 6a3f9ff..ae0170b 100644
--- a/web/html/pkgedit.php
+++ b/web/html/pkgedit.php
@@ -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
#
diff --git a/web/lang/account_po.inc b/web/lang/account_po.inc
index 833e68f..c246dca 100644
--- a/web/lang/account_po.inc
+++ b/web/lang/account_po.inc
@@ -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.";
-?>
+?> \ No newline at end of file
diff --git a/web/lang/acctfuncs_po.inc b/web/lang/acctfuncs_po.inc
index 2c070aa..862fc78 100644
--- a/web/lang/acctfuncs_po.inc
+++ b/web/lang/acctfuncs_po.inc
@@ -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.";
-?>
+?> \ No newline at end of file
diff --git a/web/lang/aur_po.inc b/web/lang/aur_po.inc
index 197ca58..8d32378 100644
--- a/web/lang/aur_po.inc
+++ b/web/lang/aur_po.inc
@@ -89,4 +89,4 @@ $_t["en"]["Developer"] = "Developer";
$_t["de"]["Developer"] = "Entwickler";
$_t["pl"]["Developer"] = "Developer";
-?>
+?> \ No newline at end of file
diff --git a/web/lang/common_po.inc b/web/lang/common_po.inc
index 617a9c3..871d477 100644
--- a/web/lang/common_po.inc
+++ b/web/lang/common_po.inc
@@ -77,4 +77,4 @@ $_t["en"]["Username"] = "Username";
$_t["de"]["Username"] = "Benutzername";
$_t["pl"]["Username"] = "Użytkownik";
-?>
+?> \ No newline at end of file
diff --git a/web/lang/hacker_po.inc b/web/lang/hacker_po.inc
index 1af174d..5798d11 100644
--- a/web/lang/hacker_po.inc
+++ b/web/lang/hacker_po.inc
@@ -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.";
-?>
+?> \ No newline at end of file
diff --git a/web/lang/index_po.inc b/web/lang/index_po.inc
index d13e9d5..be5ee66 100644
--- a/web/lang/index_po.inc
+++ b/web/lang/index_po.inc
@@ -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ść.";
-?>
+?> \ No newline at end of file
diff --git a/web/lang/logout_po.inc b/web/lang/logout_po.inc
index d52c1d5..4b3332f 100644
--- a/web/lang/logout_po.inc
+++ b/web/lang/logout_po.inc
@@ -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.";
-?>
+?> \ No newline at end of file
diff --git a/web/lang/pkgedit_po.inc b/web/lang/pkgedit_po.inc
index 0d67cc8..30cdc15 100644
--- a/web/lang/pkgedit_po.inc
+++ b/web/lang/pkgedit_po.inc
@@ -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. <--";
+
+?> \ No newline at end of file
diff --git a/web/lang/pkgfuncs_po.inc b/web/lang/pkgfuncs_po.inc
index d025117..3a9d429 100644
--- a/web/lang/pkgfuncs_po.inc
+++ b/web/lang/pkgfuncs_po.inc
@@ -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. <--";
+
+?> \ No newline at end of file
diff --git a/web/lang/search_po.inc b/web/lang/search_po.inc
index ebb8ee0..2af586e 100644
--- a/web/lang/search_po.inc
+++ b/web/lang/search_po.inc
@@ -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. <--";
+
+?> \ No newline at end of file
diff --git a/web/lang/submit_po.inc b/web/lang/submit_po.inc
index 4dd00ce..de7c942 100644
--- a/web/lang/submit_po.inc
+++ b/web/lang/submit_po.inc
@@ -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. <--";
-?>
+?> \ No newline at end of file
diff --git a/web/lang/template_po.inc b/web/lang/template_po.inc
index 8cdc85f..eb021e9 100644
--- a/web/lang/template_po.inc
+++ b/web/lang/template_po.inc
@@ -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ć!";
-?>
+?> \ No newline at end of file
diff --git a/web/lang/test_po.inc b/web/lang/test_po.inc
index f54f06b..390dc6b 100644
--- a/web/lang/test_po.inc
+++ b/web/lang/test_po.inc
@@ -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'.";
-?>
+?> \ No newline at end of file
diff --git a/web/lang/timeout_po.inc b/web/lang/timeout_po.inc
index 71ea1d7..06bc528 100644
--- a/web/lang/timeout_po.inc
+++ b/web/lang/timeout_po.inc
@@ -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.";
-?>
+?> \ No newline at end of file
diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc
index 16da5b9..451467f 100644
--- a/web/lib/pkgfuncs.inc
+++ b/web/lib/pkgfuncs.inc
@@ -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";