+ const WATCH_LIMIT = 604800; // 1 week
+
+ private static $order = null;
+
+ public $flag = 'birthday';
+ public $title = 'Anniversaire$s';
+
+ protected function buildCondition(Watch $watch)
+ {
+ $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)));
+ $profile = $watch->profile();
+ $cond = $watch->contactCondition();
+ if ($profile) {
+ $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)));
+ }
+ return new PFC_And($select_date, $cond);
+ }
+
+ public function getOrder()
+ {
+ if (!self::$order) {
+ self::$order = new UFO_Birthday();
+ }
+ return self::$order;
+ }
+
+ public function getDate(PlUser &$user)
+ {
+ return $user->profile()->next_birthday;
+ }