From efcd4d0c632c0e792ac70370e4b0fa2c001fdb45 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Tue, 4 Feb 2020 09:00:31 +0100 Subject: [PATCH] Fix unset gender property in contact class --- htdocs/contact/class/contact.class.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 56ba2e24def..465dc4a1e16 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -988,19 +988,25 @@ class Contact extends CommonObject } + /** - * Set property ->gender from property ->civility_id + * Set the property "gender" of this class, based on the property "civility_id" + * or use property "civility_code" as fallback, when "civility_id" is not available. * * @return void */ public function setGenderFromCivility() { - unset($this->gender); - if (in_array($this->civility_id, array('MR'))) { - $this->gender = 'man'; - } elseif (in_array($this->civility_id, array('MME', 'MLE'))) { - $this->gender = 'woman'; - } + unset($this->gender); + + if (in_array($this->civility_id, array('MR')) || in_array($this->civility_code, array('MR'))) + { + $this->gender = 'man'; + } + elseif(in_array($this->civility_id, array('MME','MLE')) || in_array($this->civility_code, array('MME','MLE'))) + { + $this->gender = 'woman'; + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps