diff --git a/addons/userrights/userrightsprofile.class.inc.php b/addons/userrights/userrightsprofile.class.inc.php index b3905c4213..17318815ca 100644 --- a/addons/userrights/userrightsprofile.class.inc.php +++ b/addons/userrights/userrightsprofile.class.inc.php @@ -538,6 +538,7 @@ class UserRightsProfile extends UserRightsAddOnAPI $oChange->Set("userinfo", "Initialization"); $iChangeId = $oChange->DBInsert(); + $iContactid = 0; // Support drastic data model changes: no organization class (or not writable)! if (MetaModel::IsValidClass('Organization') && !MetaModel::IsAbstract('Organization')) { @@ -545,34 +546,27 @@ class UserRightsProfile extends UserRightsAddOnAPI $oOrg->Set('name', 'My Company/Department'); $oOrg->Set('code', 'SOMECODE'); $iOrgId = $oOrg->DBInsertTrackedNoReload($oChange, true /* skip security */); - } - else - { - $iOrgId = 0; + + // Support drastic data model changes: no Person class (or not writable)! + if (MetaModel::IsValidClass('Person') && !MetaModel::IsAbstract('Person')) + { + $oContact = new Person(); + $oContact->Set('name', 'My last name'); + $oContact->Set('first_name', 'My first name'); + if (MetaModel::IsValidAttCode('Person', 'org_id')) + { + $oContact->Set('org_id', $iOrgId); + } + $oContact->Set('email', 'my.email@foo.org'); + $iContactId = $oContact->DBInsertTrackedNoReload($oChange, true /* skip security */); + } } - // Support drastic data model changes: no Person class (or not writable)! - if (MetaModel::IsValidClass('Person') && !MetaModel::IsAbstract('Person')) - { - $oContact = new Person(); - $oContact->Set('name', 'My last name'); - $oContact->Set('first_name', 'My first name'); - if (MetaModel::IsValidAttCode('Person', 'org_id')) - { - $oContact->Set('org_id', $iOrgId); - } - $oContact->Set('email', 'my.email@foo.org'); - $iContactId = $oContact->DBInsertTrackedNoReload($oChange, true /* skip security */); - } - else - { - $iContactId = 0; - } $oUser = new UserLocal(); $oUser->Set('login', $sAdminUser); $oUser->Set('password', $sAdminPwd); - if (MetaModel::IsValidAttCode('UserLocal', 'contactid')) + if (MetaModel::IsValidAttCode('UserLocal', 'contactid') && ($iContactId != 0)) { $oUser->Set('contactid', $iContactId); } diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index d0234dc582..4b954ef677 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -2594,7 +2594,7 @@ class AttributeHierarchicalKey extends AttributeExternalKey } public function IsHierarchicalKey() {return true;} - public function GetTargetClass($iType = EXTKEY_RELATIVE) {return $this->GetHostClass();} + public function GetTargetClass($iType = EXTKEY_RELATIVE) {return $this->m_sTargetClass;} public function GetKeyAttDef($iType = EXTKEY_RELATIVE){return $this;} public function GetKeyAttCode() {return $this->GetCode();}