From 87db81e71e24db248d1a5059dcd28781b0e2e75f Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Tue, 28 Sep 2010 15:32:42 +0200 Subject: [PATCH] Allow edition of the death date in the profile edition page. Note: for ethical reasons, the user cannot edit his own death date. Signed-off-by: Florent Bruneau --- core | 2 +- modules/profile/general.inc.php | 27 +++++++++++++++++++++++++-- modules/profile/page.inc.php | 5 +++++ templates/profile/general.tpl | 8 ++++++++ 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/core b/core index a2efe30..792e460 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit a2efe30f0470b8150e70189e6f8d9d7d8601ea87 +Subproject commit 792e4607bafa557ff5bde3b4e4da9406cfbc3111 diff --git a/modules/profile/general.inc.php b/modules/profile/general.inc.php index 981d985..7e2bfff 100644 --- a/modules/profile/general.inc.php +++ b/modules/profile/general.inc.php @@ -523,6 +523,9 @@ class ProfilePageGeneral extends ProfilePage $this->settings['search_names'] = new ProfileSettingSearchNames(); $this->settings['birthdate'] = new ProfileSettingDate(); + if (!S::user()->isMe($this->owner)) { + $this->settings['deathdate'] = new ProfileSettingDate(); + } $this->settings['freetext_pub'] = $this->settings['photo_pub'] = new ProfileSettingPub(); @@ -552,7 +555,8 @@ class ProfilePageGeneral extends ProfilePage // Checkout all data... $res = XDB::query("SELECT p.nationality1, p.nationality2, p.nationality3, p.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.freetext, p.freetext_pub, p.ax_id AS matricule_ax, pd.yourself, + p.deathdate FROM profiles AS p INNER JOIN profile_display AS pd ON (pd.pid = p.pid) WHERE p.pid = {?}", $this->pid()); @@ -615,7 +619,7 @@ class ProfilePageGeneral extends ProfilePage freetext = {?}, freetext_pub = {?}, email_directory = {?} WHERE pid = {?}", $this->values['nationality1'], $this->values['nationality2'], $this->values['nationality3'], - preg_replace('@(\d{2})/(\d{2})/(\d{4})@', '\3-\2-\1', $this->values['birthdate']), + ProfileSettingDate::toSQLDate($this->values['birthdate']), $this->values['freetext'], $this->values['freetext_pub'], $new_email, $this->pid()); } if ($this->changed['photo_pub']) { @@ -649,6 +653,25 @@ class ProfilePageGeneral extends ProfilePage } } } + 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 = {?} + WHERE pid = {?}', + ProfileSettingDate::toSQLDate($this->values['deathdate']), $this->pid()); + } + } } public function _prepare(PlPage &$page, $id) diff --git a/modules/profile/page.inc.php b/modules/profile/page.inc.php index 3117b29..9ea18d9 100644 --- a/modules/profile/page.inc.php +++ b/modules/profile/page.inc.php @@ -190,6 +190,11 @@ class ProfileSettingDate extends ProfileNoSave } return $value; } + + public static function toSQLDate($value) + { + return preg_replace('@(\d{2})/(\d{2})/(\d{4})@', '\3-\2-\1', $value); + } } abstract class ProfilePage implements PlWizardPage diff --git a/templates/profile/general.tpl b/templates/profile/general.tpl index 28d3946..fbe27db 100644 --- a/templates/profile/general.tpl +++ b/templates/profile/general.tpl @@ -131,6 +131,14 @@ + {if !$smarty.session.user->isMe($owner)} + + + Date de décès + + + + {/if} Nationalité -- 2.1.4