X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations%2Fmedals.inc.php;h=98d14d24e61a9a5c25cdbbd1da4d86b20da87966;hb=a62886091365824f04a967638dee269196c3899d;hp=c308d4d982d7d5bf75166090a9f6df984f6707d6;hpb=a7de4ef724d1a3b0bf978a50ce7cc9d23412c7a0;p=platal.git diff --git a/include/validations/medals.inc.php b/include/validations/medals.inc.php index c308d4d..98d14d2 100644 --- a/include/validations/medals.inc.php +++ b/include/validations/medals.inc.php @@ -1,6 +1,6 @@ Validate($_uid, false, 'medal', $_stamp); + parent::__construct($_uid, false, 'medal', $_stamp); $this->mid = $_idmedal; $this->gid = $_subidmedal; } @@ -41,15 +41,15 @@ class MedalReq extends Validate // }}} // {{{ function formu() - function formu() - { - return 'include/form.valid.medals.tpl'; - } + public function formu() + { + return 'include/form.valid.medals.tpl'; + } // }}} // {{{ function _mail_subj - function _mail_subj() + protected function _mail_subj() { return "[Polytechnique.org/Décoration] Demande de décoration : ".$this->medal_name(); } @@ -57,7 +57,7 @@ class MedalReq extends Validate // }}} // {{{ function _mail_body - function _mail_body($isok) + protected function _mail_body($isok) { if ($isok) { return " La décoration ".$this->medal_name()." vient d'être ajoutée à ta fiche."; @@ -69,23 +69,23 @@ class MedalReq extends Validate // }}} // {{{ function medal_name - function medal_name() + public function medal_name() { - //var_dump($this); - $r = XDB::query(" - 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(); + //var_dump($this); + $r = XDB::query(" + 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(); } // }}} // {{{ function submit() - function submit() + 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()) { @@ -94,13 +94,31 @@ class MedalReq extends Validate $this->commit(); } } - + // }}} // {{{ function commit() - function commit () + 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->uid, WATCH_FICHE, 'medals'); + return XDB::execute('REPLACE INTO profile_medals_sub + VALUES ({?}, {?}, {?})', + $this->uid, $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; } // }}}