From c5d17d3fd1bbdca95dd9230a2ab54f5aef04aef8 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Fri, 22 Jul 2011 09:48:47 -0400
Subject: [PATCH] Bugfixes in server list in vm server forms.

---
 interface/lib/plugins/vm_openvz_plugin.inc.php |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/interface/lib/plugins/vm_openvz_plugin.inc.php b/interface/lib/plugins/vm_openvz_plugin.inc.php
index 1112e08..a926c0a 100644
--- a/interface/lib/plugins/vm_openvz_plugin.inc.php
+++ b/interface/lib/plugins/vm_openvz_plugin.inc.php
@@ -23,6 +23,7 @@
 		//* Register for events        
         $app->plugin->registerEvent('vm:openvz_vm:on_after_insert','vm_openvz_plugin','openvz_vm_insert');
 		$app->plugin->registerEvent('vm:openvz_vm:on_after_update','vm_openvz_plugin','openvz_vm_update');
+		$app->plugin->registerEvent('vm:openvz_vm:on_after_delete','vm_openvz_plugin','openvz_vm_delete');
     }
 
     /*
@@ -105,6 +106,16 @@
         
 	}
 	
+	function openvz_vm_delete($event_name, $page_form) {
+        global $app, $conf;
+		
+		//* Free the IP address
+		$tmp = $app->db->queryOneRecord("SELECT ip_address_id FROM openvz_ip WHERE vm_id = ".$page_form->id);
+		$app->db->datalogUpdate('openvz_ip', 'vm_id = 0', 'ip_address_id', $tmp['ip_address_id']);
+		unset($tmp);
+		
+	}
+	
 	private function applyTemplate() {
 		global $app, $conf;
 		

--
Gitblit v1.9.1