Support an abstract "Organization" class: if it's the case don't create any Org neither Person during the setup.

SVN:trunk[1490]
This commit is contained in:
Denis Flaven
2011-08-22 10:06:48 +00:00
parent 54b4f67ed6
commit 48d66447b7
2 changed files with 17 additions and 23 deletions

View File

@@ -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);
}

View File

@@ -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();}