From: Florent Bruneau Date: Sat, 5 Jun 2010 12:47:45 +0000 (+0200) Subject: Take carnet notification changes into account immediately. Close #1058. X-Git-Tag: xorg/1.0.0~180 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=069ddda84d11d665359e384e6d136424ec2fae0d;p=platal.git Take carnet notification changes into account immediately. Close #1058. Signed-off-by: Florent Bruneau --- diff --git a/classes/user.php b/classes/user.php index 113d3f6..92d8d6e 100644 --- a/classes/user.php +++ b/classes/user.php @@ -462,6 +462,14 @@ class User extends PlUser return $this->watch_last; } + public function invalidWatchCache() + { + unset($this->watch_actions); + unset($this->watch_users); + unset($this->watch_last); + unset($this->watch_promos); + } + // Contacts private $contacts = null; diff --git a/classes/xorgsession.php b/classes/xorgsession.php index 9b98234..7789318 100644 --- a/classes/xorgsession.php +++ b/classes/xorgsession.php @@ -312,11 +312,7 @@ class XorgSession extends PlSession { require_once 'notifs.inc.php'; $user = S::user(); - $date = null; - if (S::has('watch_last')) { - $date = S::i('watch_last'); - } - $n = Watch::getCount($user, $date); + $n = Watch::getCount($user); S::set('notifs', $n); } diff --git a/core b/core index 023024e..fd05958 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 023024ebd592cc89ab1ded64766ad5246b7c054c +Subproject commit fd05958d9d359f5e76cb42f86e2e9398f902f74c diff --git a/modules/carnet.php b/modules/carnet.php index 054d07a..1d065af 100644 --- a/modules/carnet.php +++ b/modules/carnet.php @@ -64,7 +64,7 @@ class CarnetModule extends PLModule SET last = FROM_UNIXTIME({?}) WHERE uid = {?}', Get::i('read'), S::i('uid')); - S::set('watch_last', Get::i('read')); + S::user()->invalidWatchCache(); Platal::session()->updateNbNotifs(); pl_redirect('carnet/panel'); } @@ -131,6 +131,8 @@ class CarnetModule extends PLModule } XDB::execute('INSERT IGNORE INTO watch_promo (uid, promo) VALUES ' . implode(', ', $to_add)); + S::user()->invalidWatchCache(); + Platal::session()->updateNbNotifs(); } private function delPromo(PlPage &$page, $promo) @@ -146,12 +148,16 @@ class CarnetModule extends PLModule XDB::execute('DELETE FROM watch_promo WHERE ' . XDB::format('uid = {?}', S::i('uid')) . ' AND promo IN (' . implode(', ', $to_delete) . ')'); + S::user()->invalidWatchCache(); + Platal::session()->updateNbNotifs(); } public function addNonRegistered(PlPage &$page, PlUser &$user) { XDB::execute('INSERT IGNORE INTO watch_nonins (uid, ni_id) VALUES ({?}, {?})', S::i('uid'), $user->id()); + S::user()->invalidWatchCache(); + Platal::session()->updateNbNotifs(); } public function delNonRegistered(PlPage &$page, PlUser &$user) @@ -159,6 +165,8 @@ class CarnetModule extends PLModule XDB::execute('DELETE FROM watch_nonins WHERE uid = {?} AND ni_id = {?}', S::i('uid'), $user->id()); + S::user()->invalidWatchCache(); + Platal::session()->updateNbNotifs(); } public function handler_notifs(&$page, $action = null, $arg = null) @@ -201,6 +209,8 @@ class CarnetModule extends PLModule XDB::execute('UPDATE watch SET actions = {?} WHERE uid = {?}', $flags, S::i('uid')); + S::user()->invalidWatchCache(); + Platal::session()->updateNbNotifs(); } if (Env::has('flags_contacts')) { @@ -208,6 +218,8 @@ class CarnetModule extends PLModule XDB::execute('UPDATE watch SET ' . XDB::changeFlag('flags', 'contacts', Env::b('contacts')) . ' WHERE uid = {?}', S::i('uid')); + S::user()->invalidWatchCache(); + Platal::session()->updateNbNotifs(); } if (Env::has('flags_mail')) { @@ -215,6 +227,8 @@ class CarnetModule extends PLModule XDB::execute('UPDATE watch SET ' . XDB::changeFlag('flags', 'mail', Env::b('mail')) . ' WHERE uid = {?}', S::i('uid')); + S::user()->invalidWatchCache(); + Platal::session()->updateNbNotifs(); } $user = S::user();