X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations%2Fmedals.inc.php;h=e448358fb5febace8403c9c58f38ca598065ce85;hb=0783a5ed4d3409bcd7a7e1d908696159999810c8;hp=e419e4605016551f7f397528e75288b4035ba519;hpb=eaf30d86cc99df2414cf4f171a9b0f11b0561e3b;p=platal.git diff --git a/include/validations/medals.inc.php b/include/validations/medals.inc.php index e419e46..e448358 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; + } } // }}} @@ -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; } // }}}