X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations%2Fmedals.inc.php;h=0bc892c6468909c8d087b1df72f484617d2a3ae8;hb=2553b7686e0678b8e27858a7c377e73ecb410aec;hp=3e7cce51ce8cdcaa3cf4fce0cbb89efdb3fd54a4;hpb=612a2d8ae13ee29edb3279132877b63db18a5da5;p=platal.git diff --git a/include/validations/medals.inc.php b/include/validations/medals.inc.php index 3e7cce5..0bc892c 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; } @@ -42,7 +42,7 @@ class MedalReq extends Validate // {{{ function formu() public function formu() - { + { return 'include/form.valid.medals.tpl'; } @@ -73,11 +73,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(); } // }}} @@ -85,7 +85,7 @@ class MedalReq extends Validate public function submit() { - $res = XDB::query("SELECT FIND_IN_SET(flags, 'validation') + $res = XDB::query("SELECT FIND_IN_SET('validation', flags) FROM profile_medals WHERE id = {?}", $this->mid); if ($res->fetchOneCell()) { @@ -100,7 +100,25 @@ 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, $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; } // }}}