diff --git a/app/time_conditions/app_menu.php b/app/time_conditions/app_menu.php index 98251da4f6..d65611b2cb 100644 --- a/app/time_conditions/app_menu.php +++ b/app/time_conditions/app_menu.php @@ -14,7 +14,7 @@ $apps[$x]['menu'][0]['uuid'] = "67aede56-8623-df2d-6338-ecfbde5825f7"; $apps[$x]['menu'][0]['parent_uuid'] = "fd29e39c-c936-f5fc-8e2b-611681b266b5"; $apps[$x]['menu'][0]['category'] = "internal"; - $apps[$x]['menu'][0]['path'] = "/app/dialplan/dialplans.php?app_uuid=4b821450-926b-175a-af93-a03c441818b1"; + $apps[$x]['menu'][0]['path'] = "/app/time_conditions/time_conditions.php"; $apps[$x]['menu'][0]['groups'][] = "admin"; $apps[$x]['menu'][0]['groups'][] = "superadmin"; diff --git a/app/time_conditions/time_condition_delete.php b/app/time_conditions/time_condition_delete.php new file mode 100644 index 0000000000..10ade7ba99 --- /dev/null +++ b/app/time_conditions/time_condition_delete.php @@ -0,0 +1,113 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (permission_exists('time_condition_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//set the dialplan uuid + $dialplan_uuids = $_REQUEST["id"]; + $app_uuid = check_str($_REQUEST['app_uuid']); + +//delete the dialplans + if (sizeof($dialplan_uuids) > 0) { + + //get dialplan contexts + foreach ($dialplan_uuids as $dialplan_uuid) { + //check each + $dialplan_uuid = check_str($dialplan_uuid); + + //get the dialplan data + $sql = "select * from v_dialplans "; + $sql .= "where dialplan_uuid = '".$dialplan_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $database_dialplan_uuid = $row["dialplan_uuid"]; + $dialplan_contexts[] = $row["dialplan_context"]; + } + unset($prep_statement); + } + + //start the atomic transaction + $db->beginTransaction(); + + //delete dialplan and details + $dialplans_deleted = 0; + foreach ($dialplan_uuids as $dialplan_uuid) { + + //delete child data + $sql = "delete from v_dialplan_details "; + $sql .= "where dialplan_uuid = '".$dialplan_uuid."'; "; + $sql .= "and app_uuid = '4b821450-926b-175a-af93-a03c441818b1'; "; + $db->query($sql); + unset($sql); + + //delete parent data + $sql = "delete from v_dialplans "; + $sql .= "where dialplan_uuid = '".$dialplan_uuid."'; "; + $sql .= "and app_uuid = '4b821450-926b-175a-af93-a03c441818b1'; "; + $db->query($sql); + unset($sql); + + //count the time conditions that were deleted + $dialplans_deleted++; + } + + //commit the atomic transaction + $db->commit(); + + //synchronize the xml config + save_dialplan_xml(); + + //strip duplicate contexts + $dialplan_contexts = array_unique($dialplan_contexts, SORT_STRING); + + //clear the cache + $cache = new cache; + if (sizeof($dialplan_contexts) > 0) { + foreach($dialplan_contexts as $dialplan_context) { + $cache->delete("dialplan:".$dialplan_context); + } + } + } + +//redirect the browser + $_SESSION["message"] = $text['message-delete'].(($dialplans_deleted > 1) ? ": ".$dialplans_deleted : null); + header("Location: ".PROJECT_PATH."/app/time_conditions/time_conditions.php"); + +?> \ No newline at end of file diff --git a/app/time_conditions/time_conditions.php b/app/time_conditions/time_conditions.php new file mode 100644 index 0000000000..73bde06d7f --- /dev/null +++ b/app/time_conditions/time_conditions.php @@ -0,0 +1,277 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (permission_exists('time_condition_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']; + } + +//set the http values as php variables + $search = check_str($_REQUEST["search"]); + $order_by = check_str($_REQUEST["order_by"]); + $order = check_str($_REQUEST["order"]); + $dialplan_context = check_str($_REQUEST["dialplan_context"]); + $app_uuid = check_str($_REQUEST["app_uuid"]); + +//includes + require_once "resources/header.php"; + require_once "resources/paging.php"; + $document['title'] = $text['title-time_conditions']; + +//show the content + echo "\n"; + echo "\n"; + echo " \n"; + + echo " \n"; + + echo "\n"; + echo "
\n"; + echo " \n"; + echo " ".$text['header-time_conditions']."\n"; + echo " \n"; + echo "

\n"; + echo " \n"; + echo $text['description-time_conditions']; + echo " \n"; + echo "
\n"; + echo "
\n"; + echo " "; + if (strlen($app_uuid) > 0) { + echo " "; + } + if (strlen($order_by) > 0) { + echo " "; + echo " "; + } + echo " "; + echo "
\n"; + echo "
"; + echo "
"; + + //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 = 150; + $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; + + $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(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + 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($result as $row) { + $app_uuid = $row['app_uuid']; + + $tr_link = "href='".PROJECT_PATH."/app/time_conditions/time_condition_edit.php?id=".$row['dialplan_uuid'].(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)."'"; + + echo "\n"; + if (permission_exists("time_condition_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 (permission_exists('time_condition_add')) { + echo "$v_link_label_add"; + } + if (permission_exists('time_condition_delete') && $result_count > 0) { + echo "".$v_link_label_delete.""; + } + echo "
"; + if (permission_exists('time_condition_edit')) { + echo "".$row['dialplan_name'].""; + } + else { + echo $row['dialplan_name']; + } + echo " ".((strlen($row['dialplan_number']) > 0) ? $row['dialplan_number'] : " ")."".$row['dialplan_context']."".$row['dialplan_order']."".((strlen($row['dialplan_description']) > 0) ? $row['dialplan_description'] : " ")."\n"; + if (permission_exists('time_condition_edit')) { + echo "$v_link_label_edit"; + } + if (permission_exists('time_condition_delete')) { + echo "$v_link_label_delete"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 ".$paging_controls.""; + if (permission_exists('time_condition_add')) { + echo "$v_link_label_add"; + } + if (permission_exists('time_condition_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"; + +?> \ No newline at end of file