diff --git a/addons/userrights/userrightsmatrix.class.inc.php b/addons/userrights/userrightsmatrix.class.inc.php index d80af3ed0..da64e17df 100644 --- a/addons/userrights/userrightsmatrix.class.inc.php +++ b/addons/userrights/userrightsmatrix.class.inc.php @@ -121,7 +121,6 @@ class UserRightsMatrix extends UserRightsAddOnAPI public function CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage = 'EN US') { // Maybe we should check that no other user with userid == 0 exists - CMDBObject::SetTrackInfo('Initialization'); $oUser = new UserLocal(); $oUser->Set('login', $sAdminUser); $oUser->Set('password', $sAdminPwd); diff --git a/addons/userrights/userrightsprofile.class.inc.php b/addons/userrights/userrightsprofile.class.inc.php index f91149843..c6b1ca722 100644 --- a/addons/userrights/userrightsprofile.class.inc.php +++ b/addons/userrights/userrightsprofile.class.inc.php @@ -435,20 +435,18 @@ class UserRightsProfile extends UserRightsAddOnAPI // Installation: create the very first user public function CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage = 'EN US') { - CMDBObject::SetTrackInfo('Initialization'); + CMDBObject::SetCurrentChangeFromParams('Initialization create administrator'); $iContactId = 0; // Support drastic data model changes: no organization class (or not writable)! - if (MetaModel::IsValidClass('Organization') && !MetaModel::IsAbstract('Organization')) - { + if (MetaModel::IsValidClass('Organization') && !MetaModel::IsAbstract('Organization')) { $oOrg = MetaModel::NewObject('Organization'); $oOrg->Set('name', 'My Company/Department'); $oOrg->Set('code', 'SOMECODE'); $iOrgId = $oOrg->DBInsertNoReload(); // Support drastic data model changes: no Person class (or not writable)! - if (MetaModel::IsValidClass('Person') && !MetaModel::IsAbstract('Person')) - { + if (MetaModel::IsValidClass('Person') && !MetaModel::IsAbstract('Person')) { $oContact = MetaModel::NewObject('Person'); $oContact->Set('name', 'My last name'); $oContact->Set('first_name', 'My first name'); diff --git a/addons/userrights/userrightsprofile.db.class.inc.php b/addons/userrights/userrightsprofile.db.class.inc.php index ac5b2277b..44b40ab30 100644 --- a/addons/userrights/userrightsprofile.db.class.inc.php +++ b/addons/userrights/userrightsprofile.db.class.inc.php @@ -508,24 +508,18 @@ class UserRightsProfile extends UserRightsAddOnAPI public function CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage = 'EN US') { // Create a change to record the history of the User object - /** @var \CMDBChange $oChange */ - $oChange = MetaModel::NewObject("CMDBChange"); - $oChange->Set("date", time()); - $oChange->Set("userinfo", "Initialization"); + CMDBObject::SetCurrentChangeFromParams('Initialization : create first user admin profile'); $iContactId = 0; // Support drastic data model changes: no organization class (or not writable)! - if (MetaModel::IsValidClass('Organization') && !MetaModel::IsAbstract('Organization')) - { + if (MetaModel::IsValidClass('Organization') && !MetaModel::IsAbstract('Organization')) { $oOrg = MetaModel::NewObject('Organization'); $oOrg->Set('name', 'My Company/Department'); $oOrg->Set('code', 'SOMECODE'); - $oOrg::SetCurrentChange($oChange); $iOrgId = $oOrg->DBInsertNoReload(); // Support drastic data model changes: no Person class (or not writable)! - if (MetaModel::IsValidClass('Person') && !MetaModel::IsAbstract('Person')) - { + if (MetaModel::IsValidClass('Person') && !MetaModel::IsAbstract('Person')) { $oContact = MetaModel::NewObject('Person'); $oContact->Set('name', 'My last name'); $oContact->Set('first_name', 'My first name'); @@ -534,7 +528,6 @@ class UserRightsProfile extends UserRightsAddOnAPI $oContact->Set('org_id', $iOrgId); } $oContact->Set('email', 'my.email@foo.org'); - $oContact::SetCurrentChange($oChange); $iContactId = $oContact->DBInsertNoReload(); } } @@ -543,24 +536,22 @@ class UserRightsProfile extends UserRightsAddOnAPI $oUser = new UserLocal(); $oUser->Set('login', $sAdminUser); $oUser->Set('password', $sAdminPwd); - if (MetaModel::IsValidAttCode('UserLocal', 'contactid') && ($iContactId != 0)) - { + if (MetaModel::IsValidAttCode('UserLocal', 'contactid') && ($iContactId != 0)) { $oUser->Set('contactid', $iContactId); } $oUser->Set('language', $sLanguage); // Language was chosen during the installation // 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)) - { + if (is_object($oAdminProfile)) { $oUserProfile = new URP_UserProfile(); $oUserProfile->Set('profileid', $oAdminProfile->GetKey()); $oUserProfile->Set('reason', 'By definition, the administrator must have the administrator profile'); $oSet = DBObjectSet::FromObject($oUserProfile); $oUser->Set('profile_list', $oSet); } - $oUser::SetCurrentChange($oChange); - $iUserId = $oUser->DBInsertNoReload(); + $oUser->DBInsertNoReload(); + return true; } diff --git a/addons/userrights/userrightsprojection.class.inc.php b/addons/userrights/userrightsprojection.class.inc.php index 61fb07fe6..6aa5eefc0 100644 --- a/addons/userrights/userrightsprojection.class.inc.php +++ b/addons/userrights/userrightsprojection.class.inc.php @@ -568,14 +568,11 @@ class UserRightsProjection extends UserRightsAddOnAPI public function CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage = 'EN US') { // Create a change to record the history of the User object - $oChange = MetaModel::NewObject("CMDBChange"); - $oChange->Set("date", time()); - $oChange->Set("userinfo", "Initialization"); + CMDBObject::SetCurrentChangeFromParams('Initialization : create first user admin'); $oOrg = new Organization(); $oOrg->Set('name', 'My Company/Department'); $oOrg->Set('code', 'SOMECODE'); - $oOrg::SetCurrentChange($oChange); $iOrgId = $oOrg->DBInsertNoReload(); $oContact = new Person(); @@ -584,7 +581,6 @@ class UserRightsProjection extends UserRightsAddOnAPI //$oContact->Set('status', 'available'); $oContact->Set('org_id', $iOrgId); $oContact->Set('email', 'my.email@foo.org'); - $oContact::SetCurrentChange($oChange); $iContactId = $oContact->DBInsertNoReload(); $oUser = new UserLocal(); @@ -592,7 +588,6 @@ class UserRightsProjection extends UserRightsAddOnAPI $oUser->Set('password', $sAdminPwd); $oUser->Set('contactid', $iContactId); $oUser->Set('language', $sLanguage); // Language was chosen during the installation - $oUser::SetCurrentChange($oChange); $iUserId = $oUser->DBInsertNoReload(); // Add this user to the very specific 'admin' profile @@ -600,7 +595,6 @@ class UserRightsProjection extends UserRightsAddOnAPI $oUserProfile->Set('userid', $iUserId); $oUserProfile->Set('profileid', ADMIN_PROFILE_ID); $oUserProfile->Set('reason', 'By definition, the administrator must have the administrator profile'); - $oUserProfile::SetCurrentChange($oChange); $oUserProfile->DBInsertNoReload(); return true; } diff --git a/core/ormstopwatch.class.inc.php b/core/ormstopwatch.class.inc.php index 7bcd5f3d9..b4dddbb91 100644 --- a/core/ormstopwatch.class.inc.php +++ b/core/ormstopwatch.class.inc.php @@ -596,10 +596,9 @@ class CheckStopWatchThresholds implements iBackgroundProcess $oSW = $oObj->Get($sAttCode); $oSW->MarkThresholdAsTriggered($iThreshold); $oObj->Set($sAttCode, $oSW); - - if($oObj->IsModified()) - { - CMDBObject::SetTrackInfo("Automatic - threshold triggered"); + + if ($oObj->IsModified()) { + CMDBObject::SetCurrentChangeFromParams("Automatic - threshold triggered"); $oObj->DBUpdate(); } diff --git a/pages/csvimport.php b/pages/csvimport.php index 74ad1a6c0..fddabdff6 100644 --- a/pages/csvimport.php +++ b/pages/csvimport.php @@ -356,9 +356,7 @@ try { if (!$bSimulate) { // We're doing it for real, let's create a change - $sUserString = CMDBChange::GetCurrentUserName().' (CSV)'; - CMDBObject::SetTrackInfo($sUserString); - CMDBObject::SetTrackOrigin(CMDBChangeOrigin::CSV_INTERACTIVE); + CMDBObject::SetCurrentChangeFromParams('$sUserString', CMDBChangeOrigin::CSV_INTERACTIVE); $oMyChange = CMDBObject::GetCurrentChange(); } CMDBObject::SetTrackOrigin('csv-interactive'); diff --git a/setup/runtimeenv.class.inc.php b/setup/runtimeenv.class.inc.php index 988a9bf1d..b1928cbb6 100644 --- a/setup/runtimeenv.class.inc.php +++ b/setup/runtimeenv.class.inc.php @@ -1109,29 +1109,24 @@ class RunTimeEnvironment */ public function LoadData($aAvailableModules, $aSelectedModules, $bSampleData) { - $oDataLoader = new XMLDataLoader(); - - CMDBObject::SetTrackInfo("Initialization"); - $oMyChange = CMDBObject::GetCurrentChange(); + $oDataLoader = new XMLDataLoader(); + + CMDBObject::SetCurrentChangeFromParams("Initialization from XML files for the selected modules "); + $oMyChange = CMDBObject::GetCurrentChange(); SetupLog::Info("starting data load session"); - $oDataLoader->StartSession($oMyChange); - - $aFiles = array(); - $aPreviouslyLoadedFiles = array(); - foreach($aAvailableModules as $sModuleId => $aModule) - { - if (($sModuleId != ROOT_MODULE)) - { - $sRelativePath = 'env-'.$this->sTargetEnv.'/'.basename($aModule['root_dir']); - // Load data only for selected AND newly installed modules - if (in_array($sModuleId, $aSelectedModules)) - { - if ($aModule['version_db'] != '') - { - // Simulate the load of the previously loaded XML files to get the mapping of the keys - if ($bSampleData) - { + $oDataLoader->StartSession($oMyChange); + + $aFiles = array(); + $aPreviouslyLoadedFiles = array(); + foreach ($aAvailableModules as $sModuleId => $aModule) { + if (($sModuleId != ROOT_MODULE)) { + $sRelativePath = 'env-'.$this->sTargetEnv.'/'.basename($aModule['root_dir']); + // Load data only for selected AND newly installed modules + if (in_array($sModuleId, $aSelectedModules)) { + if ($aModule['version_db'] != '') { + // Simulate the load of the previously loaded XML files to get the mapping of the keys + if ($bSampleData) { $aPreviouslyLoadedFiles = static::MergeWithRelativeDir($aPreviouslyLoadedFiles, $sRelativePath, $aAvailableModules[$sModuleId]['data.struct']); $aPreviouslyLoadedFiles = static::MergeWithRelativeDir($aPreviouslyLoadedFiles, $sRelativePath, $aAvailableModules[$sModuleId]['data.sample']); }