Add a contructor to the dialplan class.
This commit is contained in:
@@ -29,6 +29,7 @@ include "root.php";
|
|||||||
if (!class_exists('dialplan')) {
|
if (!class_exists('dialplan')) {
|
||||||
class dialplan {
|
class dialplan {
|
||||||
//variables
|
//variables
|
||||||
|
public $db;
|
||||||
public $result;
|
public $result;
|
||||||
public $domain_uuid;
|
public $domain_uuid;
|
||||||
public $dialplan_uuid;
|
public $dialplan_uuid;
|
||||||
@@ -56,8 +57,19 @@ include "root.php";
|
|||||||
public $dialplan_detail_inline;
|
public $dialplan_detail_inline;
|
||||||
public $dialplan_detail_group;
|
public $dialplan_detail_group;
|
||||||
|
|
||||||
|
//class constructor
|
||||||
|
public function __construct() {
|
||||||
|
//connect to the database if not connected
|
||||||
|
if (!$this->db) {
|
||||||
|
require_once "resources/classes/database.php";
|
||||||
|
$database = new database;
|
||||||
|
$database->connect();
|
||||||
|
$this->db = $database->db;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function dialplan_add() {
|
public function dialplan_add() {
|
||||||
global $db;
|
|
||||||
$sql = "insert into v_dialplans ";
|
$sql = "insert into v_dialplans ";
|
||||||
$sql .= "(";
|
$sql .= "(";
|
||||||
$sql .= "domain_uuid, ";
|
$sql .= "domain_uuid, ";
|
||||||
@@ -89,12 +101,12 @@ include "root.php";
|
|||||||
$sql .= "'".check_str($this->dialplan_enabled)."', ";
|
$sql .= "'".check_str($this->dialplan_enabled)."', ";
|
||||||
$sql .= "'".check_str($this->dialplan_description)."' ";
|
$sql .= "'".check_str($this->dialplan_description)."' ";
|
||||||
$sql .= ")";
|
$sql .= ")";
|
||||||
$db->exec(check_sql($sql));
|
$this->db->exec(check_sql($sql));
|
||||||
unset($sql);
|
unset($sql);
|
||||||
} //end function
|
} //end function
|
||||||
|
|
||||||
public function dialplan_update() {
|
public function dialplan_update() {
|
||||||
global $db;
|
|
||||||
$sql = "update v_dialplans set ";
|
$sql = "update v_dialplans set ";
|
||||||
$sql .= "dialplan_name = '".check_str($this->dialplan_name)."', ";
|
$sql .= "dialplan_name = '".check_str($this->dialplan_name)."', ";
|
||||||
if (strlen($this->dialplan_continue) > 0) {
|
if (strlen($this->dialplan_continue) > 0) {
|
||||||
@@ -107,12 +119,12 @@ include "root.php";
|
|||||||
$sql .= "where (domain_uuid = '".check_str($this->domain_uuid)."' or domain_uuid is null) ";
|
$sql .= "where (domain_uuid = '".check_str($this->domain_uuid)."' or domain_uuid is null) ";
|
||||||
$sql .= "and dialplan_uuid = '".check_str($this->dialplan_uuid)."' ";
|
$sql .= "and dialplan_uuid = '".check_str($this->dialplan_uuid)."' ";
|
||||||
//echo "sql: ".$sql."<br />";
|
//echo "sql: ".$sql."<br />";
|
||||||
$db->query($sql);
|
$this->db->query($sql);
|
||||||
unset($sql);
|
unset($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dialplan_detail_add() {
|
public function dialplan_detail_add() {
|
||||||
global $db;
|
|
||||||
$dialplan_detail_uuid = uuid();
|
$dialplan_detail_uuid = uuid();
|
||||||
$sql = "insert into v_dialplan_details ";
|
$sql = "insert into v_dialplan_details ";
|
||||||
$sql .= "(";
|
$sql .= "(";
|
||||||
@@ -161,12 +173,12 @@ include "root.php";
|
|||||||
}
|
}
|
||||||
$sql .= ")";
|
$sql .= ")";
|
||||||
//echo $sql."\n\n";
|
//echo $sql."\n\n";
|
||||||
$db->exec(check_sql($sql));
|
$this->db->exec(check_sql($sql));
|
||||||
unset($sql);
|
unset($sql);
|
||||||
} //end function
|
} //end function
|
||||||
|
|
||||||
public function dialplan_detail_update() {
|
public function dialplan_detail_update() {
|
||||||
global $db;
|
|
||||||
$sql = "update v_dialplans set ";
|
$sql = "update v_dialplans set ";
|
||||||
$sql .= "dialplan_detail_order = '".check_str($this->dialplan_detail_order)."', ";
|
$sql .= "dialplan_detail_order = '".check_str($this->dialplan_detail_order)."', ";
|
||||||
$sql .= "dialplan_detail_type = '".check_str($this->dialplan_detail_type)."', ";
|
$sql .= "dialplan_detail_type = '".check_str($this->dialplan_detail_type)."', ";
|
||||||
@@ -184,7 +196,7 @@ include "root.php";
|
|||||||
$sql .= "where (domain_uuid = '".check_str($this->domain_uuid)."' or domain_uuid is null) ";
|
$sql .= "where (domain_uuid = '".check_str($this->domain_uuid)."' or domain_uuid is null) ";
|
||||||
$sql .= "and dialplan_uuid = '".check_str($this->dialplan_uuid)."' ";
|
$sql .= "and dialplan_uuid = '".check_str($this->dialplan_uuid)."' ";
|
||||||
//echo "sql: ".$sql."<br />";
|
//echo "sql: ".$sql."<br />";
|
||||||
$db->query($sql);
|
$this->db->query($sql);
|
||||||
unset($sql);
|
unset($sql);
|
||||||
} //end function
|
} //end function
|
||||||
|
|
||||||
@@ -216,11 +228,10 @@ include "root.php";
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function app_uuid_exists() {
|
private function app_uuid_exists() {
|
||||||
global $db;
|
|
||||||
$sql = "select count(*) as num_rows from v_dialplans ";
|
$sql = "select count(*) as num_rows from v_dialplans ";
|
||||||
$sql .= "where (domain_uuid = '".$this->domain_uuid."' or domain_uuid is null) ";
|
$sql .= "where (domain_uuid = '".$this->domain_uuid."' or domain_uuid is null) ";
|
||||||
$sql .= "and app_uuid = '".$this->app_uuid."' ";
|
$sql .= "and app_uuid = '".$this->app_uuid."' ";
|
||||||
$prep_statement = $db->prepare(check_sql($sql));
|
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||||
if ($prep_statement) {
|
if ($prep_statement) {
|
||||||
$prep_statement->execute();
|
$prep_statement->execute();
|
||||||
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
||||||
@@ -235,11 +246,10 @@ include "root.php";
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function dialplan_exists() {
|
public function dialplan_exists() {
|
||||||
global $db;
|
|
||||||
$sql = "select count(*) as num_rows from v_dialplans ";
|
$sql = "select count(*) as num_rows from v_dialplans ";
|
||||||
$sql .= "where (domain_uuid = '".$this->domain_uuid."' or domain_uuid is null)";
|
$sql .= "where (domain_uuid = '".$this->domain_uuid."' or domain_uuid is null)";
|
||||||
$sql .= "and dialplan_uuid = '".$this->dialplan_uuid."' ";
|
$sql .= "and dialplan_uuid = '".$this->dialplan_uuid."' ";
|
||||||
$prep_statement = $db->prepare(check_sql($sql));
|
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||||
if ($prep_statement) {
|
if ($prep_statement) {
|
||||||
$prep_statement->execute();
|
$prep_statement->execute();
|
||||||
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
||||||
@@ -254,7 +264,6 @@ include "root.php";
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function import() {
|
public function import() {
|
||||||
global $db;
|
|
||||||
if (strlen($this->xml) > 0) {
|
if (strlen($this->xml) > 0) {
|
||||||
//replace the variables
|
//replace the variables
|
||||||
$this->xml = str_replace("{v_context}", $this->default_context, $this->xml);
|
$this->xml = str_replace("{v_context}", $this->default_context, $this->xml);
|
||||||
@@ -287,7 +296,7 @@ include "root.php";
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//start the transaction
|
//start the transaction
|
||||||
$db->beginTransaction();
|
$this->db->beginTransaction();
|
||||||
//get the attributes
|
//get the attributes
|
||||||
$this->dialplan_uuid = uuid();
|
$this->dialplan_uuid = uuid();
|
||||||
$this->dialplan_name = $dialplan['extension']['@attributes']['name'];
|
$this->dialplan_name = $dialplan['extension']['@attributes']['name'];
|
||||||
@@ -381,13 +390,11 @@ include "root.php";
|
|||||||
$x++;
|
$x++;
|
||||||
}
|
}
|
||||||
//end the transaction
|
//end the transaction
|
||||||
$db->commit();
|
$this->db->commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function outbound_routes($destination_number) {
|
public function outbound_routes($destination_number) {
|
||||||
//get the database connection
|
|
||||||
global $db;
|
|
||||||
|
|
||||||
//normalize the destination number
|
//normalize the destination number
|
||||||
$destination_number = trim($destination_number);
|
$destination_number = trim($destination_number);
|
||||||
@@ -415,7 +422,7 @@ include "root.php";
|
|||||||
$sql .= "WHEN 'anti-action' THEN 3 ";
|
$sql .= "WHEN 'anti-action' THEN 3 ";
|
||||||
$sql .= "ELSE 100 END, ";
|
$sql .= "ELSE 100 END, ";
|
||||||
$sql .= "s.dialplan_detail_order asc ";
|
$sql .= "s.dialplan_detail_order asc ";
|
||||||
$prep_statement = $db->prepare(check_sql($sql));
|
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||||
$prep_statement->execute();
|
$prep_statement->execute();
|
||||||
$dialplans = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
$dialplans = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$x = 0; $y = 0;
|
$x = 0; $y = 0;
|
||||||
|
|||||||
@@ -201,9 +201,6 @@
|
|||||||
|
|
||||||
public function upgrade() {
|
public function upgrade() {
|
||||||
|
|
||||||
//set the global variable
|
|
||||||
global $db;
|
|
||||||
|
|
||||||
//get the db variables
|
//get the db variables
|
||||||
$config = new config;
|
$config = new config;
|
||||||
$config_exists = $config->exists();
|
$config_exists = $config->exists();
|
||||||
@@ -225,6 +222,7 @@
|
|||||||
$config_list_2 = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/*/*/app_menu.php");
|
$config_list_2 = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/*/*/app_menu.php");
|
||||||
$config_list = array_merge((array)$config_list_1, (array)$config_list_2);
|
$config_list = array_merge((array)$config_list_1, (array)$config_list_2);
|
||||||
unset($config_list_1,$config_list_2);
|
unset($config_list_1,$config_list_2);
|
||||||
|
$db = $this->db;
|
||||||
$x=0;
|
$x=0;
|
||||||
foreach ($config_list as &$config_path) {
|
foreach ($config_list as &$config_path) {
|
||||||
include($config_path);
|
include($config_path);
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ include "root.php";
|
|||||||
|
|
||||||
//define the schema class
|
//define the schema class
|
||||||
class schema {
|
class schema {
|
||||||
|
|
||||||
//define variables
|
//define variables
|
||||||
public $db;
|
public $db;
|
||||||
public $apps;
|
public $apps;
|
||||||
|
|||||||
Reference in New Issue
Block a user