From 5fa5c0b33700c0a8227f33bde50b664d93d4cc00 Mon Sep 17 00:00:00 2001
From: jmontoya <jmontoya@ispconfig3>
Date: Tue, 03 Aug 2010 10:31:10 -0400
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 |   48 +++++++++++++++++-------------------------------
 1 files changed, 17 insertions(+), 31 deletions(-)

diff --git a/interface/lib/classes/remoting.inc.php b/interface/lib/classes/remoting.inc.php
index 6ae0d16..4716437 100644
--- a/interface/lib/classes/remoting.inc.php
+++ b/interface/lib/classes/remoting.inc.php
@@ -263,8 +263,8 @@
 			$this->server->fault('permission_denied','You do not have the permissions to access this function.');
 			return false;
 		}
-		$affected_rows = $this->insertQuery('../mail/form/mail_user_filter.tform.php', $client_id, $params);
-		$app->plugin->raiseEvent('mail:mail_user_filter:on_after_insert',$this);
+		$affected_rows = $this->insertQuery('../mail/form/mail_user_filter.tform.php', $client_id, $params,'mail:mail_user_filter:on_after_insert');
+		// $app->plugin->raiseEvent('mail:mail_user_filter:on_after_insert',$this);
 		return $affected_rows;
 	}
 
@@ -276,8 +276,8 @@
 			$this->server->fault('permission_denied','You do not have the permissions to access this function.');
 			return false;
 		}
-		$affected_rows = $this->updateQuery('../mail/form/mail_user_filter.tform.php', $client_id, $primary_id, $params);
-		$app->plugin->raiseEvent('mail:mail_user_filter:on_after_update',$this);
+		$affected_rows = $this->updateQuery('../mail/form/mail_user_filter.tform.php', $client_id, $primary_id, $params,'mail:mail_user_filter:on_after_update');
+		// $app->plugin->raiseEvent('mail:mail_user_filter:on_after_update',$this);
 		return $affected_rows;
 	}
 
@@ -1944,22 +1944,13 @@
 		//* 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)
+	private function insertQuery($formdef_file, $client_id, $params,$event_identifier = '')
     {
 		global $app, $tform, $remoting_lib;
 		
@@ -1987,26 +1978,23 @@
 		
 		$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;
 	}
 	
 	
-	private function updateQuery($formdef_file, $client_id, $primary_id, $params)
+	private function updateQuery($formdef_file, $client_id, $primary_id, $params, $event_identifier = '')
     {
 		global $app;
 		
@@ -2032,7 +2020,6 @@
 		$this->id = $primary_id;
 		$this->dataRecord = $params;
 		
-		
 		$app->db->query($sql);
 		
 		if($app->db->errorMessage != '') {
@@ -2042,13 +2029,13 @@
 		
 		$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') {
 			$new_rec = $app->remoting_lib->getDataRecord($primary_id);
 			$app->remoting_lib->datalogSave('UPDATE',$primary_id,$old_rec,$new_rec);
 		}
-		
-		
 		
 		return $affected_rows;
 	}
@@ -2129,5 +2116,4 @@
 		}
 	}
 }
-
-?>
+?>
\ No newline at end of file

--
Gitblit v1.9.1