From 5fa5c0b33700c0a8227f33bde50b664d93d4cc00 Mon Sep 17 00:00:00 2001
From: jmontoya <jmontoya@ispconfig3>
Date: Tue, 3 Aug 2010 14:31:10 +0000
Subject: [PATCH] Moving id, and datarecord in the insertQuery in order to get
 the values when loading a plugin

---
 interface/lib/classes/remoting.inc.php | 34 +++++++-------------------
 1 file changed, 9 insertions(+), 25 deletions(-)

diff --git a/interface/lib/classes/remoting.inc.php b/interface/lib/classes/remoting.inc.php
index 57708780a2..4716437356 100644
--- a/interface/lib/classes/remoting.inc.php
+++ b/interface/lib/classes/remoting.inc.php
@@ -1944,21 +1944,12 @@ class remoting {
 		//* Save changes to Datalog
 		if($app->remoting_lib->formDef["db_history"] == 'yes') {
 			$new_rec = $app->remoting_lib->getDataRecord($insert_id);
-			$app->remoting_lib->datalogSave('INSERT',$primary_id,array(),$new_rec);
-			
-		$app->remoting_lib->ispconfig_sysuser_add($params,$insert_id);
-
+			$app->remoting_lib->datalogSave('INSERT',$primary_id,array(),$new_rec);			
+			$app->remoting_lib->ispconfig_sysuser_add($params,$insert_id);
 		}
-		
-		
-		
-		
 		return $insert_id;
 	}
 
-
-
-
 	private function insertQuery($formdef_file, $client_id, $params,$event_identifier = '')
     {
 		global $app, $tform, $remoting_lib;
@@ -1987,21 +1978,18 @@ class remoting {
 		
 		$insert_id = $app->db->insertID();
 		
+		// set a few values for compatibility with tform actions, mostly used by plugins
+		$this->id = $insert_id;
+		$this->dataRecord = $params;
+		
 		if($event_identifier != '') $app->plugin->raiseEvent($event_identifier,$this);
 	
 		//$app->uses('tform');
 		//* Save changes to Datalog
 		if($app->remoting_lib->formDef["db_history"] == 'yes') {
 			$new_rec = $app->remoting_lib->getDataRecord($insert_id);
-			$app->remoting_lib->datalogSave('INSERT',$primary_id,array(),$new_rec);
-			
-		}
-		
-		// set a few values for compatibility with tform actions, mostly used by plugins
-		$this->id = $insert_id;
-		$this->dataRecord = $params;
-		
-		
+			$app->remoting_lib->datalogSave('INSERT',$primary_id,array(),$new_rec);			
+		}		
 		return $insert_id;
 	}
 	
@@ -2032,7 +2020,6 @@ class remoting {
 		$this->id = $primary_id;
 		$this->dataRecord = $params;
 		
-		
 		$app->db->query($sql);
 		
 		if($app->db->errorMessage != '') {
@@ -2050,8 +2037,6 @@ class remoting {
 			$app->remoting_lib->datalogSave('UPDATE',$primary_id,$old_rec,$new_rec);
 		}
 		
-		
-		
 		return $affected_rows;
 	}
 	
@@ -2131,5 +2116,4 @@ class remoting {
 		}
 	}
 }
-
-?>
+?>
\ No newline at end of file
-- 
GitLab