[aur-dev] [PATCH 1/3] Rename the CommentNotify table to PackageNotifications
As a preparatory step to adding support for package notifications on events other than comments, rename the database table accordingly. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- git-interface/git-serve.py | 2 +- git-interface/git-update.py | 4 ++-- schema/aur-schema.sql | 6 +++--- scripts/notify.py | 8 ++++---- upgrading/4.2.0.txt | 6 ++++++ web/lib/acctfuncs.inc.php | 2 +- web/lib/pkgbasefuncs.inc.php | 14 +++++++------- web/lib/pkgfuncs.inc.php | 6 +++--- 8 files changed, 27 insertions(+), 21 deletions(-) diff --git a/git-interface/git-serve.py b/git-interface/git-serve.py index 8581590..ff389d2 100755 --- a/git-interface/git-serve.py +++ b/git-interface/git-serve.py @@ -81,7 +81,7 @@ def create_pkgbase(pkgbase, user): "UNIX_TIMESTAMP(), %s, %s)", [pkgbase, userid, userid]) pkgbase_id = cur.lastrowid - cur.execute("INSERT INTO CommentNotify (PackageBaseID, UserID) " + + cur.execute("INSERT INTO PackageNotifications (PackageBaseID, UserID) " + "VALUES (%s, %s)", [pkgbase_id, userid]) db.commit() diff --git a/git-interface/git-update.py b/git-interface/git-update.py index a4a8d8d..3b587b3 100755 --- a/git-interface/git-update.py +++ b/git-interface/git-update.py @@ -160,11 +160,11 @@ def save_metadata(metadata, db, cur, user): # Add user to notification list on adoption. if was_orphan: - cur.execute("SELECT COUNT(*) FROM CommentNotify WHERE " + + cur.execute("SELECT COUNT(*) FROM PackageNotifications WHERE " + "PackageBaseID = %s AND UserID = %s", [pkgbase_id, user_id]) if cur.fetchone()[0] == 0: - cur.execute("INSERT INTO CommentNotify (PackageBaseID, UserID) " + + cur.execute("INSERT INTO PackageNotifications (PackageBaseID, UserID) " + "VALUES (%s, %s)", [pkgbase_id, user_id]) db.commit() diff --git a/schema/aur-schema.sql b/schema/aur-schema.sql index 9645e13..543f025 100644 --- a/schema/aur-schema.sql +++ b/schema/aur-schema.sql @@ -284,15 +284,15 @@ CREATE TABLE PackageComaintainers ( FOREIGN KEY (PackageBaseID) REFERENCES PackageBases(ID) ON DELETE CASCADE ) ENGINE = InnoDB; --- Comment addition notifications +-- Package base notifications -- -CREATE TABLE CommentNotify ( +CREATE TABLE PackageNotifications ( PackageBaseID INTEGER UNSIGNED NOT NULL, UserID INTEGER UNSIGNED NOT NULL, FOREIGN KEY (PackageBaseID) REFERENCES PackageBases(ID) ON DELETE CASCADE, FOREIGN KEY (UserID) REFERENCES Users(ID) ON DELETE CASCADE ) ENGINE = InnoDB; -CREATE UNIQUE INDEX NotifyUserIDPkgID ON CommentNotify (UserID, PackageBaseID); +CREATE UNIQUE INDEX NotifyUserIDPkgID ON PackageNotifications (UserID, PackageBaseID); -- Package name blacklist -- diff --git a/scripts/notify.py b/scripts/notify.py index 7b10efb..08cdda8 100755 --- a/scripts/notify.py +++ b/scripts/notify.py @@ -88,10 +88,10 @@ def get_maintainer_email(cur, pkgbase_id): def get_recipients(cur, pkgbase_id, uid): cur.execute('SELECT DISTINCT Users.Email FROM Users ' + - 'INNER JOIN CommentNotify ' + - 'ON CommentNotify.UserID = Users.ID WHERE ' + - 'CommentNotify.UserID != %s AND ' + - 'CommentNotify.PackageBaseID = %s', [uid, pkgbase_id]) + 'INNER JOIN PackageNotifications ' + + 'ON PackageNotifications.UserID = Users.ID WHERE ' + + 'PackageNotifications.UserID != %s AND ' + + 'PackageNotifications.PackageBaseID = %s', [uid, pkgbase_id]) return [row[0] for row in cur.fetchall()] diff --git a/upgrading/4.2.0.txt b/upgrading/4.2.0.txt index c43c6e7..7d404b3 100644 --- a/upgrading/4.2.0.txt +++ b/upgrading/4.2.0.txt @@ -41,3 +41,9 @@ ALTER TABLE PackageRequests ADD COLUMN ClosureComment TEXT NOT NULL DEFAULT ''; ---- ALTER TABLE PackageBases MODIFY COLUMN FlaggerComment TEXT NOT NULL DEFAULT ''; ---- + +7. Rename the CommentNotify table to PackageNotifications: + +---- +ALTER TABLE CommentNotify RENAME TO PackageNotifications; +---- diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php index 6fb2b40..0c6388a 100644 --- a/web/lib/acctfuncs.inc.php +++ b/web/lib/acctfuncs.inc.php @@ -897,7 +897,7 @@ function user_delete($id) { $fields_delete = array( array("Sessions", "UsersID"), array("PackageVotes", "UsersID"), - array("CommentNotify", "UsersID") + array("PackageNotifications", "UsersID") ); $fields_set_null = array( diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php index 20f5bb4..c0e672a 100644 --- a/web/lib/pkgbasefuncs.inc.php +++ b/web/lib/pkgbasefuncs.inc.php @@ -542,15 +542,15 @@ function pkgbase_delete ($base_ids, $merge_base_id, $via, $grant=false) { $dbh->exec($q); /* Merge notifications */ - $q = "SELECT DISTINCT UserID FROM CommentNotify cn "; + $q = "SELECT DISTINCT UserID FROM PackageNotifications cn "; $q.= "WHERE PackageBaseID IN (" . implode(",", $base_ids) . ") "; - $q.= "AND NOT EXISTS (SELECT * FROM CommentNotify cn2 "; + $q.= "AND NOT EXISTS (SELECT * FROM PackageNotifications cn2 "; $q.= "WHERE cn2.PackageBaseID = " . intval($merge_base_id) . " "; $q.= "AND cn2.UserID = cn.UserID)"; $result = $dbh->query($q); while ($notify_uid = $result->fetch(PDO::FETCH_COLUMN, 0)) { - $q = "INSERT INTO CommentNotify (UserID, PackageBaseID) "; + $q = "INSERT INTO PackageNotifications (UserID, PackageBaseID) "; $q.= "VALUES (" . intval($notify_uid) . ", " . intval($merge_base_id) . ")"; $dbh->exec($q); } @@ -840,7 +840,7 @@ function pkgbase_user_voted($uid, $base_id) { function pkgbase_user_notify($uid, $base_id) { $dbh = DB::connect(); - $q = "SELECT * FROM CommentNotify WHERE UserID = " . $dbh->quote($uid); + $q = "SELECT * FROM PackageNotifications WHERE UserID = " . $dbh->quote($uid); $q.= " AND PackageBaseID = " . $dbh->quote($base_id); $result = $dbh->query($q); @@ -898,20 +898,20 @@ function pkgbase_notify ($base_ids, $action=true) { if ($action) { - $q = "SELECT COUNT(*) FROM CommentNotify WHERE "; + $q = "SELECT COUNT(*) FROM PackageNotifications WHERE "; $q .= "UserID = $uid AND PackageBaseID = $bid"; /* Notification already added. Don't add again. */ $result = $dbh->query($q); if ($result->fetchColumn() == 0) { - $q = "INSERT INTO CommentNotify (PackageBaseID, UserID) VALUES ($bid, $uid)"; + $q = "INSERT INTO PackageNotifications (PackageBaseID, UserID) VALUES ($bid, $uid)"; $dbh->exec($q); } $output .= $basename; } else { - $q = "DELETE FROM CommentNotify WHERE PackageBaseID = $bid "; + $q = "DELETE FROM PackageNotifications WHERE PackageBaseID = $bid "; $q .= "AND UserID = $uid"; $dbh->exec($q); diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index c2bbe38..0e152dd 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -716,7 +716,7 @@ function pkg_search_page($SID="") { /* Build the package search query. */ $q_select = "SELECT "; if ($SID) { - $q_select .= "CommentNotify.UserID AS Notify, + $q_select .= "PackageNotifications.UserID AS Notify, PackageVotes.UsersID AS Voted, "; } $q_select .= "Users.Username AS Maintainer, @@ -731,8 +731,8 @@ function pkg_search_page($SID="") { /* This is not needed for the total row count query. */ $q_from_extra = "LEFT JOIN PackageVotes ON (PackageBases.ID = PackageVotes.PackageBaseID AND PackageVotes.UsersID = $myuid) - LEFT JOIN CommentNotify - ON (PackageBases.ID = CommentNotify.PackageBaseID AND CommentNotify.UserID = $myuid) "; + LEFT JOIN PackageNotifications + ON (PackageBases.ID = PackageNotifications.PackageBaseID AND PackageNotifications.UserID = $myuid) "; } else { $q_from_extra = ""; } -- 2.7.0
Add a configuration option to the account edit page that allows for globally enabling/disabling package base comment notifications. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- schema/aur-schema.sql | 1 + scripts/notify.py | 12 +++++++++++- upgrading/4.2.0.txt | 7 +++++++ web/html/account.php | 18 ++++++++++++------ web/html/register.php | 4 ++-- web/lib/acctfuncs.inc.php | 7 +++++-- web/template/account_edit_form.php | 8 ++++++++ 7 files changed, 46 insertions(+), 11 deletions(-) diff --git a/schema/aur-schema.sql b/schema/aur-schema.sql index 543f025..13a052e 100644 --- a/schema/aur-schema.sql +++ b/schema/aur-schema.sql @@ -38,6 +38,7 @@ CREATE TABLE Users ( LastLoginIPAddress INTEGER UNSIGNED NOT NULL DEFAULT 0, InactivityTS BIGINT UNSIGNED NOT NULL DEFAULT 0, RegistrationTS TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + CommentNotify TINYINT(1) NOT NULL DEFAULT 1, PRIMARY KEY (ID), UNIQUE (Username), UNIQUE (Email), diff --git a/scripts/notify.py b/scripts/notify.py index 08cdda8..6b10600 100755 --- a/scripts/notify.py +++ b/scripts/notify.py @@ -95,6 +95,16 @@ def get_recipients(cur, pkgbase_id, uid): return [row[0] for row in cur.fetchall()] +def get_comment_recipients(cur, pkgbase_id, uid): + cur.execute('SELECT DISTINCT Users.Email FROM Users ' + + 'INNER JOIN PackageNotifications ' + + 'ON PackageNotifications.UserID = Users.ID WHERE ' + + 'Users.CommentNotify = 1 AND ' + + 'PackageNotifications.UserID != %s AND ' + + 'PackageNotifications.PackageBaseID = %s', [uid, pkgbase_id]) + return [row[0] for row in cur.fetchall()] + + def get_request_recipients(cur, pkgbase_id, uid): cur.execute('SELECT DISTINCT Users.Email FROM Users ' + 'INNER JOIN PackageBases ' + @@ -159,7 +169,7 @@ def welcome(cur, uid): def comment(cur, uid, pkgbase_id, comment_id): user = username_from_id(cur, uid) pkgbase = pkgbase_from_id(cur, pkgbase_id) - to = get_recipients(cur, pkgbase_id, uid) + to = get_comment_recipients(cur, pkgbase_id, uid) text = get_comment(cur, comment_id) user_uri = aur_location + '/account/' + user + '/' diff --git a/upgrading/4.2.0.txt b/upgrading/4.2.0.txt index 7d404b3..ce76f49 100644 --- a/upgrading/4.2.0.txt +++ b/upgrading/4.2.0.txt @@ -47,3 +47,10 @@ ALTER TABLE PackageBases MODIFY COLUMN FlaggerComment TEXT NOT NULL DEFAULT ''; ---- ALTER TABLE CommentNotify RENAME TO PackageNotifications; ---- + +8. Add new columns to store notification settings: + +---- +ALTER TABLE Users + ADD COLUMN CommentNotify TINYINT(1) NOT NULL DEFAULT 1; +---- diff --git a/web/html/account.php b/web/html/account.php index b2886fc..2f85a8a 100644 --- a/web/html/account.php +++ b/web/html/account.php @@ -35,7 +35,8 @@ if ($action == "UpdateAccount") { in_request("E"), in_request("H"), in_request("P"), in_request("C"), in_request("R"), in_request("L"), in_request("I"), in_request("K"), in_request("PK"), - in_request("J"), in_request("ID"), $row["Username"]); + in_request("J"), in_request("CN"), in_request("ID"), + $row["Username"]); } } @@ -81,7 +82,8 @@ if (isset($_COOKIE["AURSID"])) { $row["AccountTypeID"], $row["Suspended"], $row["Email"], $row["HideEmail"], "", "", $row["RealName"], $row["LangPreference"], $row["IRCNick"], $row["PGPKey"], $PK, - $row["InactivityTS"] ? 1 : 0, $row["ID"], $row["Username"]); + $row["InactivityTS"] ? 1 : 0, $row["CommentNotify"], + $row["ID"], $row["Username"]); } else { print __("You do not have permission to edit this account."); } @@ -114,10 +116,14 @@ if (isset($_COOKIE["AURSID"])) { print $update_account_message; if (!$success) { - display_account_form("UpdateAccount", in_request("U"), in_request("T"), - in_request("S"), in_request("E"), in_request("H"), in_request("P"), - in_request("C"), in_request("R"), in_request("L"), in_request("I"), - in_request("K"), in_request("PK"), in_request("J"), in_request("ID"), + display_account_form("UpdateAccount", in_request("U"), + in_request("T"), in_request("S"), + in_request("E"), in_request("H"), + in_request("P"), in_request("C"), + in_request("R"), in_request("L"), + in_request("I"), in_request("K"), + in_request("PK"), in_request("J"), + in_request("CN"), in_request("ID"), $row["Username"]); } diff --git a/web/html/register.php b/web/html/register.php index f8400a3..f58fb25 100644 --- a/web/html/register.php +++ b/web/html/register.php @@ -23,7 +23,7 @@ if (in_request("Action") == "NewAccount") { "new", "NewAccount", in_request("U"), 1, 0, in_request("E"), in_request("H"), '', '', in_request("R"), in_request("L"), in_request("I"), in_request("K"), - in_request("PK")); + in_request("PK"), 0, in_request("CN")); print $message; @@ -31,7 +31,7 @@ if (in_request("Action") == "NewAccount") { display_account_form("NewAccount", in_request("U"), 1, 0, in_request("E"), in_request("H"), '', '', in_request("R"), in_request("L"), in_request("I"), in_request("K"), - in_request("PK")); + in_request("PK"), 0, in_request("CN")); } } else { print '<p>' . __("Use this form to create an account.") . '</p>'; diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php index 0c6388a..796b82b 100644 --- a/web/lib/acctfuncs.inc.php +++ b/web/lib/acctfuncs.inc.php @@ -56,13 +56,14 @@ function html_format_pgp_fingerprint($fingerprint) { * @param string $K The PGP key fingerprint of the displayed user * @param string $PK The list of SSH public keys * @param string $J The inactivity status of the displayed user + * @param string $CN Whether to notify of new comments * @param string $UID The user ID of the displayed user * @param string $N The username as present in the database * * @return void */ function display_account_form($A,$U="",$T="",$S="",$E="",$H="",$P="",$C="",$R="", - $L="",$I="",$K="",$PK="",$J="",$UID=0,$N="") { + $L="",$I="",$K="",$PK="",$J="",$CN="",$UID=0,$N="") { global $SUPPORTED_LANGS; include("account_edit_form.php"); @@ -88,13 +89,14 @@ function display_account_form($A,$U="",$T="",$S="",$E="",$H="",$P="",$C="",$R="" * @param string $K The PGP fingerprint of the user * @param string $PK The list of public SSH keys * @param string $J The inactivity status of the user + * @param string $CN Whether to notify of new comments * @param string $UID The user ID of the modified account * @param string $N The username as present in the database * * @return array Boolean indicating success and message to be printed */ function process_account_form($TYPE,$A,$U="",$T="",$S="",$E="",$H="",$P="",$C="", - $R="",$L="",$I="",$K="",$PK="",$J="",$UID=0,$N="") { + $R="",$L="",$I="",$K="",$PK="",$J="",$CN="",$UID=0,$N="") { global $SUPPORTED_LANGS; $error = ''; @@ -341,6 +343,7 @@ function process_account_form($TYPE,$A,$U="",$T="",$S="",$E="",$H="",$P="",$C="" $q.= ", IRCNick = " . $dbh->quote($I); $q.= ", PGPKey = " . $dbh->quote(str_replace(" ", "", $K)); $q.= ", InactivityTS = " . $inactivity_ts; + $q.= ", CommentNotify = " . ($CN ? "1" : "0"); $q.= " WHERE ID = ".intval($UID); $result = $dbh->exec($q); diff --git a/web/template/account_edit_form.php b/web/template/account_edit_form.php index cb0fa33..4f92f69 100644 --- a/web/template/account_edit_form.php +++ b/web/template/account_edit_form.php @@ -134,6 +134,14 @@ </fieldset> <fieldset> + <legend><?= __("Notification settings") ?>:</legend> + <p> + <label for="id_commentnotify"><?= __("Notify of new comments") ?>:</label> + <input type="checkbox" name="CN" id="id_commentnotify" <?= $CN ? 'checked="checked"' : '' ?> /> + </p> + </fieldset> + + <fieldset> <p> <label></label> <?php if ($A == "UpdateAccount"): ?> -- 2.7.0
Introduce a new notification option to receive notifications when a new commit is pushed to a package repository. Implements FS#30109. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- git-interface/git-update.py | 18 ++++++++++++++++-- schema/aur-schema.sql | 1 + scripts/notify.py | 33 +++++++++++++++++++++++++++++++++ upgrading/4.2.0.txt | 3 ++- web/html/account.php | 10 +++++----- web/html/register.php | 4 ++-- web/lib/acctfuncs.inc.php | 7 +++++-- web/template/account_edit_form.php | 4 ++++ 8 files changed, 68 insertions(+), 12 deletions(-) diff --git a/git-interface/git-update.py b/git-interface/git-update.py index 3b587b3..e54e0e6 100755 --- a/git-interface/git-update.py +++ b/git-interface/git-update.py @@ -5,6 +5,7 @@ import mysql.connector import os import pygit2 import re +import subprocess import sys import srcinfo.parse @@ -19,6 +20,8 @@ aur_db_user = config.get('database', 'user') aur_db_pass = config.get('database', 'password') aur_db_socket = config.get('database', 'socket') +notify_cmd = config.get('notifications', 'notify-cmd') + repo_path = config.get('serve', 'repo-path') repo_regex = config.get('serve', 'repo-regex') @@ -169,6 +172,13 @@ def save_metadata(metadata, db, cur, user): db.commit() +def update_notify(db, cur, user, pkgbase_id): + # Obtain the user ID of the new maintainer. + cur.execute("SELECT ID FROM Users WHERE Username = %s", [user]) + user_id = int(cur.fetchone()[0]) + + # Execute the notification script. + subprocess.Popen((notify_cmd, 'update', str(user_id), str(pkgbase_id))) def die(msg): sys.stderr.write("error: {:s}\n".format(msg)) @@ -336,8 +346,6 @@ for pkgname in srcinfo.utils.get_package_names(metadata): # Store package base details in the database. save_metadata(metadata, db, cur, user) -db.close() - # Create (or update) a branch with the name of the package base for better # accessibility. repo.create_reference('refs/heads/' + pkgbase, sha1_new, True) @@ -347,3 +355,9 @@ repo.create_reference('refs/heads/' + pkgbase, sha1_new, True) # http://git.661346.n2.nabble.com/PATCH-receive-pack-Create-a-HEAD-ref-for-ref... # for details. repo.create_reference('refs/namespaces/' + pkgbase + '/HEAD', sha1_new, True) + +# Send package update notifications. +update_notify(db, cur, user, pkgbase_id) + +# Close the database. +db.close() diff --git a/schema/aur-schema.sql b/schema/aur-schema.sql index 13a052e..1a141c1 100644 --- a/schema/aur-schema.sql +++ b/schema/aur-schema.sql @@ -39,6 +39,7 @@ CREATE TABLE Users ( InactivityTS BIGINT UNSIGNED NOT NULL DEFAULT 0, RegistrationTS TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, CommentNotify TINYINT(1) NOT NULL DEFAULT 1, + UpdateNotify TINYINT(1) NOT NULL DEFAULT 0, PRIMARY KEY (ID), UNIQUE (Username), UNIQUE (Email), diff --git a/scripts/notify.py b/scripts/notify.py index 6b10600..56534ae 100755 --- a/scripts/notify.py +++ b/scripts/notify.py @@ -105,6 +105,16 @@ def get_comment_recipients(cur, pkgbase_id, uid): return [row[0] for row in cur.fetchall()] +def get_update_recipients(cur, pkgbase_id, uid): + cur.execute('SELECT DISTINCT Users.Email FROM Users ' + + 'INNER JOIN PackageNotifications ' + + 'ON PackageNotifications.UserID = Users.ID WHERE ' + + 'Users.UpdateNotify = 1 AND ' + + 'PackageNotifications.UserID != %s AND ' + + 'PackageNotifications.PackageBaseID = %s', [uid, pkgbase_id]) + return [row[0] for row in cur.fetchall()] + + def get_request_recipients(cur, pkgbase_id, uid): cur.execute('SELECT DISTINCT Users.Email FROM Users ' + 'INNER JOIN PackageBases ' + @@ -189,6 +199,28 @@ def comment(cur, uid, pkgbase_id, comment_id): send_notification(to, subject, body, refs, headers) +def update(cur, uid, pkgbase_id): + user = username_from_id(cur, uid) + pkgbase = pkgbase_from_id(cur, pkgbase_id) + to = get_update_recipients(cur, pkgbase_id, uid) + + user_uri = aur_location + '/account/' + user + '/' + pkgbase_uri = aur_location + '/pkgbase/' + pkgbase + '/' + + subject = 'AUR Package Update: %s' % (pkgbase) + body = '%s [1] pushed a new commit to %s [2].' % (user, pkgbase) + body += '\n\n' + body += 'If you no longer wish to receive notifications about this ' \ + 'package, please go to the package page [2] and select "%s".' % \ + ('Disable notifications') + refs = '[1] ' + user_uri + '\n' + refs += '[2] ' + pkgbase_uri + thread_id = '<pkg-notifications-' + pkgbase + '@aur.archlinux.org>' + headers = headers_reply(thread_id) + + send_notification(to, subject, body, refs, headers) + + def flag(cur, uid, pkgbase_id): user = username_from_id(cur, uid) pkgbase = pkgbase_from_id(cur, pkgbase_id) @@ -327,6 +359,7 @@ if __name__ == '__main__': 'send-resetkey': send_resetkey, 'welcome': welcome, 'comment': comment, + 'update': update, 'flag': flag, 'comaintainer-add': comaintainer_add, 'comaintainer-remove': comaintainer_remove, diff --git a/upgrading/4.2.0.txt b/upgrading/4.2.0.txt index ce76f49..0bf9a31 100644 --- a/upgrading/4.2.0.txt +++ b/upgrading/4.2.0.txt @@ -52,5 +52,6 @@ ALTER TABLE CommentNotify RENAME TO PackageNotifications; ---- ALTER TABLE Users - ADD COLUMN CommentNotify TINYINT(1) NOT NULL DEFAULT 1; + ADD COLUMN CommentNotify TINYINT(1) NOT NULL DEFAULT 1, + ADD COLUMN UpdateNotify TINYINT(1) NOT NULL DEFAULT 0; ---- diff --git a/web/html/account.php b/web/html/account.php index 2f85a8a..9007ace 100644 --- a/web/html/account.php +++ b/web/html/account.php @@ -35,8 +35,8 @@ if ($action == "UpdateAccount") { in_request("E"), in_request("H"), in_request("P"), in_request("C"), in_request("R"), in_request("L"), in_request("I"), in_request("K"), in_request("PK"), - in_request("J"), in_request("CN"), in_request("ID"), - $row["Username"]); + in_request("J"), in_request("CN"), in_request("UN"), + in_request("ID"), $row["Username"]); } } @@ -83,7 +83,7 @@ if (isset($_COOKIE["AURSID"])) { $row["HideEmail"], "", "", $row["RealName"], $row["LangPreference"], $row["IRCNick"], $row["PGPKey"], $PK, $row["InactivityTS"] ? 1 : 0, $row["CommentNotify"], - $row["ID"], $row["Username"]); + $row["UpdateNotify"], $row["ID"], $row["Username"]); } else { print __("You do not have permission to edit this account."); } @@ -123,8 +123,8 @@ if (isset($_COOKIE["AURSID"])) { in_request("R"), in_request("L"), in_request("I"), in_request("K"), in_request("PK"), in_request("J"), - in_request("CN"), in_request("ID"), - $row["Username"]); + in_request("CN"), in_request("UN"), + in_request("ID"), $row["Username"]); } } else { diff --git a/web/html/register.php b/web/html/register.php index f58fb25..3155449 100644 --- a/web/html/register.php +++ b/web/html/register.php @@ -23,7 +23,7 @@ if (in_request("Action") == "NewAccount") { "new", "NewAccount", in_request("U"), 1, 0, in_request("E"), in_request("H"), '', '', in_request("R"), in_request("L"), in_request("I"), in_request("K"), - in_request("PK"), 0, in_request("CN")); + in_request("PK"), 0, in_request("CN"), in_request("UN")); print $message; @@ -31,7 +31,7 @@ if (in_request("Action") == "NewAccount") { display_account_form("NewAccount", in_request("U"), 1, 0, in_request("E"), in_request("H"), '', '', in_request("R"), in_request("L"), in_request("I"), in_request("K"), - in_request("PK"), 0, in_request("CN")); + in_request("PK"), 0, in_request("CN"), in_request("UN")); } } else { print '<p>' . __("Use this form to create an account.") . '</p>'; diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php index 796b82b..b39420f 100644 --- a/web/lib/acctfuncs.inc.php +++ b/web/lib/acctfuncs.inc.php @@ -57,13 +57,14 @@ function html_format_pgp_fingerprint($fingerprint) { * @param string $PK The list of SSH public keys * @param string $J The inactivity status of the displayed user * @param string $CN Whether to notify of new comments + * @param string $UN Whether to notify of package updates * @param string $UID The user ID of the displayed user * @param string $N The username as present in the database * * @return void */ function display_account_form($A,$U="",$T="",$S="",$E="",$H="",$P="",$C="",$R="", - $L="",$I="",$K="",$PK="",$J="",$CN="",$UID=0,$N="") { + $L="",$I="",$K="",$PK="",$J="",$CN="",$UN="",$UID=0,$N="") { global $SUPPORTED_LANGS; include("account_edit_form.php"); @@ -90,13 +91,14 @@ function display_account_form($A,$U="",$T="",$S="",$E="",$H="",$P="",$C="",$R="" * @param string $PK The list of public SSH keys * @param string $J The inactivity status of the user * @param string $CN Whether to notify of new comments + * @param string $UN Whether to notify of package updates * @param string $UID The user ID of the modified account * @param string $N The username as present in the database * * @return array Boolean indicating success and message to be printed */ function process_account_form($TYPE,$A,$U="",$T="",$S="",$E="",$H="",$P="",$C="", - $R="",$L="",$I="",$K="",$PK="",$J="",$CN="",$UID=0,$N="") { + $R="",$L="",$I="",$K="",$PK="",$J="",$CN="",$UN="",$UID=0,$N="") { global $SUPPORTED_LANGS; $error = ''; @@ -344,6 +346,7 @@ function process_account_form($TYPE,$A,$U="",$T="",$S="",$E="",$H="",$P="",$C="" $q.= ", PGPKey = " . $dbh->quote(str_replace(" ", "", $K)); $q.= ", InactivityTS = " . $inactivity_ts; $q.= ", CommentNotify = " . ($CN ? "1" : "0"); + $q.= ", UpdateNotify = " . ($UN ? "1" : "0"); $q.= " WHERE ID = ".intval($UID); $result = $dbh->exec($q); diff --git a/web/template/account_edit_form.php b/web/template/account_edit_form.php index 4f92f69..b9affd6 100644 --- a/web/template/account_edit_form.php +++ b/web/template/account_edit_form.php @@ -139,6 +139,10 @@ <label for="id_commentnotify"><?= __("Notify of new comments") ?>:</label> <input type="checkbox" name="CN" id="id_commentnotify" <?= $CN ? 'checked="checked"' : '' ?> /> </p> + <p> + <label for="id_updatenotify"><?= __("Notify of package updates") ?>:</label> + <input type="checkbox" name="UN" id="id_updatenotify" <?= $UN ? 'checked="checked"' : '' ?> /> + </p> </fieldset> <fieldset> -- 2.7.0
participants (1)
-
Lukas Fleischer