瀏覽代碼

- 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...

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1372 a333f486-631f-4898-b8df-5754b55c2be0

dflaven 14 年之前
父節點
當前提交
d40ceba817
共有 1 個文件被更改,包括 5 次插入4 次删除
  1. 5 4
      synchro/synchrodatasource.class.inc.php

+ 5 - 4
synchro/synchrodatasource.class.inc.php

@@ -458,7 +458,7 @@ EOF
 		
 	public function UpdateObjectFromPostedForm($sFormPrefix = '', $sAttList = null)
 	{
-		parent::UpdateObject($sFormPrefix, $sAttList);
+		parent::UpdateObjectFromPostedForm($sFormPrefix, $sAttList);
 		// And now read the other post parameters...
 		$oAttributeSet = $this->Get('attribute_list');
 		$aAttributes = array();
@@ -647,6 +647,7 @@ EOF
 		parent::AfterInsert();
 
 		$sTable = $this->GetDataTable();
+		$sReplicaTable = MetaModel::DBGetTable('SynchroReplica');
 
 		$aColumns = $this->GetSQLColumns();
 		
@@ -669,7 +670,7 @@ EOF
 		$sTriggerInsert = "CREATE TRIGGER `{$sTable}_bi` BEFORE INSERT ON $sTable";
 		$sTriggerInsert .= "   FOR EACH ROW";
 		$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 .= "   END;";
 		CMDBSource::Query($sTriggerInsert);
@@ -691,7 +692,7 @@ EOF
 		$sTriggerUpdate .= "   FOR EACH ROW";
 		$sTriggerUpdate .= "   BEGIN";
 		$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 .= "      END IF;";
 		$sTriggerUpdate .= "   END;";
@@ -700,7 +701,7 @@ EOF
 		$sTriggerInsert = "CREATE TRIGGER `{$sTable}_ad` AFTER DELETE ON $sTable";
 		$sTriggerInsert .= "   FOR EACH ROW";
 		$sTriggerInsert .= "   BEGIN";
-		$sTriggerInsert .= "      DELETE FROM priv_sync_replica WHERE id = OLD.id;";
+		$sTriggerInsert .= "      DELETE FROM {$sReplicaTable} WHERE id = OLD.id;";
 		$sTriggerInsert .= "   END;";
 		CMDBSource::Query($sTriggerInsert);
 	}