Make sure the IVR Menu dialplan entry is created if it doesn't exist.
This commit is contained in:
@@ -199,8 +199,6 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
|||||||
|
|
||||||
//add the data
|
//add the data
|
||||||
if ($action == "add" && permission_exists('ivr_menu_add')) {
|
if ($action == "add" && permission_exists('ivr_menu_add')) {
|
||||||
$ivr->ivr_menu_uuid = uuid();
|
|
||||||
$ivr->dialplan_uuid = uuid();
|
|
||||||
$ivr->add();
|
$ivr->add();
|
||||||
|
|
||||||
//synchronize the xml config
|
//synchronize the xml config
|
||||||
|
|||||||
@@ -221,6 +221,25 @@ include "root.php";
|
|||||||
unset($prep_statement, $result);
|
unset($prep_statement, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function dialplan_exists() {
|
||||||
|
global $db;
|
||||||
|
$sql = "select count(*) as num_rows from v_dialplans ";
|
||||||
|
$sql .= "where domain_uuid = '".$this->domain_uuid."' ";
|
||||||
|
$sql .= "and dialplan_uuid = '".$this->dialplan_uuid."' ";
|
||||||
|
$prep_statement = $db->prepare(check_sql($sql));
|
||||||
|
if ($prep_statement) {
|
||||||
|
$prep_statement->execute();
|
||||||
|
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
||||||
|
if ($row['num_rows'] > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($prep_statement, $result);
|
||||||
|
}
|
||||||
|
|
||||||
public function import() {
|
public function import() {
|
||||||
if (strlen($this->xml) > 0) {
|
if (strlen($this->xml) > 0) {
|
||||||
//replace the variables
|
//replace the variables
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
*/
|
*/
|
||||||
include "root.php";
|
include "root.php";
|
||||||
|
require_once "includes/classes/switch_dialplan.php";
|
||||||
|
|
||||||
//define the directory class
|
//define the directory class
|
||||||
class switch_ivr_menu {
|
class switch_ivr_menu {
|
||||||
@@ -159,8 +160,11 @@ include "root.php";
|
|||||||
|
|
||||||
//add the ivr menu
|
//add the ivr menu
|
||||||
if (strlen($this->ivr_menu_option_action) == 0) {
|
if (strlen($this->ivr_menu_option_action) == 0) {
|
||||||
|
|
||||||
if (strlen($this->ivr_menu_extension) > 0) {
|
if (strlen($this->ivr_menu_extension) > 0) {
|
||||||
|
//ensure the dialplan_uuid has a uuid
|
||||||
|
if (strlen($this->dialplan_uuid) == 0) {
|
||||||
|
$this->dialplan_uuid = uuid();
|
||||||
|
}
|
||||||
//add the dialplan
|
//add the dialplan
|
||||||
$database = new database;
|
$database = new database;
|
||||||
if ($this->db) {
|
if ($this->db) {
|
||||||
@@ -248,7 +252,7 @@ include "root.php";
|
|||||||
}
|
}
|
||||||
|
|
||||||
//add the ivr menu
|
//add the ivr menu
|
||||||
$ivr_menu_uuid = uuid();
|
$this->ivr_menu_uuid = uuid();
|
||||||
$database = new database;
|
$database = new database;
|
||||||
if ($this->db) {
|
if ($this->db) {
|
||||||
$database->db = $this->db;
|
$database->db = $this->db;
|
||||||
@@ -288,7 +292,6 @@ include "root.php";
|
|||||||
|
|
||||||
//add the ivr menu option
|
//add the ivr menu option
|
||||||
if (strlen($this->ivr_menu_option_action) > 0) {
|
if (strlen($this->ivr_menu_option_action) > 0) {
|
||||||
$ivr_menu_uuid = uuid();
|
|
||||||
$database = new database;
|
$database = new database;
|
||||||
if ($this->db) {
|
if ($this->db) {
|
||||||
$database->db = $this->db;
|
$database->db = $this->db;
|
||||||
@@ -357,7 +360,9 @@ include "root.php";
|
|||||||
}
|
}
|
||||||
|
|
||||||
//update the ivr menu
|
//update the ivr menu
|
||||||
$ivr_menu_uuid = uuid();
|
if (strlen($this->dialplan_uuid) == 0) {
|
||||||
|
$this->dialplan_uuid = uuid();
|
||||||
|
}
|
||||||
$database = new database;
|
$database = new database;
|
||||||
$database->table = "v_ivr_menus";
|
$database->table = "v_ivr_menus";
|
||||||
$database->fields['ivr_menu_uuid'] = $this->ivr_menu_uuid;
|
$database->fields['ivr_menu_uuid'] = $this->ivr_menu_uuid;
|
||||||
@@ -394,8 +399,14 @@ include "root.php";
|
|||||||
$database->where[1]['operator'] = '=';
|
$database->where[1]['operator'] = '=';
|
||||||
$database->update();
|
$database->update();
|
||||||
|
|
||||||
if (strlen($this->ivr_menu_extension) > 0) {
|
//check to see if the dialplan entry exists
|
||||||
//update the dialplan
|
$dialplan = new dialplan;
|
||||||
|
$dialplan->domain_uuid = $_SESSION["domain_uuid"];
|
||||||
|
$dialplan->dialplan_uuid = $this->dialplan_uuid;
|
||||||
|
$dialplan_exists = $dialplan->dialplan_exists();
|
||||||
|
|
||||||
|
//if the dialplan entry does not exist then add it
|
||||||
|
if (!$dialplan_exists) {
|
||||||
$database = new database;
|
$database = new database;
|
||||||
$database->table = "v_dialplans";
|
$database->table = "v_dialplans";
|
||||||
$database->fields['dialplan_name'] = $this->ivr_menu_name;
|
$database->fields['dialplan_name'] = $this->ivr_menu_name;
|
||||||
@@ -406,25 +417,40 @@ include "root.php";
|
|||||||
$database->fields['app_uuid'] = $this->app_uuid;
|
$database->fields['app_uuid'] = $this->app_uuid;
|
||||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||||
$database->where[0]['name'] = 'domain_uuid';
|
|
||||||
$database->where[0]['value'] = $this->domain_uuid;
|
|
||||||
$database->where[0]['operator'] = '=';
|
|
||||||
$database->where[1]['name'] = 'dialplan_uuid';
|
|
||||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
|
||||||
$database->where[1]['operator'] = '=';
|
|
||||||
$database->delete();
|
|
||||||
$database->add();
|
$database->add();
|
||||||
|
}
|
||||||
|
//if the dialplan entry exists then update it
|
||||||
|
if ($dialplan_exists && strlen($this->ivr_menu_extension) > 0) {
|
||||||
|
//update the dialplan
|
||||||
|
$database = new database;
|
||||||
|
$database->table = "v_dialplans";
|
||||||
|
$database->fields['dialplan_name'] = $this->ivr_menu_name;
|
||||||
|
$database->fields['dialplan_order'] = '333';
|
||||||
|
$database->fields['dialplan_context'] = $_SESSION['context'];
|
||||||
|
$database->fields['dialplan_enabled'] = $this->ivr_menu_enabled;
|
||||||
|
$database->fields['dialplan_description'] = $this->ivr_menu_description;
|
||||||
|
$database->fields['app_uuid'] = $this->app_uuid;
|
||||||
|
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||||
|
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||||
|
$database->where[0]['name'] = 'domain_uuid';
|
||||||
|
$database->where[0]['value'] = $this->domain_uuid;
|
||||||
|
$database->where[0]['operator'] = '=';
|
||||||
|
$database->where[1]['name'] = 'dialplan_uuid';
|
||||||
|
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||||
|
$database->where[1]['operator'] = '=';
|
||||||
|
$database->update();
|
||||||
|
|
||||||
//delete the old dialplan details to prepare for new details
|
//delete the old dialplan details to prepare for new details
|
||||||
$database = new database;
|
$database = new database;
|
||||||
$database->table = "v_dialplan_details";
|
$database->table = "v_dialplan_details";
|
||||||
$database->where[0]['name'] = 'domain_uuid';
|
$database->where[0]['name'] = 'domain_uuid';
|
||||||
$database->where[0]['value'] = $this->domain_uuid;
|
$database->where[0]['value'] = $this->domain_uuid;
|
||||||
$database->where[0]['operator'] = '=';
|
$database->where[0]['operator'] = '=';
|
||||||
$database->where[1]['name'] = 'dialplan_uuid';
|
$database->where[1]['name'] = 'dialplan_uuid';
|
||||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||||
$database->where[1]['operator'] = '=';
|
$database->where[1]['operator'] = '=';
|
||||||
$database->delete();
|
$database->delete();
|
||||||
|
}
|
||||||
|
|
||||||
//add the dialplan details
|
//add the dialplan details
|
||||||
$detail_data = '^'.$this->ivr_menu_extension.'$';
|
$detail_data = '^'.$this->ivr_menu_extension.'$';
|
||||||
@@ -494,7 +520,6 @@ include "root.php";
|
|||||||
$database->fields['dialplan_detail_order'] = '030';
|
$database->fields['dialplan_detail_order'] = '030';
|
||||||
$database->add();
|
$database->add();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//update the ivr menu option
|
//update the ivr menu option
|
||||||
|
|||||||
Reference in New Issue
Block a user