X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fprofile%2Fdecos.inc.php;h=5c413163a9ba2a32def95bd854f04fa39df39e72;hb=53595c2a9d1df6993dd69217c4bd1a6a9d51bff7;hp=10305bf154921011b513a4af2f514fdb5b6c51b7;hpb=12bcf04b930ec8a4af87113af2e7d6660d723e53;p=platal.git diff --git a/modules/profile/decos.inc.php b/modules/profile/decos.inc.php index 10305bf..5c41316 100644 --- a/modules/profile/decos.inc.php +++ b/modules/profile/decos.inc.php @@ -38,8 +38,7 @@ class ProfileSettingDeco implements ProfileSetting } // Fetch not yet validated medals - require_once('validations.inc.php'); - $medals = Validate::get_typed_requests(S::i('uid'), 'medal'); + $medals = ProfileValidate::get_typed_requests($page->pid(), 'medal'); foreach ($medals as &$medal) { $value[$medal->mid] = array('grade' => $medal->gid, 'valid' => '0'); @@ -53,8 +52,6 @@ class ProfileSettingDeco implements ProfileSetting public function save(ProfilePage &$page, $field, $value) { - require_once('validations.inc.php'); - $orig =& $page->orig[$field]; // Remove old ones @@ -65,7 +62,7 @@ class ProfileSettingDeco implements ProfileSetting WHERE pid = {?} AND mid = {?}", $page->pid(), $id); } else { - $req = MedalReq::get_request(S::i('uid'), $id); + $req = MedalReq::get_request($page->pid(), $id); if ($req) { $req->clean(); } @@ -76,15 +73,24 @@ class ProfileSettingDeco implements ProfileSetting // Add new ones foreach ($value as $id=>&$val) { if (!isset($orig[$id]) || $orig[$id]['grade'] != $val['grade']) { - $req = new MedalReq(S::user(), $id, $val['grade']); + $req = new MedalReq(S::user(), $page->profile, $id, $val['grade']); $req->submit(); sleep(1); } } } + + public function getText($value) { + $medalsList = DirEnum::getOptions(DirEnum::MEDALS); + $medals = array(); + foreach ($value as $id => $medal) { + $medals[] = $medalsList[$id]; + } + return implode(', ', $medals); + } } -class ProfileSettingDecos extends ProfilePage +class ProfilePageDecos extends ProfilePage { protected $pg_template = 'profile/deco.tpl'; @@ -117,21 +123,24 @@ class ProfileSettingDecos extends ProfilePage public function _prepare(PlPage &$page, $id) { - $res = XDB::iterator("SELECT *, FIND_IN_SET('validation', flags) AS validate - FROM profile_medal_enum - ORDER BY type, text"); - $mlist = array(); + $res = XDB::iterator('SELECT *, FIND_IN_SET(\'validation\', flags) AS validate + FROM profile_medal_enum + ORDER BY type, text'); + $mlist = array(); while ($tmp = $res->next()) { $mlist[$tmp['type']][] = $tmp; } $page->assign('medal_list', $mlist); - $trad = Array('ordre' => 'Ordres', - 'croix' => 'Croix', - 'militaire' => 'Médailles militaires', - 'honneur' => 'Médailles d\'honneur', - 'resistance' => 'Médailles de la résistance', - 'prix' => 'Prix'); - $page->assign('trad', $trad); + $fullType = array( + 'ordre' => 'Ordres', + 'croix' => 'Croix', + 'militaire' => 'Médailles militaires', + 'honneur' => 'Médailles d\'honneur', + 'resistance' => 'Médailles de la résistance', + 'prix' => 'Prix', + 'sport' => 'Médailles sportives' + ); + $page->assign('fullType', $fullType); } }