Browse Source

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

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1490 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 13 years ago
parent
commit
388ef91064
2 changed files with 15 additions and 21 deletions
  1. 14 20
      addons/userrights/userrightsprofile.class.inc.php
  2. 1 1
      core/attributedef.class.inc.php

+ 14 - 20
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'))
+			// Support drastic data model changes: no Person class  (or not writable)!
+			if (MetaModel::IsValidClass('Person') && !MetaModel::IsAbstract('Person'))
 			{
-				$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 */);
 			}
-			$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);
 		}

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