From a8afe37a39a9d8ac1c1432ba5dd77fc866f8941b Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Mon, 23 Jan 2012 03:56:59 -0500
Subject: [PATCH] Changed command order in client_add function so that the insertID is executed right after the sql insert query.

---
 interface/lib/classes/remoting.inc.php |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/interface/lib/classes/remoting.inc.php b/interface/lib/classes/remoting.inc.php
index 3330447..de229c9 100644
--- a/interface/lib/classes/remoting.inc.php
+++ b/interface/lib/classes/remoting.inc.php
@@ -2156,20 +2156,29 @@
 		
 		//* Get the SQL query
 		$sql = $app->remoting_lib->getSQL($params,'INSERT',0);
-		$app->db->query($sql);
 		
 		//* Check if no system user with that username exists
 		$username = $app->db->quote($params["username"]);
-		$tmp = $app->db->queryOneRecord("SELECT count(userid) as number FROm sys_user WHERE username = '$username'");
+		$tmp = $app->db->queryOneRecord("SELECT count(userid) as number FROM sys_user WHERE username = '$username'");
 		if($tmp['number'] > 0) $app->remoting_lib->errorMessage .= "Duplicate username<br />";
 		
+		//* Stop on error while preparing the sql query
 		if($app->remoting_lib->errorMessage != '') {
 			$this->server->fault('data_processing_error', $app->remoting_lib->errorMessage);
 			return false;
 		}
 		
+		//* Execute the SQL query
+		$app->db->query($sql);
 		$insert_id = $app->db->insertID();
 		
+		
+		//* Stop on error while executing the sql query
+		if($app->remoting_lib->errorMessage != '') {
+			$this->server->fault('data_processing_error', $app->remoting_lib->errorMessage);
+			return false;
+		}
+		
 		$this->id = $insert_id;
 		$this->dataRecord = $params;
 		

--
Gitblit v1.9.1