Portions created by the Initial Developer are Copyright (C) 2008-2012 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ //includes include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; //check permissions if (permission_exists('dialplan_view')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //handle enable toggle $dialplan_uuid = check_str($_REQUEST['id']); $dialplan_enabled = check_str($_REQUEST['enabled']); if ($dialplan_uuid != '' && $dialplan_enabled != '') { $sql = "update v_dialplans set "; $sql .= "dialplan_enabled = '".$dialplan_enabled."' "; $sql .= "where dialplan_uuid = '".$dialplan_uuid."'"; $db->exec(check_sql($sql)); unset($sql); $_SESSION["message"] = $text['message-update']; } //delete the dialplan context from memcache $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); if ($fp) { $switch_cmd = "memcache delete dialplan:".$_SESSION["context"]; $switch_result = event_socket_request($fp, 'api '.$switch_cmd); } //set the http values as php variables if (isset($_REQUEST["search"])) { $search = check_str($_REQUEST["search"]); } else { $search = null; } if (isset($_REQUEST["order_by"])) { $order_by = check_str($_REQUEST["order_by"]); } else { $order_by = null; } if (isset($_REQUEST["order"])) { $order = check_str($_REQUEST["order"]); } else { $order = null; } if (isset($_REQUEST["dialplan_context"])) { $dialplan_context = check_str($_REQUEST["dialplan_context"]); } else { $dialplan_context = null; } if (isset($_REQUEST["app_uuid"])) { $app_uuid = check_str($_REQUEST["app_uuid"]); } else { $app_uuid = null; } //includes require_once "resources/header.php"; require_once "resources/paging.php"; //get the number of rows in the dialplan $sql = "select count(*) as num_rows from v_dialplans "; $sql .= "where (domain_uuid = '$domain_uuid' or domain_uuid is null) "; if (strlen($app_uuid) == 0) { //hide inbound routes $sql .= "and app_uuid <> 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' "; //hide outbound routes $sql .= "and app_uuid <> '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' "; } 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 .= ") "; } $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 { $num_rows = '0'; } } unset($prep_statement, $result); $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $param = ""; if (strlen($app_uuid) > 0) { $param = "&app_uuid=".$app_uuid; } $page = $_GET['page']; if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); $offset = $rows_per_page * $page; //get the list of dialplans $sql = "select * from v_dialplans "; $sql .= "where (domain_uuid = '$domain_uuid' or domain_uuid is null) "; if (strlen($app_uuid) == 0) { //hide inbound routes $sql .= "and app_uuid <> 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' "; //hide outbound routes $sql .= "and app_uuid <> '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' "; } 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); $result_count = count($dialplans); unset ($prep_statement, $sql); //set the alternating row style $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; //set the title if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") { $document['title'] = $text['title-inbound_routes']; } elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") { $document['title'] = $text['title-outbound_routes']; } elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7") { $document['title'] = $text['title-queues']; } elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") { $document['title'] = $text['title-time_conditions']; } else { $document['title'] = $text['title-dialplan_manager']; } //show the content echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; //echo " \n"; echo "\n"; echo "
\n"; echo " \n"; if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") { echo " ".$text['header-inbound_routes']."\n"; } elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") { echo " ".$text['header-outbound_routes']."\n"; } elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7") { echo " ".$text['header-queues']."\n"; } elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") { echo " ".$text['header-time_conditions']."\n"; } else { echo " ".$text['header-dialplan_manager']."\n"; } echo " \n"; echo "

\n"; echo "
\n"; echo "
\n"; echo " "; if (strlen($app_uuid) > 0) { echo " "; } if (strlen($order_by) > 0) { echo " "; echo " "; } echo " "; echo "
\n"; echo "
\n"; echo " \n"; if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") { echo $text['description-inbound_routes']; } elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") { echo $text['description-outbound_routes']; } elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7") { echo $text['description-queues']; } elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") { echo $text['description-time_conditions']; } else { if (if_group("superadmin")) { echo $text['description-dialplan_manager-superadmin']; } else { echo $text['description-dialplan_manager']; } } echo " \n"; echo " \n"; //if (permission_exists('dialplan_advanced_view') && strlen($app_uuid) == 0) { // echo " \n"; //} //else { // echo " \n"; //} //echo "
"; echo "
"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; if (permission_exists('dialplan_delete') && $result_count > 0) { echo ""; } echo th_order_by('dialplan_name', $text['label-name'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".$search : null)); echo th_order_by('dialplan_number', $text['label-number'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".$search : null)); echo th_order_by('dialplan_context', $text['label-context'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".$search : null)); echo th_order_by('dialplan_order', $text['label-order'], $order_by, $order, $app_uuid, "style='text-align: center;'", (($search != '') ? "search=".$search : null)); echo th_order_by('dialplan_enabled', $text['label-enabled'], $order_by, $order, $app_uuid, "style='text-align: center;'", (($search != '') ? "search=".$search : null)); echo th_order_by('dialplan_description', $text['label-description'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".$search : null)); echo "\n"; echo "\n"; if ($result_count > 0) { foreach($dialplans as $row) { //get the application id $app_uuid = $row['app_uuid']; // blank app id if doesn't match others, so will return to dialplan manager switch ($app_uuid) { case "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" : // inbound route case "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" : // outbound route case "16589224-c876-aeb3-f59f-523a1c0801f7" : // fifo case "4b821450-926b-175a-af93-a03c441818b1" : // time condition break; default : unset($app_uuid); } if ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_edit')) { $tr_link = "href='".PROJECT_PATH."/app/time_conditions/time_condition_edit.php?id=".$row['dialplan_uuid'].(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)."'"; } elseif ( ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_edit')) || ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_edit')) || ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_edit')) || permission_exists('dialplan_edit') ) { $tr_link = "href='dialplan_edit.php?id=".$row['dialplan_uuid'].(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)."'"; } echo "\n"; if (permission_exists("dialplan_delete")) { echo " \n"; $dialplan_ids[] = 'checkbox_'.$row['dialplan_uuid']; } echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; if ($c==0) { $c=1; } else { $c=0; } } //end foreach unset($sql, $result, $row_count); } //end if results echo "\n"; echo "\n"; echo "\n"; echo "
"; if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_add')) { echo "$v_link_label_add"; } elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_add')) { echo "$v_link_label_add"; } elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_add')) { echo "$v_link_label_add"; } elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_add')) { echo "$v_link_label_add"; } elseif (permission_exists('dialplan_add')) { echo "$v_link_label_add"; } if (permission_exists('dialplan_delete') && $result_count > 0) { echo "".$v_link_label_delete.""; } echo "
"; if ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_edit')) { echo "".$row['dialplan_name'].""; } elseif ( ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_edit')) || ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_edit')) || ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_edit')) || permission_exists('dialplan_edit') ) { echo "".$row['dialplan_name'].""; } else { echo $row['dialplan_name']; } echo " ".((strlen($row['dialplan_number']) > 0) ? format_phone($row['dialplan_number']) : " ")."".$row['dialplan_context']."".$row['dialplan_order']."".((strlen($row['dialplan_description']) > 0) ? $row['dialplan_description'] : " ")."\n"; if ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_edit')) { echo "$v_link_label_edit"; } elseif ( ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_edit')) || ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_edit')) || ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_edit')) || permission_exists('dialplan_edit') ) { echo "$v_link_label_edit"; } if ( ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_delete')) || ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_delete')) || ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_delete')) || ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_delete')) || permission_exists('dialplan_delete') ) { echo "$v_link_label_delete"; } echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
 ".$paging_controls.""; if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_add')) { echo "$v_link_label_add"; } elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_add')) { echo "$v_link_label_add"; } elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_add')) { echo "$v_link_label_add"; } elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_add')) { echo "$v_link_label_add"; } elseif (permission_exists('dialplan_add')) { echo "$v_link_label_add"; } if (permission_exists('dialplan_delete') && $result_count > 0) { echo "".$v_link_label_delete.""; } echo "
\n"; echo "
"; echo "

"; echo "
"; if (sizeof($dialplan_ids) > 0) { echo "\n"; } //include the footer require_once "resources/footer.php"; //unset the variables unset ($result_count); unset ($result); unset ($key); unset ($val); unset ($c); ?>