Browse Source

fixes during upgrade

Matthew Vale 9 years ago
parent
commit
e54b473c7b

+ 27 - 21
core/install/resources/classes/global_settings.php

@@ -78,7 +78,7 @@ require_once "root.php";
 		protected $_switch_sip_profiles_vdir = '';
 		protected $_switch_dialplan_vdir = '';
 		protected $_switch_backup_vdir = '';
-		public function switch_voicemail_vdir()	{ return $this->_switch_voicemail_vdir; }
+		public function switch_voicemail_vdir()		{ return $this->_switch_voicemail_vdir; }
 		public function switch_phrases_vdir()		{ return $this->_switch_phrases_vdir; }
 		public function switch_extensions_vdir()	{ return $this->_switch_extensions_vdir; }
 		public function switch_sip_profiles_vdir()	{ return $this->_switch_sip_profiles_vdir; }
@@ -104,24 +104,24 @@ require_once "root.php";
 		protected $_db_create;
 		protected $_db_create_username;
 		protected $_db_create_password;
-		public function db_type()	 			{return $this->_db_type; }
-		public function db_path()	 			{return $this->_db_path; }
-		public function db_host()	 			{return $this->_db_host; }
-		public function db_port()	 			{return $this->_db_port; }
-		public function db_name()	 			{return $this->_db_name; }
-		public function db_username()	 		{return $this->_db_username; }
-		public function db_password()	 		{return $this->_db_password; }
-		public function db_create()	 			{return $this->_db_create; }
-		public function db_create_username()	{return $this->_db_create_username; }
-		public function db_create_password()	{return $this->_db_create_password; }
+		public function db_type()	 			{ return $this->_db_type; }
+		public function db_path()	 			{ return $this->_db_path; }
+		public function db_host()	 			{ return $this->_db_host; }
+		public function db_port()	 			{ return $this->_db_port; }
+		public function db_name()	 			{ return $this->_db_name; }
+		public function db_username()	 		{ return $this->_db_username; }
+		public function db_password()	 		{ return $this->_db_password; }
+		public function db_create()	 			{ return $this->_db_create; }
+		public function db_create_username()	{ return $this->_db_create_username; }
+		public function db_create_password()	{ return $this->_db_create_password; }
 
 		//misc information
 		protected $_domain_uuid;
 		protected $_domain_name;
 		protected $_domain_count;
-		public function domain_uuid()	 		{return $this->_domain_uuid; }
-		public function domain_name()	 		{return $this->_domain_name; }
-		public function domain_count()	 		{return $this->_domain_count; }
+		public function domain_uuid()	 		{ return $this->_domain_uuid; }
+		public function domain_name()	 		{ return $this->_domain_name; }
+		public function domain_count()	 		{ return $this->_domain_count; }
 		public function set_domain_uuid($domain_uuid) {
 			$e = new Exception();
 			$trace = $e->getTrace();
@@ -143,17 +143,20 @@ require_once "root.php";
 				}
 				foreach ($this->_switch_dirs as $dir){
 					$session_var;
-					preg_match( '/^switch_.*_dir$/', $dir, $session_var);
-					$this->$dir = $_SESSION['switch'][$session_var[0]]['dir'];
+					preg_match( '/^switch_(.*)_dir$/', $dir, $session_var);
+					$dir = "_$dir";
+					if($session_var[1] == 'script'){ $session_var[1] = 'scripts'; }
+					$this->$dir = $_SESSION['switch'][$session_var[1]]['dir'];
 				}
 				foreach ($this->_switch_vdirs as $vdir){
 					$session_var;
-					preg_match( '/^switch_.*_vdir$/', $vdir, $session_var);
-					$this->$vdir = $_SESSION['switch'][$session_var[0]]['dir'];
+					preg_match( '/^switch_(.*)_vdir$/', $vdir, $session_var);
+					$vdir = "_$vdir";
+					$this->$vdir = $_SESSION['switch'][$session_var[1]]['dir'];
 				}
-				$this->switch_event_host		= $_SESSION['event_socket_ip_address'];
-				$this->switch_event_port		= $_SESSION['event_socket_port'];
-				$this->switch_event_password	= $_SESSION['event_socket_password'];
+				$this->_switch_event_host		= $_SESSION['event_socket_ip_address'];
+				$this->_switch_event_port		= $_SESSION['event_socket_port'];
+				$this->_switch_event_password	= $_SESSION['event_socket_password'];
 				
 				// domain info
 				$this->_domain_name = $_SESSION['domain_name'];
@@ -185,6 +188,9 @@ require_once "root.php";
 					$t_vdir = "_switch_$vdir";
 					$this->$t_vdir = $detect_switch->$vdir();
 				}
+				$this->_switch_event_host		= $detect_switch->event_host;
+				$this->_switch_event_port		= $detect_switch->event_port;
+				$this->_switch_event_password	= $detect_switch->event_password;
 
 				//copy from _POST
 				foreach($_POST as $key=>$value){

+ 11 - 12
core/install/resources/classes/install_switch.php

@@ -36,7 +36,7 @@ include "root.php";
 
 		function __construct($global_settings) {
 			if(is_null($global_settings)){
-				require_once "resources/classes/global_settings.php";
+				require_once "core/install/resources/classes/global_settings.php";
 				$global_settings = new global_settings();
 			}elseif(!is_a($global_settings, 'global_settings')){
 				throw new Exception('The parameter $global_settings must be a global_settings object (or a subclass of)');
@@ -411,17 +411,16 @@ include "root.php";
 			unset($tmp);
 			fclose($fout);	
 		}
-	}
-	
-	protected function restart_switch() {
-		global $errstr;
-		$esl = new EventSocket;
-		if (!$esl->connect($this->event_host, $this->event_port, $this->event_password)) {
-			throw new Exception("Failed to connect to switch: $errstr");
-		}
-		if (!$esl->request('api fsctl shutdown restart elegant')){
-			throw new Exception("Failed to send switch restart: $errstr");
+
+		protected function restart_switch() {
+			$esl = new EventSocket;
+			if(!$esl->connect($this->global_settings->switch_event_host(), $this->global_settings->switch_event_port(), $this->global_settings->switch_event_password())) {
+				throw new Exception("Failed to connect to switch");
+			}
+			if (!$esl->request('api fsctl shutdown restart elegant')){
+				throw new Exception("Failed to send switch restart");
+			}
+			$esl->reset_fp();
 		}
-		$esl->reset_fp();
 	}
 ?>