From 5ff5e3f1a7198179453943779b47cc535988f98b Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Tue, 7 Dec 2010 15:06:17 +0000 Subject: [PATCH] Patch for supporting a data model without any Person. SVN:trunk[1016] --- .../userrightsprofile.class.inc.php | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/addons/userrights/userrightsprofile.class.inc.php b/addons/userrights/userrightsprofile.class.inc.php index b67cccc4b..ec51235c6 100644 --- a/addons/userrights/userrightsprofile.class.inc.php +++ b/addons/userrights/userrightsprofile.class.inc.php @@ -444,20 +444,23 @@ class UserRightsProfile extends UserRightsAddOnAPI $iOrgId = 0; } - $oContact = new Person(); - $oContact->Set('name', 'My last name'); - $oContact->Set('first_name', 'My first name'); - //$oContact->Set('status', 'available'); - if (MetaModel::IsValidAttCode('Person', 'org_id')) + // Support drastic data model changes: no Person class ! + if (MetaModel::IsValidClass('Person')) { - // Protect for a different data model where contacts are not part of an org - $oContact->Set('org_id', $iOrgId); + $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; } - $oContact->Set('email', 'my.email@foo.org'); - //$oContact->Set('phone', ''); - //$oContact->Set('location_id', $iLocationId); - //$oContact->Set('employee_number', ''); - $iContactId = $oContact->DBInsertTrackedNoReload($oChange, true /* skip security */); $oUser = new UserLocal(); $oUser->Set('login', $sAdminUser);