From 9c930e0ba5b3ad3535a3435c2d19b26b2871d615 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Wed, 29 Jun 2011 14:32:15 +0000
Subject: [PATCH] VM module: IP was not freed when VM is deleted. VM module:
 Error in SQL query to select a template.

---
 interface/web/vm/openvz_vm_del.php             | 8 ++++++++
 interface/web/vm/openvz_vm_edit.php            | 8 --------
 server/plugins-available/openvz_plugin.inc.php | 2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/interface/web/vm/openvz_vm_del.php b/interface/web/vm/openvz_vm_del.php
index c8d8e196af..8d288444b6 100644
--- a/interface/web/vm/openvz_vm_del.php
+++ b/interface/web/vm/openvz_vm_del.php
@@ -49,6 +49,14 @@ $app->uses('tpl,tform');
 $app->load('tform_actions');
 
 class page_action extends tform_actions {
+
+	function onAfterDelete() {
+		global $app, $conf;
+		
+		//* Release all IP addresses which are assigned to this VM
+		$app->db->query("UPDATE openvz_ip SET vm_id = 0 WHERE vm_id = '".$this->id."'");
+		
+	}
 	
 }
 
diff --git a/interface/web/vm/openvz_vm_edit.php b/interface/web/vm/openvz_vm_edit.php
index 451bc01eec..bc0324907b 100644
--- a/interface/web/vm/openvz_vm_edit.php
+++ b/interface/web/vm/openvz_vm_edit.php
@@ -183,14 +183,6 @@ class page_action extends tform_actions {
 		
 	}
 	
-	function onAfterDelete() {
-		global $app, $conf;
-		
-		//* Release all IP addresses which are assigned to this VM
-		$app->db->query("UPDATE openvz_ip SET vm_id = 0 WHERE vm_id = '".$this->id."'");
-		
-	}
-	
 	function applyTemplate() {
 		global $app, $conf;
 		
diff --git a/server/plugins-available/openvz_plugin.inc.php b/server/plugins-available/openvz_plugin.inc.php
index a9c630e5a5..a0907ff865 100644
--- a/server/plugins-available/openvz_plugin.inc.php
+++ b/server/plugins-available/openvz_plugin.inc.php
@@ -77,7 +77,7 @@ class openvz_plugin {
 			return;
 		}
 		
-		$tmp = $app->db->queryOneRecord("SELECT template_file FROM openvz_ostemplate WHERE ostemplate_id = ".$vm['ostemplate_id']);
+		$tmp = $app->db->queryOneRecord("SELECT template_file FROM openvz_ostemplate WHERE ostemplate_id = ".$data['new']['ostemplate_id']);
 		$ostemplate = escapeshellcmd($tmp['template_file']);
 		unset($tmp);
 		
-- 
GitLab