mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
- Fixed Trac #433: triggers creation was incorrect when iTop was installed with a 'prefix' for the DB tables.
- Fixed a bug due to the previous renaming of UpdateObject... SVN:trunk[1372]
This commit is contained in:
@@ -458,7 +458,7 @@ EOF
|
|||||||
|
|
||||||
public function UpdateObjectFromPostedForm($sFormPrefix = '', $sAttList = null)
|
public function UpdateObjectFromPostedForm($sFormPrefix = '', $sAttList = null)
|
||||||
{
|
{
|
||||||
parent::UpdateObject($sFormPrefix, $sAttList);
|
parent::UpdateObjectFromPostedForm($sFormPrefix, $sAttList);
|
||||||
// And now read the other post parameters...
|
// And now read the other post parameters...
|
||||||
$oAttributeSet = $this->Get('attribute_list');
|
$oAttributeSet = $this->Get('attribute_list');
|
||||||
$aAttributes = array();
|
$aAttributes = array();
|
||||||
@@ -647,6 +647,7 @@ EOF
|
|||||||
parent::AfterInsert();
|
parent::AfterInsert();
|
||||||
|
|
||||||
$sTable = $this->GetDataTable();
|
$sTable = $this->GetDataTable();
|
||||||
|
$sReplicaTable = MetaModel::DBGetTable('SynchroReplica');
|
||||||
|
|
||||||
$aColumns = $this->GetSQLColumns();
|
$aColumns = $this->GetSQLColumns();
|
||||||
|
|
||||||
@@ -669,7 +670,7 @@ EOF
|
|||||||
$sTriggerInsert = "CREATE TRIGGER `{$sTable}_bi` BEFORE INSERT ON $sTable";
|
$sTriggerInsert = "CREATE TRIGGER `{$sTable}_bi` BEFORE INSERT ON $sTable";
|
||||||
$sTriggerInsert .= " FOR EACH ROW";
|
$sTriggerInsert .= " FOR EACH ROW";
|
||||||
$sTriggerInsert .= " BEGIN";
|
$sTriggerInsert .= " BEGIN";
|
||||||
$sTriggerInsert .= " INSERT INTO priv_sync_replica (sync_source_id, status_last_seen, `status`) VALUES ({$this->GetKey()}, NOW(), 'new');";
|
$sTriggerInsert .= " INSERT INTO {$sReplicaTable} (sync_source_id, status_last_seen, `status`) VALUES ({$this->GetKey()}, NOW(), 'new');";
|
||||||
$sTriggerInsert .= " SET NEW.id = LAST_INSERT_ID();";
|
$sTriggerInsert .= " SET NEW.id = LAST_INSERT_ID();";
|
||||||
$sTriggerInsert .= " END;";
|
$sTriggerInsert .= " END;";
|
||||||
CMDBSource::Query($sTriggerInsert);
|
CMDBSource::Query($sTriggerInsert);
|
||||||
@@ -691,7 +692,7 @@ EOF
|
|||||||
$sTriggerUpdate .= " FOR EACH ROW";
|
$sTriggerUpdate .= " FOR EACH ROW";
|
||||||
$sTriggerUpdate .= " BEGIN";
|
$sTriggerUpdate .= " BEGIN";
|
||||||
$sTriggerUpdate .= " IF @itopuser is null THEN";
|
$sTriggerUpdate .= " IF @itopuser is null THEN";
|
||||||
$sTriggerUpdate .= " UPDATE priv_sync_replica SET status_last_seen = NOW(), `status` = IF(`status` = 'obsolete', IF(`dest_id` IS NULL, 'new', 'modified'), IF(`status` IN ('synchronized') AND ($sIsModified), 'modified', `status`)) WHERE sync_source_id = {$this->GetKey()} AND id = OLD.id;";
|
$sTriggerUpdate .= " UPDATE {$sReplicaTable} SET status_last_seen = NOW(), `status` = IF(`status` = 'obsolete', IF(`dest_id` IS NULL, 'new', 'modified'), IF(`status` IN ('synchronized') AND ($sIsModified), 'modified', `status`)) WHERE sync_source_id = {$this->GetKey()} AND id = OLD.id;";
|
||||||
$sTriggerUpdate .= " SET NEW.id = OLD.id;"; // make sure this id won't change
|
$sTriggerUpdate .= " SET NEW.id = OLD.id;"; // make sure this id won't change
|
||||||
$sTriggerUpdate .= " END IF;";
|
$sTriggerUpdate .= " END IF;";
|
||||||
$sTriggerUpdate .= " END;";
|
$sTriggerUpdate .= " END;";
|
||||||
@@ -700,7 +701,7 @@ EOF
|
|||||||
$sTriggerInsert = "CREATE TRIGGER `{$sTable}_ad` AFTER DELETE ON $sTable";
|
$sTriggerInsert = "CREATE TRIGGER `{$sTable}_ad` AFTER DELETE ON $sTable";
|
||||||
$sTriggerInsert .= " FOR EACH ROW";
|
$sTriggerInsert .= " FOR EACH ROW";
|
||||||
$sTriggerInsert .= " BEGIN";
|
$sTriggerInsert .= " BEGIN";
|
||||||
$sTriggerInsert .= " DELETE FROM priv_sync_replica WHERE id = OLD.id;";
|
$sTriggerInsert .= " DELETE FROM {$sReplicaTable} WHERE id = OLD.id;";
|
||||||
$sTriggerInsert .= " END;";
|
$sTriggerInsert .= " END;";
|
||||||
CMDBSource::Query($sTriggerInsert);
|
CMDBSource::Query($sTriggerInsert);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user