Dialplans: Database class integration.

This commit is contained in:
Nate 2019-08-05 19:18:21 -06:00
parent 66f22bada1
commit d3c6182f85
9 changed files with 682 additions and 756 deletions

View File

@ -84,31 +84,34 @@
} }
//update the dialplan order //update the dialplan order
$database = new database;
$sql = "update v_dialplans set dialplan_order = '870' where dialplan_order = '980' and dialplan_name = 'cidlookup';\n"; $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"; $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"; $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); unset($sql);
//set empty strings to null //set empty strings to null
$database = new database;
$sql = "update v_device_lines set outbound_proxy_primary = null where outbound_proxy_primary = '';\n"; $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"; $sql = "update v_device_lines set outbound_proxy_secondary = null where outbound_proxy_secondary = '';\n";
$db->query($sql); $database->execute($sql);
unset($sql); unset($sql);
//change recording_slots to recording_id //change recording_slots to recording_id
$database = new database;
$sql = "update v_dialplan_details set dialplan_detail_data = 'recording_id=true' "; $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 .= "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"; $sql .= "and dialplan_detail_data = 'recording_slots=true'; \n";
$db->query($sql); $database->execute($sql);
unset($sql);
$sql = "update v_dialplan_details set dialplan_detail_data = 'recording_id=false' "; $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 .= "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"; $sql .= "and dialplan_detail_data = 'recording_slots=false'; \n";
$db->query($sql); $database->execute($sql);
unset($sql); unset($sql);
} }
@ -116,18 +119,20 @@
if ($domains_processed == 1) { if ($domains_processed == 1) {
$sql = "select domain_name "; $sql = "select domain_name ";
$sql .= "from v_domains \n"; $sql .= "from v_domains \n";
$prep_statement = $this->db->prepare(check_sql($sql)); $database = new database;
$prep_statement->execute(); $results = $database->select($sql, null, 'all');
$results = $prep_statement->fetchAll(PDO::FETCH_NAMED); if (is_array($results) && @sizeof($results) != 0) {
foreach ($results as $row) { foreach ($results as $row) {
$dialplans = new dialplan; $dialplans = new dialplan;
$dialplans->source = "details"; $dialplans->source = "details";
$dialplans->destination = "database"; $dialplans->destination = "database";
$dialplans->context = $row["domain_name"]; $dialplans->context = $row["domain_name"];
$dialplans->is_empty = "dialplan_xml"; $dialplans->is_empty = "dialplan_xml";
$array = $dialplans->xml(); $array = $dialplans->xml();
//print_r($array); //print_r($array);
}
} }
unset($sql, $results);
$dialplans = new dialplan; $dialplans = new dialplan;
$dialplans->source = "details"; $dialplans->source = "details";
$dialplans->destination = "database"; $dialplans->destination = "database";
@ -137,41 +142,59 @@
//delete the follow me bridge dialplan //delete the follow me bridge dialplan
if ($domains_processed == 1) { if ($domains_processed == 1) {
$database = new database;
$sql = "delete from v_dialplan_details where dialplan_uuid = '8ed73d1f-698f-466c-8a7a-1cf4cd229f7f' "; $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' "; $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 //add not found dialplan to inbound routes
/* /*
if ($domains_processed == 1) { if ($domains_processed == 1) {
if (is_readable($_SESSION['switch']['dialplan']['dir'])) { 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' "; $sql .= "where dialplan_uuid = 'ea5339de-1982-46ca-9695-c35176165314' ";
$prep_statement = $db->prepare(check_sql($sql)); $database = new database;
if ($prep_statement) { $num_rows = $database->select($sql, null, 'column');
$prep_statement->execute(); if ($num_rows == 0) {
$row = $prep_statement->fetch(PDO::FETCH_ASSOC); $array['dialplans'][0]['dialplan_uuid'] = 'ea5339de-1982-46ca-9695-c35176165314';
if ($row['num_rows'] == 0) { $array['dialplans'][0]['app_uuid'] = 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4';
$sql = "INSERT INTO v_dialplans "; $array['dialplans'][0]['dialplan_context'] = 'public';
$sql .= "(dialplan_uuid, app_uuid, dialplan_context, dialplan_name, dialplan_continue, dialplan_order, dialplan_enabled) "; $array['dialplans'][0]['dialplan_name'] = 'not-found';
$sql .= "VALUES ('ea5339de-1982-46ca-9695-c35176165314', 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4', 'public', 'not-found', 'false', '999', 'false');"; $array['dialplans'][0]['dialplan_continue'] = 'false';
$db->query($sql); $array['dialplans'][0]['dialplan_order'] = '999';
$array['dialplans'][0]['dialplan_enabled'] = 'false';
$sql = "INSERT INTO v_dialplan_details "; $array['dialplan_details'][0]['dialplan_uuid'] = 'ea5339de-1982-46ca-9695-c35176165314';
$sql .= "(dialplan_uuid, dialplan_detail_uuid, dialplan_detail_tag, dialplan_detail_type, dialplan_detail_data, dialplan_detail_order) "; $array['dialplan_details'][0]['dialplan_detail_uuid'] = '8a21744d-b381-4cb0-9930-55b776e4e461';
$sql .= "VALUES ('ea5339de-1982-46ca-9695-c35176165314', '8a21744d-b381-4cb0-9930-55b776e4e461', 'condition', 'context', 'public', '10');"; $array['dialplan_details'][0]['dialplan_detail_tag'] = 'condition';
$db->query($sql); $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 "; $array['dialplan_details'][1]['dialplan_uuid'] = 'ea5339de-1982-46ca-9695-c35176165314';
$sql .= "(dialplan_uuid, dialplan_detail_uuid, dialplan_detail_tag, dialplan_detail_type, dialplan_detail_data, dialplan_detail_order) "; $array['dialplan_details'][1]['dialplan_detail_uuid'] = 'e391530c-4078-4b49-bc11-bda4a23ad566';
$sql .= "VALUES ('ea5339de-1982-46ca-9695-c35176165314', 'e391530c-4078-4b49-bc11-bda4a23ad566', 'action', 'log', '[inbound routes] 404 not found \${sip_network_ip}', '20');"; $array['dialplan_details'][1]['dialplan_detail_tag'] = 'action';
$db->query($sql); $array['dialplan_details'][1]['dialplan_detail_type'] = 'log';
unset($sql); $array['dialplan_details'][1]['dialplan_detail_data'] = '[inbound routes] 404 not found \${sip_network_ip}';
} $array['dialplan_details'][1]['dialplan_detail_order'] = '20';
unset($prep_statement);
$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);
} }
} }
*/ */

View File

@ -49,34 +49,34 @@
//set the variables //set the variables
if (count($_POST) > 0) { 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_field_1 = $_POST["condition_field_1"];
$condition_expression_1 = check_str($_POST["condition_expression_1"]); $condition_expression_1 = $_POST["condition_expression_1"];
$condition_field_2 = check_str($_POST["condition_field_2"]); $condition_field_2 = $_POST["condition_field_2"];
$condition_expression_2 = check_str($_POST["condition_expression_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 = "transfer:1001 XML default";
$action_1_array = explode(":", $action_1); $action_1_array = explode(":", $action_1);
$action_application_1 = array_shift($action_1_array); $action_application_1 = array_shift($action_1_array);
$action_data_1 = join(':', $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 = "transfer:1001 XML default";
$action_2_array = explode(":", $action_2); $action_2_array = explode(":", $action_2);
$action_application_2 = array_shift($action_2_array); $action_application_2 = array_shift($action_2_array);
$action_data_2 = join(':', $action_2_array); $action_data_2 = join(':', $action_2_array);
//$action_application_1 = check_str($_POST["action_application_1"]); //$action_application_1 = $_POST["action_application_1"];
//$action_data_1 = check_str($_POST["action_data_1"]); //$action_data_1 = $_POST["action_data_1"];
//$action_application_2 = check_str($_POST["action_application_2"]); //$action_application_2 = $_POST["action_application_2"];
//$action_data_2 = check_str($_POST["action_data_2"]); //$action_data_2 = $_POST["action_data_2"];
$dialplan_context = check_str($_POST["dialplan_context"]); $dialplan_context = $_POST["dialplan_context"];
$dialplan_order = check_str($_POST["dialplan_order"]); $dialplan_order = $_POST["dialplan_order"];
$dialplan_enabled = check_str($_POST["dialplan_enabled"]); $dialplan_enabled = $_POST["dialplan_enabled"];
$dialplan_description = check_str($_POST["dialplan_description"]); $dialplan_description = $_POST["dialplan_description"];
if (strlen($dialplan_enabled) == 0) { $dialplan_enabled = "true"; } //set default to enabled 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);
$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 //add the main dialplan include entry
$dialplan_uuid = uuid(); $dialplan_uuid = uuid();
$sql = "insert into v_dialplans "; $array['dialplans'][0]['domain_uuid'] = $domain_uuid;
$sql .= "("; $array['dialplans'][0]['dialplan_uuid'] = $dialplan_uuid;
$sql .= "domain_uuid, "; $array['dialplans'][0]['app_uuid'] = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
$sql .= "dialplan_uuid, "; $array['dialplans'][0]['dialplan_name'] = $dialplan_name;
$sql .= "app_uuid, "; $array['dialplans'][0]['dialplan_order'] = $dialplan_order;
$sql .= "dialplan_name, "; $array['dialplans'][0]['dialplan_continue'] = 'false';
$sql .= "dialplan_order, "; $array['dialplans'][0]['dialplan_context'] = $dialplan_context;
$sql .= "dialplan_continue, "; $array['dialplans'][0]['dialplan_enabled'] = $dialplan_enabled;
$sql .= "dialplan_context, "; $array['dialplans'][0]['dialplan_description'] = $dialplan_description;
$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);
//add condition 1 //add condition 1
$dialplan_detail_uuid = uuid(); $dialplan_detail_uuid = uuid();
$sql = "insert into v_dialplan_details "; $array['dialplan_details'][0]['domain_uuid'] = $domain_uuid;
$sql .= "("; $array['dialplan_details'][0]['dialplan_uuid'] = $dialplan_uuid;
$sql .= "domain_uuid, "; $array['dialplan_details'][0]['dialplan_detail_uuid'] = $dialplan_detail_uuid;
$sql .= "dialplan_uuid, "; $array['dialplan_details'][0]['dialplan_detail_tag'] = 'condition';
$sql .= "dialplan_detail_uuid, "; $array['dialplan_details'][0]['dialplan_detail_type'] = $condition_field_1;
$sql .= "dialplan_detail_tag, "; $array['dialplan_details'][0]['dialplan_detail_data'] = $condition_expression_1;
$sql .= "dialplan_detail_type, "; $array['dialplan_details'][0]['dialplan_detail_order'] = '1';
$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);
//add condition 2 //add condition 2
if (strlen($condition_field_2) > 0) { if (strlen($condition_field_2) > 0) {
$dialplan_detail_uuid = uuid(); $dialplan_detail_uuid = uuid();
$sql = "insert into v_dialplan_details "; $array['dialplan_details'][1]['domain_uuid'] = $domain_uuid;
$sql .= "("; $array['dialplan_details'][1]['dialplan_uuid'] = $dialplan_uuid;
$sql .= "domain_uuid, "; $array['dialplan_details'][1]['dialplan_detail_uuid'] = $dialplan_detail_uuid;
$sql .= "dialplan_uuid, "; $array['dialplan_details'][1]['dialplan_detail_tag'] = 'condition';
$sql .= "dialplan_detail_uuid, "; $array['dialplan_details'][1]['dialplan_detail_type'] = $condition_field_2;
$sql .= "dialplan_detail_tag, "; $array['dialplan_details'][1]['dialplan_detail_data'] = $condition_expression_2;
$sql .= "dialplan_detail_type, "; $array['dialplan_details'][1]['dialplan_detail_order'] = '2';
$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);
} }
//add action 1 //add action 1
$dialplan_detail_uuid = uuid(); $dialplan_detail_uuid = uuid();
$sql = "insert into v_dialplan_details "; $array['dialplan_details'][2]['domain_uuid'] = $domain_uuid;
$sql .= "("; $array['dialplan_details'][2]['dialplan_uuid'] = $dialplan_uuid;
$sql .= "domain_uuid, "; $array['dialplan_details'][2]['dialplan_detail_uuid'] = $dialplan_detail_uuid;
$sql .= "dialplan_uuid, "; $array['dialplan_details'][2]['dialplan_detail_tag'] = 'action';
$sql .= "dialplan_detail_uuid, "; $array['dialplan_details'][2]['dialplan_detail_type'] = $action_application_1;
$sql .= "dialplan_detail_tag, "; $array['dialplan_details'][2]['dialplan_detail_data'] = $action_data_1;
$sql .= "dialplan_detail_type, "; $array['dialplan_details'][2]['dialplan_detail_order'] = '3';
$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);
//add action 2 //add action 2
if (strlen($action_application_2) > 0) { if (strlen($action_application_2) > 0) {
$dialplan_detail_uuid = uuid(); $dialplan_detail_uuid = uuid();
$sql = "insert into v_dialplan_details "; $array['dialplan_details'][3]['domain_uuid'] = $domain_uuid;
$sql .= "("; $array['dialplan_details'][3]['dialplan_uuid'] = $dialplan_uuid;
$sql .= "domain_uuid, "; $array['dialplan_details'][3]['dialplan_detail_uuid'] = $dialplan_detail_uuid;
$sql .= "dialplan_uuid, "; $array['dialplan_details'][3]['dialplan_detail_tag'] = 'action';
$sql .= "dialplan_detail_uuid, "; $array['dialplan_details'][3]['dialplan_detail_type'] = $action_application_2;
$sql .= "dialplan_detail_tag, "; $array['dialplan_details'][3]['dialplan_detail_data'] = $action_data_2;
$sql .= "dialplan_detail_type, "; $array['dialplan_details'][3]['dialplan_detail_order'] = '4';
$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);
} }
//commit the atomic transaction //execute inserts
$count = $db->exec("COMMIT;"); //returns affected rows $database = new database;
$database->app_name = 'dialplans';
$database->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
$database->save($array);
unset($array);
//synchronize the xml config //synchronize the xml config
save_dialplan_xml(); save_dialplan_xml();
@ -259,8 +183,8 @@
//send a message and redirect the user //send a message and redirect the user
message::add($text['message-update']); message::add($text['message-update']);
header("Location: ".PROJECT_PATH."/app/dialplans/dialplans.php"); header("Location: ".PROJECT_PATH."/app/dialplans/dialplans.php");
return; exit;
} //end if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) }
//initialize the destinations object //initialize the destinations object
$destination = new destinations; $destination = new destinations;

View File

@ -52,8 +52,8 @@
$log = new Logging(); $log = new Logging();
//set the http get/post variable(s) to a php variable //set the http get/post variable(s) to a php variable
if (isset($_REQUEST["id"])) { if (is_uuid($_REQUEST["id"])) {
$id = check_str($_REQUEST["id"]); $id = $_REQUEST["id"];
$log->log("debug", "isset id."); $log->log("debug", "isset id.");
$log->log("debug", $id); $log->log("debug", $id);
} }
@ -61,60 +61,62 @@
//get the dialplan data //get the dialplan data
if (is_uuid($id)) { if (is_uuid($id)) {
$sql = "select * from v_dialplans "; $sql = "select * from v_dialplans ";
$sql .= "where dialplan_uuid = '$id' "; $sql .= "where dialplan_uuid = :dialplan_uuid ";
$log->log("debug", check_sql($sql)); $parameters['dialplan_uuid'] = $id;
$prep_statement = $db->prepare(check_sql($sql)); $database = new database;
$prep_statement->execute(); $dialplans = $database->select($sql, $parameters, 'all');
$dialplans = $prep_statement->fetchAll(PDO::FETCH_NAMED); if (is_array($dialplans) && @sizeof($dialplans) != 0) {
$log->log("debug", $result); foreach ($dialplans as &$row) {
foreach ($dialplans as &$row) { //create a new primary key for the new row
//create a new primary key for the new row $dialplan_uuid = uuid();
$dialplan_uuid = uuid(); $row['dialplan_uuid'] = $dialplan_uuid;
$row['dialplan_uuid'] = $dialplan_uuid;
//get the app_uuid //get the app_uuid
if (is_uuid($row["app_uuid"])) { if (is_uuid($row["app_uuid"])) {
//get the app uuid //get the app uuid
$app_uuid = $row["app_uuid"]; $app_uuid = $row["app_uuid"];
//create a new app_uuid when copying a dialplan except for these exceptions //create a new app_uuid when copying a dialplan except for these exceptions
switch ($app_uuid) { switch ($app_uuid) {
case "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4": break; //inbound routes case "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4": break; //inbound routes
case "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3": break; //outbound routes case "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3": break; //outbound routes
case "4b821450-926b-175a-af93-a03c441818b1": break; //time conditions case "4b821450-926b-175a-af93-a03c441818b1": break; //time conditions
default: default:
$app_uuid = uuid(); $app_uuid = uuid();
} }
//set the app uuid //set the app uuid
$row['app_uuid'] = $app_uuid; $row['app_uuid'] = $app_uuid;
} }
//add copy to the name and description //add copy to the name and description
//$row['dialplan_name'] = $row['dialplan_name'].'-copy'; //$row['dialplan_name'] = $row['dialplan_name'].'-copy';
if (strlen($row['dialplan_description']) == 0) { if (strlen($row['dialplan_description']) == 0) {
$dialplan_description = 'copy'; $dialplan_description = 'copy';
} }
else { else {
$dialplan_description = $row['dialplan_description'].'-copy'; $dialplan_description = $row['dialplan_description'].'-copy';
} }
$row['dialplan_description'] = $dialplan_description; $row['dialplan_description'] = $dialplan_description;
}
} }
unset ($prep_statement); unset($sql, $parameters, $row);
} }
//get the the dialplan details //get the the dialplan details
if (is_uuid($id)) { if (is_uuid($id)) {
$sql = "select * from v_dialplan_details "; $sql = "select * from v_dialplan_details ";
$sql .= "where dialplan_uuid = '$id' "; $sql .= "where dialplan_uuid = :dialplan_uuid ";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['dialplan_uuid'] = $id;
$prep_statement->execute(); $database = new database;
$dialplan_details = $prep_statement->fetchAll(PDO::FETCH_NAMED); $dialplan_details = $database->select($sql, $parameters, 'all');
foreach ($dialplan_details as &$row) { if (is_array($dialplan_details) && @sizeof($dialplan_details) != 0) {
//create a new primary key for the new row foreach ($dialplan_details as &$row) {
$row['dialplan_detail_uuid'] = uuid(); //create a new primary key for the new row
//update the foreign relation uuid $row['dialplan_detail_uuid'] = uuid();
$row['dialplan_uuid'] = $dialplan_uuid; //update the foreign relation uuid
$row['dialplan_uuid'] = $dialplan_uuid;
}
} }
unset ($prep_statement); unset($sql, $parameters);
} }
//build the array //build the array
@ -123,17 +125,13 @@
$array['dialplans'][0]['dialplan_details'] = $dialplan_details; $array['dialplans'][0]['dialplan_details'] = $dialplan_details;
} }
//debug info
//echo "<pre>".print_r($array, true)."</pre>\n";
//exit;
//add or update the database //add or update the database
$database = new database; $database = new database;
$database->app_name = 'dialplans'; $database->app_name = 'dialplans';
$database->app_uuid = $app_uuid; $database->app_uuid = $app_uuid;
$database->uuid($dialplan_uuid); $database->uuid($dialplan_uuid);
$database->save($array); $database->save($array);
//$message = $database->message; unset($array);
//update the dialplan xml //update the dialplan xml
$dialplans = new dialplan; $dialplans = new dialplan;

View File

@ -48,10 +48,10 @@
//set the dialplan uuid //set the dialplan uuid
$dialplan_uuids = $_REQUEST["id"]; $dialplan_uuids = $_REQUEST["id"];
$app_uuid = check_str($_REQUEST['app_uuid']); $app_uuid = $_REQUEST['app_uuid'];
//delete the dialplans //delete the dialplans
if (sizeof($dialplan_uuids) > 0) { if (is_array($dialplan_uuids) && @sizeof($dialplan_uuids) != 0) {
//get dialplan contexts //get dialplan contexts
foreach ($dialplan_uuids as $dialplan_uuid) { foreach ($dialplan_uuids as $dialplan_uuid) {
@ -60,41 +60,43 @@
//get the dialplan data //get the dialplan data
$sql = "select * from v_dialplans "; $sql = "select * from v_dialplans ";
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' "; $sql .= "where dialplan_uuid = :dialplan_uuid ";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['dialplan_uuid'] = $dialplan_uuid;
$prep_statement->execute(); $database = new database;
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result = $database->select($sql, $parameters, 'all');
foreach ($result as &$row) { if (is_array($result) && @sizeof($result) != 0) {
$database_dialplan_uuid = $row["dialplan_uuid"]; foreach ($result as &$row) {
$dialplan_contexts[] = $row["dialplan_context"]; $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 //delete dialplan and details
$dialplans_deleted = 0; $dialplans_deleted = 0;
foreach ($dialplan_uuids as $dialplan_uuid) { foreach ($dialplan_uuids as $index => $dialplan_uuid) {
//child data
//delete child data $array['dialplan_details'][$index]['dialplan_uuid'] = $dialplan_uuid;
$sql = "delete from v_dialplan_details "; //parent data
$sql .= "where dialplan_uuid = '".$dialplan_uuid."'; "; $array['dialplans'][$index]['dialplan_uuid'] = $dialplan_uuid;
$db->query($sql); //increment counter
unset($sql); $dialplans_deleted++;
//delete parent data
$sql = "delete from v_dialplans ";
$sql .= "where dialplan_uuid = '".$dialplan_uuid."'; ";
$db->query($sql);
unset($sql);
$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 $database = new database;
$db->commit(); $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 //synchronize the xml config
save_dialplan_xml(); save_dialplan_xml();

View File

@ -47,20 +47,26 @@
$text = $language->get(); $text = $language->get();
//set the variables //set the variables
if (count($_GET) > 0) { $dialplan_detail_uuid = $_GET["id"];
$dialplan_detail_uuid = check_str($_GET["id"]); $dialplan_uuid = $_REQUEST["dialplan_uuid"];
$dialplan_uuid = check_str($_REQUEST["dialplan_uuid"]); $app_uuid = $_REQUEST["app_uuid"];
$app_uuid = check_str($_REQUEST["app_uuid"]);
}
//delete the dialplan detail //delete the dialplan detail
if (is_uuid($dialplan_detail_uuid)) { if (is_uuid($dialplan_detail_uuid)) {
//delete child data //delete child data
$sql = "delete from v_dialplan_details "; $array['dialplan_details'][0]['dialplan_detail_uuid'] = $dialplan_detail_uuid;
//$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; //$array['dialplan_details'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
$sql .= "where dialplan_detail_uuid = '$dialplan_detail_uuid' ";
$db->query($sql); $p = new permissions;
unset($sql); $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 //synchronize the xml config
save_dialplan_xml(); save_dialplan_xml();
@ -75,10 +81,10 @@
$dialplans->destination = "database"; $dialplans->destination = "database";
$dialplans->uuid = $dialplan_uuid; $dialplans->uuid = $dialplan_uuid;
$dialplans->xml(); $dialplans->xml();
}
//save the message to a session variable //set message
message::add($text['message-delete']); message::add($text['message-delete']);
}
//redirect the browser //redirect the browser
header("Location: dialplan_edit.php?id=".$dialplan_uuid.(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)); header("Location: dialplan_edit.php?id=".$dialplan_uuid.(($app_uuid != '') ? "&app_uuid=".$app_uuid : null));

View File

@ -48,33 +48,33 @@ else {
$text = $language->get(); $text = $language->get();
//set the action as an add or update //set the action as an add or update
if (isset($_REQUEST["id"])) { if (is_uuid($_REQUEST["id"])) {
$action = "update"; $action = "update";
$dialplan_detail_uuid = check_str($_REQUEST["id"]); $dialplan_detail_uuid = $_REQUEST["id"];
} }
else { else {
$action = "add"; $action = "add";
} }
$dialplan_uuid = check_str($_REQUEST["dialplan_uuid"]); $dialplan_uuid = $_REQUEST["dialplan_uuid"];
//get the http values and set them as php variables //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) { if (count($_POST)>0) {
$dialplan_uuid = check_str($_POST["dialplan_uuid"]); $dialplan_uuid = $_POST["dialplan_uuid"];
$dialplan_detail_tag = check_str($_POST["dialplan_detail_tag"]); $dialplan_detail_tag = $_POST["dialplan_detail_tag"];
$dialplan_detail_order = check_str($_POST["dialplan_detail_order"]); $dialplan_detail_order = $_POST["dialplan_detail_order"];
$dialplan_detail_type = check_str($_POST["dialplan_detail_type"]); $dialplan_detail_type = $_POST["dialplan_detail_type"];
$dialplan_detail_data = check_str($_POST["dialplan_detail_data"]); $dialplan_detail_data = $_POST["dialplan_detail_data"];
$dialplan_detail_break = check_str($_POST["dialplan_detail_break"]); $dialplan_detail_break = $_POST["dialplan_detail_break"];
$dialplan_detail_inline = check_str($_POST["dialplan_detail_inline"]); $dialplan_detail_inline = $_POST["dialplan_detail_inline"];
$dialplan_detail_group = check_str($_POST["dialplan_detail_group"]); $dialplan_detail_group = $_POST["dialplan_detail_group"];
} }
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$msg = ''; $msg = '';
if ($action == "update") { if ($action == "update") {
$dialplan_detail_uuid = check_str($_POST["dialplan_detail_uuid"]); $dialplan_detail_uuid = $_POST["dialplan_detail_uuid"];
} }
//check for all required data //check for all required data
@ -99,39 +99,27 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
if ($_POST["persistformvar"] != "true") { if ($_POST["persistformvar"] != "true") {
if ($action == "add" && permission_exists('dialplan_add')) { if ($action == "add" && permission_exists('dialplan_add')) {
$dialplan_detail_uuid = uuid(); $dialplan_detail_uuid = uuid();
$sql = "insert into v_dialplan_details "; $array['dialplan_details'][0]['dialplan_uuid'] = $dialplan_uuid;
$sql .= "("; $array['dialplan_details'][0]['dialplan_detail_uuid'] = $dialplan_detail_uuid;
$sql .= "dialplan_uuid, "; $array['dialplan_details'][0]['dialplan_detail_tag'] = $dialplan_detail_tag;
$sql .= "dialplan_detail_uuid, "; $array['dialplan_details'][0]['dialplan_detail_order'] = $dialplan_detail_order;
$sql .= "dialplan_detail_tag, "; $array['dialplan_details'][0]['dialplan_detail_type'] = $dialplan_detail_type;
$sql .= "dialplan_detail_order, "; $array['dialplan_details'][0]['dialplan_detail_data'] = $dialplan_detail_data;
$sql .= "dialplan_detail_type, "; $array['dialplan_details'][0]['dialplan_detail_break'] = $dialplan_detail_break;
$sql .= "dialplan_detail_data, "; $array['dialplan_details'][0]['dialplan_detail_inline'] = $dialplan_detail_inline;
$sql .= "dialplan_detail_break, "; $array['dialplan_details'][0]['dialplan_detail_group'] = $dialplan_detail_group != '' ? $dialplan_detail_group : null;
$sql .= "dialplan_detail_inline, "; $array['dialplan_details'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
$sql .= "dialplan_detail_group, ";
$sql .= "domain_uuid "; $p = new permissions;
$sql .= ")"; $p->add('dialplan_detail_add', 'temp');
$sql .= "values ";
$sql .= "("; $database = new database;
$sql .= "'$dialplan_uuid', "; $database->app_name = 'dialplans';
$sql .= "'$dialplan_detail_uuid', "; $database->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
$sql .= "'$dialplan_detail_tag', "; $database->save($array);
$sql .= "'$dialplan_detail_order', "; unset($array);
$sql .= "'$dialplan_detail_type', ";
$sql .= "'$dialplan_detail_data', "; $p->delete('dialplan_detail_add', 'temp');
$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);
//synchronize the xml config //synchronize the xml config
save_dialplan_xml(); save_dialplan_xml();
@ -144,27 +132,33 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
message::add($text['message-add']); message::add($text['message-add']);
header("Location: dialplan_edit.php?id=".$dialplan_uuid."&app_uuid=".$app_uuid); header("Location: dialplan_edit.php?id=".$dialplan_uuid."&app_uuid=".$app_uuid);
return; return;
} //if ($action == "add") }
if ($action == "update" && permission_exists('dialplan_edit')) { if ($action == "update" && permission_exists('dialplan_edit')) {
$sql = "update v_dialplan_details set "; $sql = "update v_dialplan_details set ";
$sql .= "dialplan_uuid = '$dialplan_uuid', "; $sql .= "dialplan_uuid = :dialplan_uuid ";
$sql .= "dialplan_detail_tag = '$dialplan_detail_tag', "; $sql .= "dialplan_detail_tag = :dialplan_detail_tag, ";
$sql .= "dialplan_detail_order = '$dialplan_detail_order', "; $sql .= "dialplan_detail_order = :dialplan_detail_order, ";
$sql .= "dialplan_detail_type = '$dialplan_detail_type', "; $sql .= "dialplan_detail_type = :dialplan_detail_type, ";
$sql .= "dialplan_detail_data = '$dialplan_detail_data', "; $sql .= "dialplan_detail_data = :dialplan_detail_data, ";
$sql .= "dialplan_detail_break = '$dialplan_detail_break', "; $sql .= "dialplan_detail_break = :dialplan_detail_break, ";
$sql .= "dialplan_detail_inline = '$dialplan_detail_inline', "; $sql .= "dialplan_detail_inline = :dialplan_detail_inline, ";
if (strlen($dialplan_detail_group) == 0) { $sql .= "dialplan_detail_group = :dialplan_detail_group ";
$sql .= "dialplan_detail_group = null "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
} $sql .= "and dialplan_detail_uuid = :dialplan_detail_uuid ";
else { $parameters['dialplan_uuid'] = $dialplan_uuid;
$sql .= "dialplan_detail_group = '$dialplan_detail_group' "; $parameters['dialplan_detail_tag'] = $dialplan_detail_tag;
} $parameters['dialplan_detail_order'] = $dialplan_detail_order;
$sql .= "where (domain_uuid = '".$_SESSION['domain_uuid']."' or domain_uuid is null) "; $parameters['dialplan_detail_type'] = $dialplan_detail_type;
$sql .= "and dialplan_detail_uuid = '$dialplan_detail_uuid'"; $parameters['dialplan_detail_data'] = $dialplan_detail_data;
$db->exec(check_sql($sql)); $parameters['dialplan_detail_break'] = $dialplan_detail_break;
unset($sql); $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 //synchronize the xml config
save_dialplan_xml(); save_dialplan_xml();
@ -187,12 +181,13 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
if (count($_GET)>0 && $_POST["persistformvar"] != "true") { if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
$dialplan_detail_uuid = $_GET["id"]; $dialplan_detail_uuid = $_GET["id"];
$sql = "select * from v_dialplan_details "; $sql = "select * from v_dialplan_details ";
$sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and dialplan_detail_uuid = '$dialplan_detail_uuid' "; $sql .= "and dialplan_detail_uuid = :dialplan_detail_uuid ";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['domain_uuid'] = $domain_uuid;
$prep_statement->execute(); $parameters['dialplan_detail_uuid'] = $dialplan_detail_uuid;
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $database = new database;
foreach ($result as &$row) { $row = $database->select($sql, $parameters, 'row');
if (is_array($row) && @sizeof($row) != 0) {
$dialplan_uuid = $row["dialplan_uuid"]; $dialplan_uuid = $row["dialplan_uuid"];
$dialplan_detail_tag = $row["dialplan_detail_tag"]; $dialplan_detail_tag = $row["dialplan_detail_tag"];
$dialplan_detail_order = $row["dialplan_detail_order"]; $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_inline = $row["dialplan_detail_inline"];
$dialplan_detail_group = $row["dialplan_detail_group"]; $dialplan_detail_group = $row["dialplan_detail_group"];
} }
unset ($prep_statement); unset($sql, $parameters, $row);
} }
//show the header //show the header

View File

@ -63,22 +63,21 @@
} }
//set the app_uuid //set the app_uuid
if (strlen($_GET["app_uuid"]) > 0) { if (is_uuid($_GET["app_uuid"])) {
$app_uuid = $_GET["app_uuid"]; $app_uuid = $_GET["app_uuid"];
} }
//get the http post values and set them as php variables //get the http post values and set them as php variables
if (count($_POST) > 0) { if (count($_POST) > 0) {
$hostname = check_str($_POST["hostname"]); $hostname = $_POST["hostname"];
$dialplan_name = check_str($_POST["dialplan_name"]); $dialplan_name = $_POST["dialplan_name"];
$dialplan_number = check_str($_POST["dialplan_number"]); $dialplan_number = $_POST["dialplan_number"];
$dialplan_order = check_str($_POST["dialplan_order"]); $dialplan_order = $_POST["dialplan_order"];
$dialplan_continue = check_str($_POST["dialplan_continue"]); $dialplan_continue = $_POST["dialplan_continue"] != '' ? $_POST["dialplan_continue"] : 'false';
$dialplan_details = $_POST["dialplan_details"]; $dialplan_details = $_POST["dialplan_details"];
if (strlen($dialplan_continue) == 0) { $dialplan_continue = "false"; } $dialplan_context = $_POST["dialplan_context"];
$dialplan_context = check_str($_POST["dialplan_context"]); $dialplan_enabled = $_POST["dialplan_enabled"];
$dialplan_enabled = check_str($_POST["dialplan_enabled"]); $dialplan_description = $_POST["dialplan_description"];
$dialplan_description = check_str($_POST["dialplan_description"]);
} }
//get the list of applications //get the list of applications
@ -131,14 +130,14 @@
//build the array //build the array
$x = 0; $x = 0;
if (isset($_POST["dialplan_uuid"])) { if (is_uuid($_POST["dialplan_uuid"])) {
$array['dialplans'][$x]['dialplan_uuid'] = $_POST["dialplan_uuid"]; $array['dialplans'][$x]['dialplan_uuid'] = $_POST["dialplan_uuid"];
} }
else { else {
$dialplan_uuid = uuid(); $dialplan_uuid = uuid();
$array['dialplans'][$x]['dialplan_uuid'] = $dialplan_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']; $array['dialplans'][$x]['domain_uuid'] = $_POST['domain_uuid'];
} }
else { else {
@ -183,7 +182,7 @@
$database->app_uuid = $app_uuid; $database->app_uuid = $app_uuid;
$database->uuid($dialplan_uuid); $database->uuid($dialplan_uuid);
$database->save($array); $database->save($array);
$message = $database->message; unset($array);
} }
//update the dialplan xml //update the dialplan xml
@ -207,7 +206,7 @@
else if ($action == "update") { else if ($action == "update") {
message::add($text['message-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; exit;
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
@ -215,11 +214,11 @@
//pre-populate the form //pre-populate the form
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
$sql = "select * from v_dialplans "; $sql = "select * from v_dialplans ";
$sql .= "where dialplan_uuid = '$dialplan_uuid' "; $sql .= "where dialplan_uuid = :dialplan_uuid ";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['dialplan_uuid'] = $dialplan_uuid;
$prep_statement->execute(); $database = new database;
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $row = $database->select($sql, $parameters, 'row');
if (is_array($result)) foreach ($result as &$row) { if (is_array($row) && @sizeof($row) != 0) {
$domain_uuid = $row["domain_uuid"]; $domain_uuid = $row["domain_uuid"];
$hostname = $row["hostname"]; $hostname = $row["hostname"];
$dialplan_name = $row["dialplan_name"]; $dialplan_name = $row["dialplan_name"];
@ -231,7 +230,7 @@
$dialplan_enabled = $row["dialplan_enabled"]; $dialplan_enabled = $row["dialplan_enabled"];
$dialplan_description = $row["dialplan_description"]; $dialplan_description = $row["dialplan_description"];
} }
unset ($prep_statement); unset($sql, $parameters, $row);
} }
//set the defaults //set the defaults
@ -248,13 +247,12 @@
//get the dialplan details in an array //get the dialplan details in an array
$sql = "select * from v_dialplan_details "; $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"; $sql .= "order by dialplan_detail_group asc, dialplan_detail_order asc";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['dialplan_uuid'] = $dialplan_uuid;
$prep_statement->execute(); $database = new database;
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result = $database->select($sql, $parameters, 'all');
$result_count = count($result); unset($sql, $parameters);
unset ($prep_statement, $sql);
//create a new array that is sorted into groups and put the tags in order conditions, actions, anti-actions //create a new array that is sorted into groups and put the tags in order conditions, actions, anti-actions
//set the array index //set the array index
@ -262,69 +260,81 @@
//define the array //define the array
$details = array(); $details = array();
//conditions //conditions
if (is_array($result)) foreach($result as $row) { if (is_array($result) && @sizeof($result) != 0) {
if ($row['dialplan_detail_tag'] == "condition") { foreach ($result as $row) {
$group = $row['dialplan_detail_group']; if ($row['dialplan_detail_tag'] == "condition") {
foreach ($row as $key => $val) { $group = $row['dialplan_detail_group'];
$details[$group][$x][$key] = $val; foreach ($row as $key => $val) {
$details[$group][$x][$key] = $val;
}
} }
$x++;
} }
$x++;
} }
//regex //regex
if (is_array($result)) foreach($result as $row) { if (is_array($result) && @sizeof($result) != 0) {
if ($row['dialplan_detail_tag'] == "regex") { foreach ($result as $row) {
$group = $row['dialplan_detail_group']; if ($row['dialplan_detail_tag'] == "regex") {
foreach ($row as $key => $val) { $group = $row['dialplan_detail_group'];
$details[$group][$x][$key] = $val; foreach ($row as $key => $val) {
$details[$group][$x][$key] = $val;
}
} }
$x++;
} }
$x++;
} }
//actions //actions
if (is_array($result)) foreach($result as $row) { if (is_array($result) && @sizeof($result) != 0) {
if ($row['dialplan_detail_tag'] == "action") { foreach ($result as $row) {
$group = $row['dialplan_detail_group']; if ($row['dialplan_detail_tag'] == "action") {
foreach ($row as $key => $val) { $group = $row['dialplan_detail_group'];
$details[$group][$x][$key] = $val; foreach ($row as $key => $val) {
$details[$group][$x][$key] = $val;
}
} }
$x++;
} }
$x++;
} }
//anti-actions //anti-actions
if (is_array($result)) foreach($result as $row) { if (is_array($result) && @sizeof($result) != 0) {
if ($row['dialplan_detail_tag'] == "anti-action") { foreach ($result as $row) {
$group = $row['dialplan_detail_group']; if ($row['dialplan_detail_tag'] == "anti-action") {
foreach ($row as $key => $val) { $group = $row['dialplan_detail_group'];
$details[$group][$x][$key] = $val; foreach ($row as $key => $val) {
$details[$group][$x][$key] = $val;
}
} }
$x++;
} }
$x++;
} }
unset($result); unset($result);
//blank row //blank row
if (is_array($details)) foreach($details as $group => $row) { if (is_array($details) && @sizeof($details) != 0) {
//set the array key for the empty row foreach ($details as $group => $row) {
$x = "999"; //set the array key for the empty row
//get the highest dialplan_detail_order $x = "999";
if (is_array($row)) foreach ($row as $key => $field) { //get the highest dialplan_detail_order
$dialplan_detail_order = 0; if (is_array($row) && @sizeof($details) != 0) {
if ($dialplan_detail_order < $field['dialplan_detail_order']) { foreach ($row as $key => $field) {
$dialplan_detail_order = $field['dialplan_detail_order']; $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
//increment the highest order by 5 $dialplan_detail_order = $dialplan_detail_order + 10;
$dialplan_detail_order = $dialplan_detail_order + 10; //set the rest of the empty array
//set the rest of the empty array //$details[$group][$x]['domain_uuid'] = '';
//$details[$group][$x]['domain_uuid'] = ''; //$details[$group][$x]['dialplan_uuid'] = '';
//$details[$group][$x]['dialplan_uuid'] = ''; $details[$group][$x]['dialplan_detail_tag'] = '';
$details[$group][$x]['dialplan_detail_tag'] = ''; $details[$group][$x]['dialplan_detail_type'] = '';
$details[$group][$x]['dialplan_detail_type'] = ''; $details[$group][$x]['dialplan_detail_data'] = '';
$details[$group][$x]['dialplan_detail_data'] = ''; $details[$group][$x]['dialplan_detail_break'] = '';
$details[$group][$x]['dialplan_detail_break'] = ''; $details[$group][$x]['dialplan_detail_inline'] = '';
$details[$group][$x]['dialplan_detail_inline'] = ''; $details[$group][$x]['dialplan_detail_group'] = $group;
$details[$group][$x]['dialplan_detail_group'] = $group; $details[$group][$x]['dialplan_detail_order'] = $dialplan_detail_order;
$details[$group][$x]['dialplan_detail_order'] = $dialplan_detail_order; }
} }
//sort the details array by group number //sort the details array by group number
if (is_array($details)) { if (is_array($details)) {
@ -521,18 +531,20 @@
echo " </td>\n"; echo " </td>\n";
echo " <td class='vtable' align='left'>\n"; echo " <td class='vtable' align='left'>\n";
echo " <select class='formfld' name='domain_uuid'>\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"; echo " <option value='' selected='selected'>".$text['select-global']."</option>\n";
} }
else { else {
echo " <option value=''>".$text['select-global']."</option>\n"; echo " <option value=''>".$text['select-global']."</option>\n";
} }
if (is_array($_SESSION['domains'])) foreach ($_SESSION['domains'] as $row) { if (is_array($_SESSION['domains']) && @sizeof($_SESSION['domains']) != 0) {
if ($row['domain_uuid'] == $domain_uuid) { foreach ($_SESSION['domains'] as $row) {
echo " <option value='".escape($row['domain_uuid'])."' selected='selected'>".escape($row['domain_name'])."</option>\n"; 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"; else {
echo " <option value='".escape($row['domain_uuid'])."'>".escape($row['domain_name'])."</option>\n";
}
} }
} }
echo " </select>\n"; echo " </select>\n";
@ -599,7 +611,7 @@
<?php <?php
//display the results //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"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0' style='margin: -2px; border-spacing: 2px;'>\n";
@ -621,231 +633,233 @@
echo "<td>&nbsp;</td>\n"; echo "<td>&nbsp;</td>\n";
echo "</tr>\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 //get the values from the database and set as variables
$dialplan_detail_uuid = $row['dialplan_detail_uuid']; $dialplan_detail_uuid = $row['dialplan_detail_uuid'];
$dialplan_detail_tag = $row['dialplan_detail_tag']; $dialplan_detail_tag = $row['dialplan_detail_tag'];
$dialplan_detail_type = $row['dialplan_detail_type']; $dialplan_detail_type = $row['dialplan_detail_type'];
$dialplan_detail_data = $row['dialplan_detail_data']; $dialplan_detail_data = $row['dialplan_detail_data'];
$dialplan_detail_break = $row['dialplan_detail_break']; $dialplan_detail_break = $row['dialplan_detail_break'];
$dialplan_detail_inline = $row['dialplan_detail_inline']; $dialplan_detail_inline = $row['dialplan_detail_inline'];
$dialplan_detail_group = $row['dialplan_detail_group']; $dialplan_detail_group = $row['dialplan_detail_group'];
$dialplan_detail_order = $row['dialplan_detail_order']; $dialplan_detail_order = $row['dialplan_detail_order'];
//no border on last row //no border on last row
$no_border = ($index == 999) ? "border: none;" : null; $no_border = ($index == 999) ? "border: none;" : null;
//begin the row //begin the row
echo "<tr>\n"; echo "<tr>\n";
//determine whether to hide the element //determine whether to hide the element
if (strlen($dialplan_detail_tag) == 0) { if (strlen($dialplan_detail_tag) == 0) {
$element['hidden'] = false; $element['hidden'] = false;
$element['visibility'] = ""; $element['visibility'] = "";
} }
else { else {
$element['hidden'] = true; $element['hidden'] = true;
$element['visibility'] = "display: none;"; $element['visibility'] = "display: none;";
} }
//add the primary key uuid //add the primary key uuid
if (strlen($dialplan_detail_uuid) > 0) { if (is_uuid($dialplan_detail_uuid)) {
echo " <input name='dialplan_details[".$x."][dialplan_detail_uuid]' type='hidden' value=\"".escape($dialplan_detail_uuid)."\">\n"; echo " <input name='dialplan_details[".$x."][dialplan_detail_uuid]' type='hidden' value=\"".escape($dialplan_detail_uuid)."\">\n";
} }
//tag //tag
$selected = "selected=\"selected\" "; $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"; 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']) { if ($element['hidden']) {
echo " <label id=\"label_dialplan_detail_tag_".$x."\">".escape($dialplan_detail_tag)."</label>\n"; 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 " <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></option>\n";
echo " <option value='condition' ".($dialplan_detail_tag == "condition" ? $selected : null).">".$text['option-condition']."</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='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='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 " <option value='anti-action' ".($dialplan_detail_tag == "anti-action" ? $selected : null).">".$text['option-anti-action']."</option>\n";
echo " </select>\n"; echo " </select>\n";
echo "</td>\n"; echo "</td>\n";
//type //type
echo "<td class='vtablerow' style='".$no_border."' onclick=\"label_to_form('label_dialplan_detail_type_".$x."','dialplan_detail_type_".$x."');\" nowrap='nowrap'>\n"; 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']) { if ($element['hidden']) {
echo " <label id=\"label_dialplan_detail_type_".$x."\">".escape($dialplan_detail_type)."</label>\n"; 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"; 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) { if (strlen($dialplan_detail_type) > 0) {
echo " <optgroup label='selected'>\n"; echo " <optgroup label='selected'>\n";
echo " <option value=\"".escape($dialplan_detail_type)."\">".escape($dialplan_detail_type)."</option>\n"; echo " <option value=\"".escape($dialplan_detail_type)."\">".escape($dialplan_detail_type)."</option>\n";
echo " </optgroup>\n"; echo " </optgroup>\n";
} }
else { else {
echo " <option value=''></option>\n"; echo " <option value=''></option>\n";
} }
//if (strlen($dialplan_detail_tag) == 0 || $dialplan_detail_tag == "condition" || $dialplan_detail_tag == "regex") { //if (strlen($dialplan_detail_tag) == 0 || $dialplan_detail_tag == "condition" || $dialplan_detail_tag == "regex") {
echo " <optgroup label='".$text['optgroup-condition_or_regex']."'>\n"; echo " <optgroup label='".$text['optgroup-condition_or_regex']."'>\n";
echo " <option value='context'>".$text['option-context']."</option>\n"; echo " <option value='context'>".$text['option-context']."</option>\n";
echo " <option value='username'>".$text['option-username']."</option>\n"; echo " <option value='username'>".$text['option-username']."</option>\n";
echo " <option value='rdnis'>".$text['option-rdnis']."</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='destination_number'>".$text['option-destination_number']."</option>\n";
echo " <option value='dialplan'>".$text['option-dialplan']."</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_name'>".$text['option-caller_id_name']."</option>\n";
echo " <option value='caller_id_number'>".$text['option-caller_id_number']."</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='ani'>".$text['option-ani']."</option>\n";
echo " <option value='ani2'>".$text['option-ani2']."</option>\n"; echo " <option value='ani2'>".$text['option-ani2']."</option>\n";
echo " <option value='uuid'>".$text['option-uuid']."</option>\n"; echo " <option value='uuid'>".$text['option-uuid']."</option>\n";
echo " <option value='source'>".$text['option-source']."</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='chan_name'>".$text['option-chan_name']."</option>\n";
echo " <option value='network_addr'>".$text['option-network_addr']."</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='\${number_alias}'>\${number_alias}</option>\n";
echo " <option value='\${sip_from_uri}'>\${sip_from_uri}</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_user}'>\${sip_from_user}</option>\n";
echo " <option value='\${sip_from_host}'>\${sip_from_host}</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_uri}'>\${sip_contact_uri}</option>\n";
echo " <option value='\${sip_contact_user}'>\${sip_contact_user}</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_contact_host}'>\${sip_contact_host}</option>\n";
echo " <option value='\${sip_to_uri}'>\${sip_to_uri}</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_user}'>\${sip_to_user}</option>\n";
echo " <option value='\${sip_to_host}'>\${sip_to_host}</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='\${toll_allow}'>\${toll_allow}</option>\n";
echo " <option value='\${sip_h_Diversion}'>\${sip_h_Diversion}</option>\n"; echo " <option value='\${sip_h_Diversion}'>\${sip_h_Diversion}</option>\n";
echo " </optgroup>\n"; echo " </optgroup>\n";
//} //}
//if (strlen($dialplan_detail_tag) == 0 || $dialplan_detail_tag == "action" || $dialplan_detail_tag == "anti-action") { //if (strlen($dialplan_detail_tag) == 0 || $dialplan_detail_tag == "action" || $dialplan_detail_tag == "anti-action") {
echo " <optgroup label='".$text['optgroup-applications']."'>\n"; echo " <optgroup label='".$text['optgroup-applications']."'>\n";
if (is_array($_SESSION['switch']['applications'])) { if (is_array($_SESSION['switch']['applications'])) {
foreach ($_SESSION['switch']['applications'] as $row) { foreach ($_SESSION['switch']['applications'] as $row) {
if (strlen($row) > 0) { if (strlen($row) > 0) {
$application = explode(",", $row); $application = explode(",", $row);
if ($application[0] != "name" && stristr($application[0], "[") != true) { if ($application[0] != "name" && stristr($application[0], "[") != true) {
echo " <option value='".escape($application[0])."'>".escape($application[0])."</option>\n"; echo " <option value='".escape($application[0])."'>".escape($application[0])."</option>\n";
}
} }
} }
} }
} echo " </optgroup>\n";
echo " </optgroup>\n"; //}
//} echo " </select>\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='&#9665;'>\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='&#9665;'>\n"; echo "</td>\n";
echo "</td>\n"; //data
//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";
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']) {
if ($element['hidden']) { $dialplan_detail_data_mod = $dialplan_detail_data;
$dialplan_detail_data_mod = $dialplan_detail_data; if ($dialplan_detail_type == 'bridge') {
if ($dialplan_detail_type == 'bridge') { // split up failover bridges and get variables in statement
// split up failover bridges and get variables in statement $failover_bridges = explode('|', $dialplan_detail_data);
$failover_bridges = explode('|', $dialplan_detail_data); preg_match('/^\{.*\}/', $failover_bridges[0], $bridge_vars);
preg_match('/^\{.*\}/', $failover_bridges[0], $bridge_vars); $bridge_vars = $bridge_vars[0];
$bridge_vars = $bridge_vars[0];
// rename parse and rename each gateway
// rename parse and rename each gateway foreach ($failover_bridges as $bridge_statement_exploded) {
foreach ($failover_bridges as $bridge_statement_exploded) { // parse out gateway uuid
// parse out gateway uuid $bridge_statement = str_replace($bridge_vars, '', explode('/', $bridge_statement_exploded));
$bridge_statement = str_replace($bridge_vars, '', explode('/', $bridge_statement_exploded)); array_unshift($bridge_statement, $bridge_vars);
array_unshift($bridge_statement, $bridge_vars);
if ($bridge_statement[1] == 'sofia' && $bridge_statement[2] == 'gateway' && is_uuid($bridge_statement[3])) {
if ($bridge_statement[1] == 'sofia' && $bridge_statement[2] == 'gateway' && is_uuid($bridge_statement[3])) { // retrieve gateway name from db
// retrieve gateway name from db $sql = "select gateway from v_gateways where gateway_uuid = :gateway_uuid ";
$sql = "select gateway from v_gateways where gateway_uuid = '".$bridge_statement[3]."' "; $parameters['gateway_uuid'] = $bridge_statement[3];
$prep_statement = $db->prepare(check_sql($sql)); $database = new database;
$prep_statement->execute(); $gateways = $database->select($sql, $parameters, 'all');
$gateways = $prep_statement->fetchAll(PDO::FETCH_NAMED); if (is_array($gateways) && @sizeof($gateways) != 0) {
if (is_array($gateways)) { $gateway_name = $gateways[0]['gateway'];
$gateway_name = $gateways[0]['gateway']; $bridge_statement_exploded_mod = str_replace($bridge_statement[3], $gateway_name, $bridge_statement_exploded);
$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";
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"; //break
echo "</td>\n"; echo "<td class='vtablerow' style='".$no_border."' onclick=\"label_to_form('label_dialplan_detail_break_".$x."','dialplan_detail_break_".$x."');\" nowrap='nowrap'>\n";
//break if ($element['hidden']) {
echo "<td class='vtablerow' style='".$no_border."' onclick=\"label_to_form('label_dialplan_detail_break_".$x."','dialplan_detail_break_".$x."');\" nowrap='nowrap'>\n"; echo " <label id=\"label_dialplan_detail_break_".$x."\">".escape($dialplan_detail_break)."</label>\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";
} }
if (strlen($i) == 2) { echo " <select id='dialplan_detail_break_".$x."' name='dialplan_details[".$x."][dialplan_detail_break]' class='formfld' style='width: auto; ".$element['visibility']."'>\n";
echo " <option value='0$i'>0$i</option>\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"; echo " <option value='$i'>$i</option>\n";
$i++;
} }
$i++; echo " </select>\n";
} */
echo " </select>\n"; echo "</td>\n";
*/ //order
echo "</td>\n"; 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";
//tools if ($element['hidden']) {
echo " <td class='list_control_icon'>\n"; echo " <label id=\"label_dialplan_detail_order_".$x."\">".escape($dialplan_detail_order)."</label>\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 " <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 " <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 " <select id='dialplan_detail_order_".$x."' name='dialplan_details[".$x."][dialplan_detail_order]' class='formfld' style='".$element['width']." ".$element['visibility']."'>\n";
echo " </td>\n"; if (strlen($dialplan_detail_order)> 0) {
//end the row echo " <option $selected value='".escape($dialplan_detail_order)."'>".escape($dialplan_detail_order)."</option>\n";
echo "</tr>\n"; }
//increment the value $i=0;
$x++; 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++; $x++;
} //end foreach } //end foreach
unset($sql, $details); unset($details);
echo "</table>"; echo "</table>";

View File

@ -48,18 +48,18 @@
} }
//set the default app_uuid //set the default app_uuid
if (strlen($app_uuid) == 0) { if (!is_uuid($app_uuid)) {
$app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db'; $app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
} }
//get the dialplan xml //get the dialplan xml
if (is_uuid($dialplan_uuid)) { if (is_uuid($dialplan_uuid)) {
$sql = "select * from v_dialplans "; $sql = "select * from v_dialplans ";
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' "; $sql .= "where dialplan_uuid = :dialplan_uuid ";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['dialplan_uuid'] = $dialplan_uuid;
$prep_statement->execute(); $database = new database;
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $row = $database->select($sql, $parameters, 'row');
foreach ($result as &$row) { if (is_array($row) && @sizeof($row) != 0) {
$domain_uuid = $row["domain_uuid"]; $domain_uuid = $row["domain_uuid"];
//$app_uuid = $row["app_uuid"]; //$app_uuid = $row["app_uuid"];
$dialplan_name = $row["dialplan_name"]; $dialplan_name = $row["dialplan_name"];
@ -71,7 +71,7 @@
$dialplan_enabled = $row["dialplan_enabled"]; $dialplan_enabled = $row["dialplan_enabled"];
$dialplan_description = $row["dialplan_description"]; $dialplan_description = $row["dialplan_description"];
} }
unset ($prep_statement); unset($sql, $parameters, $row);
} }
//process the HTTP POST //process the HTTP POST
@ -87,19 +87,10 @@
$database = new database; $database = new database;
$database->app_name = 'dialplans'; $database->app_name = 'dialplans';
$database->app_uuid = $app_uuid; $database->app_uuid = $app_uuid;
//if (strlen($dialplan_uuid) > 0) {
// $database->uuid($dialplan_uuid);
//}
$database->save($array); $database->save($array);
$message = $database->message; unset($array);
//debug info //clear the cache
//echo "<pre>\n";
//print_r($message);
//echo "</pre>\n";
//exit;
//clear the cache
$cache = new cache; $cache = new cache;
$cache->delete("dialplan:".$dialplan_context); $cache->delete("dialplan:".$dialplan_context);
@ -126,7 +117,7 @@
echo " <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">\n"; echo " <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td align='left' width='30%'>\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>\n";
echo " <td width='70%' align='right'>\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"; 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";

View File

@ -43,9 +43,9 @@
$text = $language->get(); $text = $language->get();
//handle enable toggle //handle enable toggle
$dialplan_uuid = check_str($_REQUEST['id']); $dialplan_uuid = $_REQUEST['id'];
$dialplan_enabled = check_str($_REQUEST['enabled']); $dialplan_enabled = $_REQUEST['enabled'];
if (isset($dialplan_uuid) && is_uuid($dialplan_uuid) && $dialplan_enabled != '') { if (is_uuid($dialplan_uuid) && $dialplan_enabled != '') {
//make sure enabled is only true or false //make sure enabled is only true or false
if ($dialplan_enabled == "true") { if ($dialplan_enabled == "true") {
$dialplan_enabled = 'true'; $dialplan_enabled = 'true';
@ -55,20 +55,27 @@
} }
//get the dialplan context //get the dialplan context
$sql = "select * from v_dialplans "; $sql = "select dialplan_context from v_dialplans ";
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' "; $sql .= "where dialplan_uuid = :dialplan_uuid ";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['dialplan_uuid'] = $dialplan_uuid;
$prep_statement->execute(); $database = new database;
$row = $prep_statement->fetch(PDO::FETCH_NAMED); $dialplan_context = $database->select($sql, $parameters, 'column');
$dialplan_context = $row["dialplan_context"]; unset($sql, $parameters);
unset($sql);
//change the status //change the status
$sql = "update v_dialplans set "; $array['dialplans'][0]['dialplan_uuid'] = $dialplan_uuid;
$sql .= "dialplan_enabled = '".$dialplan_enabled."' "; $array['dialplans'][0]['dialplan_enabled'] = $dialplan_enabled;
$sql .= "where dialplan_uuid = '".$dialplan_uuid."'";
$db->exec(check_sql($sql)); $p = new permissions;
unset($sql); $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 //clear the cache
$cache = new cache; $cache = new cache;
@ -79,11 +86,11 @@
} }
//set the http values as php variables //set the http values as php variables
if (isset($_REQUEST["search"])) { $search = check_str($_REQUEST["search"]); } else { $search = null; } $search = $_REQUEST["search"];
if (isset($_REQUEST["order_by"])) { $order_by = check_str($_REQUEST["order_by"]); } else { $order_by = null; } $order_by = $_REQUEST["order_by"];
if (isset($_REQUEST["order"])) { $order = check_str($_REQUEST["order"]); } else { $order = null; } $order = $_REQUEST["order"];
if (isset($_REQUEST["dialplan_context"])) { $dialplan_context = check_str($_REQUEST["dialplan_context"]); } else { $dialplan_context = null; } $dialplan_context = $_REQUEST["dialplan_context"];
if (isset($_REQUEST["app_uuid"])) { $app_uuid = check_str($_REQUEST["app_uuid"]); } else { $app_uuid = null; } $app_uuid = $_REQUEST["app_uuid"];
//make sure all dialplans with context of public have the inbound route app_uuid //make sure all dialplans with context of public have the inbound route app_uuid
if ($app_uuid == 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4') { if ($app_uuid == 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4') {
@ -91,7 +98,8 @@
$sql .= "app_uuid = 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' "; $sql .= "app_uuid = 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' ";
$sql .= "where dialplan_context = 'public' "; $sql .= "where dialplan_context = 'public' ";
$sql .= "and app_uuid is null; "; $sql .= "and app_uuid is null; ";
$db->exec($sql); $database = new database;
$database->execute($sql);
unset($sql); unset($sql);
} }
@ -99,49 +107,50 @@
require_once "resources/header.php"; require_once "resources/header.php";
require_once "resources/paging.php"; require_once "resources/paging.php";
//get the number of rows in the dialplan //common sql where
$sql = "select count(*) as num_rows from v_dialplans ";
if ($_GET['show'] == "all" && permission_exists('dialplan_all')) { if ($_GET['show'] == "all" && permission_exists('dialplan_all')) {
$sql .= "where 1 = 1 "; $sql_where = "where true ";
} }
else { 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 //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 //hide outbound routes
$sql .= "and app_uuid <> '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' "; $sql_where .= "and app_uuid <> '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' ";
} }
else { else {
$sql .= "and app_uuid = '".$app_uuid."' "; if ($app_uuid == 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4') {
} $sql_where .= "and (app_uuid = :app_uuid or dialplan_context = 'public') ";
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'];
} }
else { 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; $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = "&search=".escape($search); $param = "&search=".escape($search);
@ -155,48 +164,12 @@
$offset = $rows_per_page * $page; $offset = $rows_per_page * $page;
//get the list of dialplans //get the list of dialplans
$sql = "select * from v_dialplans "; $sql = str_replace('count(*)', '*', $sql);
if ($_GET['show'] == "all" && permission_exists('dialplan_all')) { $sql .= ($order_by != '' ? order_by($order_by, $order) : 'order by dialplan_order asc, dialplan_name asc ');
$sql .= "where 1 = 1 "; $sql .= limit_offset($rows_per_page, $offset);
} $database = new database;
else { $dialplans = $database->select($sql, $parameters, 'all');
$sql .= "where (domain_uuid = '$domain_uuid' or domain_uuid is null) "; unset($sql, $parameters);
}
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);
//set the alternating row style //set the alternating row style
$c = 0; $c = 0;
@ -254,7 +227,7 @@
} }
} }
echo " <input type='text' class='txt' style='width: 150px' name='search' value='".escape($search)."'>"; 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)."'>"; echo " <input type='hidden' class='txt' name='app_uuid' value='".escape($app_uuid)."'>";
} }
if (strlen($order_by) > 0) { if (strlen($order_by) > 0) {
@ -299,7 +272,7 @@
echo "<input type='hidden' name='app_uuid' value='".escape($app_uuid)."'>\n"; 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 "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\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>"; 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')) { if ($_GET['show'] == "all" && permission_exists('destination_all')) {
@ -327,13 +300,13 @@
elseif (permission_exists('dialplan_add')) { elseif (permission_exists('dialplan_add')) {
echo "<a href='".PROJECT_PATH."/app/dialplans/dialplan_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>"; 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 "<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 "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
if (is_array($dialplans)) { if (is_array($dialplans) && @sizeof($dialplans) != 0) {
foreach($dialplans as $row) { foreach($dialplans as $row) {
//get the application id //get the application id
@ -421,10 +394,10 @@
} }
echo " </td>\n"; echo " </td>\n";
echo "</tr>\n"; echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; } $c = $c == 0 ? 1 : 0;
} //end foreach }
unset($sql, $result, $row_count); }
} //end if results unset($dialplans, $row);
echo "<tr>\n"; echo "<tr>\n";
echo "<td colspan='9'>\n"; echo "<td colspan='9'>\n";
@ -448,7 +421,7 @@
elseif (permission_exists('dialplan_add')) { elseif (permission_exists('dialplan_add')) {
echo "<a href='".PROJECT_PATH."/app/dialplans/dialplan_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>"; 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 "<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 " </td>\n";