Browse Source

Bug fix: create the admin accounts with its linked profile (admin) in one operations since profiles are now mandatory when creating/updating a user.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@870 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 14 năm trước cách đây
mục cha
commit
6d21fe3fcc
1 tập tin đã thay đổi với 5 bổ sung3 xóa
  1. 5 3
      addons/userrights/userrightsprofile.class.inc.php

+ 5 - 3
addons/userrights/userrightsprofile.class.inc.php

@@ -454,18 +454,20 @@ class UserRightsProfile extends UserRightsAddOnAPI
 		$oUser->Set('password', $sAdminPwd);
 		$oUser->Set('contactid', $iContactId);
 		$oUser->Set('language', $sLanguage); // Language was chosen during the installation
-		$iUserId = $oUser->DBInsertTrackedNoReload($oChange, true /* skip security */);
 
 		// Add this user to the very specific 'admin' profile
 		$oAdminProfile = MetaModel::GetObjectFromOQL("SELECT URP_Profiles WHERE name = :name", array('name' => ADMIN_PROFILE_NAME), true /*all data*/);
 		if (is_object($oAdminProfile))
 		{
 			$oUserProfile = new URP_UserProfile();
-			$oUserProfile->Set('userid', $iUserId);
+			//$oUserProfile->Set('userid', $iUserId);
 			$oUserProfile->Set('profileid', $oAdminProfile->GetKey());
 			$oUserProfile->Set('reason', 'By definition, the administrator must have the administrator profile');
-			$oUserProfile->DBInsertTrackedNoReload($oChange, true /* skip security */);
+			//$oUserProfile->DBInsertTrackedNoReload($oChange, true /* skip security */);
+			$oSet = DBObjectSet::FromObject($oUserProfile);
+			$oUser->Set('profile_list', $oSet);
 		}
+		$iUserId = $oUser->DBInsertTrackedNoReload($oChange, true /* skip security */);
 		return true;
 	}