Parcourir la source

Patch for supporting a data model without any Person.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1016 a333f486-631f-4898-b8df-5754b55c2be0
dflaven il y a 14 ans
Parent
commit
aea2cdc6b7
1 fichiers modifiés avec 17 ajouts et 14 suppressions
  1. 17 14
      addons/userrights/userrightsprofile.class.inc.php

+ 17 - 14
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'))
-		{
-			// Protect for a different data model where contacts are not part of an org
-			$oContact->Set('org_id', $iOrgId);
-		}
-		$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 */);
+		// Support drastic data model changes: no Person class !
+		if (MetaModel::IsValidClass('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);