diff --git a/addons/userrights/userrightsmatrix.class.inc.php b/addons/userrights/userrightsmatrix.class.inc.php index 732516f8f..4141cfffb 100644 --- a/addons/userrights/userrightsmatrix.class.inc.php +++ b/addons/userrights/userrightsmatrix.class.inc.php @@ -121,20 +121,14 @@ 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); $oUser->Set('contactid', 1); // one is for root ! $oUser->Set('language', $sLanguage); // Language was chosen during the installation - // 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"); - // Now record the admin user object - $oUser::SetCurrentChange($oChange); $iUserId = $oUser->DBInsertNoReload(); $this->SetupUser($iUserId, true); return true; diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 20767828f..7e6b7f0f9 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -4433,7 +4433,7 @@ EOF * * @param \WebPage $oP * @param $sClass - * @param $aObjects + * @param \DBObject[] $aObjects * @param $bPreview * @param $sCustomOperation * @param array $aContextData @@ -4453,7 +4453,7 @@ EOF } else { - $oObj->DBDelete(); + $oObj->DBDelete($oDeletionPlan); } } diff --git a/application/loginwebpage.class.inc.php b/application/loginwebpage.class.inc.php index 8d32ed890..751124bd5 100644 --- a/application/loginwebpage.class.inc.php +++ b/application/loginwebpage.class.inc.php @@ -786,7 +786,13 @@ class LoginWebPage extends NiceWebPage $oPerson = null; try { - /** @var Person $oPerson */ + $sOrigin = 'External User provisioning'; + if (isset($_SESSION['login_mode'])) + { + $sOrigin .= " ({$_SESSION['login_mode']})"; + } + CMDBObject::SetTrackOrigin($sOrigin); + $oPerson = MetaModel::NewObject('Person'); $oPerson->Set('first_name', $sFirstName); $oPerson->Set('name', $sLastName); @@ -801,16 +807,6 @@ class LoginWebPage extends NiceWebPage { $oPerson->Set($sAttCode, $sValue); } - /** @var CMDBChange $oMyChange */ - $oMyChange = MetaModel::NewObject('CMDBChange'); - $oMyChange->Set("date", time()); - $sOrigin = 'External User provisioning'; - if (isset($_SESSION['login_mode'])) - { - $sOrigin .= " ({$_SESSION['login_mode']})"; - } - $oMyChange->Set('userinfo', $sOrigin); - $oPerson::SetCurrentChange($oMyChange); $oPerson->DBInsert(); } catch (Exception $e) diff --git a/core/bulkchange.class.inc.php b/core/bulkchange.class.inc.php index fc6d1ce93..19f12c574 100644 --- a/core/bulkchange.class.inc.php +++ b/core/bulkchange.class.inc.php @@ -654,7 +654,7 @@ class BulkChange return $aResults; } - + protected function CreateObject(&$aResult, $iRow, $aRowData, CMDBChange $oChange = null) { $oTargetObj = MetaModel::NewObject($this->m_sClass); @@ -731,18 +731,17 @@ class BulkChange // if ($oChange) { - $oTargetObj::SetCurrentChange($oChange); $newID = $oTargetObj->DBInsert(); - $aResult[$iRow]["__STATUS__"] = new RowStatus_NewObj(); - $aResult[$iRow]["finalclass"] = get_class($oTargetObj); - $aResult[$iRow]["id"] = new CellStatus_Void($newID); } else { - $aResult[$iRow]["__STATUS__"] = new RowStatus_NewObj(); - $aResult[$iRow]["finalclass"] = get_class($oTargetObj); - $aResult[$iRow]["id"] = new CellStatus_Void(0); + $newID = 0; } + + $aResult[$iRow]["__STATUS__"] = new RowStatus_NewObj(); + $aResult[$iRow]["finalclass"] = get_class($oTargetObj); + $aResult[$iRow]["id"] = new CellStatus_Void($newID); + return $oTargetObj; } @@ -786,7 +785,6 @@ class BulkChange { try { - $oTargetObj::SetCurrentChange($oChange); $oTargetObj->DBUpdate(); } catch(CoreException $e) @@ -852,6 +850,11 @@ class BulkChange public function Process(CMDBChange $oChange = null) { + if ($oChange) + { + CMDBObject::SetCurrentChange($oChange); + } + // Note: $oChange can be null, in which case the aim is to check what would be done // Debug... diff --git a/datamodels/2.x/authent-cas/src/CASLoginExtension.php b/datamodels/2.x/authent-cas/src/CASLoginExtension.php index aee207670..cefc54b56 100644 --- a/datamodels/2.x/authent-cas/src/CASLoginExtension.php +++ b/datamodels/2.x/authent-cas/src/CASLoginExtension.php @@ -8,6 +8,7 @@ namespace Combodo\iTop\Cas; use AbstractLoginFSMExtension; +use CMDBObject; use DBObjectSearch; use DBObjectSet; use Dict; @@ -185,6 +186,7 @@ class CASLoginExtension extends AbstractLoginFSMExtension implements iLogoutExte return; } + CMDBObject::SetTrackInfo('CAS/LDAP Synchro'); $oUser = LoginWebPage::FindUser($sLogin, false); if ($oUser) { diff --git a/datamodels/2.x/itop-tickets/module.itop-tickets.php b/datamodels/2.x/itop-tickets/module.itop-tickets.php index 4821b9def..4bcc9e36b 100755 --- a/datamodels/2.x/itop-tickets/module.itop-tickets.php +++ b/datamodels/2.x/itop-tickets/module.itop-tickets.php @@ -50,21 +50,13 @@ class TicketsInstaller extends ModuleInstallerAPI public static function AfterDatabaseCreation(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion) { // Delete all Triggers corresponding to a no more valid class + CMDBObject::SetTrackInfo('Uninstallation'); $oSearch = new DBObjectSearch('TriggerOnObject'); $oSet = new DBObjectSet($oSearch); - $oChange = null; while($oTrigger = $oSet->Fetch()) { if (!MetaModel::IsValidClass($oTrigger->Get('target_class'))) { - if ($oChange == null) - { - // Create the change for its first use - $oChange = new CMDBChange; - $oChange->Set("date", time()); - $oChange->Set("userinfo", "Uninstallation"); - } - $oTrigger::SetCurrentChange($oChange); $oTrigger->DBDelete(); } } diff --git a/synchro/synchrodatasource.class.inc.php b/synchro/synchrodatasource.class.inc.php index 0cbf6c324..3bcc89098 100644 --- a/synchro/synchrodatasource.class.inc.php +++ b/synchro/synchrodatasource.class.inc.php @@ -3001,6 +3001,7 @@ class SynchroExecution $this->m_oChange->Set('userinfo', $sUserString.' '.Dict::S('Core:SyncDataExchangeComment')); $this->m_oChange->Set('origin', 'synchro-data-source'); $this->m_oChange->DBInsert(); + CMDBObject::SetCurrentChange($oChange); // Start logging this execution (stats + protection against reentrance) // @@ -3377,6 +3378,7 @@ class SynchroExecution self::$m_oCurrentTask = $this->m_oDataSource; $this->m_oStatLog = $oLog; $this->m_oChange = $oChange; + CMDBObject::SetCurrentChange($oChange); // Prepare internal structures (not the first pass) $this->PrepareProcessing(false); diff --git a/test/benchmark.php b/test/benchmark.php index a24afe339..4a9997bd7 100644 --- a/test/benchmark.php +++ b/test/benchmark.php @@ -43,9 +43,7 @@ class BenchmarkDataCreation var $m_oChange; public function __construct() { - $this->m_oChange = MetaModel::NewObject("CMDBChange"); - $this->m_oChange->Set("date", time()); - $this->m_oChange->Set("userinfo", "Benchmark setup"); + CMDBObject::SetTrackInfo('Benchmark setup'); } public function PlanStructure($iPlannedContacts, $iPlannedContracts) @@ -147,7 +145,6 @@ class BenchmarkDataCreation $oMyObject->Set($sProp, $value); } - $oMyObject::SetCurrentChange($this->m_oChange); $iId = $oMyObject->DBInsertNoReload(); $sClassId = "$sClass ($sClassDesc)"; diff --git a/test/test.class.inc.php b/test/test.class.inc.php index 516be37bc..a23a85e7b 100644 --- a/test/test.class.inc.php +++ b/test/test.class.inc.php @@ -434,22 +434,13 @@ abstract class TestBizModel extends TestHandler } protected function ObjectToDB($oNew, $bReload = false) { - if ($oNew instanceof CMDBObject) + if ($bReload) { - $oChange = $this->GetCurrentChange(); - $oNew::SetCurrentChange($oChange); - $oNew->DBWrite(); + $iId = $oNew->DBInsert(); } else { - if ($bReload) - { - $iId = $oNew->DBInsert(); - } - else - { - $iId = $oNew->DBInsertNoReload(); - } + $iId = $oNew->DBInsertNoReload(); } return $iId; } diff --git a/test/testlist.inc.php b/test/testlist.inc.php index 62a78b620..b02e9ddc7 100644 --- a/test/testlist.inc.php +++ b/test/testlist.inc.php @@ -342,12 +342,9 @@ class TestMyBizModel extends TestBizModel self::DumpVariable($team->ListChanges()); echo "New headcount = {$team->Get("headcount")}\n"; echo "Computed name = {$team->Get("name")}\n"; - - $oMyChange = MetaModel::NewObject("CMDBChange"); - $oMyChange->Set("date", time()); - $oMyChange->Set("userinfo", "test_setattribute / Made by robot #".rand(1,100)); + + CMDBObject::SetTrackInfo('test_setattribute / Made by robot #'.rand(1, 100)); //DBSearch::StartDebugQuery(); - $team::SetCurrentChange($oMyChange); $team->DBUpdate(); //DBSearch::StopDebugQuery(); @@ -524,12 +521,8 @@ class TestMyBizModel extends TestBizModel echo "