X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fnotifs.inc.php;h=19a64809f0a5c88576afbae4ed59207ded49c91d;hb=3424387cde6c635ff16c3b5459c4caa88bb76e2e;hp=045adee37fc7aafdfad7e5f484e8f691a089bdba;hpb=77d4417766e20c5b2b33613f1198893d470ba6b2;p=platal.git diff --git a/include/notifs.inc.php b/include/notifs.inc.php index 045adee..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,10 +72,11 @@ 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('REPLACE INTO watch_profile (pid, ts, field) - VALUES ({?}, NOW(), {?})', + XDB::execute('INSERT INTO watch_profile (pid, ts, field) + VALUES ({?}, NOW(), {?}) + ON DUPLICATE KEY UPDATE ts = NOW()', $profile->id(), $field); } @@ -94,29 +95,12 @@ class WatchProfileUpdate extends WatchOperation return self::$order; } - public function getDate(PlUser &$user) + public function getDate(PlUser $user) { return $user->profile()->last_change; } - static private $descriptions = array('search_names' => 'L\'un de ses noms', - 'freetext' => 'Le texte libre', - 'mobile' => 'Son numéro de téléphone portable', - 'nationalite' => 'Sa nationalité', - 'nationalite2' => 'Sa seconde nationalité', - 'nationalite3' => 'Sa troisième nationalité', - 'nick' => 'Son surnom', - 'networking' => 'La liste de ses adresses de networking', - 'edus' => 'Ses formations', - 'addresses' => 'Ses adresses', - 'section' => 'Sa section sportive', - 'binets' => 'La liste de ses binets', - 'medals' => 'Ses décorations', - 'cv' => 'Son Curriculum Vitae', - 'corps' => 'Son Corps d\'État', - 'jobs' => 'Ses informations professionnelles', - 'photo' => 'Sa photographie'); - public function getData(PlUser &$user) + public function getData(PlUser $user) { $data = XDB::fetchColumn("SELECT field FROM watch_profile @@ -128,7 +112,7 @@ class WatchProfileUpdate extends WatchOperation } else { $text = array(); foreach ($data as $f) { - $text[] = self::$descriptions[$f]; + $text[] = Profile::$descriptions[$f]; } return $text; } @@ -146,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() @@ -157,7 +142,7 @@ class WatchRegistration extends WatchOperation return self::$order; } - public function getDate(PlUser &$user) + public function getDate(PlUser $user) { return $user->registration_date; } @@ -174,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() @@ -185,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; } @@ -212,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))); @@ -221,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() @@ -234,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 @@ -264,6 +252,7 @@ class Watch private $date = null; private $contactCond = null; private $promoCond = null; + private $groupCond = null; private $filters = array(); @@ -304,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])) { @@ -318,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]; } @@ -362,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(); @@ -374,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: ?>