From 465f2bbfb524dc21021f71e78e8a2ab31a064d93 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Wed, 09 Apr 2014 12:30:42 -0400
Subject: [PATCH] Merge branch 'stable-3.0.5' of git.ispconfig.org:ispconfig/ispconfig3 into stable-3.0.5

---
 interface/lib/plugins/sites_web_vhost_subdomain_plugin.inc.php |   34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/interface/lib/plugins/sites_web_vhost_subdomain_plugin.inc.php b/interface/lib/plugins/sites_web_vhost_subdomain_plugin.inc.php
index e28c184..c417033 100644
--- a/interface/lib/plugins/sites_web_vhost_subdomain_plugin.inc.php
+++ b/interface/lib/plugins/sites_web_vhost_subdomain_plugin.inc.php
@@ -44,25 +44,27 @@
     */
 	function sites_web_vhost_subdomain_edit($event_name, $page_form) {
 		global $app, $conf;
+		
+		if(isset($page_form->dataRecord["parent_domain_id"]) && $page_form->dataRecord["parent_domain_id"] != $page_form->oldDataRecord["parent_domain_id"]) {
+			// Get configuration for the web system
+			$app->uses("getconf");
+			$web_config = $app->getconf->get_server_config($app->functions->intval($page_form->dataRecord['server_id']), 'web');
 
-		// Get configuration for the web system
-		$app->uses("getconf");
-		$web_config = $app->getconf->get_server_config($app->functions->intval($page_form->dataRecord['server_id']), 'web');
+			$parent_domain = $app->db->queryOneRecord("SELECT * FROM `web_domain` WHERE `domain_id` = '" . $app->functions->intval($page_form->dataRecord['parent_domain_id']) . "'");
 
-		$parent_domain = $app->db->queryOneRecord("SELECT * FROM `web_domain` WHERE `domain_id` = '" . $app->functions->intval($page_form->dataRecord['parent_domain_id']) . "'");
+			// Set the values for document_root, system_user and system_group
+			$system_user = $app->db->quote($parent_domain['system_user']);
+			$system_group = $app->db->quote($parent_domain['system_group']);
+			$document_root = $app->db->quote($parent_domain['document_root']);
+			$php_open_basedir = str_replace("[website_path]/web", $document_root.'/'.$page_form->dataRecord['web_folder'], $web_config["php_open_basedir"]);
+			$php_open_basedir = str_replace("[website_domain]/web", $page_form->dataRecord['domain'].'/'.$page_form->dataRecord['web_folder'], $php_open_basedir);
+			$php_open_basedir = str_replace("[website_path]", $document_root, $php_open_basedir);
+			$php_open_basedir = $app->db->quote(str_replace("[website_domain]", $page_form->dataRecord['domain'], $php_open_basedir));
+			$htaccess_allow_override = $app->db->quote($parent_domain['allow_override']);
 
-		// Set the values for document_root, system_user and system_group
-		$system_user = $app->db->quote($parent_domain['system_user']);
-		$system_group = $app->db->quote($parent_domain['system_group']);
-		$document_root = $app->db->quote($parent_domain['document_root']);
-		$php_open_basedir = str_replace("[website_path]/web", $document_root.'/'.$page_form->dataRecord['web_folder'], $web_config["php_open_basedir"]);
-		$php_open_basedir = str_replace("[website_domain]/web", $page_form->dataRecord['domain'].'/'.$page_form->dataRecord['web_folder'], $php_open_basedir);
-		$php_open_basedir = str_replace("[website_path]", $document_root, $php_open_basedir);
-		$php_open_basedir = $app->db->quote(str_replace("[website_domain]", $page_form->dataRecord['domain'], $php_open_basedir));
-		$htaccess_allow_override = $app->db->quote($parent_domain['allow_override']);
-
-		$sql = "UPDATE web_domain SET sys_groupid = ".$app->functions->intval($parent_domain['sys_groupid']).",system_user = '$system_user', system_group = '$system_group', document_root = '$document_root', allow_override = '$htaccess_allow_override', php_open_basedir = '$php_open_basedir'  WHERE domain_id = ".$page_form->id;
-		$app->db->query($sql);
+			$sql = "UPDATE web_domain SET sys_groupid = ".$app->functions->intval($parent_domain['sys_groupid']).",system_user = '$system_user', system_group = '$system_group', document_root = '$document_root', allow_override = '$htaccess_allow_override', php_open_basedir = '$php_open_basedir'  WHERE domain_id = ".$page_form->id;
+			$app->db->query($sql);
+		}
 	}
 
 }

--
Gitblit v1.9.1