X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fvalidations%2Fmedals.inc.php;h=4a2f6a9ba1b1d70d26d05d14080b35201acf3c73;hb=100e66fc8ab2b48621b287d50079558d83187278;hp=a742da5e6dd3d93c08e9f81d68aa8cae13606c4b;hpb=010268b2e818de5aa8db1cef05bca1c91701b2f9;p=platal.git diff --git a/include/validations/medals.inc.php b/include/validations/medals.inc.php index a742da5..4a2f6a9 100644 --- a/include/validations/medals.inc.php +++ b/include/validations/medals.inc.php @@ -1,6 +1,6 @@ mid = $_idmedal; + parent::__construct($_user, false, 'medal', $_stamp); + $this->mid = $_idmedal; $this->gid = $_subidmedal; + if (is_null($this->gid)) { + $this->gid = 0; + } } // }}} // {{{ function formu() public function formu() - { + { return 'include/form.valid.medals.tpl'; } @@ -73,11 +76,11 @@ class MedalReq extends Validate { //var_dump($this); $r = XDB::query(" - SELECT IF (g.text IS NOT NULL, CONCAT(m.text,' - ', g.text), m.text) + SELECT IF (g.text IS NOT NULL, CONCAT(m.text,' - ', g.text), m.text) FROM profile_medals AS m LEFT JOIN profile_medals_grades AS g ON(g.mid = m.id AND g.gid = {?}) WHERE m.id = {?}", $this->gid, $this->mid); - return $r->fetchOneCell(); + return $r->fetchOneCell(); } // }}} @@ -100,7 +103,26 @@ class MedalReq extends Validate public function commit () { - return XDB::execute('REPLACE INTO profile_medals_sub VALUES({?}, {?}, {?})', $this->uid, $this->mid, $this->gid); + require_once 'notifs.inc.php'; + register_watch_op($this->user->id(), WATCH_FICHE, '', 'medals'); + return XDB::execute('REPLACE INTO profile_medals_sub + VALUES ({?}, {?}, {?})', + $this->user->id(), $this->mid, + is_null($this->gid) ? 0 : $this->gid); + } + + // }}} + // {{{ function get_request($medal) + + static public function get_request($uid, $type) + { + $reqs = Validate::get_typed_requests($uid, 'medal'); + foreach ($reqs as &$req) { + if ($req->mid == $type) { + return $req; + } + } + return null; } // }}}