X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fnotifs.inc.php;h=fd952cb6012cab29b0bc296cdcb7317a38e04980;hb=93d42b4fcc6f055a428c9b63e386ac62c918d08a;hp=5e8d8aeda5d97c657ac425a033213f3d1be8a618;hpb=c350577bb79078fabcb4818f4ffa31022d34ccb7;p=platal.git diff --git a/include/notifs.inc.php b/include/notifs.inc.php index 5e8d8ae..fd952cb 100644 --- a/include/notifs.inc.php +++ b/include/notifs.inc.php @@ -1,6 +1,6 @@ watch($this->flag)) { - return new UFC_False(); + $this->date = $date; + if (!$user->watchType($this->flag)) { + return new PFC_False(); } else { - return $this->buildCondition($user, $date); + return $this->buildCondition($user); } } - abstract protected function buildCondition(PlUser &$user, $date); + abstract protected function buildCondition(PlUser &$user); abstract public function getOrder(); abstract public function getDate(PlUser &$user); @@ -66,14 +69,14 @@ class WatchProfileUpdate extends WatchOperation public static function register(Profile &$profile, $field) { - XDB::execute('REPLACE INTO watch_profile (uid, ts, field) + XDB::execute('REPLACE INTO watch_profile (pid, ts, field) VALUES ({?}, NOW(), {?})', $profile->id(), $field); } - protected function buildCondition(PlUser &$user, $date) + protected function buildCondition(PlUser &$user) { - return new UFC_And(new UFC_ProfileUpdated('>', $date), + return new PFC_And(new UFC_ProfileUpdated('>', $this->date), new UFC_WatchContact($user)); } @@ -86,6 +89,41 @@ class WatchProfileUpdate extends WatchOperation { 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) + { + $data = XDB::fetchColumn("SELECT field + FROM watch_profile + WHERE pid = {?} AND ts > FROM_UNIXTIME({?}) AND field != '' + ORDER BY ts", + $user->profile()->id(), $this->date); + if (count($data) == 0) { + return null; + } else { + $text = array(); + foreach ($data as $f) { + $text[] = self::$descriptions[$f]; + } + return $text; + } + } } class WatchRegistration extends WatchOperation @@ -93,10 +131,10 @@ class WatchRegistration extends WatchOperation public $flag = 'registration'; public $title = 'Inscription$s'; - protected function buildCondition(PlUser &$user, $date) + protected function buildCondition(PlUser &$user) { - return new UFC_And(new UFC_Registered(false, '>', $date), - new UFC_Or(new UFC_WatchContact($user), + return new PFC_And(new UFC_Registered(false, '>', $this->date), + new PFC_Or(new UFC_WatchContact($user), new UFC_WatchPromo($user))); } @@ -116,10 +154,10 @@ class WatchDeath extends WatchOperation public $flag = 'death'; public $title = 'Décès'; - protected function buildCondition(PlUser &$user, $date) + protected function buildCondition(PlUser &$user) { - return new UFC_And(new UFC_Dead('>', $date, true), - new UFC_Or(new UFC_WatchPromo($user), + return new PFC_And(new UFC_Dead('>', $this->date, true), + new PFC_Or(new UFC_WatchPromo($user), new UFC_WatchContact($user))); } @@ -151,12 +189,12 @@ class WatchBirthday extends WatchOperation public $flag = 'birthday'; public $title = 'Anniversaire$s'; - protected function buildCondition(PlUser &$user, $date) + protected function buildCondition(PlUser &$user) { - return new UFC_And(new UFC_OR(new UFC_Birthday('=', time()), - new UFC_And(new UFC_Birthday('<=', time() + self::WATCH_LIMIT), - new UFC_Birthday('>', $date + self::WATCH_LIMIT))), - new UFC_Or(new UFC_WatchPromo($user), + return new PFC_And(new PFC_OR(new UFC_Birthday('=', time()), + new PFC_And(new UFC_Birthday('<=', time() + self::WATCH_LIMIT), + new UFC_Birthday('>', $this->date + self::WATCH_LIMIT))), + new PFC_Or(new UFC_WatchPromo($user), new UFC_WatchContact($user))); } @@ -214,12 +252,13 @@ class Watch { $obj = new $class(); $uf = new UserFilter($obj->getCondition($user, $date), - array($obj->getOrder(), new UFO_Name(UserFilter::DN_SORT))); + array($obj->getOrder(), new UFO_Name(Profile::DN_SORT))); $users = $uf->getUsers(); if (count($users) == 0) { return null; } else { - return array('operation' => $obj, + return array('type' => $obj->flag, + 'operation' => $obj, 'title' => $obj->getTitle(count($users)), 'users' => $users); }