$value = array();
$value = XDB::fetchAllAssoc("SELECT eduid, degreeid, fieldid, grad_year, program
FROM profile_education
- WHERE pid = {?} AND !FIND_IN_SET('primary', flags)
+ WHERE pid = {?} AND !(FIND_IN_SET('primary', flags) OR FIND_IN_SET('secondary', flags))
ORDER BY id",
$page->pid());
} else if (!is_array($value)) {
public function save(ProfilePage $page, $field, $value)
{
XDB::execute("DELETE FROM profile_education
- WHERE pid = {?} AND !FIND_IN_SET('primary', flags)",
+ WHERE pid = {?} AND !(FIND_IN_SET('primary', flags) OR FIND_IN_SET('secondary', flags))",
$page->pid());
+ $schoolsList = DirEnum::getOptions(DirEnum::EDUSCHOOLS);
foreach ($value as $eduid=>&$edu) {
- if ($edu['eduid'] != '') {
+ if ($edu['eduid'] != '' && $schoolsList[$edu['eduid']] != Profile::EDU_X) {
$fieldId = ($edu['fieldid'] == 0) ? null : $edu['fieldid'];
XDB::execute("INSERT INTO profile_education
SET id = {?}, pid = {?}, eduid = {?}, degreeid = {?},
$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",
+ WHERE pid = {?} AND (FIND_IN_SET('primary', flags) OR FIND_IN_SET('secondary', flags))
+ ORDER BY NOT FIND_IN_SET('primary', flags), degreeid",
$page->pid());
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 = {?}",
+ WHERE pid = {?} AND (FIND_IN_SET('primary', flags) OR FIND_IN_SET('secondary', flags)) AND degreeid = {?}",
$fieldId, $item['program'], $page->pid(), $item['degreeid']);
}
}
}
Platal::page()->assign('promo_choice', $promoChoice);
}
- return $yearpromo;
+
+ // If this profile belongs to an X, return grad year minus education duration.
+ if ($page->profile->mainEducation() == 'X') {
+ return $gradYear - $page->profile->mainEducationDuration();
+ }
+
+ return $gradYear;
}
// If this profile belongs to an X, $promoNew needs to be changed to
if (!S::user()->isMe($this->owner)) {
$this->settings['deathdate'] = new ProfileSettingDate(true);
$this->settings['birthdate'] = new ProfileSettingDate(true);
+ $this->settings['birthdate_ref'] = new ProfileSettingDate(true);
} else {
$this->settings['yourself'] = null;
$this->settings['birthdate'] = new ProfileSettingDate();
$res = XDB::query("SELECT p.nationality1, p.nationality2, p.nationality3, IF(p.birthdate = 0, '', p.birthdate) AS birthdate,
p.email_directory as email_directory, pd.promo AS promo_display,
p.freetext, p.freetext_pub, p.ax_id AS matricule_ax, pd.yourself,
- p.deathdate
+ p.deathdate, IF(p.birthdate_ref = 0, '', p.birthdate_ref) AS birthdate_ref
FROM profiles AS p
INNER JOIN profile_display AS pd ON (pd.pid = p.pid)
WHERE p.pid = {?}", $this->pid());
}
}
}
+ if ($this->orig['birthdate_ref'] == 0 && !S::user()->isMe($this->owner) && $this->changed['birthdate_ref']) {
+ XDB::execute('UPDATE profiles
+ SET birthdate_ref = {?}
+ WHERE pid = {?}',
+ ProfileSettingDate::toSQLDate($this->values['birthdate_ref']), $this->pid());
+ }
if (!S::user()->isMe($this->owner) && $this->changed['deathdate']) {
XDB::execute('UPDATE profiles
SET deathdate = {?}, deathdate_rec = NOW()