X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fnotifs.inc.php;h=19a64809f0a5c88576afbae4ed59207ded49c91d;hb=3424387cde6c635ff16c3b5459c4caa88bb76e2e;hp=b114ae5dab05aa657477e3e82feb7d1ee8eb65ed;hpb=4d9b63f8ec02d84eabd554234a32718758bf9e21;p=platal.git diff --git a/include/notifs.inc.php b/include/notifs.inc.php index b114ae5..19a6480 100644 --- a/include/notifs.inc.php +++ b/include/notifs.inc.php @@ -1,6 +1,6 @@ getDate($user); } - public function seen(PlUser &$user, $last) + public function seen(PlUser $user, $last) { return strtotime($this->getDate($user)) > $last; } - public function getData(PlUser &$user) + public function getData(PlUser $user) { return null; } @@ -72,7 +72,7 @@ class WatchProfileUpdate extends WatchOperation public $title = 'Mise$s à jour de fiche'; private $date = null; - public static function register(Profile &$profile, $field) + public static function register(Profile $profile, $field) { XDB::execute('INSERT INTO watch_profile (pid, ts, field) VALUES ({?}, NOW(), {?}) @@ -95,12 +95,12 @@ class WatchProfileUpdate extends WatchOperation return self::$order; } - public function getDate(PlUser &$user) + public function getDate(PlUser $user) { return $user->profile()->last_change; } - public function getData(PlUser &$user) + public function getData(PlUser $user) { $data = XDB::fetchColumn("SELECT field FROM watch_profile @@ -130,7 +130,8 @@ class WatchRegistration extends WatchOperation { return new PFC_And(new UFC_Registered(false, '>', $watch->date()), new PFC_Or($watch->contactCondition(), - $watch->promoCondition())); + $watch->promoCondition(), + $watch->groupCondition())); } public function getOrder() @@ -141,7 +142,7 @@ class WatchRegistration extends WatchOperation return self::$order; } - public function getDate(PlUser &$user) + public function getDate(PlUser $user) { return $user->registration_date; } @@ -158,7 +159,8 @@ class WatchDeath extends WatchOperation { return new PFC_And(new UFC_Dead('>', $watch->date(), true), new PFC_Or($watch->contactCondition(), - $watch->promoCondition())); + $watch->promoCondition(), + $watch->groupCondition())); } public function getOrder() @@ -169,17 +171,17 @@ class WatchDeath extends WatchOperation return self::$order; } - public function getDate(PlUser &$user) + public function getDate(PlUser $user) { return $user->profile()->deathdate; } - public function publicationDate(PlUser &$user) + public function publicationDate(PlUser $user) { return $user->profile()->deathdate_rec; } - public function seen(PlUser &$user, $last) + public function seen(PlUser $user, $last) { return strtotime($user->profile()->deathdate_rec) > $last; } @@ -196,6 +198,7 @@ class WatchBirthday extends WatchOperation protected function buildCondition(Watch $watch) { + $not_dead = new PFC_Not(new UFC_Dead()); $select_date = new PFC_OR(new UFC_Birthday('=', time()), new PFC_And(new UFC_Birthday('<=', time() + self::WATCH_LIMIT), new UFC_Birthday('>', $watch->date() + self::WATCH_LIMIT))); @@ -205,9 +208,10 @@ class WatchBirthday extends WatchOperation $cond = new PFC_Or($cond, new PFC_And($watch->promoCondition(), new UFC_Promo('>=', $profile->mainGrade(), $profile->yearpromo() - 1), - new UFC_Promo('<=', $profile->mainGrade(), $profile->yearpromo() + 1))); + new UFC_Promo('<=', $profile->mainGrade(), $profile->yearpromo() + 1)), + $watch->groupCondition()); } - return new PFC_And($select_date, $cond); + return new PFC_And($not_dead, $select_date, $cond); } public function getOrder() @@ -218,17 +222,17 @@ class WatchBirthday extends WatchOperation return self::$order; } - public function getDate(PlUser &$user) + public function getDate(PlUser $user) { return $user->profile()->next_birthday; } - public function publicationDate(PlUser &$user) + public function publicationDate(PlUser $user) { return date('Y-m-d', strtotime($user->profile()->next_birthday) - self::WATCH_LIMIT); } - public function seen(PlUser &$user, $last) + public function seen(PlUser $user, $last) { $birthday = strtotime($user->profile()->next_birthday); return $birthday > $last + self::WATCH_LIMIT @@ -248,6 +252,7 @@ class Watch private $date = null; private $contactCond = null; private $promoCond = null; + private $groupCond = null; private $filters = array(); @@ -288,6 +293,14 @@ class Watch return $this->promoCond; } + public function groupCondition() + { + if (!$this->groupCond) { + $this->groupCond = new UFC_WatchGroup($this->user); + } + return $this->groupCond; + } + private function fetchEventWatch($class) { if (!isset(self::$events[$class])) { @@ -302,7 +315,7 @@ class Watch if (!isset($this->filters[$class])) { $event = $this->fetchEventWatch($class); $this->filters[$class] = new UserFilter($event->getCondition($this), - array($event->getOrder(), new UFO_Name(Profile::DN_SORT))); + array($event->getOrder(), new UFO_Name())); } return $this->filters[$class]; } @@ -346,7 +359,7 @@ class Watch } - private static function getDate(PlUser &$user, $date) + private static function getDate(PlUser $user, $date) { if (is_null($date)) { $date = $user->watchLast(); @@ -358,18 +371,18 @@ class Watch return $date; } - public static function getCount(PlUser &$user, $date = null) + public static function getCount(PlUser $user, $date = null) { $watch = new Watch($user, $date); return $watch->count(); } - public static function getEvents(PlUser &$user, $date = null) + public static function getEvents(PlUser $user, $date = null) { $watch = new Watch($user, $date); return $watch->events(); } } -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: ?>