From 355efb9a7f74a2035f595bbd0d03375710d08587 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Wed, 25 Jan 2012 09:43:56 -0500
Subject: [PATCH] Merged revisions 2886-2909 from stable branch.

---
 interface/lib/classes/remoting.inc.php |   30 ++++++++++++++++++++----------
 1 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/interface/lib/classes/remoting.inc.php b/interface/lib/classes/remoting.inc.php
index cfdc227..9f88cfc 100644
--- a/interface/lib/classes/remoting.inc.php
+++ b/interface/lib/classes/remoting.inc.php
@@ -348,8 +348,8 @@
 			$this->server->fault('permission_denied','You do not have the permissions to access this function.');
 			return false;
 		}
-		$affected_rows = $this->deleteQuery('../mail/form/mail_user_filter.tform.php', $primary_id);
-		$app->plugin->raiseEvent('mail:mail_user_filter:on_after_delete',$this);
+		$affected_rows = $this->deleteQuery('../mail/form/mail_user_filter.tform.php', $primary_id,'mail:mail_user_filter:on_after_delete');
+		// $app->plugin->raiseEvent('mail:mail_user_filter:on_after_delete',$this);
 		return $affected_rows;
 	}
 
@@ -2180,19 +2180,28 @@
 		
 		//* 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;
@@ -2332,22 +2341,23 @@
 		// set a few values for compatibility with tform actions, mostly used by plugins
 		$this->oldDataRecord = $old_rec;
 		$this->id = $primary_id;
-		$this->dataRecord = $params;
+		$this->dataRecord = $old_rec;
+		//$this->dataRecord = $params;
 		
 		//* Get the SQL query
 		$sql = $app->remoting_lib->getDeleteSQL($primary_id);
-		
+		$app->db->errorMessage = '';
 		$app->db->query($sql);
+		$affected_rows = $app->db->affectedRows();
 		
 		if($app->db->errorMessage != '') {
-			
-			if($event_identifier != '') $app->plugin->raiseEvent($event_identifier,$this);
-			
 			$this->server->fault('database_error', $app->db->errorMessage . ' '.$sql);
 			return false;
 		}
 		
-		$affected_rows = $app->db->affectedRows();
+		if($event_identifier != '') {
+			$app->plugin->raiseEvent($event_identifier,$this);
+		}
 		
 		//* Save changes to Datalog
 		if($app->remoting_lib->formDef["db_history"] == 'yes') {

--
Gitblit v1.9.1