}
}
+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(){}
$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,
</tr>
</table>
+<table class="bicol" style="margin-bottom: 1em" summary="Profil : Formations à l'X">
+ <tr>
+ <th colspan="2">
+ <div class="flags" style="float: left">
+ <input type="checkbox" disabled="disabled" checked="checked" />
+ {icon name="flag_green" title="site public"}
+ </div>
+ Formations à l'École polytechnique
+ </th>
+ </tr>
+ {foreach from=$main_edus key=eduid item=main_edu}
+ {cycle values="impair, pair" assign=class}
+ <tr class="{$class}">
+ <td><span class="titre">Cycle :</span></td>
+ <td>{$main_edu.cycle}</td>
+ </tr>
+ <tr class="{$class}">
+ <td><span class="titre">Promotion :</span></td>
+ <td>{$main_edu.promo_year}</td>
+ </tr>
+ <tr class="{$class}">
+ <td><span class="titre">Domaine de formation :</span></td>
+ <td>
+ <select name="main_edus[{$main_edu.degreeid}][fieldid]">
+ <option value=""> </option>
+ {foreach from=$edu_fields item=field}
+ <option value="{$field.id}" {if $field.id eq $main_edu.fieldid}selected="selected"{/if}>{$field.field}</option>
+ {/foreach}
+ </select>
+ </td>
+ </tr>
+ <tr class="{$class}">
+ <td><span class="titre">Description de la formation :</span></td>
+ <td>
+ <input type="text" name="main_edus[{$main_edu.degreeid}][program]" value="{$main_edu.program}" size="30" maxlength="255" />
+ <input type="hidden" name="main_edus[{$main_edu.degreeid}][degreeid]" value="{$main_edu.degreeid}" />
+ <input type="hidden" name="main_edus[{$main_edu.degreeid}][cycle]" value="{$main_edu.cycle}" />
+ </td>
+ </tr>
+ {/foreach}
+</table>
+
<table class="bicol" style="margin-bottom: 1em" summary="Profil : Formations">
<tr>
<th colspan="2">