瀏覽代碼

Update schema dn domains

Mark Crane 11 年之前
父節點
當前提交
a8c2e72c49
共有 4 個文件被更改,包括 27 次插入154 次删除
  1. 4 141
      core/upgrade/upgrade_domains.php
  2. 3 4
      core/upgrade/upgrade_schema.php
  3. 12 8
      resources/classes/schema.php
  4. 8 1
      resources/install.php

+ 4 - 141
core/upgrade/upgrade_domains.php

@@ -50,146 +50,9 @@
 		}
 	}
 
-//get the list of installed apps from the core and mod directories
-	$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
-	$x=0;
-	foreach ($config_list as &$config_path) {
-		include($config_path);
-		$x++;
-	}
-
-//get the domain_uuid
-	$sql = "select * from v_domains ";
-	$prep_statement = $db->prepare($sql);
-	$prep_statement->execute();
-	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
-	foreach($result as $row) {
-		if (count($result) == 1) {
-			$_SESSION["domain_uuid"] = $row["domain_uuid"];
-			$_SESSION["domain_name"] = $row['domain_name'];
-		}
-		else {
-			if ($row['domain_name'] == $domain_array[0] || $row['domain_name'] == 'www.'.$domain_array[0]) {
-				$_SESSION["domain_uuid"] = $row["domain_uuid"];
-				$_SESSION["domain_name"] = $row['domain_name'];
-			}
-			$_SESSION['domains'][$row['domain_uuid']]['domain_uuid'] = $row['domain_uuid'];
-			$_SESSION['domains'][$row['domain_uuid']]['domain_name'] = $row['domain_name'];
-		}
-	}
-	unset($result, $prep_statement);
-
-//get the default settings
-	$sql = "select * from v_default_settings ";
-	$sql .= "where default_setting_enabled = 'true' ";
-	$prep_statement = $db->prepare($sql);
-	$prep_statement->execute();
-	$result_default_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED);
-
-//get the default recordings directory
-	foreach($result_default_settings as $row) {
-		$name = $row['default_setting_name'];
-		$category = $row['default_setting_category'];
-		$subcategory = $row['default_setting_subcategory'];
-		if ($category == 'switch' && $subcategory == 'recordings' && $name == 'dir') {
-			$switch_recordings_dir = $row['default_setting_value'];
-		}
-	}
-
-//loop through all domains
-	$sql = "select * from v_domains ";
-	$v_prep_statement = $db->prepare(check_sql($sql));
-	$v_prep_statement->execute();
-	$main_result = $v_prep_statement->fetchAll(PDO::FETCH_ASSOC);
-	$domain_count = count($main_result);
-	$domains_processed = 1;
-	foreach ($main_result as &$row) {
-		//get the values from database and set them as php variables
-			$domain_uuid = $row["domain_uuid"];
-			$domain_name = $row["domain_name"];
-
-		//get the context
-			if ($domain_count == 1) {
-				$context = "default";
-			}
-			else {
-				$context = $domain_name;
-			}
-
-		//show the domain when display_type is set to text
-			if ($display_type == "text") {
-				echo "\n";
-				echo $domain_name;
-				echo "\n";
-			}
-
-		//get the default settings - this needs to be done to reset the session values back to the defaults for each domain in the loop
-			foreach($result_defaults_settings as $row) {
-				$name = $row['default_setting_name'];
-				$category = $row['default_setting_category'];
-				$subcategory = $row['default_setting_subcategory'];
-				if (strlen($subcategory) == 0) {
-					if ($name == "array") {
-						$_SESSION[$category][] = $row['default_setting_value'];
-					}
-					else {
-						$_SESSION[$category][$name] = $row['default_setting_value'];
-					}
-				} else {
-					if ($name == "array") {
-						$_SESSION[$category][$subcategory][] = $row['default_setting_value'];
-					}
-					else {
-						$_SESSION[$category][$subcategory]['uuid'] = $row['default_setting_uuid'];
-						$_SESSION[$category][$subcategory][$name] = $row['default_setting_value'];
-					}
-				}
-			}
-
-		//get the domains settings
-			$sql = "select * from v_domain_settings ";
-			$sql .= "where domain_uuid = '".$domain_uuid."' ";
-			$sql .= "and domain_setting_enabled = 'true' ";
-			$prep_statement = $db->prepare($sql);
-			$prep_statement->execute();
-			$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
-			foreach($result as $row) {
-				$name = $row['domain_setting_name'];
-				$category = $row['domain_setting_category'];
-				$subcategory = $row['domain_setting_subcategory'];
-				if (strlen($subcategory) == 0) {
-					//$$category[$name] = $row['domain_setting_value'];
-					$_SESSION[$category][$name] = $row['domain_setting_value'];
-				}
-				else {
-					//$$category[$subcategory][$name] = $row['domain_setting_value'];
-					$_SESSION[$category][$subcategory][$name] = $row['domain_setting_value'];
-				}
-			}
-
-		//set the recordings directory
-			if (strlen($switch_recordings_dir) > 1 && count($_SESSION["domains"]) > 1) {
-				$_SESSION['switch']['recordings']['dir'] = $switch_recordings_dir."/".$domain_name;
-			}
-
-		//get the list of installed apps from the core and mod directories and execute the php code in app_defaults.php
-			$default_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_defaults.php");
-			foreach ($default_list as &$default_path) {
-				include($default_path);
-			}
-
-		//track of the number of domains processed
-			$domains_processed++;
-	}
-	unset ($v_prep_statement);
-
-//synchronize the dialplan
-	if (function_exists('save_dialplan_xml')) {
-		save_dialplan_xml();
-	}
-
-//clear the session variables
-	unset($_SESSION['domain']);
-	unset($_SESSION['switch']);
+//run all app_defaults.php files
+	require_once "resources/classes/domains.php";
+	$domain = new domains;
+	$domain->upgrade();
 
 ?>

+ 3 - 4
core/upgrade/upgrade_schema.php

@@ -69,16 +69,15 @@
 		$response_format = 'html'; //html, text
 	}
 
-
 //set the default
 	if (!isset($response_output)) {
 		$response_output = "echo";
 	}
 
-
 //load the default database into memory and compare it with the active database
-	require_once "resources/schema.php";
-	$response_upgrade_schema = db_upgrade_schema($db, $db_type, $db_name, $response_output);
+	require_once "resources/classes/schema.php";
+	$obj = new schema;
+	$obj->schema($db, $db_type, $db_name, $response_output);
 	unset($apps);
 
 

+ 12 - 8
resources/classes/schema.php

@@ -446,10 +446,14 @@ include "root.php";
 
 		//datatase schema
 			public function schema ($db, $db_type, $db_name, $response_output) {
-				global $db;
-				global $text; // pulls in language variable array
-				global $response_format;
-				global $upgrade_data_types;
+				//set the global variables
+					global $db;
+					global $text; // pulls in language variable array
+					global $response_format;
+					global $upgrade_data_types;
+				
+				//get the PROJECT PATH
+					include "root.php";
 
 				//PHP PDO check if table or column exists
 					//check if table exists
@@ -850,8 +854,8 @@ include "root.php";
 
 //example use
 	//require_once "resources/classes/schema.php";
-	//$schema = new schema;
-	//$schema->db_type = $db_type;
-	//$schema->sql();
-	//$result_array = $schema->result['sql'];
+	//$obj = new schema;
+	//$obj->db_type = $db_type;
+	//$obj->schema();
+	//$result_array = $schema->obj['sql'];
 	//print_r($result_array);

+ 8 - 1
resources/install.php

@@ -1355,7 +1355,14 @@ if ($_POST["install_step"] == "3" && count($_POST) > 0 && strlen($_POST["persist
 	//make sure the database schema and installation have performed all necessary tasks
 		$display_results = false;
 		$display_type = 'none';
-		require_once "core/upgrade/upgrade_schema.php";
+		require_once "resources/classes/schema.php";
+		$obj = new schema;
+		$obj->schema($db, $db_type, $db_name, $display_type);
+
+	//run all app_defaults.php files
+		require_once "resources/classes/domains.php";
+		$domain = new domains;
+		$domain->upgrade();
 
 	//synchronize the config with the saved settings
 		save_switch_xml();