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,9 +119,9 @@
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";
@ -128,6 +131,8 @@
$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,144 +110,68 @@
$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,12 +61,11 @@
//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();
@ -98,23 +97,26 @@
} }
$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');
if (is_array($dialplan_details) && @sizeof($dialplan_details) != 0) {
foreach ($dialplan_details as &$row) { foreach ($dialplan_details as &$row) {
//create a new primary key for the new row //create a new primary key for the new row
$row['dialplan_detail_uuid'] = uuid(); $row['dialplan_detail_uuid'] = uuid();
//update the foreign relation uuid //update the foreign relation uuid
$row['dialplan_uuid'] = $dialplan_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');
if (is_array($result) && @sizeof($result) != 0) {
foreach ($result as &$row) { foreach ($result as &$row) {
$database_dialplan_uuid = $row["dialplan_uuid"]; $database_dialplan_uuid = $row["dialplan_uuid"];
$dialplan_contexts[] = $row["dialplan_context"]; $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);
//delete parent data
$sql = "delete from v_dialplans ";
$sql .= "where dialplan_uuid = '".$dialplan_uuid."'; ";
$db->query($sql);
unset($sql);
$dialplans_deleted++; $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,7 +260,8 @@
//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) {
foreach ($result as $row) {
if ($row['dialplan_detail_tag'] == "condition") { if ($row['dialplan_detail_tag'] == "condition") {
$group = $row['dialplan_detail_group']; $group = $row['dialplan_detail_group'];
foreach ($row as $key => $val) { foreach ($row as $key => $val) {
@ -271,8 +270,10 @@
} }
$x++; $x++;
} }
}
//regex //regex
if (is_array($result)) foreach($result as $row) { if (is_array($result) && @sizeof($result) != 0) {
foreach ($result as $row) {
if ($row['dialplan_detail_tag'] == "regex") { if ($row['dialplan_detail_tag'] == "regex") {
$group = $row['dialplan_detail_group']; $group = $row['dialplan_detail_group'];
foreach ($row as $key => $val) { foreach ($row as $key => $val) {
@ -281,8 +282,10 @@
} }
$x++; $x++;
} }
}
//actions //actions
if (is_array($result)) foreach($result as $row) { if (is_array($result) && @sizeof($result) != 0) {
foreach ($result as $row) {
if ($row['dialplan_detail_tag'] == "action") { if ($row['dialplan_detail_tag'] == "action") {
$group = $row['dialplan_detail_group']; $group = $row['dialplan_detail_group'];
foreach ($row as $key => $val) { foreach ($row as $key => $val) {
@ -291,8 +294,10 @@
} }
$x++; $x++;
} }
}
//anti-actions //anti-actions
if (is_array($result)) foreach($result as $row) { if (is_array($result) && @sizeof($result) != 0) {
foreach ($result as $row) {
if ($row['dialplan_detail_tag'] == "anti-action") { if ($row['dialplan_detail_tag'] == "anti-action") {
$group = $row['dialplan_detail_group']; $group = $row['dialplan_detail_group'];
foreach ($row as $key => $val) { foreach ($row as $key => $val) {
@ -301,18 +306,22 @@
} }
$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) {
foreach ($details as $group => $row) {
//set the array key for the empty row //set the array key for the empty row
$x = "999"; $x = "999";
//get the highest dialplan_detail_order //get the highest dialplan_detail_order
if (is_array($row)) foreach ($row as $key => $field) { if (is_array($row) && @sizeof($details) != 0) {
foreach ($row as $key => $field) {
$dialplan_detail_order = 0; $dialplan_detail_order = 0;
if ($dialplan_detail_order < $field['dialplan_detail_order']) { if ($dialplan_detail_order < $field['dialplan_detail_order']) {
$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
@ -326,6 +335,7 @@
$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)) {
ksort($details); ksort($details);
@ -521,13 +531,14 @@
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) {
foreach ($_SESSION['domains'] as $row) {
if ($row['domain_uuid'] == $domain_uuid) { if ($row['domain_uuid'] == $domain_uuid) {
echo " <option value='".escape($row['domain_uuid'])."' selected='selected'>".escape($row['domain_name'])."</option>\n"; echo " <option value='".escape($row['domain_uuid'])."' selected='selected'>".escape($row['domain_name'])."</option>\n";
} }
@ -535,6 +546,7 @@
echo " <option value='".escape($row['domain_uuid'])."'>".escape($row['domain_name'])."</option>\n"; echo " <option value='".escape($row['domain_uuid'])."'>".escape($row['domain_name'])."</option>\n";
} }
} }
}
echo " </select>\n"; echo " </select>\n";
echo " <br />\n"; echo " <br />\n";
echo " ".$text['description-domain_name']."\n"; echo " ".$text['description-domain_name']."\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,7 +633,8 @@
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'];
@ -648,7 +661,7 @@
$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
@ -743,16 +756,16 @@
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 = '".$bridge_statement[3]."' "; $sql = "select gateway from v_gateways where gateway_uuid = :gateway_uuid ";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['gateway_uuid'] = $bridge_statement[3];
$prep_statement->execute(); $database = new database;
$gateways = $prep_statement->fetchAll(PDO::FETCH_NAMED); $gateways = $database->select($sql, $parameters, 'all');
if (is_array($gateways)) { if (is_array($gateways) && @sizeof($gateways) != 0) {
$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); $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); unset($sql, $parameters, $bridge_statement, $gateways, $bridge_statement_exploded, $bridge_statement_exploded_mod);
} }
} }
} }
@ -843,9 +856,10 @@
//increment the value //increment the value
$x++; $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,17 +87,8 @@
$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
//echo "<pre>\n";
//print_r($message);
//echo "</pre>\n";
//exit;
//clear the cache //clear the cache
$cache = new cache; $cache = new cache;
@ -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') ";
}
else {
$sql_where .= "and app_uuid = :app_uuid ";
}
$parameters['app_uuid'] = $app_uuid;
} }
if (strlen($search) > 0) { if (strlen($search) > 0) {
$search = strtolower($search); $sql_where .= "and (";
$sql .= "and ("; $sql_where .= " dialplan_context like :search ";
$sql .= " lower(dialplan_context) like '%".$search."%' "; $sql_where .= " or dialplan_name like :search ";
$sql .= " or lower(dialplan_name) like '%".$search."%' "; $sql_where .= " or dialplan_number like :search ";
$sql .= " or dialplan_number like '%".$search."%' "; $sql_where .= " or dialplan_continue like :search ";
$sql .= " or dialplan_continue like '%".$search."%' ";
if (is_numeric($search)) { if (is_numeric($search)) {
$sql .= " or dialplan_order = '".$search."' "; $sql_where .= " or dialplan_order = :search ";
} }
$sql .= " or dialplan_enabled like '%".$search."%' "; $sql_where .= " or dialplan_enabled like :search ";
$sql .= " or lower(dialplan_description) like '%".$search."%' "; $sql_where .= " or dialplan_description like :search ";
$sql .= ") "; $sql_where .= ") ";
$parameters['search'] = '%'.$search.'%';
} }
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) { //get the number of rows in the dialplan
$prep_statement->execute(); $sql = "select count(*) from v_dialplans ";
$row = $prep_statement->fetch(PDO::FETCH_ASSOC); $sql .= $sql_where;
if ($row['num_rows'] > 0) { $database = new database;
$num_rows = $row['num_rows']; $num_rows = $database->select($sql, $parameters, 'column');
}
else {
$num_rows = '0';
}
}
unset($prep_statement, $result);
$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";