Update ivr_menu.php
Update the ivr_menu class to use the orm class this simplifies and reduces the size of the code.
This commit is contained in:
@@ -158,203 +158,49 @@ include "root.php";
|
|||||||
return $database->find();
|
return $database->find();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add() {
|
public function save($array) {
|
||||||
|
//action add or update
|
||||||
//create the database object
|
if (strlen($this->ivr_menu_uuid) == 0) {
|
||||||
$database = new database;
|
$action = "add";
|
||||||
if ($this->db) {
|
|
||||||
$database->db = $this->db;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
//add the ivr menu
|
$action = "update";
|
||||||
if (strlen($this->ivr_menu_extension) > 0) {
|
|
||||||
//set the ivr menu uuid
|
|
||||||
if (strlen($this->ivr_menu_uuid) == 0) {
|
|
||||||
$this->ivr_menu_uuid = uuid();
|
|
||||||
}
|
|
||||||
|
|
||||||
//ensure the dialplan_uuid has a uuid
|
|
||||||
if (strlen($this->dialplan_uuid) == 0) {
|
|
||||||
$this->dialplan_uuid = uuid();
|
|
||||||
}
|
|
||||||
|
|
||||||
//add the ivr menu
|
|
||||||
$database->table = "v_ivr_menus";
|
|
||||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
|
||||||
$database->fields['ivr_menu_extension'] = $this->ivr_menu_extension;
|
|
||||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
|
||||||
$database->fields['ivr_menu_uuid'] = $this->ivr_menu_uuid;
|
|
||||||
$database->fields['ivr_menu_name'] = $this->ivr_menu_name;
|
|
||||||
$database->fields['ivr_menu_greet_long'] = $this->ivr_menu_greet_long;
|
|
||||||
$database->fields['ivr_menu_greet_short'] = $this->ivr_menu_greet_short;
|
|
||||||
$database->fields['ivr_menu_invalid_sound'] = $this->ivr_menu_invalid_sound;
|
|
||||||
$database->fields['ivr_menu_exit_sound'] = $this->ivr_menu_exit_sound;
|
|
||||||
$database->fields['ivr_menu_confirm_macro'] = $this->ivr_menu_confirm_macro;
|
|
||||||
$database->fields['ivr_menu_confirm_key'] = $this->ivr_menu_confirm_key;
|
|
||||||
$database->fields['ivr_menu_tts_engine'] = $this->ivr_menu_tts_engine;
|
|
||||||
$database->fields['ivr_menu_tts_voice'] = $this->ivr_menu_tts_voice;
|
|
||||||
$database->fields['ivr_menu_confirm_attempts'] = $this->ivr_menu_confirm_attempts;
|
|
||||||
$database->fields['ivr_menu_timeout'] = $this->ivr_menu_timeout;
|
|
||||||
$database->fields['ivr_menu_exit_app'] = $this->ivr_menu_exit_app;
|
|
||||||
$database->fields['ivr_menu_exit_data'] = $this->ivr_menu_exit_data;
|
|
||||||
$database->fields['ivr_menu_inter_digit_timeout'] = $this->ivr_menu_inter_digit_timeout;
|
|
||||||
$database->fields['ivr_menu_max_failures'] = $this->ivr_menu_max_failures;
|
|
||||||
$database->fields['ivr_menu_max_timeouts'] = $this->ivr_menu_max_timeouts;
|
|
||||||
$database->fields['ivr_menu_max_timeouts'] = $this->ivr_menu_max_timeouts;
|
|
||||||
$database->fields['ivr_menu_digit_len'] = $this->ivr_menu_digit_len;
|
|
||||||
$database->fields['ivr_menu_digit_len'] = $this->ivr_menu_digit_len;
|
|
||||||
$database->fields['ivr_menu_direct_dial'] = $this->ivr_menu_direct_dial;
|
|
||||||
$database->fields['ivr_menu_ringback'] = $this->ivr_menu_ringback;
|
|
||||||
$database->fields['ivr_menu_cid_prefix'] = $this->ivr_menu_cid_prefix;
|
|
||||||
$database->fields['ivr_menu_enabled'] = $this->ivr_menu_enabled;
|
|
||||||
$database->fields['ivr_menu_description'] = $this->ivr_menu_description;
|
|
||||||
$database->add();
|
|
||||||
}
|
|
||||||
|
|
||||||
//add the ivr menu option
|
|
||||||
if (strlen($this->ivr_menu_option_action) > 0) {
|
|
||||||
$database = new database;
|
|
||||||
$database->table = "v_ivr_menu_options";
|
|
||||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
|
||||||
$database->fields['ivr_menu_uuid'] = $this->ivr_menu_uuid;
|
|
||||||
$database->fields['ivr_menu_option_uuid'] = $this->ivr_menu_option_uuid;
|
|
||||||
$database->fields['ivr_menu_option_digits'] = $this->ivr_menu_option_digits;
|
|
||||||
$database->fields['ivr_menu_option_action'] = $this->ivr_menu_option_action;
|
|
||||||
$database->fields['ivr_menu_option_param'] = $this->ivr_menu_option_param;
|
|
||||||
$database->fields['ivr_menu_option_order'] = $this->ivr_menu_option_order;
|
|
||||||
$database->fields['ivr_menu_option_description'] = $this->ivr_menu_option_description;
|
|
||||||
$database->add();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//update the dialplan
|
//update the dialplan
|
||||||
$this->dialplan();
|
$this->dialplan($array);
|
||||||
}
|
$array['dialplan_uuid'] = $this->dialplan_uuid;
|
||||||
|
|
||||||
public function update() {
|
//save the ivr_menus
|
||||||
|
$orm = new orm;
|
||||||
|
$orm->name('ivr_menus');
|
||||||
|
if (strlen($this->ivr_menu_uuid) > 0) {
|
||||||
|
$orm->uuid($this->ivr_menu_uuid);
|
||||||
|
}
|
||||||
|
$orm->save($array);
|
||||||
|
|
||||||
//create the database object
|
//set the add message
|
||||||
$database = new database;
|
if ($action == "add" && permission_exists('ivr_menu_add')) {
|
||||||
if ($this->db) {
|
$_SESSION['message'] = $text['message-add'];
|
||||||
$database->db = $this->db;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the dialplan uuid
|
//set the update message
|
||||||
$database->table = "v_ivr_menus";
|
if ($action == "update" && permission_exists('ivr_menu_edit')) {
|
||||||
$database->where[0]['name'] = 'domain_uuid';
|
$_SESSION['message'] = $text['message-update'];
|
||||||
$database->where[0]['value'] = $this->domain_uuid;
|
|
||||||
$database->where[0]['operator'] = '=';
|
|
||||||
$database->where[1]['name'] = 'ivr_menu_uuid';
|
|
||||||
$database->where[1]['value'] = $this->ivr_menu_uuid;
|
|
||||||
$database->where[1]['operator'] = '=';
|
|
||||||
$result = $database->find();
|
|
||||||
foreach($result as $row) {
|
|
||||||
$this->dialplan_uuid = $row['dialplan_uuid'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//if the extension number is empty and the dialplan exists then delete the dialplan
|
//return the result
|
||||||
if (strlen($this->ivr_menu_extension) == 0) {
|
return $orm->message;
|
||||||
if (strlen($this->dialplan_uuid) > 0) {
|
|
||||||
//delete dialplan entry
|
|
||||||
$database = new database;
|
|
||||||
$database->table = "v_dialplan_details";
|
|
||||||
$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();
|
|
||||||
|
|
||||||
//delete the child dialplan information
|
|
||||||
$database = new database;
|
|
||||||
$database->table = "v_dialplans";
|
|
||||||
$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();
|
|
||||||
|
|
||||||
//update the table to remove the dialplan_uuid
|
|
||||||
$this->dialplan_uuid = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//update the ivr menu
|
|
||||||
if (strlen($this->ivr_menu_extension) > 0) {
|
|
||||||
if (strlen($this->dialplan_uuid) == 0) {
|
|
||||||
$this->dialplan_uuid = uuid();
|
|
||||||
}
|
|
||||||
$database = new database;
|
|
||||||
$database->table = "v_ivr_menus";
|
|
||||||
$database->fields['ivr_menu_uuid'] = $this->ivr_menu_uuid;
|
|
||||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
|
||||||
$database->fields['ivr_menu_name'] = $this->ivr_menu_name;
|
|
||||||
$database->fields['ivr_menu_extension'] = $this->ivr_menu_extension;
|
|
||||||
$database->fields['ivr_menu_greet_long'] = $this->ivr_menu_greet_long;
|
|
||||||
$database->fields['ivr_menu_greet_short'] = $this->ivr_menu_greet_short;
|
|
||||||
$database->fields['ivr_menu_invalid_sound'] = $this->ivr_menu_invalid_sound;
|
|
||||||
$database->fields['ivr_menu_exit_sound'] = $this->ivr_menu_exit_sound;
|
|
||||||
$database->fields['ivr_menu_confirm_macro'] = $this->ivr_menu_confirm_macro;
|
|
||||||
$database->fields['ivr_menu_confirm_key'] = $this->ivr_menu_confirm_key;
|
|
||||||
$database->fields['ivr_menu_tts_engine'] = $this->ivr_menu_tts_engine;
|
|
||||||
$database->fields['ivr_menu_tts_voice'] = $this->ivr_menu_tts_voice;
|
|
||||||
$database->fields['ivr_menu_confirm_attempts'] = $this->ivr_menu_confirm_attempts;
|
|
||||||
$database->fields['ivr_menu_timeout'] = $this->ivr_menu_timeout;
|
|
||||||
$database->fields['ivr_menu_exit_app'] = $this->ivr_menu_exit_app;
|
|
||||||
$database->fields['ivr_menu_exit_data'] = $this->ivr_menu_exit_data;
|
|
||||||
$database->fields['ivr_menu_inter_digit_timeout'] = $this->ivr_menu_inter_digit_timeout;
|
|
||||||
$database->fields['ivr_menu_max_failures'] = $this->ivr_menu_max_failures;
|
|
||||||
$database->fields['ivr_menu_max_timeouts'] = $this->ivr_menu_max_timeouts;
|
|
||||||
$database->fields['ivr_menu_max_timeouts'] = $this->ivr_menu_max_timeouts;
|
|
||||||
$database->fields['ivr_menu_digit_len'] = $this->ivr_menu_digit_len;
|
|
||||||
$database->fields['ivr_menu_digit_len'] = $this->ivr_menu_digit_len;
|
|
||||||
$database->fields['ivr_menu_direct_dial'] = $this->ivr_menu_direct_dial;
|
|
||||||
$database->fields['ivr_menu_ringback'] = $this->ivr_menu_ringback;
|
|
||||||
$database->fields['ivr_menu_cid_prefix'] = $this->ivr_menu_cid_prefix;
|
|
||||||
$database->fields['ivr_menu_enabled'] = $this->ivr_menu_enabled;
|
|
||||||
$database->fields['ivr_menu_description'] = $this->ivr_menu_description;
|
|
||||||
$database->where[0]['name'] = 'domain_uuid';
|
|
||||||
$database->where[0]['value'] = $this->domain_uuid;
|
|
||||||
$database->where[0]['operator'] = '=';
|
|
||||||
$database->where[1]['name'] = 'ivr_menu_uuid';
|
|
||||||
$database->where[1]['value'] = $this->ivr_menu_uuid;
|
|
||||||
$database->where[1]['operator'] = '=';
|
|
||||||
$database->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
//update the ivr menu option
|
|
||||||
if (strlen($this->ivr_menu_option_action) > 0) {
|
|
||||||
$database = new database;
|
|
||||||
$database->table = "v_ivr_menu_options";
|
|
||||||
$database->fields['ivr_menu_option_digits'] = $this->ivr_menu_option_digits;
|
|
||||||
$database->fields['ivr_menu_option_action'] = $this->ivr_menu_option_action;
|
|
||||||
$database->fields['ivr_menu_option_param'] = $this->ivr_menu_option_param;
|
|
||||||
$database->fields['ivr_menu_option_order'] = $this->ivr_menu_option_order;
|
|
||||||
$database->fields['ivr_menu_option_description'] = $this->ivr_menu_option_description;
|
|
||||||
$database->where[0]['name'] = 'domain_uuid';
|
|
||||||
$database->where[0]['value'] = $this->domain_uuid;
|
|
||||||
$database->where[0]['operator'] = '=';
|
|
||||||
$database->where[1]['name'] = 'ivr_menu_uuid';
|
|
||||||
$database->where[1]['value'] = $this->ivr_menu_uuid;
|
|
||||||
$database->where[1]['operator'] = '=';
|
|
||||||
$database->where[2]['name'] = 'ivr_menu_option_uuid';
|
|
||||||
$database->where[2]['value'] = $this->ivr_menu_option_uuid;
|
|
||||||
$database->where[2]['operator'] = '=';
|
|
||||||
$database->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
//update the dialplan
|
|
||||||
$this->dialplan();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete() {
|
function delete() {
|
||||||
|
|
||||||
//create the database object
|
//create the database object
|
||||||
$database = new database;
|
$database = new database;
|
||||||
if ($this->db) {
|
if ($this->db) {
|
||||||
$database->db = $this->db;
|
$database->db = $this->db;
|
||||||
}
|
}
|
||||||
|
|
||||||
//start the transaction
|
//start the transaction
|
||||||
//$count = $database->db->exec("BEGIN;");
|
//$count = $database->db->exec("BEGIN;");
|
||||||
|
|
||||||
@@ -437,183 +283,190 @@ include "root.php";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dialplan() {
|
public function dialplan($field) {
|
||||||
//create the database object
|
|
||||||
|
//set global variables
|
||||||
|
global $db;
|
||||||
|
|
||||||
|
//action add or update
|
||||||
|
if (strlen($field['dialplan_uuid']) == 0) {
|
||||||
|
$field['dialplan_uuid'] = uuid();
|
||||||
|
$action = "add";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$action = "update";
|
||||||
|
}
|
||||||
|
|
||||||
|
//delete child data
|
||||||
|
if ($action == "update") {
|
||||||
|
$sql = "delete from v_dialplan_details ";
|
||||||
|
$sql .= "where dialplan_uuid = '".$field["dialplan_uuid"]."'; ";
|
||||||
|
$db->query($sql);
|
||||||
|
unset($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
//get dialplan details from the database
|
||||||
|
if ($action == "update") {
|
||||||
|
$sql = "select * from v_dialplan_details ";
|
||||||
|
$sql .= "where dialplan_uuid = '".$field["dialplan_uuid"]."' ";
|
||||||
|
$prep_statement = $db->prepare($sql);
|
||||||
|
if ($prep_statement) {
|
||||||
|
$prep_statement->execute();
|
||||||
|
$dialplan_details = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||||
|
}
|
||||||
|
unset($sql, $prep_statement, $row);
|
||||||
|
}
|
||||||
|
|
||||||
|
//get the array from the database
|
||||||
|
/*
|
||||||
$database = new database;
|
$database = new database;
|
||||||
if ($this->db) {
|
if ($this->db) { $database->db = $this->db; }
|
||||||
$database->db = $this->db;
|
$database->table = "v_ivr_menu_details";
|
||||||
}
|
$database->where[0]['name'] = 'ivr_menu_uuid';
|
||||||
|
$database->where[0]['value'] = $field["ivr_menu_uuid"];
|
||||||
|
$database->where[0]['operator'] = '=';
|
||||||
|
$ivr_menu_details = $database->find();
|
||||||
|
*/
|
||||||
|
|
||||||
//check to see if the dialplan entry exists
|
//add the details array
|
||||||
$dialplan = new dialplan;
|
$x=0;
|
||||||
$dialplan->domain_uuid = $_SESSION["domain_uuid"];
|
$details[$x]['dialplan_detail_tag'] = 'condition'; //condition, action, antiaction
|
||||||
$dialplan->dialplan_uuid = $this->dialplan_uuid;
|
$details[$x]['dialplan_detail_type'] = 'destination_number';
|
||||||
$dialplan_exists = $dialplan->dialplan_exists();
|
$details[$x]['dialplan_detail_data'] = '^'.$field['ivr_menu_extension'].'$';
|
||||||
|
$details[$x]['dialplan_detail_order'] = '005';
|
||||||
|
|
||||||
//if the dialplan entry does not exist then add it
|
$x++;
|
||||||
if (!$dialplan_exists) {
|
$details[$x]['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||||
$database = new database;
|
$details[$x]['dialplan_detail_type'] = 'answer';
|
||||||
$database->table = "v_dialplans";
|
$details[$x]['dialplan_detail_data'] = '';
|
||||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
$details[$x]['dialplan_detail_order'] = '010';
|
||||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
|
||||||
$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->add();
|
|
||||||
}
|
|
||||||
|
|
||||||
//if the dialplan entry exists then update it
|
$x++;
|
||||||
if ($dialplan_exists && strlen($this->ivr_menu_extension) > 0) {
|
$details[$x]['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||||
//update the dialplan
|
$details[$x]['dialplan_detail_type'] = 'sleep';
|
||||||
$database = new database;
|
$details[$x]['dialplan_detail_data'] = '1000';
|
||||||
$database->table = "v_dialplans";
|
$details[$x]['dialplan_detail_order'] = '015';
|
||||||
$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
|
$x++;
|
||||||
$database = new database;
|
$details[$x]['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||||
$database->table = "v_dialplan_details";
|
$details[$x]['dialplan_detail_type'] = 'set';
|
||||||
$database->where[0]['name'] = 'domain_uuid';
|
$details[$x]['dialplan_detail_data'] = 'hangup_after_bridge=true';
|
||||||
$database->where[0]['value'] = $this->domain_uuid;
|
$details[$x]['dialplan_detail_order'] = '020';
|
||||||
$database->where[0]['operator'] = '=';
|
|
||||||
$database->where[1]['name'] = 'dialplan_uuid';
|
|
||||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
|
||||||
$database->where[1]['operator'] = '=';
|
|
||||||
$database->delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
//add the dialplan details
|
$x++;
|
||||||
$detail_data = '^'.$this->ivr_menu_extension.'$';
|
$details[$x]['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||||
$database->table = "v_dialplan_details";
|
$details[$x]['dialplan_detail_type'] = 'set';
|
||||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
if ($field['ivr_menu_ringback'] == "music" || $field['ivr_menu_ringback'] == "") {
|
||||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
$details[$x]['dialplan_detail_data'] = 'ringback=${hold_music}';
|
||||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
|
||||||
$database->fields['dialplan_detail_tag'] = 'condition'; //condition, action, antiaction
|
|
||||||
$database->fields['dialplan_detail_type'] = 'destination_number';
|
|
||||||
$database->fields['dialplan_detail_data'] = $detail_data;
|
|
||||||
$database->fields['dialplan_detail_order'] = '005';
|
|
||||||
$database->add();
|
|
||||||
|
|
||||||
$database->table = "v_dialplan_details";
|
|
||||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
|
||||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
|
||||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
|
||||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
|
||||||
$database->fields['dialplan_detail_type'] = 'answer';
|
|
||||||
$database->fields['dialplan_detail_data'] = '';
|
|
||||||
$database->fields['dialplan_detail_order'] = '010';
|
|
||||||
$database->add();
|
|
||||||
|
|
||||||
$database->table = "v_dialplan_details";
|
|
||||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
|
||||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
|
||||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
|
||||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
|
||||||
$database->fields['dialplan_detail_type'] = 'sleep';
|
|
||||||
$database->fields['dialplan_detail_data'] = '1000';
|
|
||||||
$database->fields['dialplan_detail_order'] = '015';
|
|
||||||
$database->add();
|
|
||||||
|
|
||||||
$database->table = "v_dialplan_details";
|
|
||||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
|
||||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
|
||||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
|
||||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
|
||||||
$database->fields['dialplan_detail_type'] = 'set';
|
|
||||||
$database->fields['dialplan_detail_data'] = 'hangup_after_bridge=true';
|
|
||||||
$database->fields['dialplan_detail_order'] = '020';
|
|
||||||
$database->add();
|
|
||||||
|
|
||||||
$database->table = "v_dialplan_details";
|
|
||||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
|
||||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
|
||||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
|
||||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
|
||||||
$database->fields['dialplan_detail_type'] = 'set';
|
|
||||||
if ($this->ivr_menu_ringback == "music" || $this->ivr_menu_ringback == "") {
|
|
||||||
$database->fields['dialplan_detail_data'] = 'ringback=${hold_music}';
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$database->fields['dialplan_detail_data'] = 'ringback='.$this->ivr_menu_ringback;
|
$details[$x]['dialplan_detail_data'] = 'ringback='.$field['ivr_menu_ringback'];
|
||||||
}
|
}
|
||||||
$database->fields['dialplan_detail_order'] = '025';
|
$details[$x]['dialplan_detail_order'] = '025';
|
||||||
$database->add();
|
|
||||||
|
|
||||||
$database->table = "v_dialplan_details";
|
$x++;
|
||||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
$details[$x]['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
$details[$x]['dialplan_detail_type'] = 'set';
|
||||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
if ($field['ivr_menu_ringback'] == "music" || $field['ivr_menu_ringback'] == "") {
|
||||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
$details[$x]['dialplan_detail_data'] = 'transfer_ringback=${hold_music}';
|
||||||
$database->fields['dialplan_detail_type'] = 'set';
|
|
||||||
if ($this->ivr_menu_ringback == "music" || $this->ivr_menu_ringback == "") {
|
|
||||||
$database->fields['dialplan_detail_data'] = 'transfer_ringback=${hold_music}';
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$database->fields['dialplan_detail_data'] = 'transfer_ringback='.$this->ivr_menu_ringback;
|
$details[$x]['dialplan_detail_data'] = 'transfer_ringback='.$field['ivr_menu_ringback'];
|
||||||
}
|
}
|
||||||
$database->fields['dialplan_detail_order'] = '030';
|
$details[$x]['dialplan_detail_order'] = '030';
|
||||||
$database->add();
|
|
||||||
|
|
||||||
$database->table = "v_dialplan_details";
|
$x++;
|
||||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
$details[$x]['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
$details[$x]['dialplan_detail_type'] = 'set';
|
||||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
$details[$x]['dialplan_detail_data'] = 'ivr_menu_uuid='.$this->ivr_menu_uuid;
|
||||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
$details[$x]['dialplan_detail_order'] = '035';
|
||||||
$database->fields['dialplan_detail_type'] = 'set';
|
|
||||||
$database->fields['dialplan_detail_data'] = 'ivr_menu_uuid='.$this->ivr_menu_uuid;
|
|
||||||
$database->fields['dialplan_detail_order'] = '035';
|
|
||||||
$database->add();
|
|
||||||
|
|
||||||
$database->table = "v_dialplan_details";
|
$x++;
|
||||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
$details[$x]['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
|
||||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
|
||||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
|
||||||
if ($_SESSION['ivr menu']['application']['text'] == "lua") {
|
if ($_SESSION['ivr menu']['application']['text'] == "lua") {
|
||||||
$database->fields['dialplan_detail_type'] = 'lua';
|
$details[$x]['dialplan_detail_type'] = 'lua';
|
||||||
$database->fields['dialplan_detail_data'] = 'ivr_menu.lua';
|
$details[$x]['dialplan_detail_data'] = 'ivr_menu.lua';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$database->fields['dialplan_detail_type'] = 'ivr';
|
$details[$x]['dialplan_detail_type'] = 'ivr';
|
||||||
$database->fields['dialplan_detail_data'] = $this->ivr_menu_uuid;
|
$details[$x]['dialplan_detail_data'] = $this->ivr_menu_uuid;
|
||||||
}
|
}
|
||||||
$database->fields['dialplan_detail_order'] = '040';
|
$details[$x]['dialplan_detail_order'] = '040';
|
||||||
$database->add();
|
|
||||||
|
|
||||||
if (strlen($this->ivr_menu_exit_app) > 0) {
|
if (strlen($field['ivr_menu_exit_app']) > 0) {
|
||||||
$database->table = "v_dialplan_details";
|
$x++;
|
||||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
$details[$x]['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
$details[$x]['dialplan_detail_type'] = $field['ivr_menu_exit_app'];
|
||||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
$details[$x]['dialplan_detail_data'] = $field['ivr_menu_exit_data'];
|
||||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
$details[$x]['dialplan_detail_order'] = '045';
|
||||||
$database->fields['dialplan_detail_type'] = $this->ivr_menu_exit_app;
|
$x++;
|
||||||
$database->fields['dialplan_detail_data'] = $this->ivr_menu_exit_data;
|
|
||||||
$database->fields['dialplan_detail_order'] = '045';
|
|
||||||
$database->add();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//build the array
|
||||||
|
$array['domain_uuid'] = $field['domain_uuid'];
|
||||||
|
$array['dialplan_uuid'] = $field['dialplan_uuid'];
|
||||||
|
$array['dialplan_name'] = $field['ivr_menu_name'];
|
||||||
|
$array['dialplan_order'] = '333';
|
||||||
|
$array['dialplan_context'] = $_SESSION['context'];
|
||||||
|
$array['dialplan_enabled'] = $field['ivr_menu_enabled'];
|
||||||
|
$array['dialplan_description'] = $field['ivr_menu_description'];
|
||||||
|
$array['app_uuid'] = $this->app_uuid;
|
||||||
|
$x=0;
|
||||||
|
foreach ($details as $row) {
|
||||||
|
//find the matching uuid
|
||||||
|
/*
|
||||||
|
foreach ($dialplan_details as $database) {
|
||||||
|
if ($database['dialplan_detail_tag'] == $row['dialplan_detail_tag']
|
||||||
|
&& $database['dialplan_detail_type'] == $row['dialplan_detail_type']
|
||||||
|
&& $database['dialplan_detail_data'] == $row['dialplan_detail_data']) {
|
||||||
|
$array['dialplan_details'][$x]['dialplan_detail_uuid'] = $database['dialplan_detail_uuid'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//add to the array
|
||||||
|
$array['dialplan_details'][$x]['domain_uuid'] = $field['domain_uuid'];
|
||||||
|
$array['dialplan_details'][$x]['dialplan_uuid'] = $field['dialplan_uuid'];
|
||||||
|
$array['dialplan_details'][$x]['dialplan_detail_tag'] = $row['dialplan_detail_tag'];
|
||||||
|
$array['dialplan_details'][$x]['dialplan_detail_type'] = $row['dialplan_detail_type'];
|
||||||
|
$array['dialplan_details'][$x]['dialplan_detail_data'] = $row['dialplan_detail_data'];
|
||||||
|
$array['dialplan_details'][$x]['dialplan_detail_order'] = $row['dialplan_detail_order'];
|
||||||
|
|
||||||
|
//increment the row
|
||||||
|
$x++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//debug
|
||||||
|
//echo "<pre>\n";
|
||||||
|
//print_r($dialplan_details);
|
||||||
|
//print_r($array);
|
||||||
|
//echo "</pre>\n";
|
||||||
|
//exit;
|
||||||
|
|
||||||
|
//save the dialplan
|
||||||
|
$orm = new orm;
|
||||||
|
$orm->name('dialplans');
|
||||||
|
$orm->save($array);
|
||||||
|
$response = $orm->message;
|
||||||
|
if (strlen($response['uuid']) > 0) {
|
||||||
|
$this->dialplan_uuid = $response['uuid'];
|
||||||
|
}
|
||||||
|
|
||||||
|
//debug
|
||||||
|
//echo "<pre>\n";
|
||||||
|
//print_r($response);
|
||||||
|
//echo "</pre>\n";
|
||||||
|
//exit;
|
||||||
|
|
||||||
|
//synchronize the xml config
|
||||||
|
save_dialplan_xml();
|
||||||
|
|
||||||
//delete the dialplan context from memcache
|
//delete the dialplan context from memcache
|
||||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
//$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||||
if ($fp) {
|
//if ($fp) {
|
||||||
$switch_cmd .= "memcache delete dialplan:".$_SESSION["context"]."@".$_SESSION['domain_name'];
|
// $switch_cmd .= "memcache delete dialplan:".$_SESSION["context"]."@".$_SESSION['domain_name'];
|
||||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
// $switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_xml(){
|
function get_xml(){
|
||||||
@@ -779,4 +632,4 @@ include "root.php";
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user