From b557f16cfa75c81a4b281e970581c63fae62cdec Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Tue, 14 Sep 2021 11:06:36 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B04211=20-=20Remove=20DBObject::Reload=20c?= =?UTF-8?q?alls=20added=20in=203.0.0=20-=20Try=20Person=20for=20User's=20C?= =?UTF-8?q?ontact?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/userrights.class.inc.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/core/userrights.class.inc.php b/core/userrights.class.inc.php index 2a8f22cd5..a4fbdc514 100644 --- a/core/userrights.class.inc.php +++ b/core/userrights.class.inc.php @@ -321,7 +321,14 @@ abstract class User extends cmdbAbstractObject { if (MetaModel::IsValidAttCode(get_class($this), 'contactid') && ($this->Get('contactid') != 0)) { - $this->oContactObject = MetaModel::GetObject('Contact', $this->Get('contactid')); + $this->oContactObject = null; + // The User Contact is generally a Person, so try it first + if (MetaModel::IsValidClass('Person')) { + $this->oContactObject = MetaModel::GetObject('Person', $this->Get('contactid'), false); + } + if (is_null($this->oContactObject)) { + $this->oContactObject = MetaModel::GetObject('Contact', $this->Get('contactid')); + } } } return $this->oContactObject; @@ -1196,7 +1203,14 @@ class UserRights // Then check if the user has a contact attached and if it has an picture defined $sContactId = UserRights::GetContactId($sLogin); if (!empty($sContactId)) { - $oContact = MetaModel::GetObject('Contact', $sContactId, false, true); + $oContact = null; + // Picture if generally for Person, so try it first + if (MetaModel::IsValidClass('Person')) { + $oContact = MetaModel::GetObject('Person', $sContactId, false, true); + } + if (is_null($oContact)) { + $oContact = MetaModel::GetObject('Contact', $sContactId, false, true); + } $sContactClass = get_class($oContact); // Check that Contact object still exists and that Contact class has a picture attribute