mid = $_idmedal; $this->gid = $_subidmedal; if (is_null($this->gid)) { $this->gid = 0; } } // }}} // {{{ function formu() public function formu() { return 'include/form.valid.medals.tpl'; } // }}} // {{{ function _mail_subj protected function _mail_subj() { return '[Polytechnique.org/Décoration] Demande de décoration : ' . $this->medal_name(); } // }}} // {{{ function _mail_body protected function _mail_body($isok) { if ($isok) { return ' La décoration ' . $this->medal_name() . ' vient d\'être ajoutée à ta fiche.'; } else { return ' La demande que tu avais faite pour la décoration ' . $this->medal_name() . ' a été refusée.'; } } // }}} // {{{ function medal_name public function medal_name() { $res = XDB::query('SELECT m.text FROM profile_medal_enum AS m WHERE m.id = {?}', $this->mid); return $res->fetchOneCell(); } // }}} // {{{ function submit() public function submit() { $res = XDB::query("SELECT FIND_IN_SET('validation', flags) FROM profile_medal_enum WHERE id = {?}", $this->mid); if ($res->fetchOneCell()) { parent::submit(); } else { $this->commit(); } } // }}} // {{{ function commit() public function commit () { return XDB::execute('INSERT INTO profile_medals (pid, mid, gid) VALUES ({?}, {?}, {?}) ON DUPLICATE KEY UPDATE gid = VALUES(gid)', $this->profile->id(), $this->mid, is_null($this->gid) ? 0 : $this->gid); } // }}} // {{{ function get_request($medal) static public function get_request($pid, $type) { $reqs = parent::get_typed_requests($pid, 'medal'); foreach ($reqs as &$req) { if ($req->mid == $type) { return $req; } } return null; } // }}} } // }}} // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>