From: Stéphane Jacob Date: Wed, 20 Apr 2011 13:23:17 +0000 (+0200) Subject: Gives details about main education (field and program). X-Git-Tag: xorg/1.1.1~82 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=d7de04afa0cfc2166fad9c6643b5af2bdf9fe153;p=platal.git Gives details about main education (field and program). Signed-off-by: Stéphane Jacob --- diff --git a/classes/profile.php b/classes/profile.php index 5e113a4..92a5ae2 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -113,6 +113,7 @@ class Profile implements PlExportable 'networking' => 'Messageries…', 'tels' => 'Téléphones', 'edus' => 'Formations', + 'main_edus' => 'Formations à l\'X', 'promo' => 'Promotion de sortie', 'birthdate' => 'Date de naissance', 'yourself' => 'Nom affiché', diff --git a/modules/profile/general.inc.php b/modules/profile/general.inc.php index 85c3dd5..6c29940 100644 --- a/modules/profile/general.inc.php +++ b/modules/profile/general.inc.php @@ -346,6 +346,75 @@ class ProfileSettingEdu implements ProfileSetting } } +class ProfileSettingMainEdu implements ProfileSetting +{ + private $cycles; + + public function __construct() + { + $eduDegrees = DirEnum::getOptions(DirEnum::EDUDEGREES); + $eduDegrees = array_flip($eduDegrees); + $this->cycles = array( + $eduDegrees[Profile::DEGREE_X] => 'Cycle polytechnicien', + $eduDegrees[Profile::DEGREE_M] => 'Cycle master', + $eduDegrees[Profile::DEGREE_D] => 'Cycle doctoral' + ); + } + + public function value(ProfilePage $page, $field, $value, &$success) + { + $success = true; + if (is_null($value)) { + $value = array(); + $value = XDB::fetchAllAssoc("SELECT degreeid, fieldid, promo_year, program + FROM profile_education + WHERE pid = {?} AND FIND_IN_SET('primary', flags) + ORDER BY degreeid", + $page->pid()); + + foreach ($value as &$item) { + $item['cycle'] = $this->cycles[$item['degreeid']]; + } + } elseif (!is_array($value)) { + $value = array(); + } else { + foreach ($value as $key => $item) { + if (!isset($item['degreeid'])) { + unset($value[$key]); + } + } + } + + return $value; + } + + public function save(ProfilePage $page, $field, $value) + { + foreach ($value as $item) { + $fieldId = ($item['fieldid'] == 0) ? null : $item['fieldid']; + XDB::execute("UPDATE profile_education + SET fieldid = {?}, program = {?} + WHERE pid = {?} AND FIND_IN_SET('primary', flags) AND degreeid = {?}", + $fieldId, $item['program'], $page->pid(), $item['degreeid']); + } + } + + public function getText($value) { + $fieldsList = DirEnum::getOptions(DirEnum::EDUFIELDS); + $educations = array(); + foreach ($value as $item) { + $details = array($this->cycles[$item['degreeid']]); + if ($education['program']) { + $details[] = '« ' . $education['program'] . ' »'; + } + if ($education['fieldid']) { + $details[] = $fieldsList[$education['fieldid']]; + } + } + return implode(', ', $educations); + } +} + class ProfileSettingEmailDirectory implements ProfileSetting { public function __construct(){} @@ -551,6 +620,7 @@ class ProfilePageGeneral extends ProfilePage $this->settings['networking'] = new ProfileSettingNetworking(); $this->settings['tels'] = new ProfileSettingPhones(); $this->settings['edus'] = new ProfileSettingEdu(); + $this->settings['main_edus'] = new ProfileSettingMainEdu(); $this->settings['promo'] = new ProfileSettingPromo(); $this->watched= array('tels' => true, 'networking' => true, 'edus' => true, diff --git a/templates/profile/general.tpl b/templates/profile/general.tpl index ede21f9..e23aec5 100644 --- a/templates/profile/general.tpl +++ b/templates/profile/general.tpl @@ -181,6 +181,48 @@ + + + + + {foreach from=$main_edus key=eduid item=main_edu} + {cycle values="impair, pair" assign=class} + + + + + + + + + + + + + + + + + {/foreach} +
+
+ + {icon name="flag_green" title="site public"} +
+ Formations à l'École polytechnique +
Cycle :{$main_edu.cycle}
Promotion :{$main_edu.promo_year}
Domaine de formation : + +
Description de la formation : + + + +
+