From c54eb15c7c117d6e5cca131653159d7e5b9cf3c6 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Fri, 10 Aug 2018 17:45:02 -0600 Subject: [PATCH] Update dialplans.php --- app/dialplans/dialplans.php | 43 ++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/app/dialplans/dialplans.php b/app/dialplans/dialplans.php index c2205c6752..f430d0a0b5 100644 --- a/app/dialplans/dialplans.php +++ b/app/dialplans/dialplans.php @@ -45,20 +45,37 @@ //handle enable toggle $dialplan_uuid = check_str($_REQUEST['id']); $dialplan_enabled = check_str($_REQUEST['enabled']); - if ($dialplan_uuid != '' && $dialplan_enabled != '') { + if (isset($dialplan_uuid) && is_uuid($dialplan_uuid) && $dialplan_enabled != '') { + //make sure enabled is only true or false + if ($dialplan_enabled == "true") { + $dialplan_enabled = 'true'; + } + else { + $dialplan_enabled == 'false'; + } + + //get the dialplan context + $sql = "select * from v_dialplans "; + $sql .= "where dialplan_uuid = '".$dialplan_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_NAMED); + $dialplan_context = $row["dialplan_context"]; + unset($sql); + + //change the status $sql = "update v_dialplans set "; $sql .= "dialplan_enabled = '".$dialplan_enabled."' "; $sql .= "where dialplan_uuid = '".$dialplan_uuid."'"; $db->exec(check_sql($sql)); unset($sql); - messages::add($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); + //clear the cache + $cache = new cache; + $cache->delete("dialplan:".$dialplan_context); + + //set the message + messages::add($text['message-update']); } //set the http values as php variables @@ -164,7 +181,7 @@ $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $dialplans = $prep_statement->fetchAll(PDO::FETCH_NAMED); - $result_count = count($dialplans); + $dialplan_count = count($dialplans); unset ($prep_statement, $sql); //set the alternating row style @@ -260,7 +277,7 @@ echo "\n"; echo "\n"; echo "\n"; - if (permission_exists('dialplan_delete') && $result_count > 0) { + if (permission_exists('dialplan_delete') && $dialplan_count > 0) { echo ""; } echo th_order_by('dialplan_name', $text['label-name'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".escape($search) : null)); @@ -285,7 +302,7 @@ elseif (permission_exists('dialplan_add')) { echo "$v_link_label_add"; } - if (permission_exists('dialplan_delete') && $result_count > 0) { + if (permission_exists('dialplan_delete') && $dialplan_count > 0) { echo "".$v_link_label_delete.""; } echo "\n"; @@ -397,7 +414,7 @@ elseif (permission_exists('dialplan_add')) { echo "$v_link_label_add"; } - if (permission_exists('dialplan_delete') && $result_count > 0) { + if (permission_exists('dialplan_delete') && $dialplan_count > 0) { echo "".$v_link_label_delete.""; } echo " \n"; @@ -424,7 +441,7 @@ require_once "resources/footer.php"; //unset the variables - unset ($result_count); + unset ($dialplan_count); unset ($result); unset ($key); unset ($val);