X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fnotifs.inc.php;h=0cdfdf5b546312dcdd87b445865167f7c2ccac25;hb=7e735012ce134d53e532d2d9b23ea5437127c5b8;hp=8efb10862ec920fc2ce64410b374cf2d63c632a1;hpb=4e7bf1e01f3896d22bea3e23abf4cd7db2c12754;p=platal.git diff --git a/include/notifs.inc.php b/include/notifs.inc.php index 8efb108..0cdfdf5 100644 --- a/include/notifs.inc.php +++ b/include/notifs.inc.php @@ -30,9 +30,9 @@ class WatchProfileUpdate $profile->id(), $field); } - public static function getCondition(PlUser &$user) + public function getCondition(PlUser &$user) { - return new UFC_And(new UFC_ProfileUpdated('>=', $user->watch_last), + return new UFC_And(new UFC_ProfileUpdated('>', $user->watch_last), new UFC_WatchContacts($user->id())); } } @@ -41,10 +41,12 @@ class WatchRegistration { const ID = 2; - public static function getCondition(PlUser &$user) + public function getCondition(PlUser &$user) { - return new UFC_And(new UFC_Registered(false, '>=', $user->watch_last), - new UFC_WatchRegistration($user->id())); + return new UFC_And(new UFC_Registered(false, '>', $user->watch_last), + new UFC_Or(new UFC_WatchContacts($user->id()), + new UFC_WatchPromo($user->id()), + new UFC_WatchRegistration($user->id()))); } } @@ -52,9 +54,9 @@ class WatchDeath { const ID = 3; - public static function getCondition(PlUser &$user) + public function getCondition(PlUser &$user) { - return new UFC_And(new UFC_Dead('>=', $user->watch_last, true), + return new UFC_And(new UFC_Dead('>', $user->watch_last, true), new UFC_Or(new UFC_WatchPromo($user->id()), new UFC_WatchContacts($user->id()))); } @@ -64,12 +66,39 @@ class WatchBirthday { const ID = 4; - public static function getCondition(PlUser &$user) + public function getCondition(PlUser &$user) { - return new UFC_And(new UFC_Birthday(), + return new UFC_And(new UFC_OR(new UFC_Birthday('=', time()), + new UFC_And(new UFC_Birthday('<=', time() + 864000), + new UFC_Birthday('>', $user->watch_last + 864000))), new UFC_Or(new UFC_WatchPromo($user->id()), new UFC_WatchContacts($user->id()))); } } +class Watch +{ + private static $classes = array('WatchRegistration', + 'WatchProfileUpdate', + 'WatchDeath', + 'WatchBirthday'); + + private static function fetchCount(PlUser &$user, $class) + { + $obj = new $class(); + $uf = new UserFilter($obj->getCondition($user)); + return $uf->getTotalCount(); + } + + public static function getCount(PlUser &$user) + { + $count = 0; + foreach (self::$classes as $class) { + $count += self::fetchCount($user, $class); + } + return $count; + } +} + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>