From cfb05c41e63840d57434c4c8bb8eec6a17ed237d Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Thu, 22 Oct 2009 23:02:35 +0200 Subject: [PATCH] Cleans up watch_nonins when someone dies (Closes #975). --- ChangeLog | 3 +++ include/notifs.inc.php | 28 ++++++++++++++++++---------- upgrade/0.10.2/01_watch_nonins.sql | 6 ++++++ 3 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 upgrade/0.10.2/01_watch_nonins.sql diff --git a/ChangeLog b/ChangeLog index 48d2ad8..e60dd09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,9 @@ Bug/Wish: * AXLetter: - #980: Adds option to invert a subset definition -XEL + * Carnet: + - #975: Cleans up watch_nonins when someone dies -JAC + * Core: - #984: Properly upper/lowercases accented letters when necessary -JAC diff --git a/include/notifs.inc.php b/include/notifs.inc.php index eb70cc8..58d214c 100644 --- a/include/notifs.inc.php +++ b/include/notifs.inc.php @@ -34,25 +34,33 @@ function inscription_notifs_base($uid) // }}} // {{{ function register_watch_op -function register_watch_op($uid, $cid, $date='', $info='') +function register_watch_op($uid, $cid, $date = '', $info = '') { if (empty($date)) { $date = date('Y-m-d'); - }; - XDB::execute('REPLACE INTO watch_ops (uid,cid,known,date,info) + } + XDB::execute('REPLACE INTO watch_ops (uid, cid, known, date, info) VALUES ({?}, {?}, NOW(), {?}, {?})', $uid, $cid, $date, $info); - if($cid == WATCH_FICHE) { + if ($cid == WATCH_FICHE) { if ($info) { register_profile_update($uid, $info); } - XDB::execute('UPDATE auth_user_md5 SET DATE=NOW() WHERE user_id={?}', $uid); - } elseif($cid == WATCH_INSCR) { - XDB::execute('REPLACE INTO contacts (uid,contact) - SELECT uid,ni_id + XDB::execute('UPDATE auth_user_md5 + SET DATE = NOW() + WHERE user_id = {?}', $uid); + } elseif ($cid == WATCH_INSCR) { + XDB::execute('REPLACE INTO contacts (uid, contact) + SELECT uid, ni_id FROM watch_nonins - WHERE ni_id={?}', $uid); - XDB::execute('DELETE FROM watch_nonins WHERE ni_id={?}', $uid); + WHERE ni_id = {?}', $uid); + XDB::execute('DELETE FROM watch_nonins + WHERE ni_id = {?}', $uid); + } elseif ($cid == WATCH_DEATH) { + // We delete nonins watches both for the dead (if non registered), and + // for people watched by the dead. + XDB::execute('DELETE FROM watch_nonins + WHERE ni_id = {?} OR uid = {?}', $uid); } Platal::session()->updateNbNotifs(); } diff --git a/upgrade/0.10.2/01_watch_nonins.sql b/upgrade/0.10.2/01_watch_nonins.sql new file mode 100644 index 0000000..13e1d9f --- /dev/null +++ b/upgrade/0.10.2/01_watch_nonins.sql @@ -0,0 +1,6 @@ + DELETE w.* + FROM watch_nonins AS w +INNER JOIN auth_user_md5 AS a ON (w.uid = a.user_id OR w.ni_id = a.user_id) + WHERE a.deces != '0000-00-00'; + +-- vim:set syntax=mysql: -- 2.1.4