瀏覽代碼

- Track the changes/history when creating the administrator account (Trac #48)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@211 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 15 年之前
父節點
當前提交
a3d5682e0f
共有 2 個文件被更改,包括 19 次插入5 次删除
  1. 9 1
      addons/userrights/userrightsmatrix.class.inc.php
  2. 10 4
      addons/userrights/userrightsprofile.class.inc.php

+ 9 - 1
addons/userrights/userrightsmatrix.class.inc.php

@@ -173,7 +173,15 @@ class UserRightsMatrix extends UserRightsAddOnAPI
 		$oUser->Set('login', $sAdminUser);
 		$oUser->Set('password', $sAdminPwd);
 		$oUser->Set('userid', 1); // one is for root !
-		$iUserId = $oUser->DBInsertNoReload();
+
+		// Create a change to record the history of the User object
+		$oChange = MetaModel::NewObject("CMDBChange");
+		$oChange->Set("date", time());
+		$oChange->Set("userinfo", "Initialization");
+		$iChangeId = $oChange->DBInsert();
+
+		// Now record the admin user object
+		$iUserId = $oUser->DBInsertTrackedNoReload($oChange);
 		$this->SetupUser($iUserId, true);
 		return true;
 	}

+ 10 - 4
addons/userrights/userrightsprofile.class.inc.php

@@ -757,12 +757,18 @@ class UserRightsProfile extends UserRightsAddOnAPI
 	// Installation: create the very first user
 	public function CreateAdministrator($sAdminUser, $sAdminPwd)
 	{
+		// Create a change to record the history of the User object
+		$oChange = MetaModel::NewObject("CMDBChange");
+		$oChange->Set("date", time());
+		$oChange->Set("userinfo", "Initialization");
+		$iChangeId = $oChange->DBInsert();
+
 		$oOrg = new bizOrganization();
 		$oOrg->Set('name', 'My Company/Department');
 		$oOrg->Set('code', 'SOMECODE');
 		$oOrg->Set('status', 'implementation');
 		//$oOrg->Set('parent_id', xxx);
-		$iOrgId = $oOrg->DBInsertNoReload();
+		$iOrgId = $oOrg->DBInsertTrackedNoReload($oChange);
 
 		// Location : optional
 		//$oLocation = new bizLocation();
@@ -784,20 +790,20 @@ class UserRightsProfile extends UserRightsAddOnAPI
 		$oContact->Set('phone', '');
 		//$oContact->Set('location_id', $iLocationId);
 		$oContact->Set('employee_number', '');
-		$iContactId = $oContact->DBInsertNoReload();
+		$iContactId = $oContact->DBInsertTrackedNoReload($oChange);
 		
 		$oUser = new URP_Users();
 		$oUser->Set('login', $sAdminUser);
 		$oUser->Set('password', $sAdminPwd);
 		$oUser->Set('userid', $iContactId);
-		$iUserId = $oUser->DBInsertNoReload();
+		$iUserId = $oUser->DBInsertTrackedNoReload($oChange);
 		
 		// Add this user to the very specific 'admin' profile
 		$oUserProfile = new URP_UserProfile();
 		$oUserProfile->Set('userid', $iUserId);
 		$oUserProfile->Set('profileid', ADMIN_PROFILE_ID);
 		$oUserProfile->Set('reason', 'By definition, the administrator must have the administrator profile');
-		$oUserProfile->DBInsertNoReload();
+		$oUserProfile->DBInsertTrackedNoReload($oChange);
 		return true;
 	}