From a66fd7d0856fa9006d18ed1ea2bd818a5bbc4764 Mon Sep 17 00:00:00 2001
From: Till Brehm <tbrehm@ispconfig.org>
Date: Fri, 30 May 2014 07:56:44 -0400
Subject: [PATCH] Improved API behaviour: The $params array must contain only the new values and not all values of a record on update. Setting all values does not hurt though, so the change is downwards compatible with older versions.

---
 interface/lib/classes/remote.d/client.inc.php |    3 +++
 interface/lib/classes/remoting.inc.php        |    4 ++++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/interface/lib/classes/remote.d/client.inc.php b/interface/lib/classes/remote.d/client.inc.php
index 5cafc62..445312b 100644
--- a/interface/lib/classes/remote.d/client.inc.php
+++ b/interface/lib/classes/remote.d/client.inc.php
@@ -182,6 +182,9 @@
 		$app->uses('remoting_lib');
 		$app->remoting_lib->loadFormDef('../client/form/' . (isset($params['limit_client']) && $params['limit_client'] > 0 ? 'reseller' : 'client') . '.tform.php');
 		$old_rec = $app->remoting_lib->getDataRecord($client_id);
+		
+		//* merge old record with params, so only new values have to be set in $params
+		$params = $app->functions->array_merge($old_rec,$params);
 
 		// we need the previuos templates assigned here
 		$this->oldTemplatesAssigned = $app->db->queryAllRecords('SELECT * FROM `client_template_assigned` WHERE `client_id` = ' . $client_id);
diff --git a/interface/lib/classes/remoting.inc.php b/interface/lib/classes/remoting.inc.php
index 5541fcb..f42d22b 100644
--- a/interface/lib/classes/remoting.inc.php
+++ b/interface/lib/classes/remoting.inc.php
@@ -340,6 +340,10 @@
 
 		//* Load the form definition
 		$app->remoting_lib->loadFormDef($formdef_file);
+		
+		//* get old record and merge with params, so only new values have to be set in $params
+		$old_rec = $app->remoting_lib->getDataRecord($primary_id);
+		$params = $app->functions->array_merge($old_rec,$params);
 
 		//* Get the SQL query
 		$sql = $app->remoting_lib->getSQL($params, 'UPDATE', $primary_id);

--
Gitblit v1.9.1