- if ($this->values['promo_display']{0} == $this->profile->mainEducation()
- && intval(substr($this->values['promo_display'], 1, 4)) >= $this->profile->entry_year + $this->profile->mainEducationDuration()) {
- XDB::execute('UPDATE profile_display
- SET promo = {?}
+ if ($this->values['promo_display']{0} == $this->profile->mainEducation()) {
+ if (($this->profile->mainEducation() == 'X'
+ && intval(substr($this->values['promo_display'], 1, 4)) >= $this->profile->entry_year)
+ || ($this->profile->mainEducation() != 'X'
+ && intval(substr($this->values['promo_display'], 1, 4)) >= $this->profile->entry_year + $this->profile->mainEducationDuration())) {
+ XDB::execute('UPDATE profile_display
+ SET promo = {?}
+ WHERE pid = {?}',
+ $this->values['promo_display'], $this->pid());
+ }
+ }
+ }
+ if ($this->changed['deathdate']) {
+ XDB::execute('UPDATE profiles
+ SET deathdate = {?}, deathdate_rec = NOW()
+ WHERE pid = {?} AND deathdate_rec IS NULL',
+ ProfileSettingDate::toSQLDate($this->values['deathdate']), $this->pid());
+ if (XDB::affectedRows() > 0) {
+ $this->profile->clear();
+ if ($this->owner) {
+ $this->owner->clear(true);
+ }
+ } else {
+ /* deathdate_rec was not NULL, this is just an update of the death date
+ */
+ XDB::execute('UPDATE profiles
+ SET deathdate = {?}