Dialplans: Database class integration.
This commit is contained in:
parent
66f22bada1
commit
d3c6182f85
|
|
@ -84,31 +84,34 @@
|
|||
}
|
||||
|
||||
//update the dialplan order
|
||||
$database = new database;
|
||||
$sql = "update v_dialplans set dialplan_order = '870' where dialplan_order = '980' and dialplan_name = 'cidlookup';\n";
|
||||
$db->query($sql);
|
||||
$database->execute($sql);
|
||||
$sql = "update v_dialplans set dialplan_order = '880' where dialplan_order = '990' and dialplan_name = 'call_screen';\n";
|
||||
$db->query($sql);
|
||||
$database->execute($sql);
|
||||
$sql = "update v_dialplans set dialplan_order = '890' where dialplan_order = '999' and dialplan_name = 'local_extension';\n";
|
||||
$db->query($sql);
|
||||
$database->execute($sql);
|
||||
unset($sql);
|
||||
|
||||
|
||||
//set empty strings to null
|
||||
$database = new database;
|
||||
$sql = "update v_device_lines set outbound_proxy_primary = null where outbound_proxy_primary = '';\n";
|
||||
$db->query($sql);
|
||||
$database->execute($sql);
|
||||
$sql = "update v_device_lines set outbound_proxy_secondary = null where outbound_proxy_secondary = '';\n";
|
||||
$db->query($sql);
|
||||
$database->execute($sql);
|
||||
unset($sql);
|
||||
|
||||
//change recording_slots to recording_id
|
||||
$database = new database;
|
||||
$sql = "update v_dialplan_details set dialplan_detail_data = 'recording_id=true' ";
|
||||
$sql .= "where dialplan_uuid in (select dialplan_uuid from v_dialplans where app_uuid = '430737df-5385-42d1-b933-22600d3fb79e') ";
|
||||
$sql .= "and dialplan_detail_data = 'recording_slots=true'; \n";
|
||||
$db->query($sql);
|
||||
unset($sql);
|
||||
$database->execute($sql);
|
||||
$sql = "update v_dialplan_details set dialplan_detail_data = 'recording_id=false' ";
|
||||
$sql .= "where dialplan_uuid in (select dialplan_uuid from v_dialplans where app_uuid = '430737df-5385-42d1-b933-22600d3fb79e') ";
|
||||
$sql .= "and dialplan_detail_data = 'recording_slots=false'; \n";
|
||||
$db->query($sql);
|
||||
$database->execute($sql);
|
||||
unset($sql);
|
||||
}
|
||||
|
||||
|
|
@ -116,18 +119,20 @@
|
|||
if ($domains_processed == 1) {
|
||||
$sql = "select domain_name ";
|
||||
$sql .= "from v_domains \n";
|
||||
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$results = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($results as $row) {
|
||||
$dialplans = new dialplan;
|
||||
$dialplans->source = "details";
|
||||
$dialplans->destination = "database";
|
||||
$dialplans->context = $row["domain_name"];
|
||||
$dialplans->is_empty = "dialplan_xml";
|
||||
$array = $dialplans->xml();
|
||||
//print_r($array);
|
||||
$database = new database;
|
||||
$results = $database->select($sql, null, 'all');
|
||||
if (is_array($results) && @sizeof($results) != 0) {
|
||||
foreach ($results as $row) {
|
||||
$dialplans = new dialplan;
|
||||
$dialplans->source = "details";
|
||||
$dialplans->destination = "database";
|
||||
$dialplans->context = $row["domain_name"];
|
||||
$dialplans->is_empty = "dialplan_xml";
|
||||
$array = $dialplans->xml();
|
||||
//print_r($array);
|
||||
}
|
||||
}
|
||||
unset($sql, $results);
|
||||
$dialplans = new dialplan;
|
||||
$dialplans->source = "details";
|
||||
$dialplans->destination = "database";
|
||||
|
|
@ -137,41 +142,59 @@
|
|||
|
||||
//delete the follow me bridge dialplan
|
||||
if ($domains_processed == 1) {
|
||||
$database = new database;
|
||||
$sql = "delete from v_dialplan_details where dialplan_uuid = '8ed73d1f-698f-466c-8a7a-1cf4cd229f7f' ";
|
||||
$db->query($sql);
|
||||
$database->execute($sql);
|
||||
$sql = "delete from v_dialplans where dialplan_uuid = '8ed73d1f-698f-466c-8a7a-1cf4cd229f7f' ";
|
||||
$db->query($sql);
|
||||
$database->execute($sql);
|
||||
unset($sql);
|
||||
}
|
||||
|
||||
//add not found dialplan to inbound routes
|
||||
/*
|
||||
if ($domains_processed == 1) {
|
||||
if (is_readable($_SESSION['switch']['dialplan']['dir'])) {
|
||||
$sql = "select count(*) as num_rows from v_dialplans ";
|
||||
$sql = "select count(*) from v_dialplans ";
|
||||
$sql .= "where dialplan_uuid = 'ea5339de-1982-46ca-9695-c35176165314' ";
|
||||
$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) {
|
||||
$sql = "INSERT INTO v_dialplans ";
|
||||
$sql .= "(dialplan_uuid, app_uuid, dialplan_context, dialplan_name, dialplan_continue, dialplan_order, dialplan_enabled) ";
|
||||
$sql .= "VALUES ('ea5339de-1982-46ca-9695-c35176165314', 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4', 'public', 'not-found', 'false', '999', 'false');";
|
||||
$db->query($sql);
|
||||
$database = new database;
|
||||
$num_rows = $database->select($sql, null, 'column');
|
||||
if ($num_rows == 0) {
|
||||
$array['dialplans'][0]['dialplan_uuid'] = 'ea5339de-1982-46ca-9695-c35176165314';
|
||||
$array['dialplans'][0]['app_uuid'] = 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4';
|
||||
$array['dialplans'][0]['dialplan_context'] = 'public';
|
||||
$array['dialplans'][0]['dialplan_name'] = 'not-found';
|
||||
$array['dialplans'][0]['dialplan_continue'] = 'false';
|
||||
$array['dialplans'][0]['dialplan_order'] = '999';
|
||||
$array['dialplans'][0]['dialplan_enabled'] = 'false';
|
||||
|
||||
$sql = "INSERT INTO v_dialplan_details ";
|
||||
$sql .= "(dialplan_uuid, dialplan_detail_uuid, dialplan_detail_tag, dialplan_detail_type, dialplan_detail_data, dialplan_detail_order) ";
|
||||
$sql .= "VALUES ('ea5339de-1982-46ca-9695-c35176165314', '8a21744d-b381-4cb0-9930-55b776e4e461', 'condition', 'context', 'public', '10');";
|
||||
$db->query($sql);
|
||||
$array['dialplan_details'][0]['dialplan_uuid'] = 'ea5339de-1982-46ca-9695-c35176165314';
|
||||
$array['dialplan_details'][0]['dialplan_detail_uuid'] = '8a21744d-b381-4cb0-9930-55b776e4e461';
|
||||
$array['dialplan_details'][0]['dialplan_detail_tag'] = 'condition';
|
||||
$array['dialplan_details'][0]['dialplan_detail_type'] = 'context';
|
||||
$array['dialplan_details'][0]['dialplan_detail_data'] = 'public';
|
||||
$array['dialplan_details'][0]['dialplan_detail_order'] = '10';
|
||||
|
||||
$sql = "INSERT INTO v_dialplan_details ";
|
||||
$sql .= "(dialplan_uuid, dialplan_detail_uuid, dialplan_detail_tag, dialplan_detail_type, dialplan_detail_data, dialplan_detail_order) ";
|
||||
$sql .= "VALUES ('ea5339de-1982-46ca-9695-c35176165314', 'e391530c-4078-4b49-bc11-bda4a23ad566', 'action', 'log', '[inbound routes] 404 not found \${sip_network_ip}', '20');";
|
||||
$db->query($sql);
|
||||
unset($sql);
|
||||
}
|
||||
unset($prep_statement);
|
||||
$array['dialplan_details'][1]['dialplan_uuid'] = 'ea5339de-1982-46ca-9695-c35176165314';
|
||||
$array['dialplan_details'][1]['dialplan_detail_uuid'] = 'e391530c-4078-4b49-bc11-bda4a23ad566';
|
||||
$array['dialplan_details'][1]['dialplan_detail_tag'] = 'action';
|
||||
$array['dialplan_details'][1]['dialplan_detail_type'] = 'log';
|
||||
$array['dialplan_details'][1]['dialplan_detail_data'] = '[inbound routes] 404 not found \${sip_network_ip}';
|
||||
$array['dialplan_details'][1]['dialplan_detail_order'] = '20';
|
||||
|
||||
$p = new permissions;
|
||||
$p->add('dialplan_add', 'temp');
|
||||
$p->add('dialplan_detail_add', 'temp');
|
||||
|
||||
$database = new database;
|
||||
$database->app_name = 'dialplans';
|
||||
$database->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
$p->delete('dialplan_add', 'temp');
|
||||
$p->delete('dialplan_detail_add', 'temp');
|
||||
}
|
||||
unset($sql, $num_rows);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -49,34 +49,34 @@
|
|||
|
||||
//set the variables
|
||||
if (count($_POST) > 0) {
|
||||
$dialplan_name = check_str($_POST["dialplan_name"]);
|
||||
$dialplan_name = $_POST["dialplan_name"];
|
||||
|
||||
$condition_field_1 = check_str($_POST["condition_field_1"]);
|
||||
$condition_expression_1 = check_str($_POST["condition_expression_1"]);
|
||||
$condition_field_2 = check_str($_POST["condition_field_2"]);
|
||||
$condition_expression_2 = check_str($_POST["condition_expression_2"]);
|
||||
$condition_field_1 = $_POST["condition_field_1"];
|
||||
$condition_expression_1 = $_POST["condition_expression_1"];
|
||||
$condition_field_2 = $_POST["condition_field_2"];
|
||||
$condition_expression_2 = $_POST["condition_expression_2"];
|
||||
|
||||
$action_1 = check_str($_POST["action_1"]);
|
||||
$action_1 = $_POST["action_1"];
|
||||
//$action_1 = "transfer:1001 XML default";
|
||||
$action_1_array = explode(":", $action_1);
|
||||
$action_application_1 = array_shift($action_1_array);
|
||||
$action_data_1 = join(':', $action_1_array);
|
||||
|
||||
$action_2 = check_str($_POST["action_2"]);
|
||||
$action_2 = $_POST["action_2"];
|
||||
//$action_2 = "transfer:1001 XML default";
|
||||
$action_2_array = explode(":", $action_2);
|
||||
$action_application_2 = array_shift($action_2_array);
|
||||
$action_data_2 = join(':', $action_2_array);
|
||||
|
||||
//$action_application_1 = check_str($_POST["action_application_1"]);
|
||||
//$action_data_1 = check_str($_POST["action_data_1"]);
|
||||
//$action_application_2 = check_str($_POST["action_application_2"]);
|
||||
//$action_data_2 = check_str($_POST["action_data_2"]);
|
||||
//$action_application_1 = $_POST["action_application_1"];
|
||||
//$action_data_1 = $_POST["action_data_1"];
|
||||
//$action_application_2 = $_POST["action_application_2"];
|
||||
//$action_data_2 = $_POST["action_data_2"];
|
||||
|
||||
$dialplan_context = check_str($_POST["dialplan_context"]);
|
||||
$dialplan_order = check_str($_POST["dialplan_order"]);
|
||||
$dialplan_enabled = check_str($_POST["dialplan_enabled"]);
|
||||
$dialplan_description = check_str($_POST["dialplan_description"]);
|
||||
$dialplan_context = $_POST["dialplan_context"];
|
||||
$dialplan_order = $_POST["dialplan_order"];
|
||||
$dialplan_enabled = $_POST["dialplan_enabled"];
|
||||
$dialplan_description = $_POST["dialplan_description"];
|
||||
if (strlen($dialplan_enabled) == 0) { $dialplan_enabled = "true"; } //set default to enabled
|
||||
}
|
||||
|
||||
|
|
@ -110,145 +110,69 @@
|
|||
$dialplan_name = str_replace(" ", "_", $dialplan_name);
|
||||
$dialplan_name = str_replace("/", "", $dialplan_name);
|
||||
|
||||
//start the atomic transaction
|
||||
$db->exec("BEGIN;"); //returns affected rows
|
||||
|
||||
//add the main dialplan include entry
|
||||
$dialplan_uuid = uuid();
|
||||
$sql = "insert into v_dialplans ";
|
||||
$sql .= "(";
|
||||
$sql .= "domain_uuid, ";
|
||||
$sql .= "dialplan_uuid, ";
|
||||
$sql .= "app_uuid, ";
|
||||
$sql .= "dialplan_name, ";
|
||||
$sql .= "dialplan_order, ";
|
||||
$sql .= "dialplan_continue, ";
|
||||
$sql .= "dialplan_context, ";
|
||||
$sql .= "dialplan_enabled, ";
|
||||
$sql .= "dialplan_description ";
|
||||
$sql .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'$domain_uuid', ";
|
||||
$sql .= "'$dialplan_uuid', ";
|
||||
$sql .= "'742714e5-8cdf-32fd-462c-cbe7e3d655db', ";
|
||||
$sql .= "'$dialplan_name', ";
|
||||
$sql .= "'$dialplan_order', ";
|
||||
$sql .= "'false', ";
|
||||
$sql .= "'$dialplan_context', ";
|
||||
$sql .= "'$dialplan_enabled', ";
|
||||
$sql .= "'$dialplan_description' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
|
||||
$array['dialplans'][0]['domain_uuid'] = $domain_uuid;
|
||||
$array['dialplans'][0]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplans'][0]['app_uuid'] = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
|
||||
$array['dialplans'][0]['dialplan_name'] = $dialplan_name;
|
||||
$array['dialplans'][0]['dialplan_order'] = $dialplan_order;
|
||||
$array['dialplans'][0]['dialplan_continue'] = 'false';
|
||||
$array['dialplans'][0]['dialplan_context'] = $dialplan_context;
|
||||
$array['dialplans'][0]['dialplan_enabled'] = $dialplan_enabled;
|
||||
$array['dialplans'][0]['dialplan_description'] = $dialplan_description;
|
||||
|
||||
//add condition 1
|
||||
$dialplan_detail_uuid = uuid();
|
||||
$sql = "insert into v_dialplan_details ";
|
||||
$sql .= "(";
|
||||
$sql .= "domain_uuid, ";
|
||||
$sql .= "dialplan_uuid, ";
|
||||
$sql .= "dialplan_detail_uuid, ";
|
||||
$sql .= "dialplan_detail_tag, ";
|
||||
$sql .= "dialplan_detail_type, ";
|
||||
$sql .= "dialplan_detail_data, ";
|
||||
$sql .= "dialplan_detail_order ";
|
||||
$sql .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'$domain_uuid', ";
|
||||
$sql .= "'$dialplan_uuid', ";
|
||||
$sql .= "'$dialplan_detail_uuid', ";
|
||||
$sql .= "'condition', ";
|
||||
$sql .= "'$condition_field_1', ";
|
||||
$sql .= "'$condition_expression_1', ";
|
||||
$sql .= "'1' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
|
||||
$array['dialplan_details'][0]['domain_uuid'] = $domain_uuid;
|
||||
$array['dialplan_details'][0]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplan_details'][0]['dialplan_detail_uuid'] = $dialplan_detail_uuid;
|
||||
$array['dialplan_details'][0]['dialplan_detail_tag'] = 'condition';
|
||||
$array['dialplan_details'][0]['dialplan_detail_type'] = $condition_field_1;
|
||||
$array['dialplan_details'][0]['dialplan_detail_data'] = $condition_expression_1;
|
||||
$array['dialplan_details'][0]['dialplan_detail_order'] = '1';
|
||||
|
||||
//add condition 2
|
||||
if (strlen($condition_field_2) > 0) {
|
||||
$dialplan_detail_uuid = uuid();
|
||||
$sql = "insert into v_dialplan_details ";
|
||||
$sql .= "(";
|
||||
$sql .= "domain_uuid, ";
|
||||
$sql .= "dialplan_uuid, ";
|
||||
$sql .= "dialplan_detail_uuid, ";
|
||||
$sql .= "dialplan_detail_tag, ";
|
||||
$sql .= "dialplan_detail_type, ";
|
||||
$sql .= "dialplan_detail_data, ";
|
||||
$sql .= "dialplan_detail_order ";
|
||||
$sql .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'$domain_uuid', ";
|
||||
$sql .= "'$dialplan_uuid', ";
|
||||
$sql .= "'$dialplan_detail_uuid', ";
|
||||
$sql .= "'condition', ";
|
||||
$sql .= "'$condition_field_2', ";
|
||||
$sql .= "'$condition_expression_2', ";
|
||||
$sql .= "'2' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
$array['dialplan_details'][1]['domain_uuid'] = $domain_uuid;
|
||||
$array['dialplan_details'][1]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplan_details'][1]['dialplan_detail_uuid'] = $dialplan_detail_uuid;
|
||||
$array['dialplan_details'][1]['dialplan_detail_tag'] = 'condition';
|
||||
$array['dialplan_details'][1]['dialplan_detail_type'] = $condition_field_2;
|
||||
$array['dialplan_details'][1]['dialplan_detail_data'] = $condition_expression_2;
|
||||
$array['dialplan_details'][1]['dialplan_detail_order'] = '2';
|
||||
}
|
||||
|
||||
//add action 1
|
||||
$dialplan_detail_uuid = uuid();
|
||||
$sql = "insert into v_dialplan_details ";
|
||||
$sql .= "(";
|
||||
$sql .= "domain_uuid, ";
|
||||
$sql .= "dialplan_uuid, ";
|
||||
$sql .= "dialplan_detail_uuid, ";
|
||||
$sql .= "dialplan_detail_tag, ";
|
||||
$sql .= "dialplan_detail_type, ";
|
||||
$sql .= "dialplan_detail_data, ";
|
||||
$sql .= "dialplan_detail_order ";
|
||||
$sql .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'$domain_uuid', ";
|
||||
$sql .= "'$dialplan_uuid', ";
|
||||
$sql .= "'$dialplan_detail_uuid', ";
|
||||
$sql .= "'action', ";
|
||||
$sql .= "'$action_application_1', ";
|
||||
$sql .= "'$action_data_1', ";
|
||||
$sql .= "'3' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
$array['dialplan_details'][2]['domain_uuid'] = $domain_uuid;
|
||||
$array['dialplan_details'][2]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplan_details'][2]['dialplan_detail_uuid'] = $dialplan_detail_uuid;
|
||||
$array['dialplan_details'][2]['dialplan_detail_tag'] = 'action';
|
||||
$array['dialplan_details'][2]['dialplan_detail_type'] = $action_application_1;
|
||||
$array['dialplan_details'][2]['dialplan_detail_data'] = $action_data_1;
|
||||
$array['dialplan_details'][2]['dialplan_detail_order'] = '3';
|
||||
|
||||
//add action 2
|
||||
if (strlen($action_application_2) > 0) {
|
||||
$dialplan_detail_uuid = uuid();
|
||||
$sql = "insert into v_dialplan_details ";
|
||||
$sql .= "(";
|
||||
$sql .= "domain_uuid, ";
|
||||
$sql .= "dialplan_uuid, ";
|
||||
$sql .= "dialplan_detail_uuid, ";
|
||||
$sql .= "dialplan_detail_tag, ";
|
||||
$sql .= "dialplan_detail_type, ";
|
||||
$sql .= "dialplan_detail_data, ";
|
||||
$sql .= "dialplan_detail_order ";
|
||||
$sql .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'$domain_uuid', ";
|
||||
$sql .= "'$dialplan_uuid', ";
|
||||
$sql .= "'$dialplan_detail_uuid', ";
|
||||
$sql .= "'action', ";
|
||||
$sql .= "'$action_application_2', ";
|
||||
$sql .= "'$action_data_2', ";
|
||||
$sql .= "'4' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
$array['dialplan_details'][3]['domain_uuid'] = $domain_uuid;
|
||||
$array['dialplan_details'][3]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplan_details'][3]['dialplan_detail_uuid'] = $dialplan_detail_uuid;
|
||||
$array['dialplan_details'][3]['dialplan_detail_tag'] = 'action';
|
||||
$array['dialplan_details'][3]['dialplan_detail_type'] = $action_application_2;
|
||||
$array['dialplan_details'][3]['dialplan_detail_data'] = $action_data_2;
|
||||
$array['dialplan_details'][3]['dialplan_detail_order'] = '4';
|
||||
}
|
||||
|
||||
//commit the atomic transaction
|
||||
$count = $db->exec("COMMIT;"); //returns affected rows
|
||||
|
||||
//execute inserts
|
||||
$database = new database;
|
||||
$database->app_name = 'dialplans';
|
||||
$database->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
//synchronize the xml config
|
||||
save_dialplan_xml();
|
||||
|
||||
|
|
@ -259,8 +183,8 @@
|
|||
//send a message and redirect the user
|
||||
message::add($text['message-update']);
|
||||
header("Location: ".PROJECT_PATH."/app/dialplans/dialplans.php");
|
||||
return;
|
||||
} //end if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
|
||||
exit;
|
||||
}
|
||||
|
||||
//initialize the destinations object
|
||||
$destination = new destinations;
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@
|
|||
$log = new Logging();
|
||||
|
||||
//set the http get/post variable(s) to a php variable
|
||||
if (isset($_REQUEST["id"])) {
|
||||
$id = check_str($_REQUEST["id"]);
|
||||
if (is_uuid($_REQUEST["id"])) {
|
||||
$id = $_REQUEST["id"];
|
||||
$log->log("debug", "isset id.");
|
||||
$log->log("debug", $id);
|
||||
}
|
||||
|
|
@ -61,60 +61,62 @@
|
|||
//get the dialplan data
|
||||
if (is_uuid($id)) {
|
||||
$sql = "select * from v_dialplans ";
|
||||
$sql .= "where dialplan_uuid = '$id' ";
|
||||
$log->log("debug", check_sql($sql));
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$dialplans = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
$log->log("debug", $result);
|
||||
foreach ($dialplans as &$row) {
|
||||
//create a new primary key for the new row
|
||||
$dialplan_uuid = uuid();
|
||||
$row['dialplan_uuid'] = $dialplan_uuid;
|
||||
$sql .= "where dialplan_uuid = :dialplan_uuid ";
|
||||
$parameters['dialplan_uuid'] = $id;
|
||||
$database = new database;
|
||||
$dialplans = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($dialplans) && @sizeof($dialplans) != 0) {
|
||||
foreach ($dialplans as &$row) {
|
||||
//create a new primary key for the new row
|
||||
$dialplan_uuid = uuid();
|
||||
$row['dialplan_uuid'] = $dialplan_uuid;
|
||||
|
||||
//get the app_uuid
|
||||
if (is_uuid($row["app_uuid"])) {
|
||||
//get the app uuid
|
||||
$app_uuid = $row["app_uuid"];
|
||||
//create a new app_uuid when copying a dialplan except for these exceptions
|
||||
switch ($app_uuid) {
|
||||
case "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4": break; //inbound routes
|
||||
case "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3": break; //outbound routes
|
||||
case "4b821450-926b-175a-af93-a03c441818b1": break; //time conditions
|
||||
default:
|
||||
$app_uuid = uuid();
|
||||
}
|
||||
//set the app uuid
|
||||
$row['app_uuid'] = $app_uuid;
|
||||
}
|
||||
//get the app_uuid
|
||||
if (is_uuid($row["app_uuid"])) {
|
||||
//get the app uuid
|
||||
$app_uuid = $row["app_uuid"];
|
||||
//create a new app_uuid when copying a dialplan except for these exceptions
|
||||
switch ($app_uuid) {
|
||||
case "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4": break; //inbound routes
|
||||
case "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3": break; //outbound routes
|
||||
case "4b821450-926b-175a-af93-a03c441818b1": break; //time conditions
|
||||
default:
|
||||
$app_uuid = uuid();
|
||||
}
|
||||
//set the app uuid
|
||||
$row['app_uuid'] = $app_uuid;
|
||||
}
|
||||
|
||||
//add copy to the name and description
|
||||
//$row['dialplan_name'] = $row['dialplan_name'].'-copy';
|
||||
if (strlen($row['dialplan_description']) == 0) {
|
||||
$dialplan_description = 'copy';
|
||||
}
|
||||
else {
|
||||
$dialplan_description = $row['dialplan_description'].'-copy';
|
||||
}
|
||||
$row['dialplan_description'] = $dialplan_description;
|
||||
//add copy to the name and description
|
||||
//$row['dialplan_name'] = $row['dialplan_name'].'-copy';
|
||||
if (strlen($row['dialplan_description']) == 0) {
|
||||
$dialplan_description = 'copy';
|
||||
}
|
||||
else {
|
||||
$dialplan_description = $row['dialplan_description'].'-copy';
|
||||
}
|
||||
$row['dialplan_description'] = $dialplan_description;
|
||||
}
|
||||
}
|
||||
unset ($prep_statement);
|
||||
unset($sql, $parameters, $row);
|
||||
}
|
||||
|
||||
//get the the dialplan details
|
||||
if (is_uuid($id)) {
|
||||
$sql = "select * from v_dialplan_details ";
|
||||
$sql .= "where dialplan_uuid = '$id' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$dialplan_details = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($dialplan_details as &$row) {
|
||||
//create a new primary key for the new row
|
||||
$row['dialplan_detail_uuid'] = uuid();
|
||||
//update the foreign relation uuid
|
||||
$row['dialplan_uuid'] = $dialplan_uuid;
|
||||
$sql .= "where dialplan_uuid = :dialplan_uuid ";
|
||||
$parameters['dialplan_uuid'] = $id;
|
||||
$database = new database;
|
||||
$dialplan_details = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($dialplan_details) && @sizeof($dialplan_details) != 0) {
|
||||
foreach ($dialplan_details as &$row) {
|
||||
//create a new primary key for the new row
|
||||
$row['dialplan_detail_uuid'] = uuid();
|
||||
//update the foreign relation uuid
|
||||
$row['dialplan_uuid'] = $dialplan_uuid;
|
||||
}
|
||||
}
|
||||
unset ($prep_statement);
|
||||
unset($sql, $parameters);
|
||||
}
|
||||
|
||||
//build the array
|
||||
|
|
@ -123,17 +125,13 @@
|
|||
$array['dialplans'][0]['dialplan_details'] = $dialplan_details;
|
||||
}
|
||||
|
||||
//debug info
|
||||
//echo "<pre>".print_r($array, true)."</pre>\n";
|
||||
//exit;
|
||||
|
||||
//add or update the database
|
||||
$database = new database;
|
||||
$database->app_name = 'dialplans';
|
||||
$database->app_uuid = $app_uuid;
|
||||
$database->uuid($dialplan_uuid);
|
||||
$database->save($array);
|
||||
//$message = $database->message;
|
||||
unset($array);
|
||||
|
||||
//update the dialplan xml
|
||||
$dialplans = new dialplan;
|
||||
|
|
|
|||
|
|
@ -48,10 +48,10 @@
|
|||
|
||||
//set the dialplan uuid
|
||||
$dialplan_uuids = $_REQUEST["id"];
|
||||
$app_uuid = check_str($_REQUEST['app_uuid']);
|
||||
$app_uuid = $_REQUEST['app_uuid'];
|
||||
|
||||
//delete the dialplans
|
||||
if (sizeof($dialplan_uuids) > 0) {
|
||||
if (is_array($dialplan_uuids) && @sizeof($dialplan_uuids) != 0) {
|
||||
|
||||
//get dialplan contexts
|
||||
foreach ($dialplan_uuids as $dialplan_uuid) {
|
||||
|
|
@ -60,41 +60,43 @@
|
|||
|
||||
//get the dialplan data
|
||||
$sql = "select * from v_dialplans ";
|
||||
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$database_dialplan_uuid = $row["dialplan_uuid"];
|
||||
$dialplan_contexts[] = $row["dialplan_context"];
|
||||
$sql .= "where dialplan_uuid = :dialplan_uuid ";
|
||||
$parameters['dialplan_uuid'] = $dialplan_uuid;
|
||||
$database = new database;
|
||||
$result = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
foreach ($result as &$row) {
|
||||
$database_dialplan_uuid = $row["dialplan_uuid"];
|
||||
$dialplan_contexts[] = $row["dialplan_context"];
|
||||
}
|
||||
}
|
||||
unset($prep_statement);
|
||||
unset($sql, $parameters, $result, $row);
|
||||
}
|
||||
|
||||
//start the atomic transaction
|
||||
$db->beginTransaction();
|
||||
|
||||
//delete dialplan and details
|
||||
$dialplans_deleted = 0;
|
||||
foreach ($dialplan_uuids as $dialplan_uuid) {
|
||||
|
||||
//delete child data
|
||||
$sql = "delete from v_dialplan_details ";
|
||||
$sql .= "where dialplan_uuid = '".$dialplan_uuid."'; ";
|
||||
$db->query($sql);
|
||||
unset($sql);
|
||||
|
||||
//delete parent data
|
||||
$sql = "delete from v_dialplans ";
|
||||
$sql .= "where dialplan_uuid = '".$dialplan_uuid."'; ";
|
||||
$db->query($sql);
|
||||
unset($sql);
|
||||
|
||||
$dialplans_deleted++;
|
||||
foreach ($dialplan_uuids as $index => $dialplan_uuid) {
|
||||
//child data
|
||||
$array['dialplan_details'][$index]['dialplan_uuid'] = $dialplan_uuid;
|
||||
//parent data
|
||||
$array['dialplans'][$index]['dialplan_uuid'] = $dialplan_uuid;
|
||||
//increment counter
|
||||
$dialplans_deleted++;
|
||||
}
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
$p = new permissions;
|
||||
$p->add('dialplan_delete', 'temp');
|
||||
$p->add('dialplan_detail_delete', 'temp');
|
||||
|
||||
//commit the atomic transaction
|
||||
$db->commit();
|
||||
$database = new database;
|
||||
$database->app_name = 'dialplans';
|
||||
$database->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
|
||||
$p->delete('dialplan_delete', 'temp');
|
||||
$p->delete('dialplan_detail_delete', 'temp');
|
||||
}
|
||||
|
||||
//synchronize the xml config
|
||||
save_dialplan_xml();
|
||||
|
|
|
|||
|
|
@ -47,20 +47,26 @@
|
|||
$text = $language->get();
|
||||
|
||||
//set the variables
|
||||
if (count($_GET) > 0) {
|
||||
$dialplan_detail_uuid = check_str($_GET["id"]);
|
||||
$dialplan_uuid = check_str($_REQUEST["dialplan_uuid"]);
|
||||
$app_uuid = check_str($_REQUEST["app_uuid"]);
|
||||
}
|
||||
$dialplan_detail_uuid = $_GET["id"];
|
||||
$dialplan_uuid = $_REQUEST["dialplan_uuid"];
|
||||
$app_uuid = $_REQUEST["app_uuid"];
|
||||
|
||||
//delete the dialplan detail
|
||||
if (is_uuid($dialplan_detail_uuid)) {
|
||||
//delete child data
|
||||
$sql = "delete from v_dialplan_details ";
|
||||
//$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "where dialplan_detail_uuid = '$dialplan_detail_uuid' ";
|
||||
$db->query($sql);
|
||||
unset($sql);
|
||||
$array['dialplan_details'][0]['dialplan_detail_uuid'] = $dialplan_detail_uuid;
|
||||
//$array['dialplan_details'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
|
||||
$p = new permissions;
|
||||
$p->add('dialplan_detail_delete', 'temp');
|
||||
|
||||
$database = new database;
|
||||
$database->app_name = 'dialplans';
|
||||
$database->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
|
||||
$p->delete('dialplan_detail_delete', 'temp');
|
||||
|
||||
//synchronize the xml config
|
||||
save_dialplan_xml();
|
||||
|
|
@ -75,10 +81,10 @@
|
|||
$dialplans->destination = "database";
|
||||
$dialplans->uuid = $dialplan_uuid;
|
||||
$dialplans->xml();
|
||||
}
|
||||
|
||||
//save the message to a session variable
|
||||
message::add($text['message-delete']);
|
||||
//set message
|
||||
message::add($text['message-delete']);
|
||||
}
|
||||
|
||||
//redirect the browser
|
||||
header("Location: dialplan_edit.php?id=".$dialplan_uuid.(($app_uuid != '') ? "&app_uuid=".$app_uuid : null));
|
||||
|
|
|
|||
|
|
@ -48,33 +48,33 @@ else {
|
|||
$text = $language->get();
|
||||
|
||||
//set the action as an add or update
|
||||
if (isset($_REQUEST["id"])) {
|
||||
if (is_uuid($_REQUEST["id"])) {
|
||||
$action = "update";
|
||||
$dialplan_detail_uuid = check_str($_REQUEST["id"]);
|
||||
$dialplan_detail_uuid = $_REQUEST["id"];
|
||||
}
|
||||
else {
|
||||
$action = "add";
|
||||
}
|
||||
$dialplan_uuid = check_str($_REQUEST["dialplan_uuid"]);
|
||||
$dialplan_uuid = $_REQUEST["dialplan_uuid"];
|
||||
|
||||
//get the http values and set them as php variables
|
||||
$app_uuid = check_str($_REQUEST["app_uuid"]);
|
||||
$app_uuid = $_REQUEST["app_uuid"];
|
||||
if (count($_POST)>0) {
|
||||
$dialplan_uuid = check_str($_POST["dialplan_uuid"]);
|
||||
$dialplan_detail_tag = check_str($_POST["dialplan_detail_tag"]);
|
||||
$dialplan_detail_order = check_str($_POST["dialplan_detail_order"]);
|
||||
$dialplan_detail_type = check_str($_POST["dialplan_detail_type"]);
|
||||
$dialplan_detail_data = check_str($_POST["dialplan_detail_data"]);
|
||||
$dialplan_detail_break = check_str($_POST["dialplan_detail_break"]);
|
||||
$dialplan_detail_inline = check_str($_POST["dialplan_detail_inline"]);
|
||||
$dialplan_detail_group = check_str($_POST["dialplan_detail_group"]);
|
||||
$dialplan_uuid = $_POST["dialplan_uuid"];
|
||||
$dialplan_detail_tag = $_POST["dialplan_detail_tag"];
|
||||
$dialplan_detail_order = $_POST["dialplan_detail_order"];
|
||||
$dialplan_detail_type = $_POST["dialplan_detail_type"];
|
||||
$dialplan_detail_data = $_POST["dialplan_detail_data"];
|
||||
$dialplan_detail_break = $_POST["dialplan_detail_break"];
|
||||
$dialplan_detail_inline = $_POST["dialplan_detail_inline"];
|
||||
$dialplan_detail_group = $_POST["dialplan_detail_group"];
|
||||
}
|
||||
|
||||
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
|
||||
$msg = '';
|
||||
if ($action == "update") {
|
||||
$dialplan_detail_uuid = check_str($_POST["dialplan_detail_uuid"]);
|
||||
$dialplan_detail_uuid = $_POST["dialplan_detail_uuid"];
|
||||
}
|
||||
|
||||
//check for all required data
|
||||
|
|
@ -99,39 +99,27 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
|||
if ($_POST["persistformvar"] != "true") {
|
||||
if ($action == "add" && permission_exists('dialplan_add')) {
|
||||
$dialplan_detail_uuid = uuid();
|
||||
$sql = "insert into v_dialplan_details ";
|
||||
$sql .= "(";
|
||||
$sql .= "dialplan_uuid, ";
|
||||
$sql .= "dialplan_detail_uuid, ";
|
||||
$sql .= "dialplan_detail_tag, ";
|
||||
$sql .= "dialplan_detail_order, ";
|
||||
$sql .= "dialplan_detail_type, ";
|
||||
$sql .= "dialplan_detail_data, ";
|
||||
$sql .= "dialplan_detail_break, ";
|
||||
$sql .= "dialplan_detail_inline, ";
|
||||
$sql .= "dialplan_detail_group, ";
|
||||
$sql .= "domain_uuid ";
|
||||
$sql .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'$dialplan_uuid', ";
|
||||
$sql .= "'$dialplan_detail_uuid', ";
|
||||
$sql .= "'$dialplan_detail_tag', ";
|
||||
$sql .= "'$dialplan_detail_order', ";
|
||||
$sql .= "'$dialplan_detail_type', ";
|
||||
$sql .= "'$dialplan_detail_data', ";
|
||||
$sql .= "'$dialplan_detail_break', ";
|
||||
$sql .= "'$dialplan_detail_inline', ";
|
||||
if (strlen($dialplan_detail_group) == 0) {
|
||||
$sql .= "null, ";
|
||||
}
|
||||
else {
|
||||
$sql .= "'$dialplan_detail_group', ";
|
||||
}
|
||||
$sql .= "'".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
$array['dialplan_details'][0]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplan_details'][0]['dialplan_detail_uuid'] = $dialplan_detail_uuid;
|
||||
$array['dialplan_details'][0]['dialplan_detail_tag'] = $dialplan_detail_tag;
|
||||
$array['dialplan_details'][0]['dialplan_detail_order'] = $dialplan_detail_order;
|
||||
$array['dialplan_details'][0]['dialplan_detail_type'] = $dialplan_detail_type;
|
||||
$array['dialplan_details'][0]['dialplan_detail_data'] = $dialplan_detail_data;
|
||||
$array['dialplan_details'][0]['dialplan_detail_break'] = $dialplan_detail_break;
|
||||
$array['dialplan_details'][0]['dialplan_detail_inline'] = $dialplan_detail_inline;
|
||||
$array['dialplan_details'][0]['dialplan_detail_group'] = $dialplan_detail_group != '' ? $dialplan_detail_group : null;
|
||||
$array['dialplan_details'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
|
||||
$p = new permissions;
|
||||
$p->add('dialplan_detail_add', 'temp');
|
||||
|
||||
$database = new database;
|
||||
$database->app_name = 'dialplans';
|
||||
$database->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
$p->delete('dialplan_detail_add', 'temp');
|
||||
|
||||
//synchronize the xml config
|
||||
save_dialplan_xml();
|
||||
|
|
@ -144,27 +132,33 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
|||
message::add($text['message-add']);
|
||||
header("Location: dialplan_edit.php?id=".$dialplan_uuid."&app_uuid=".$app_uuid);
|
||||
return;
|
||||
} //if ($action == "add")
|
||||
}
|
||||
|
||||
if ($action == "update" && permission_exists('dialplan_edit')) {
|
||||
$sql = "update v_dialplan_details set ";
|
||||
$sql .= "dialplan_uuid = '$dialplan_uuid', ";
|
||||
$sql .= "dialplan_detail_tag = '$dialplan_detail_tag', ";
|
||||
$sql .= "dialplan_detail_order = '$dialplan_detail_order', ";
|
||||
$sql .= "dialplan_detail_type = '$dialplan_detail_type', ";
|
||||
$sql .= "dialplan_detail_data = '$dialplan_detail_data', ";
|
||||
$sql .= "dialplan_detail_break = '$dialplan_detail_break', ";
|
||||
$sql .= "dialplan_detail_inline = '$dialplan_detail_inline', ";
|
||||
if (strlen($dialplan_detail_group) == 0) {
|
||||
$sql .= "dialplan_detail_group = null ";
|
||||
}
|
||||
else {
|
||||
$sql .= "dialplan_detail_group = '$dialplan_detail_group' ";
|
||||
}
|
||||
$sql .= "where (domain_uuid = '".$_SESSION['domain_uuid']."' or domain_uuid is null) ";
|
||||
$sql .= "and dialplan_detail_uuid = '$dialplan_detail_uuid'";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
$sql .= "dialplan_uuid = :dialplan_uuid ";
|
||||
$sql .= "dialplan_detail_tag = :dialplan_detail_tag, ";
|
||||
$sql .= "dialplan_detail_order = :dialplan_detail_order, ";
|
||||
$sql .= "dialplan_detail_type = :dialplan_detail_type, ";
|
||||
$sql .= "dialplan_detail_data = :dialplan_detail_data, ";
|
||||
$sql .= "dialplan_detail_break = :dialplan_detail_break, ";
|
||||
$sql .= "dialplan_detail_inline = :dialplan_detail_inline, ";
|
||||
$sql .= "dialplan_detail_group = :dialplan_detail_group ";
|
||||
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$sql .= "and dialplan_detail_uuid = :dialplan_detail_uuid ";
|
||||
$parameters['dialplan_uuid'] = $dialplan_uuid;
|
||||
$parameters['dialplan_detail_tag'] = $dialplan_detail_tag;
|
||||
$parameters['dialplan_detail_order'] = $dialplan_detail_order;
|
||||
$parameters['dialplan_detail_type'] = $dialplan_detail_type;
|
||||
$parameters['dialplan_detail_data'] = $dialplan_detail_data;
|
||||
$parameters['dialplan_detail_break'] = $dialplan_detail_break;
|
||||
$parameters['dialplan_detail_inline'] = $dialplan_detail_inline;
|
||||
$parameters['dialplan_detail_group'] = $dialplan_detail_group != '' ? $dialplan_detail_group : null;
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$parameters['dialplan_detail_uuid'] = $dialplan_detail_uuid;
|
||||
$database = new database;
|
||||
$database->execute($sql, $parameters);
|
||||
unset($sql, $parameters);
|
||||
|
||||
//synchronize the xml config
|
||||
save_dialplan_xml();
|
||||
|
|
@ -187,12 +181,13 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
|||
if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
|
||||
$dialplan_detail_uuid = $_GET["id"];
|
||||
$sql = "select * from v_dialplan_details ";
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "and dialplan_detail_uuid = '$dialplan_detail_uuid' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$sql .= "and dialplan_detail_uuid = :dialplan_detail_uuid ";
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
$parameters['dialplan_detail_uuid'] = $dialplan_detail_uuid;
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
if (is_array($row) && @sizeof($row) != 0) {
|
||||
$dialplan_uuid = $row["dialplan_uuid"];
|
||||
$dialplan_detail_tag = $row["dialplan_detail_tag"];
|
||||
$dialplan_detail_order = $row["dialplan_detail_order"];
|
||||
|
|
@ -202,7 +197,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
|||
$dialplan_detail_inline = $row["dialplan_detail_inline"];
|
||||
$dialplan_detail_group = $row["dialplan_detail_group"];
|
||||
}
|
||||
unset ($prep_statement);
|
||||
unset($sql, $parameters, $row);
|
||||
}
|
||||
|
||||
//show the header
|
||||
|
|
|
|||
|
|
@ -63,22 +63,21 @@
|
|||
}
|
||||
|
||||
//set the app_uuid
|
||||
if (strlen($_GET["app_uuid"]) > 0) {
|
||||
if (is_uuid($_GET["app_uuid"])) {
|
||||
$app_uuid = $_GET["app_uuid"];
|
||||
}
|
||||
|
||||
//get the http post values and set them as php variables
|
||||
if (count($_POST) > 0) {
|
||||
$hostname = check_str($_POST["hostname"]);
|
||||
$dialplan_name = check_str($_POST["dialplan_name"]);
|
||||
$dialplan_number = check_str($_POST["dialplan_number"]);
|
||||
$dialplan_order = check_str($_POST["dialplan_order"]);
|
||||
$dialplan_continue = check_str($_POST["dialplan_continue"]);
|
||||
$hostname = $_POST["hostname"];
|
||||
$dialplan_name = $_POST["dialplan_name"];
|
||||
$dialplan_number = $_POST["dialplan_number"];
|
||||
$dialplan_order = $_POST["dialplan_order"];
|
||||
$dialplan_continue = $_POST["dialplan_continue"] != '' ? $_POST["dialplan_continue"] : 'false';
|
||||
$dialplan_details = $_POST["dialplan_details"];
|
||||
if (strlen($dialplan_continue) == 0) { $dialplan_continue = "false"; }
|
||||
$dialplan_context = check_str($_POST["dialplan_context"]);
|
||||
$dialplan_enabled = check_str($_POST["dialplan_enabled"]);
|
||||
$dialplan_description = check_str($_POST["dialplan_description"]);
|
||||
$dialplan_context = $_POST["dialplan_context"];
|
||||
$dialplan_enabled = $_POST["dialplan_enabled"];
|
||||
$dialplan_description = $_POST["dialplan_description"];
|
||||
}
|
||||
|
||||
//get the list of applications
|
||||
|
|
@ -131,14 +130,14 @@
|
|||
|
||||
//build the array
|
||||
$x = 0;
|
||||
if (isset($_POST["dialplan_uuid"])) {
|
||||
if (is_uuid($_POST["dialplan_uuid"])) {
|
||||
$array['dialplans'][$x]['dialplan_uuid'] = $_POST["dialplan_uuid"];
|
||||
}
|
||||
else {
|
||||
$dialplan_uuid = uuid();
|
||||
$array['dialplans'][$x]['dialplan_uuid'] = $dialplan_uuid;
|
||||
}
|
||||
if (isset($_POST["domain_uuid"])) {
|
||||
if (is_uuid($_POST["domain_uuid"])) {
|
||||
$array['dialplans'][$x]['domain_uuid'] = $_POST['domain_uuid'];
|
||||
}
|
||||
else {
|
||||
|
|
@ -183,7 +182,7 @@
|
|||
$database->app_uuid = $app_uuid;
|
||||
$database->uuid($dialplan_uuid);
|
||||
$database->save($array);
|
||||
$message = $database->message;
|
||||
unset($array);
|
||||
}
|
||||
|
||||
//update the dialplan xml
|
||||
|
|
@ -207,7 +206,7 @@
|
|||
else if ($action == "update") {
|
||||
message::add($text['message-update']);
|
||||
}
|
||||
header("Location: ?id=".escape($dialplan_uuid).(($app_uuid != '') ? "&app_uuid=".escape($app_uuid) : null));
|
||||
header("Location: ?id=".escape($dialplan_uuid).(is_uuid($app_uuid) ? "&app_uuid=".$app_uuid : null));
|
||||
exit;
|
||||
|
||||
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
|
||||
|
|
@ -215,11 +214,11 @@
|
|||
//pre-populate the form
|
||||
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
|
||||
$sql = "select * from v_dialplans ";
|
||||
$sql .= "where dialplan_uuid = '$dialplan_uuid' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
if (is_array($result)) foreach ($result as &$row) {
|
||||
$sql .= "where dialplan_uuid = :dialplan_uuid ";
|
||||
$parameters['dialplan_uuid'] = $dialplan_uuid;
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
if (is_array($row) && @sizeof($row) != 0) {
|
||||
$domain_uuid = $row["domain_uuid"];
|
||||
$hostname = $row["hostname"];
|
||||
$dialplan_name = $row["dialplan_name"];
|
||||
|
|
@ -231,7 +230,7 @@
|
|||
$dialplan_enabled = $row["dialplan_enabled"];
|
||||
$dialplan_description = $row["dialplan_description"];
|
||||
}
|
||||
unset ($prep_statement);
|
||||
unset($sql, $parameters, $row);
|
||||
}
|
||||
|
||||
//set the defaults
|
||||
|
|
@ -248,13 +247,12 @@
|
|||
|
||||
//get the dialplan details in an array
|
||||
$sql = "select * from v_dialplan_details ";
|
||||
$sql .= "where dialplan_uuid = '$dialplan_uuid' ";
|
||||
$sql .= "where dialplan_uuid = :dialplan_uuid ";
|
||||
$sql .= "order by dialplan_detail_group asc, dialplan_detail_order asc";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
$result_count = count($result);
|
||||
unset ($prep_statement, $sql);
|
||||
$parameters['dialplan_uuid'] = $dialplan_uuid;
|
||||
$database = new database;
|
||||
$result = $database->select($sql, $parameters, 'all');
|
||||
unset($sql, $parameters);
|
||||
|
||||
//create a new array that is sorted into groups and put the tags in order conditions, actions, anti-actions
|
||||
//set the array index
|
||||
|
|
@ -262,69 +260,81 @@
|
|||
//define the array
|
||||
$details = array();
|
||||
//conditions
|
||||
if (is_array($result)) foreach($result as $row) {
|
||||
if ($row['dialplan_detail_tag'] == "condition") {
|
||||
$group = $row['dialplan_detail_group'];
|
||||
foreach ($row as $key => $val) {
|
||||
$details[$group][$x][$key] = $val;
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
foreach ($result as $row) {
|
||||
if ($row['dialplan_detail_tag'] == "condition") {
|
||||
$group = $row['dialplan_detail_group'];
|
||||
foreach ($row as $key => $val) {
|
||||
$details[$group][$x][$key] = $val;
|
||||
}
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
//regex
|
||||
if (is_array($result)) foreach($result as $row) {
|
||||
if ($row['dialplan_detail_tag'] == "regex") {
|
||||
$group = $row['dialplan_detail_group'];
|
||||
foreach ($row as $key => $val) {
|
||||
$details[$group][$x][$key] = $val;
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
foreach ($result as $row) {
|
||||
if ($row['dialplan_detail_tag'] == "regex") {
|
||||
$group = $row['dialplan_detail_group'];
|
||||
foreach ($row as $key => $val) {
|
||||
$details[$group][$x][$key] = $val;
|
||||
}
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
//actions
|
||||
if (is_array($result)) foreach($result as $row) {
|
||||
if ($row['dialplan_detail_tag'] == "action") {
|
||||
$group = $row['dialplan_detail_group'];
|
||||
foreach ($row as $key => $val) {
|
||||
$details[$group][$x][$key] = $val;
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
foreach ($result as $row) {
|
||||
if ($row['dialplan_detail_tag'] == "action") {
|
||||
$group = $row['dialplan_detail_group'];
|
||||
foreach ($row as $key => $val) {
|
||||
$details[$group][$x][$key] = $val;
|
||||
}
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
//anti-actions
|
||||
if (is_array($result)) foreach($result as $row) {
|
||||
if ($row['dialplan_detail_tag'] == "anti-action") {
|
||||
$group = $row['dialplan_detail_group'];
|
||||
foreach ($row as $key => $val) {
|
||||
$details[$group][$x][$key] = $val;
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
foreach ($result as $row) {
|
||||
if ($row['dialplan_detail_tag'] == "anti-action") {
|
||||
$group = $row['dialplan_detail_group'];
|
||||
foreach ($row as $key => $val) {
|
||||
$details[$group][$x][$key] = $val;
|
||||
}
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
unset($result);
|
||||
//blank row
|
||||
if (is_array($details)) foreach($details as $group => $row) {
|
||||
//set the array key for the empty row
|
||||
$x = "999";
|
||||
//get the highest dialplan_detail_order
|
||||
if (is_array($row)) foreach ($row as $key => $field) {
|
||||
$dialplan_detail_order = 0;
|
||||
if ($dialplan_detail_order < $field['dialplan_detail_order']) {
|
||||
$dialplan_detail_order = $field['dialplan_detail_order'];
|
||||
if (is_array($details) && @sizeof($details) != 0) {
|
||||
foreach ($details as $group => $row) {
|
||||
//set the array key for the empty row
|
||||
$x = "999";
|
||||
//get the highest dialplan_detail_order
|
||||
if (is_array($row) && @sizeof($details) != 0) {
|
||||
foreach ($row as $key => $field) {
|
||||
$dialplan_detail_order = 0;
|
||||
if ($dialplan_detail_order < $field['dialplan_detail_order']) {
|
||||
$dialplan_detail_order = $field['dialplan_detail_order'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//increment the highest order by 5
|
||||
$dialplan_detail_order = $dialplan_detail_order + 10;
|
||||
//set the rest of the empty array
|
||||
//$details[$group][$x]['domain_uuid'] = '';
|
||||
//$details[$group][$x]['dialplan_uuid'] = '';
|
||||
$details[$group][$x]['dialplan_detail_tag'] = '';
|
||||
$details[$group][$x]['dialplan_detail_type'] = '';
|
||||
$details[$group][$x]['dialplan_detail_data'] = '';
|
||||
$details[$group][$x]['dialplan_detail_break'] = '';
|
||||
$details[$group][$x]['dialplan_detail_inline'] = '';
|
||||
$details[$group][$x]['dialplan_detail_group'] = $group;
|
||||
$details[$group][$x]['dialplan_detail_order'] = $dialplan_detail_order;
|
||||
//increment the highest order by 5
|
||||
$dialplan_detail_order = $dialplan_detail_order + 10;
|
||||
//set the rest of the empty array
|
||||
//$details[$group][$x]['domain_uuid'] = '';
|
||||
//$details[$group][$x]['dialplan_uuid'] = '';
|
||||
$details[$group][$x]['dialplan_detail_tag'] = '';
|
||||
$details[$group][$x]['dialplan_detail_type'] = '';
|
||||
$details[$group][$x]['dialplan_detail_data'] = '';
|
||||
$details[$group][$x]['dialplan_detail_break'] = '';
|
||||
$details[$group][$x]['dialplan_detail_inline'] = '';
|
||||
$details[$group][$x]['dialplan_detail_group'] = $group;
|
||||
$details[$group][$x]['dialplan_detail_order'] = $dialplan_detail_order;
|
||||
}
|
||||
}
|
||||
//sort the details array by group number
|
||||
if (is_array($details)) {
|
||||
|
|
@ -521,18 +531,20 @@
|
|||
echo " </td>\n";
|
||||
echo " <td class='vtable' align='left'>\n";
|
||||
echo " <select class='formfld' name='domain_uuid'>\n";
|
||||
if (strlen($domain_uuid) == 0) {
|
||||
if (!is_uuid($domain_uuid)) {
|
||||
echo " <option value='' selected='selected'>".$text['select-global']."</option>\n";
|
||||
}
|
||||
else {
|
||||
echo " <option value=''>".$text['select-global']."</option>\n";
|
||||
}
|
||||
if (is_array($_SESSION['domains'])) foreach ($_SESSION['domains'] as $row) {
|
||||
if ($row['domain_uuid'] == $domain_uuid) {
|
||||
echo " <option value='".escape($row['domain_uuid'])."' selected='selected'>".escape($row['domain_name'])."</option>\n";
|
||||
}
|
||||
else {
|
||||
echo " <option value='".escape($row['domain_uuid'])."'>".escape($row['domain_name'])."</option>\n";
|
||||
if (is_array($_SESSION['domains']) && @sizeof($_SESSION['domains']) != 0) {
|
||||
foreach ($_SESSION['domains'] as $row) {
|
||||
if ($row['domain_uuid'] == $domain_uuid) {
|
||||
echo " <option value='".escape($row['domain_uuid'])."' selected='selected'>".escape($row['domain_name'])."</option>\n";
|
||||
}
|
||||
else {
|
||||
echo " <option value='".escape($row['domain_uuid'])."'>".escape($row['domain_name'])."</option>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
echo " </select>\n";
|
||||
|
|
@ -599,7 +611,7 @@
|
|||
<?php
|
||||
|
||||
//display the results
|
||||
if (is_array($details)) {
|
||||
if (is_array($details) && @sizeof($details) != 0) {
|
||||
|
||||
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0' style='margin: -2px; border-spacing: 2px;'>\n";
|
||||
|
||||
|
|
@ -621,231 +633,233 @@
|
|||
echo "<td> </td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
if (is_array($group)) foreach($group as $index => $row) {
|
||||
if (is_array($group) && @sizeof($group) != 0) {
|
||||
foreach($group as $index => $row) {
|
||||
|
||||
//get the values from the database and set as variables
|
||||
$dialplan_detail_uuid = $row['dialplan_detail_uuid'];
|
||||
$dialplan_detail_tag = $row['dialplan_detail_tag'];
|
||||
$dialplan_detail_type = $row['dialplan_detail_type'];
|
||||
$dialplan_detail_data = $row['dialplan_detail_data'];
|
||||
$dialplan_detail_break = $row['dialplan_detail_break'];
|
||||
$dialplan_detail_inline = $row['dialplan_detail_inline'];
|
||||
$dialplan_detail_group = $row['dialplan_detail_group'];
|
||||
$dialplan_detail_order = $row['dialplan_detail_order'];
|
||||
//get the values from the database and set as variables
|
||||
$dialplan_detail_uuid = $row['dialplan_detail_uuid'];
|
||||
$dialplan_detail_tag = $row['dialplan_detail_tag'];
|
||||
$dialplan_detail_type = $row['dialplan_detail_type'];
|
||||
$dialplan_detail_data = $row['dialplan_detail_data'];
|
||||
$dialplan_detail_break = $row['dialplan_detail_break'];
|
||||
$dialplan_detail_inline = $row['dialplan_detail_inline'];
|
||||
$dialplan_detail_group = $row['dialplan_detail_group'];
|
||||
$dialplan_detail_order = $row['dialplan_detail_order'];
|
||||
|
||||
//no border on last row
|
||||
$no_border = ($index == 999) ? "border: none;" : null;
|
||||
//no border on last row
|
||||
$no_border = ($index == 999) ? "border: none;" : null;
|
||||
|
||||
//begin the row
|
||||
echo "<tr>\n";
|
||||
//determine whether to hide the element
|
||||
if (strlen($dialplan_detail_tag) == 0) {
|
||||
$element['hidden'] = false;
|
||||
$element['visibility'] = "";
|
||||
}
|
||||
else {
|
||||
$element['hidden'] = true;
|
||||
$element['visibility'] = "display: none;";
|
||||
}
|
||||
//add the primary key uuid
|
||||
if (strlen($dialplan_detail_uuid) > 0) {
|
||||
echo " <input name='dialplan_details[".$x."][dialplan_detail_uuid]' type='hidden' value=\"".escape($dialplan_detail_uuid)."\">\n";
|
||||
}
|
||||
//tag
|
||||
$selected = "selected=\"selected\" ";
|
||||
echo "<td class='vtablerow' style='".$no_border."' onclick=\"label_to_form('label_dialplan_detail_tag_".$x."','dialplan_detail_tag_".$x."');\" nowrap='nowrap'>\n";
|
||||
if ($element['hidden']) {
|
||||
echo " <label id=\"label_dialplan_detail_tag_".$x."\">".escape($dialplan_detail_tag)."</label>\n";
|
||||
}
|
||||
echo " <select id='dialplan_detail_tag_".$x."' name='dialplan_details[".$x."][dialplan_detail_tag]' class='formfld' style='width: 97px; ".$element['visibility']."'>\n";
|
||||
echo " <option></option>\n";
|
||||
echo " <option value='condition' ".($dialplan_detail_tag == "condition" ? $selected : null).">".$text['option-condition']."</option>\n";
|
||||
echo " <option value='regex' ".($dialplan_detail_tag == "regex" ? $selected : null).">".$text['option-regex']."</option>\n";
|
||||
echo " <option value='action' ".($dialplan_detail_tag == "action" ? $selected : null).">".$text['option-action']."</option>\n";
|
||||
echo " <option value='anti-action' ".($dialplan_detail_tag == "anti-action" ? $selected : null).">".$text['option-anti-action']."</option>\n";
|
||||
echo " </select>\n";
|
||||
echo "</td>\n";
|
||||
//type
|
||||
echo "<td class='vtablerow' style='".$no_border."' onclick=\"label_to_form('label_dialplan_detail_type_".$x."','dialplan_detail_type_".$x."');\" nowrap='nowrap'>\n";
|
||||
if ($element['hidden']) {
|
||||
echo " <label id=\"label_dialplan_detail_type_".$x."\">".escape($dialplan_detail_type)."</label>\n";
|
||||
}
|
||||
echo " <select id='dialplan_detail_type_".$x."' name='dialplan_details[".$x."][dialplan_detail_type]' class='formfld' style='width: auto; ".$element['visibility']."' onchange='change_to_input(this);'>\n";
|
||||
if (strlen($dialplan_detail_type) > 0) {
|
||||
echo " <optgroup label='selected'>\n";
|
||||
echo " <option value=\"".escape($dialplan_detail_type)."\">".escape($dialplan_detail_type)."</option>\n";
|
||||
echo " </optgroup>\n";
|
||||
}
|
||||
else {
|
||||
echo " <option value=''></option>\n";
|
||||
}
|
||||
//if (strlen($dialplan_detail_tag) == 0 || $dialplan_detail_tag == "condition" || $dialplan_detail_tag == "regex") {
|
||||
echo " <optgroup label='".$text['optgroup-condition_or_regex']."'>\n";
|
||||
echo " <option value='context'>".$text['option-context']."</option>\n";
|
||||
echo " <option value='username'>".$text['option-username']."</option>\n";
|
||||
echo " <option value='rdnis'>".$text['option-rdnis']."</option>\n";
|
||||
echo " <option value='destination_number'>".$text['option-destination_number']."</option>\n";
|
||||
echo " <option value='dialplan'>".$text['option-dialplan']."</option>\n";
|
||||
echo " <option value='caller_id_name'>".$text['option-caller_id_name']."</option>\n";
|
||||
echo " <option value='caller_id_number'>".$text['option-caller_id_number']."</option>\n";
|
||||
echo " <option value='ani'>".$text['option-ani']."</option>\n";
|
||||
echo " <option value='ani2'>".$text['option-ani2']."</option>\n";
|
||||
echo " <option value='uuid'>".$text['option-uuid']."</option>\n";
|
||||
echo " <option value='source'>".$text['option-source']."</option>\n";
|
||||
echo " <option value='chan_name'>".$text['option-chan_name']."</option>\n";
|
||||
echo " <option value='network_addr'>".$text['option-network_addr']."</option>\n";
|
||||
echo " <option value='\${number_alias}'>\${number_alias}</option>\n";
|
||||
echo " <option value='\${sip_from_uri}'>\${sip_from_uri}</option>\n";
|
||||
echo " <option value='\${sip_from_user}'>\${sip_from_user}</option>\n";
|
||||
echo " <option value='\${sip_from_host}'>\${sip_from_host}</option>\n";
|
||||
echo " <option value='\${sip_contact_uri}'>\${sip_contact_uri}</option>\n";
|
||||
echo " <option value='\${sip_contact_user}'>\${sip_contact_user}</option>\n";
|
||||
echo " <option value='\${sip_contact_host}'>\${sip_contact_host}</option>\n";
|
||||
echo " <option value='\${sip_to_uri}'>\${sip_to_uri}</option>\n";
|
||||
echo " <option value='\${sip_to_user}'>\${sip_to_user}</option>\n";
|
||||
echo " <option value='\${sip_to_host}'>\${sip_to_host}</option>\n";
|
||||
echo " <option value='\${toll_allow}'>\${toll_allow}</option>\n";
|
||||
echo " <option value='\${sip_h_Diversion}'>\${sip_h_Diversion}</option>\n";
|
||||
echo " </optgroup>\n";
|
||||
//}
|
||||
//if (strlen($dialplan_detail_tag) == 0 || $dialplan_detail_tag == "action" || $dialplan_detail_tag == "anti-action") {
|
||||
echo " <optgroup label='".$text['optgroup-applications']."'>\n";
|
||||
if (is_array($_SESSION['switch']['applications'])) {
|
||||
foreach ($_SESSION['switch']['applications'] as $row) {
|
||||
if (strlen($row) > 0) {
|
||||
$application = explode(",", $row);
|
||||
if ($application[0] != "name" && stristr($application[0], "[") != true) {
|
||||
echo " <option value='".escape($application[0])."'>".escape($application[0])."</option>\n";
|
||||
//begin the row
|
||||
echo "<tr>\n";
|
||||
//determine whether to hide the element
|
||||
if (strlen($dialplan_detail_tag) == 0) {
|
||||
$element['hidden'] = false;
|
||||
$element['visibility'] = "";
|
||||
}
|
||||
else {
|
||||
$element['hidden'] = true;
|
||||
$element['visibility'] = "display: none;";
|
||||
}
|
||||
//add the primary key uuid
|
||||
if (is_uuid($dialplan_detail_uuid)) {
|
||||
echo " <input name='dialplan_details[".$x."][dialplan_detail_uuid]' type='hidden' value=\"".escape($dialplan_detail_uuid)."\">\n";
|
||||
}
|
||||
//tag
|
||||
$selected = "selected=\"selected\" ";
|
||||
echo "<td class='vtablerow' style='".$no_border."' onclick=\"label_to_form('label_dialplan_detail_tag_".$x."','dialplan_detail_tag_".$x."');\" nowrap='nowrap'>\n";
|
||||
if ($element['hidden']) {
|
||||
echo " <label id=\"label_dialplan_detail_tag_".$x."\">".escape($dialplan_detail_tag)."</label>\n";
|
||||
}
|
||||
echo " <select id='dialplan_detail_tag_".$x."' name='dialplan_details[".$x."][dialplan_detail_tag]' class='formfld' style='width: 97px; ".$element['visibility']."'>\n";
|
||||
echo " <option></option>\n";
|
||||
echo " <option value='condition' ".($dialplan_detail_tag == "condition" ? $selected : null).">".$text['option-condition']."</option>\n";
|
||||
echo " <option value='regex' ".($dialplan_detail_tag == "regex" ? $selected : null).">".$text['option-regex']."</option>\n";
|
||||
echo " <option value='action' ".($dialplan_detail_tag == "action" ? $selected : null).">".$text['option-action']."</option>\n";
|
||||
echo " <option value='anti-action' ".($dialplan_detail_tag == "anti-action" ? $selected : null).">".$text['option-anti-action']."</option>\n";
|
||||
echo " </select>\n";
|
||||
echo "</td>\n";
|
||||
//type
|
||||
echo "<td class='vtablerow' style='".$no_border."' onclick=\"label_to_form('label_dialplan_detail_type_".$x."','dialplan_detail_type_".$x."');\" nowrap='nowrap'>\n";
|
||||
if ($element['hidden']) {
|
||||
echo " <label id=\"label_dialplan_detail_type_".$x."\">".escape($dialplan_detail_type)."</label>\n";
|
||||
}
|
||||
echo " <select id='dialplan_detail_type_".$x."' name='dialplan_details[".$x."][dialplan_detail_type]' class='formfld' style='width: auto; ".$element['visibility']."' onchange='change_to_input(this);'>\n";
|
||||
if (strlen($dialplan_detail_type) > 0) {
|
||||
echo " <optgroup label='selected'>\n";
|
||||
echo " <option value=\"".escape($dialplan_detail_type)."\">".escape($dialplan_detail_type)."</option>\n";
|
||||
echo " </optgroup>\n";
|
||||
}
|
||||
else {
|
||||
echo " <option value=''></option>\n";
|
||||
}
|
||||
//if (strlen($dialplan_detail_tag) == 0 || $dialplan_detail_tag == "condition" || $dialplan_detail_tag == "regex") {
|
||||
echo " <optgroup label='".$text['optgroup-condition_or_regex']."'>\n";
|
||||
echo " <option value='context'>".$text['option-context']."</option>\n";
|
||||
echo " <option value='username'>".$text['option-username']."</option>\n";
|
||||
echo " <option value='rdnis'>".$text['option-rdnis']."</option>\n";
|
||||
echo " <option value='destination_number'>".$text['option-destination_number']."</option>\n";
|
||||
echo " <option value='dialplan'>".$text['option-dialplan']."</option>\n";
|
||||
echo " <option value='caller_id_name'>".$text['option-caller_id_name']."</option>\n";
|
||||
echo " <option value='caller_id_number'>".$text['option-caller_id_number']."</option>\n";
|
||||
echo " <option value='ani'>".$text['option-ani']."</option>\n";
|
||||
echo " <option value='ani2'>".$text['option-ani2']."</option>\n";
|
||||
echo " <option value='uuid'>".$text['option-uuid']."</option>\n";
|
||||
echo " <option value='source'>".$text['option-source']."</option>\n";
|
||||
echo " <option value='chan_name'>".$text['option-chan_name']."</option>\n";
|
||||
echo " <option value='network_addr'>".$text['option-network_addr']."</option>\n";
|
||||
echo " <option value='\${number_alias}'>\${number_alias}</option>\n";
|
||||
echo " <option value='\${sip_from_uri}'>\${sip_from_uri}</option>\n";
|
||||
echo " <option value='\${sip_from_user}'>\${sip_from_user}</option>\n";
|
||||
echo " <option value='\${sip_from_host}'>\${sip_from_host}</option>\n";
|
||||
echo " <option value='\${sip_contact_uri}'>\${sip_contact_uri}</option>\n";
|
||||
echo " <option value='\${sip_contact_user}'>\${sip_contact_user}</option>\n";
|
||||
echo " <option value='\${sip_contact_host}'>\${sip_contact_host}</option>\n";
|
||||
echo " <option value='\${sip_to_uri}'>\${sip_to_uri}</option>\n";
|
||||
echo " <option value='\${sip_to_user}'>\${sip_to_user}</option>\n";
|
||||
echo " <option value='\${sip_to_host}'>\${sip_to_host}</option>\n";
|
||||
echo " <option value='\${toll_allow}'>\${toll_allow}</option>\n";
|
||||
echo " <option value='\${sip_h_Diversion}'>\${sip_h_Diversion}</option>\n";
|
||||
echo " </optgroup>\n";
|
||||
//}
|
||||
//if (strlen($dialplan_detail_tag) == 0 || $dialplan_detail_tag == "action" || $dialplan_detail_tag == "anti-action") {
|
||||
echo " <optgroup label='".$text['optgroup-applications']."'>\n";
|
||||
if (is_array($_SESSION['switch']['applications'])) {
|
||||
foreach ($_SESSION['switch']['applications'] as $row) {
|
||||
if (strlen($row) > 0) {
|
||||
$application = explode(",", $row);
|
||||
if ($application[0] != "name" && stristr($application[0], "[") != true) {
|
||||
echo " <option value='".escape($application[0])."'>".escape($application[0])."</option>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo " </optgroup>\n";
|
||||
//}
|
||||
echo " </select>\n";
|
||||
//echo " <input type='button' id='btn_select_to_input_dialplan_detail_type' class='btn' style='visibility:hidden;' name='' alt='".$text['button-back']."' onclick='change_to_input(document.getElementById(\"dialplan_detail_type\"));this.style.visibility = \"hidden\";' value='◁'>\n";
|
||||
echo "</td>\n";
|
||||
//data
|
||||
echo "<td class='vtablerow' onclick=\"label_to_form('label_dialplan_detail_data_".$x."','dialplan_detail_data_".$x."');\" style='".$no_border." width: 100%; max-width: 150px; overflow: hidden; _text-overflow: ellipsis; white-space: nowrap;' nowrap='nowrap'>\n";
|
||||
if ($element['hidden']) {
|
||||
$dialplan_detail_data_mod = $dialplan_detail_data;
|
||||
if ($dialplan_detail_type == 'bridge') {
|
||||
// split up failover bridges and get variables in statement
|
||||
$failover_bridges = explode('|', $dialplan_detail_data);
|
||||
preg_match('/^\{.*\}/', $failover_bridges[0], $bridge_vars);
|
||||
$bridge_vars = $bridge_vars[0];
|
||||
|
||||
// rename parse and rename each gateway
|
||||
foreach ($failover_bridges as $bridge_statement_exploded) {
|
||||
// parse out gateway uuid
|
||||
$bridge_statement = str_replace($bridge_vars, '', explode('/', $bridge_statement_exploded));
|
||||
array_unshift($bridge_statement, $bridge_vars);
|
||||
|
||||
if ($bridge_statement[1] == 'sofia' && $bridge_statement[2] == 'gateway' && is_uuid($bridge_statement[3])) {
|
||||
// retrieve gateway name from db
|
||||
$sql = "select gateway from v_gateways where gateway_uuid = '".$bridge_statement[3]."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$gateways = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
if (is_array($gateways)) {
|
||||
$gateway_name = $gateways[0]['gateway'];
|
||||
$bridge_statement_exploded_mod = str_replace($bridge_statement[3], $gateway_name, $bridge_statement_exploded);
|
||||
echo " </optgroup>\n";
|
||||
//}
|
||||
echo " </select>\n";
|
||||
//echo " <input type='button' id='btn_select_to_input_dialplan_detail_type' class='btn' style='visibility:hidden;' name='' alt='".$text['button-back']."' onclick='change_to_input(document.getElementById(\"dialplan_detail_type\"));this.style.visibility = \"hidden\";' value='◁'>\n";
|
||||
echo "</td>\n";
|
||||
//data
|
||||
echo "<td class='vtablerow' onclick=\"label_to_form('label_dialplan_detail_data_".$x."','dialplan_detail_data_".$x."');\" style='".$no_border." width: 100%; max-width: 150px; overflow: hidden; _text-overflow: ellipsis; white-space: nowrap;' nowrap='nowrap'>\n";
|
||||
if ($element['hidden']) {
|
||||
$dialplan_detail_data_mod = $dialplan_detail_data;
|
||||
if ($dialplan_detail_type == 'bridge') {
|
||||
// split up failover bridges and get variables in statement
|
||||
$failover_bridges = explode('|', $dialplan_detail_data);
|
||||
preg_match('/^\{.*\}/', $failover_bridges[0], $bridge_vars);
|
||||
$bridge_vars = $bridge_vars[0];
|
||||
|
||||
// rename parse and rename each gateway
|
||||
foreach ($failover_bridges as $bridge_statement_exploded) {
|
||||
// parse out gateway uuid
|
||||
$bridge_statement = str_replace($bridge_vars, '', explode('/', $bridge_statement_exploded));
|
||||
array_unshift($bridge_statement, $bridge_vars);
|
||||
|
||||
if ($bridge_statement[1] == 'sofia' && $bridge_statement[2] == 'gateway' && is_uuid($bridge_statement[3])) {
|
||||
// retrieve gateway name from db
|
||||
$sql = "select gateway from v_gateways where gateway_uuid = :gateway_uuid ";
|
||||
$parameters['gateway_uuid'] = $bridge_statement[3];
|
||||
$database = new database;
|
||||
$gateways = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($gateways) && @sizeof($gateways) != 0) {
|
||||
$gateway_name = $gateways[0]['gateway'];
|
||||
$bridge_statement_exploded_mod = str_replace($bridge_statement[3], $gateway_name, $bridge_statement_exploded);
|
||||
}
|
||||
$dialplan_detail_data_mod = str_replace($bridge_statement_exploded, $bridge_statement_exploded_mod, $dialplan_detail_data_mod);
|
||||
unset($sql, $parameters, $bridge_statement, $gateways, $bridge_statement_exploded, $bridge_statement_exploded_mod);
|
||||
}
|
||||
$dialplan_detail_data_mod = str_replace($bridge_statement_exploded, $bridge_statement_exploded_mod, $dialplan_detail_data_mod);
|
||||
unset ($prep_statement, $sql, $bridge_statement, $gateways, $bridge_statement_exploded, $bridge_statement_exploded_mod);
|
||||
}
|
||||
}
|
||||
echo " <label id=\"label_dialplan_detail_data_".$x."\">".escape($dialplan_detail_data_mod)."</label>\n";
|
||||
}
|
||||
echo " <label id=\"label_dialplan_detail_data_".$x."\">".escape($dialplan_detail_data_mod)."</label>\n";
|
||||
}
|
||||
echo " <input id='dialplan_detail_data_".$x."' name='dialplan_details[".$x."][dialplan_detail_data]' class='formfld' type='text' style='width: calc(100% - 2px); min-width: calc(100% - 2px); max-width: calc(100% - 2px); ".$element['visibility']."' placeholder='' value=\"".escape($dialplan_detail_data)."\">\n";
|
||||
echo "</td>\n";
|
||||
//break
|
||||
echo "<td class='vtablerow' style='".$no_border."' onclick=\"label_to_form('label_dialplan_detail_break_".$x."','dialplan_detail_break_".$x."');\" nowrap='nowrap'>\n";
|
||||
if ($element['hidden']) {
|
||||
echo " <label id=\"label_dialplan_detail_break_".$x."\">".escape($dialplan_detail_break)."</label>\n";
|
||||
}
|
||||
echo " <select id='dialplan_detail_break_".$x."' name='dialplan_details[".$x."][dialplan_detail_break]' class='formfld' style='width: auto; ".$element['visibility']."'>\n";
|
||||
echo " <option></option>\n";
|
||||
echo " <option value='on-true' ".($dialplan_detail_break == "on-true" ? $selected : null).">".$text['option-on_true']."</option>\n";
|
||||
echo " <option value='on-false' ".($dialplan_detail_break == "on-false" ? $selected : null).">".$text['option-on_false']."</option>\n";
|
||||
echo " <option value='always' ".($dialplan_detail_break == "always" ? $selected : null).">".$text['option-always']."</option>\n";
|
||||
echo " <option value='never' ".($dialplan_detail_break == "never" ? $selected : null).">".$text['option-never']."</option>\n";
|
||||
echo " </select>\n";
|
||||
echo "</td>\n";
|
||||
//inline
|
||||
echo "<td class='vtablerow' style='".$no_border." text-align: center;' onclick=\"label_to_form('label_dialplan_detail_inline_".$x."','dialplan_detail_inline_".$x."');\" nowrap='nowrap'>\n";
|
||||
if ($element['hidden']) {
|
||||
echo " <label id=\"label_dialplan_detail_inline_".$x."\">".escape($dialplan_detail_inline)."</label>\n";
|
||||
}
|
||||
echo " <select id='dialplan_detail_inline_".$x."' name='dialplan_details[".$x."][dialplan_detail_inline]' class='formfld' style='width: auto; ".$element['visibility']."'>\n";
|
||||
echo " <option></option>\n";
|
||||
echo " <option value='true' ".($dialplan_detail_inline == "true" ? $selected : null).">".$text['option-true']."</option>\n";
|
||||
echo " <option value='false' ".($dialplan_detail_inline == "false" ? $selected : null).">".$text['option-false']."</option>\n";
|
||||
echo " </select>\n";
|
||||
echo "</td>\n";
|
||||
//group
|
||||
echo "<td class='vtablerow' style='".$no_border." text-align: center;' onclick=\"label_to_form('label_dialplan_detail_group_".$x."','dialplan_detail_group_".$x."');\" nowrap='nowrap'>\n";
|
||||
if ($element['hidden']) {
|
||||
echo " <label id=\"label_dialplan_detail_group_".$x."\">".escape($dialplan_detail_group)."</label>\n";
|
||||
}
|
||||
echo " <input id='dialplan_detail_group_".$x."' name='dialplan_details[".$x."][dialplan_detail_group]' class='formfld' type='number' min='0' step='1' style='width: 30px; text-align: center; ".$element['visibility']."' placeholder='' value=\"".escape($dialplan_detail_group)."\" onclick='this.select();'>\n";
|
||||
/*
|
||||
echo " <select id='dialplan_detail_group_".$x."' name='dialplan_details[".$x."][dialplan_detail_group]' class='formfld' style='".$element['width']." ".$element['visibility']."'>\n";
|
||||
echo " <option value=''></option>\n";
|
||||
if (strlen($dialplan_detail_group)> 0) {
|
||||
echo " <option $selected value='".escape($dialplan_detail_group)."'>".escape($dialplan_detail_group)."</option>\n";
|
||||
}
|
||||
$i=0;
|
||||
while($i<=999) {
|
||||
echo " <option value='$i'>$i</option>\n";
|
||||
$i++;
|
||||
}
|
||||
echo " </select>\n";
|
||||
*/
|
||||
echo "</td>\n";
|
||||
//order
|
||||
echo "<td class='vtablerow' style='".$no_border." text-align: center;' onclick=\"label_to_form('label_dialplan_detail_order_".$x."','dialplan_detail_order_".$x."');\" nowrap='nowrap'>\n";
|
||||
if ($element['hidden']) {
|
||||
echo " <label id=\"label_dialplan_detail_order_".$x."\">".escape($dialplan_detail_order)."</label>\n";
|
||||
}
|
||||
echo " <input id='dialplan_detail_order_".$x."' name='dialplan_details[".$x."][dialplan_detail_order]' class='formfld' type='number' min='0' step='1' style='width: 32px; text-align: center; ".$element['visibility']."' placeholder='' value=\"".escape($dialplan_detail_order)."\" onclick='this.select();'>\n";
|
||||
/*
|
||||
echo " <select id='dialplan_detail_order_".$x."' name='dialplan_details[".$x."][dialplan_detail_order]' class='formfld' style='".$element['width']." ".$element['visibility']."'>\n";
|
||||
if (strlen($dialplan_detail_order)> 0) {
|
||||
echo " <option $selected value='".escape($dialplan_detail_order)."'>".escape($dialplan_detail_order)."</option>\n";
|
||||
}
|
||||
$i=0;
|
||||
while($i<=999) {
|
||||
if (strlen($i) == 1) {
|
||||
echo " <option value='00$i'>00$i</option>\n";
|
||||
echo " <input id='dialplan_detail_data_".$x."' name='dialplan_details[".$x."][dialplan_detail_data]' class='formfld' type='text' style='width: calc(100% - 2px); min-width: calc(100% - 2px); max-width: calc(100% - 2px); ".$element['visibility']."' placeholder='' value=\"".escape($dialplan_detail_data)."\">\n";
|
||||
echo "</td>\n";
|
||||
//break
|
||||
echo "<td class='vtablerow' style='".$no_border."' onclick=\"label_to_form('label_dialplan_detail_break_".$x."','dialplan_detail_break_".$x."');\" nowrap='nowrap'>\n";
|
||||
if ($element['hidden']) {
|
||||
echo " <label id=\"label_dialplan_detail_break_".$x."\">".escape($dialplan_detail_break)."</label>\n";
|
||||
}
|
||||
if (strlen($i) == 2) {
|
||||
echo " <option value='0$i'>0$i</option>\n";
|
||||
echo " <select id='dialplan_detail_break_".$x."' name='dialplan_details[".$x."][dialplan_detail_break]' class='formfld' style='width: auto; ".$element['visibility']."'>\n";
|
||||
echo " <option></option>\n";
|
||||
echo " <option value='on-true' ".($dialplan_detail_break == "on-true" ? $selected : null).">".$text['option-on_true']."</option>\n";
|
||||
echo " <option value='on-false' ".($dialplan_detail_break == "on-false" ? $selected : null).">".$text['option-on_false']."</option>\n";
|
||||
echo " <option value='always' ".($dialplan_detail_break == "always" ? $selected : null).">".$text['option-always']."</option>\n";
|
||||
echo " <option value='never' ".($dialplan_detail_break == "never" ? $selected : null).">".$text['option-never']."</option>\n";
|
||||
echo " </select>\n";
|
||||
echo "</td>\n";
|
||||
//inline
|
||||
echo "<td class='vtablerow' style='".$no_border." text-align: center;' onclick=\"label_to_form('label_dialplan_detail_inline_".$x."','dialplan_detail_inline_".$x."');\" nowrap='nowrap'>\n";
|
||||
if ($element['hidden']) {
|
||||
echo " <label id=\"label_dialplan_detail_inline_".$x."\">".escape($dialplan_detail_inline)."</label>\n";
|
||||
}
|
||||
if (strlen($i) == 3) {
|
||||
echo " <select id='dialplan_detail_inline_".$x."' name='dialplan_details[".$x."][dialplan_detail_inline]' class='formfld' style='width: auto; ".$element['visibility']."'>\n";
|
||||
echo " <option></option>\n";
|
||||
echo " <option value='true' ".($dialplan_detail_inline == "true" ? $selected : null).">".$text['option-true']."</option>\n";
|
||||
echo " <option value='false' ".($dialplan_detail_inline == "false" ? $selected : null).">".$text['option-false']."</option>\n";
|
||||
echo " </select>\n";
|
||||
echo "</td>\n";
|
||||
//group
|
||||
echo "<td class='vtablerow' style='".$no_border." text-align: center;' onclick=\"label_to_form('label_dialplan_detail_group_".$x."','dialplan_detail_group_".$x."');\" nowrap='nowrap'>\n";
|
||||
if ($element['hidden']) {
|
||||
echo " <label id=\"label_dialplan_detail_group_".$x."\">".escape($dialplan_detail_group)."</label>\n";
|
||||
}
|
||||
echo " <input id='dialplan_detail_group_".$x."' name='dialplan_details[".$x."][dialplan_detail_group]' class='formfld' type='number' min='0' step='1' style='width: 30px; text-align: center; ".$element['visibility']."' placeholder='' value=\"".escape($dialplan_detail_group)."\" onclick='this.select();'>\n";
|
||||
/*
|
||||
echo " <select id='dialplan_detail_group_".$x."' name='dialplan_details[".$x."][dialplan_detail_group]' class='formfld' style='".$element['width']." ".$element['visibility']."'>\n";
|
||||
echo " <option value=''></option>\n";
|
||||
if (strlen($dialplan_detail_group)> 0) {
|
||||
echo " <option $selected value='".escape($dialplan_detail_group)."'>".escape($dialplan_detail_group)."</option>\n";
|
||||
}
|
||||
$i=0;
|
||||
while($i<=999) {
|
||||
echo " <option value='$i'>$i</option>\n";
|
||||
$i++;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
echo " </select>\n";
|
||||
*/
|
||||
echo "</td>\n";
|
||||
//tools
|
||||
echo " <td class='list_control_icon'>\n";
|
||||
if ($element['hidden']) {
|
||||
//echo " <a href='dialplan_detail_edit.php?id=".$dialplan_detail_uuid."&dialplan_uuid=".$dialplan_uuid."&app_uuid=".$app_uuid."' alt='".$text['button-edit']."'>$v_link_label_edit</a>\n";
|
||||
echo " <a href='dialplan_detail_delete.php?id=".escape($dialplan_detail_uuid)."&dialplan_uuid=".escape($dialplan_uuid).(($app_uuid != '') ? "&app_uuid=".escape($app_uuid) : null)."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
|
||||
}
|
||||
echo " </td>\n";
|
||||
//end the row
|
||||
echo "</tr>\n";
|
||||
//increment the value
|
||||
$x++;
|
||||
echo " </select>\n";
|
||||
*/
|
||||
echo "</td>\n";
|
||||
//order
|
||||
echo "<td class='vtablerow' style='".$no_border." text-align: center;' onclick=\"label_to_form('label_dialplan_detail_order_".$x."','dialplan_detail_order_".$x."');\" nowrap='nowrap'>\n";
|
||||
if ($element['hidden']) {
|
||||
echo " <label id=\"label_dialplan_detail_order_".$x."\">".escape($dialplan_detail_order)."</label>\n";
|
||||
}
|
||||
echo " <input id='dialplan_detail_order_".$x."' name='dialplan_details[".$x."][dialplan_detail_order]' class='formfld' type='number' min='0' step='1' style='width: 32px; text-align: center; ".$element['visibility']."' placeholder='' value=\"".escape($dialplan_detail_order)."\" onclick='this.select();'>\n";
|
||||
/*
|
||||
echo " <select id='dialplan_detail_order_".$x."' name='dialplan_details[".$x."][dialplan_detail_order]' class='formfld' style='".$element['width']." ".$element['visibility']."'>\n";
|
||||
if (strlen($dialplan_detail_order)> 0) {
|
||||
echo " <option $selected value='".escape($dialplan_detail_order)."'>".escape($dialplan_detail_order)."</option>\n";
|
||||
}
|
||||
$i=0;
|
||||
while($i<=999) {
|
||||
if (strlen($i) == 1) {
|
||||
echo " <option value='00$i'>00$i</option>\n";
|
||||
}
|
||||
if (strlen($i) == 2) {
|
||||
echo " <option value='0$i'>0$i</option>\n";
|
||||
}
|
||||
if (strlen($i) == 3) {
|
||||
echo " <option value='$i'>$i</option>\n";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
echo " </select>\n";
|
||||
*/
|
||||
echo "</td>\n";
|
||||
//tools
|
||||
echo " <td class='list_control_icon'>\n";
|
||||
if ($element['hidden']) {
|
||||
//echo " <a href='dialplan_detail_edit.php?id=".$dialplan_detail_uuid."&dialplan_uuid=".$dialplan_uuid."&app_uuid=".$app_uuid."' alt='".$text['button-edit']."'>$v_link_label_edit</a>\n";
|
||||
echo " <a href='dialplan_detail_delete.php?id=".escape($dialplan_detail_uuid)."&dialplan_uuid=".escape($dialplan_uuid).(($app_uuid != '') ? "&app_uuid=".escape($app_uuid) : null)."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
|
||||
}
|
||||
echo " </td>\n";
|
||||
//end the row
|
||||
echo "</tr>\n";
|
||||
//increment the value
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
$x++;
|
||||
} //end foreach
|
||||
unset($sql, $details);
|
||||
unset($details);
|
||||
|
||||
echo "</table>";
|
||||
|
||||
|
|
|
|||
|
|
@ -48,18 +48,18 @@
|
|||
}
|
||||
|
||||
//set the default app_uuid
|
||||
if (strlen($app_uuid) == 0) {
|
||||
if (!is_uuid($app_uuid)) {
|
||||
$app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
|
||||
}
|
||||
|
||||
//get the dialplan xml
|
||||
if (is_uuid($dialplan_uuid)) {
|
||||
$sql = "select * from v_dialplans ";
|
||||
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$sql .= "where dialplan_uuid = :dialplan_uuid ";
|
||||
$parameters['dialplan_uuid'] = $dialplan_uuid;
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
if (is_array($row) && @sizeof($row) != 0) {
|
||||
$domain_uuid = $row["domain_uuid"];
|
||||
//$app_uuid = $row["app_uuid"];
|
||||
$dialplan_name = $row["dialplan_name"];
|
||||
|
|
@ -71,7 +71,7 @@
|
|||
$dialplan_enabled = $row["dialplan_enabled"];
|
||||
$dialplan_description = $row["dialplan_description"];
|
||||
}
|
||||
unset ($prep_statement);
|
||||
unset($sql, $parameters, $row);
|
||||
}
|
||||
|
||||
//process the HTTP POST
|
||||
|
|
@ -87,19 +87,10 @@
|
|||
$database = new database;
|
||||
$database->app_name = 'dialplans';
|
||||
$database->app_uuid = $app_uuid;
|
||||
//if (strlen($dialplan_uuid) > 0) {
|
||||
// $database->uuid($dialplan_uuid);
|
||||
//}
|
||||
$database->save($array);
|
||||
$message = $database->message;
|
||||
unset($array);
|
||||
|
||||
//debug info
|
||||
//echo "<pre>\n";
|
||||
//print_r($message);
|
||||
//echo "</pre>\n";
|
||||
//exit;
|
||||
|
||||
//clear the cache
|
||||
//clear the cache
|
||||
$cache = new cache;
|
||||
$cache->delete("dialplan:".$dialplan_context);
|
||||
|
||||
|
|
@ -126,7 +117,7 @@
|
|||
echo " <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td align='left' width='30%'>\n";
|
||||
echo" <span class=\"title\">".$text['title-dialplan_edit']."</span><br />\n";
|
||||
echo " <span class=\"title\">".$text['title-dialplan_edit']."</span><br />\n";
|
||||
echo " </td>\n";
|
||||
echo " <td width='70%' align='right'>\n";
|
||||
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='dialplan_edit.php?id=".$dialplan_uuid."&".((strlen($app_uuid) > 0) ? "app_uuid=".$app_uuid : null)."';\" value='".$text['button-back']."'>\n";
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@
|
|||
$text = $language->get();
|
||||
|
||||
//handle enable toggle
|
||||
$dialplan_uuid = check_str($_REQUEST['id']);
|
||||
$dialplan_enabled = check_str($_REQUEST['enabled']);
|
||||
if (isset($dialplan_uuid) && is_uuid($dialplan_uuid) && $dialplan_enabled != '') {
|
||||
$dialplan_uuid = $_REQUEST['id'];
|
||||
$dialplan_enabled = $_REQUEST['enabled'];
|
||||
if (is_uuid($dialplan_uuid) && $dialplan_enabled != '') {
|
||||
//make sure enabled is only true or false
|
||||
if ($dialplan_enabled == "true") {
|
||||
$dialplan_enabled = 'true';
|
||||
|
|
@ -55,20 +55,27 @@
|
|||
}
|
||||
|
||||
//get the dialplan context
|
||||
$sql = "select * from v_dialplans ";
|
||||
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$row = $prep_statement->fetch(PDO::FETCH_NAMED);
|
||||
$dialplan_context = $row["dialplan_context"];
|
||||
unset($sql);
|
||||
$sql = "select dialplan_context from v_dialplans ";
|
||||
$sql .= "where dialplan_uuid = :dialplan_uuid ";
|
||||
$parameters['dialplan_uuid'] = $dialplan_uuid;
|
||||
$database = new database;
|
||||
$dialplan_context = $database->select($sql, $parameters, 'column');
|
||||
unset($sql, $parameters);
|
||||
|
||||
//change the status
|
||||
$sql = "update v_dialplans set ";
|
||||
$sql .= "dialplan_enabled = '".$dialplan_enabled."' ";
|
||||
$sql .= "where dialplan_uuid = '".$dialplan_uuid."'";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
$array['dialplans'][0]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplans'][0]['dialplan_enabled'] = $dialplan_enabled;
|
||||
|
||||
$p = new permissions;
|
||||
$p->add('dialplan_edit', 'temp');
|
||||
|
||||
$database = new database;
|
||||
$database->app_name = 'dialplans';
|
||||
$database->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
$p->delete('dialplan_edit', 'temp');
|
||||
|
||||
//clear the cache
|
||||
$cache = new cache;
|
||||
|
|
@ -79,11 +86,11 @@
|
|||
}
|
||||
|
||||
//set the http values as php variables
|
||||
if (isset($_REQUEST["search"])) { $search = check_str($_REQUEST["search"]); } else { $search = null; }
|
||||
if (isset($_REQUEST["order_by"])) { $order_by = check_str($_REQUEST["order_by"]); } else { $order_by = null; }
|
||||
if (isset($_REQUEST["order"])) { $order = check_str($_REQUEST["order"]); } else { $order = null; }
|
||||
if (isset($_REQUEST["dialplan_context"])) { $dialplan_context = check_str($_REQUEST["dialplan_context"]); } else { $dialplan_context = null; }
|
||||
if (isset($_REQUEST["app_uuid"])) { $app_uuid = check_str($_REQUEST["app_uuid"]); } else { $app_uuid = null; }
|
||||
$search = $_REQUEST["search"];
|
||||
$order_by = $_REQUEST["order_by"];
|
||||
$order = $_REQUEST["order"];
|
||||
$dialplan_context = $_REQUEST["dialplan_context"];
|
||||
$app_uuid = $_REQUEST["app_uuid"];
|
||||
|
||||
//make sure all dialplans with context of public have the inbound route app_uuid
|
||||
if ($app_uuid == 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4') {
|
||||
|
|
@ -91,7 +98,8 @@
|
|||
$sql .= "app_uuid = 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' ";
|
||||
$sql .= "where dialplan_context = 'public' ";
|
||||
$sql .= "and app_uuid is null; ";
|
||||
$db->exec($sql);
|
||||
$database = new database;
|
||||
$database->execute($sql);
|
||||
unset($sql);
|
||||
}
|
||||
|
||||
|
|
@ -99,49 +107,50 @@
|
|||
require_once "resources/header.php";
|
||||
require_once "resources/paging.php";
|
||||
|
||||
//get the number of rows in the dialplan
|
||||
$sql = "select count(*) as num_rows from v_dialplans ";
|
||||
//common sql where
|
||||
if ($_GET['show'] == "all" && permission_exists('dialplan_all')) {
|
||||
$sql .= "where 1 = 1 ";
|
||||
$sql_where = "where true ";
|
||||
}
|
||||
else {
|
||||
$sql .= "where (domain_uuid = '$domain_uuid' or domain_uuid is null) ";
|
||||
$sql_where .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
}
|
||||
if (strlen($app_uuid) == 0) {
|
||||
if (!is_uuid($app_uuid)) {
|
||||
//hide inbound routes
|
||||
$sql .= "and app_uuid <> 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' ";
|
||||
$sql_where .= "and app_uuid <> 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' ";
|
||||
$sql_where .= "and dialplan_context <> 'public' ";
|
||||
//hide outbound routes
|
||||
$sql .= "and app_uuid <> '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' ";
|
||||
$sql_where .= "and app_uuid <> '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' ";
|
||||
}
|
||||
else {
|
||||
$sql .= "and app_uuid = '".$app_uuid."' ";
|
||||
}
|
||||
if (strlen($search) > 0) {
|
||||
$search = strtolower($search);
|
||||
$sql .= "and (";
|
||||
$sql .= " lower(dialplan_context) like '%".$search."%' ";
|
||||
$sql .= " or lower(dialplan_name) like '%".$search."%' ";
|
||||
$sql .= " or dialplan_number like '%".$search."%' ";
|
||||
$sql .= " or dialplan_continue like '%".$search."%' ";
|
||||
if (is_numeric($search)) {
|
||||
$sql .= " or dialplan_order = '".$search."' ";
|
||||
}
|
||||
$sql .= " or dialplan_enabled like '%".$search."%' ";
|
||||
$sql .= " or lower(dialplan_description) like '%".$search."%' ";
|
||||
$sql .= ") ";
|
||||
}
|
||||
$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) {
|
||||
$num_rows = $row['num_rows'];
|
||||
if ($app_uuid == 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4') {
|
||||
$sql_where .= "and (app_uuid = :app_uuid or dialplan_context = 'public') ";
|
||||
}
|
||||
else {
|
||||
$num_rows = '0';
|
||||
$sql_where .= "and app_uuid = :app_uuid ";
|
||||
}
|
||||
$parameters['app_uuid'] = $app_uuid;
|
||||
}
|
||||
unset($prep_statement, $result);
|
||||
if (strlen($search) > 0) {
|
||||
$sql_where .= "and (";
|
||||
$sql_where .= " dialplan_context like :search ";
|
||||
$sql_where .= " or dialplan_name like :search ";
|
||||
$sql_where .= " or dialplan_number like :search ";
|
||||
$sql_where .= " or dialplan_continue like :search ";
|
||||
if (is_numeric($search)) {
|
||||
$sql_where .= " or dialplan_order = :search ";
|
||||
}
|
||||
$sql_where .= " or dialplan_enabled like :search ";
|
||||
$sql_where .= " or dialplan_description like :search ";
|
||||
$sql_where .= ") ";
|
||||
$parameters['search'] = '%'.$search.'%';
|
||||
}
|
||||
|
||||
//get the number of rows in the dialplan
|
||||
$sql = "select count(*) from v_dialplans ";
|
||||
$sql .= $sql_where;
|
||||
$database = new database;
|
||||
$num_rows = $database->select($sql, $parameters, 'column');
|
||||
|
||||
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
|
||||
$param = "&search=".escape($search);
|
||||
|
|
@ -155,48 +164,12 @@
|
|||
$offset = $rows_per_page * $page;
|
||||
|
||||
//get the list of dialplans
|
||||
$sql = "select * from v_dialplans ";
|
||||
if ($_GET['show'] == "all" && permission_exists('dialplan_all')) {
|
||||
$sql .= "where 1 = 1 ";
|
||||
}
|
||||
else {
|
||||
$sql .= "where (domain_uuid = '$domain_uuid' or domain_uuid is null) ";
|
||||
}
|
||||
if (strlen($app_uuid) == 0) {
|
||||
//hide inbound routes
|
||||
$sql .= "and app_uuid <> 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' ";
|
||||
$sql .= "and dialplan_context <> 'public' ";
|
||||
//hide outbound routes
|
||||
$sql .= "and app_uuid <> '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' ";
|
||||
}
|
||||
else {
|
||||
if ($app_uuid == 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4') {
|
||||
$sql .= "and (app_uuid = '".$app_uuid."' or dialplan_context = 'public') ";
|
||||
}
|
||||
else {
|
||||
$sql .= "and app_uuid = '".$app_uuid."' ";
|
||||
}
|
||||
}
|
||||
if (strlen($search) > 0) {
|
||||
$sql .= "and (";
|
||||
$sql .= " dialplan_context like '%".$search."%' ";
|
||||
$sql .= " or dialplan_name like '%".$search."%' ";
|
||||
$sql .= " or dialplan_number like '%".$search."%' ";
|
||||
$sql .= " or dialplan_continue like '%".$search."%' ";
|
||||
if (is_numeric($search)) {
|
||||
$sql .= " or dialplan_order = '".$search."' ";
|
||||
}
|
||||
$sql .= " or dialplan_enabled like '%".$search."%' ";
|
||||
$sql .= " or dialplan_description like '%".$search."%' ";
|
||||
$sql .= ") ";
|
||||
}
|
||||
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } else { $sql .= "order by dialplan_order asc, dialplan_name asc "; }
|
||||
$sql .= " limit $rows_per_page offset $offset ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$dialplans = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
$dialplan_count = count($dialplans);
|
||||
unset ($prep_statement, $sql);
|
||||
$sql = str_replace('count(*)', '*', $sql);
|
||||
$sql .= ($order_by != '' ? order_by($order_by, $order) : 'order by dialplan_order asc, dialplan_name asc ');
|
||||
$sql .= limit_offset($rows_per_page, $offset);
|
||||
$database = new database;
|
||||
$dialplans = $database->select($sql, $parameters, 'all');
|
||||
unset($sql, $parameters);
|
||||
|
||||
//set the alternating row style
|
||||
$c = 0;
|
||||
|
|
@ -254,7 +227,7 @@
|
|||
}
|
||||
}
|
||||
echo " <input type='text' class='txt' style='width: 150px' name='search' value='".escape($search)."'>";
|
||||
if (strlen($app_uuid) > 0) {
|
||||
if (is_uuid($app_uuid)) {
|
||||
echo " <input type='hidden' class='txt' name='app_uuid' value='".escape($app_uuid)."'>";
|
||||
}
|
||||
if (strlen($order_by) > 0) {
|
||||
|
|
@ -299,7 +272,7 @@
|
|||
echo "<input type='hidden' name='app_uuid' value='".escape($app_uuid)."'>\n";
|
||||
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo "<tr>\n";
|
||||
if (permission_exists('dialplan_delete') && $dialplan_count > 0) {
|
||||
if (permission_exists('dialplan_delete') && @sizeof($dialplans) != 0) {
|
||||
echo "<th style='width: 30px; text-align: center; padding: 3px 0px 0px 0px;' width='1'><input type='checkbox' style='margin: 0px 0px 0px 2px;' onchange=\"(this.checked) ? check('all') : check('none');\"></th>";
|
||||
}
|
||||
if ($_GET['show'] == "all" && permission_exists('destination_all')) {
|
||||
|
|
@ -327,13 +300,13 @@
|
|||
elseif (permission_exists('dialplan_add')) {
|
||||
echo "<a href='".PROJECT_PATH."/app/dialplans/dialplan_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
}
|
||||
if (permission_exists('dialplan_delete') && $dialplan_count > 0) {
|
||||
if (permission_exists('dialplan_delete') && @sizeof($dialplans) != 0) {
|
||||
echo "<a href='javascript:void(0);' onclick=\"if (confirm('".$text['confirm-delete']."')) { document.forms.frm_delete.submit(); }\" alt='".$text['button-delete']."'>".$v_link_label_delete."</a>";
|
||||
}
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
if (is_array($dialplans)) {
|
||||
if (is_array($dialplans) && @sizeof($dialplans) != 0) {
|
||||
foreach($dialplans as $row) {
|
||||
|
||||
//get the application id
|
||||
|
|
@ -421,10 +394,10 @@
|
|||
}
|
||||
echo " </td>\n";
|
||||
echo "</tr>\n";
|
||||
if ($c==0) { $c=1; } else { $c=0; }
|
||||
} //end foreach
|
||||
unset($sql, $result, $row_count);
|
||||
} //end if results
|
||||
$c = $c == 0 ? 1 : 0;
|
||||
}
|
||||
}
|
||||
unset($dialplans, $row);
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td colspan='9'>\n";
|
||||
|
|
@ -448,7 +421,7 @@
|
|||
elseif (permission_exists('dialplan_add')) {
|
||||
echo "<a href='".PROJECT_PATH."/app/dialplans/dialplan_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
}
|
||||
if (permission_exists('dialplan_delete') && $dialplan_count > 0) {
|
||||
if (permission_exists('dialplan_delete') && @sizeof($dialplans) != 0) {
|
||||
echo "<a href='javascript:void(0);' onclick=\"if (confirm('".$text['confirm-delete']."')) { document.forms.frm_delete.submit(); }\" alt='".$text['button-delete']."'>".$v_link_label_delete."</a>";
|
||||
}
|
||||
echo " </td>\n";
|
||||
|
|
|
|||
Loading…
Reference in New Issue