summaryrefslogtreecommitdiffstats
path: root/web/lib/pkgbasefuncs.inc.php
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2015-09-13 14:45:15 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2015-09-16 22:05:40 +0200
commit34e7f7084ae30cd2cb50edfef5ff14f3a311e11a (patch)
treeaff667d9608c4b58549e7114b3edaa8afa28c655 /web/lib/pkgbasefuncs.inc.php
parentf9476c10930029ca7a44a14b5e1749d36512880c (diff)
downloadaur-34e7f7084ae30cd2cb50edfef5ff14f3a311e11a.tar.gz
aur-34e7f7084ae30cd2cb50edfef5ff14f3a311e11a.tar.xz
Transfer notifications when merging packages
When a package base is merged into another one, followers of the old package base usually want to be notified about comments the new package base as well. Fixes FS#27687. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web/lib/pkgbasefuncs.inc.php')
-rw-r--r--web/lib/pkgbasefuncs.inc.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php
index 799f1da9..cb756f61 100644
--- a/web/lib/pkgbasefuncs.inc.php
+++ b/web/lib/pkgbasefuncs.inc.php
@@ -448,6 +448,20 @@ function pkgbase_delete ($base_ids, $merge_base_id, $via, $grant=false) {
$q.= "WHERE PackageBaseID IN (" . implode(",", $base_ids) . ")";
$dbh->exec($q);
+ /* Merge notifications */
+ $q = "SELECT DISTINCT UserID FROM CommentNotify cn ";
+ $q.= "WHERE PackageBaseID IN (" . implode(",", $base_ids) . ") ";
+ $q.= "AND NOT EXISTS (SELECT * FROM CommentNotify 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.= "VALUES (" . intval($notify_uid) . ", " . intval($merge_base_id) . ")";
+ $dbh->exec($q);
+ }
+
/* Merge votes */
foreach ($base_ids as $base_id) {
$q = "UPDATE PackageVotes ";