From 5720a59824953dd0fde12e850ce9bd769a3ab3d8 Mon Sep 17 00:00:00 2001
From: ftimme <ft@falkotimme.com>
Date: Wed, 13 Feb 2013 11:39:06 -0500
Subject: [PATCH] - Fixed FS#2639 - App Installer: Apps not deleted from ISPConfig if website is deleted. -Fixed FS#2672 - Rename website - APS instance domain must be renamed as well.

---
 interface/web/sites/web_domain_edit.php |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/interface/web/sites/web_domain_edit.php b/interface/web/sites/web_domain_edit.php
index c714fa3..20cdb7e 100644
--- a/interface/web/sites/web_domain_edit.php
+++ b/interface/web/sites/web_domain_edit.php
@@ -832,7 +832,7 @@
 
 		}
 
-		//* If the domain name has been changed, we will have to change all subdomains
+		//* If the domain name has been changed, we will have to change all subdomains + APS instances
 		if(!empty($this->dataRecord["domain"]) && !empty($this->oldDataRecord["domain"]) && $this->dataRecord["domain"] != $this->oldDataRecord["domain"]) {
 			$records = $app->db->queryAllRecords("SELECT domain_id,domain FROM web_domain WHERE (type = 'subdomain' OR type = 'vhostsubdomain') AND domain LIKE '%.".$app->db->quote($this->oldDataRecord["domain"])."'");
 			foreach($records as $rec) {
@@ -842,6 +842,17 @@
 			unset($records);
 			unset($rec);
 			unset($subdomain);
+			
+			// Update APS instances
+			$records = $app->db->queryAllRecords("SELECT id, instance_id FROM aps_instances_settings WHERE name = 'main_domain' AND value = '".$this->oldDataRecord["domain"]."'");
+			if(is_array($records) && !empty($records)){
+				foreach($records as $rec){
+					$app->db->datalogUpdate('aps_instances_settings', "value = '".$this->dataRecord["domain"]."'", 'id', $rec['id']);
+					$app->db->datalogUpdate('aps_instances', "instance_status = '1'", 'id', $rec['instance_id']);
+				}
+			}
+			unset($records);
+			unset($rec);
 		}
 
 		//* Set allow_override if empty

--
Gitblit v1.9.1