X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile%2Fdecos.inc.php;h=5db7017dafc78fd0445fb13bf5b4fb0296587c2c;hb=66c4bdaf7813c6dd607a275ab9a2ef163d8b0a51;hp=418ad69054911a96f990dc81cb2fda69cc75cf8a;hpb=e5bcd851d41fb3d177bdf48c6d6be57eb6a57441;p=platal.git diff --git a/modules/profile/decos.inc.php b/modules/profile/decos.inc.php index 418ad69..5db7017 100644 --- a/modules/profile/decos.inc.php +++ b/modules/profile/decos.inc.php @@ -1,6 +1,6 @@ pid()); $value = array(); while (list($id, $grade) = $res->next()) { @@ -38,8 +38,8 @@ class ProfileDeco implements ProfileSetting } // Fetch not yet validated medals - require_once('validations.inc.php'); - $medals = Validate::get_typed_requests(S::i('uid'), 'medal'); + require_once 'validations.inc.php'; + $medals = ProfileValidate::get_typed_requests($page->pid(), 'medal'); foreach ($medals as &$medal) { $value[$medal->mid] = array('grade' => $medal->gid, 'valid' => '0'); @@ -53,7 +53,7 @@ class ProfileDeco implements ProfileSetting public function save(ProfilePage &$page, $field, $value) { - require_once('validations.inc.php'); + require_once 'validations.inc.php'; $orig =& $page->orig[$field]; @@ -61,11 +61,11 @@ class ProfileDeco implements ProfileSetting foreach ($orig as $id=>&$val) { if (!isset($value[$id]) || $val['grade'] != $value[$id]['grade']) { if ($val['valid']) { - XDB::execute("DELETE FROM profile_medals_sub - WHERE uid = {?} AND mid = {?}", + XDB::execute("DELETE FROM profile_medals + 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,23 +76,32 @@ class ProfileDeco 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 ProfileDecos extends ProfilePage +class ProfilePageDecos extends ProfilePage { protected $pg_template = 'profile/deco.tpl'; public function __construct(PlWizard &$wiz) { parent::__construct($wiz); - $this->settings['medals'] = new ProfileDeco(); - $this->settings['medals_pub'] = new ProfilePub(); + $this->settings['medals'] = new ProfileSettingDeco(); + $this->settings['medals_pub'] = new ProfileSettingPub(); $this->watched['medals'] = true; } @@ -117,21 +126,24 @@ class ProfileDecos extends ProfilePage public function _prepare(PlPage &$page, $id) { - $res = XDB::iterator("SELECT *, FIND_IN_SET('validation', flags) AS validate - FROM profile_medals - 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); } }