diff --git a/app/call_block/call_block.php b/app/call_block/call_block.php index a4ab54e559..567b4dcdcb 100644 --- a/app/call_block/call_block.php +++ b/app/call_block/call_block.php @@ -23,8 +23,10 @@ Contributor(s): Mark J Crane - Call Block is written by Gerrit Visser + The original Call Block was written by Gerrit Visser + All of it has been rewritten over years. */ + //includes require_once "root.php"; require_once "resources/require.php"; @@ -92,7 +94,15 @@ //prepare to page the results $sql = "select count(*) from view_call_block "; - $sql .= "where domain_uuid = :domain_uuid "; + $sql .= "where true "; + if ($_GET['show'] == "all" && permission_exists('call_forward_all')) { + $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + } + else { + $sql .= "and (domain_uuid = :domain_uuid) "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + } if (!permission_exists('call_block_all') && is_array($_SESSION['user']['extension']) && count($_SESSION['user']['extension']) > 0) { $sql .= "and extension_uuid in ("; $x = 0; @@ -107,13 +117,16 @@ if (isset($sql_search)) { $sql .= "and ".$sql_search; } - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $database = new database; $num_rows = $database->select($sql, $parameters, 'column'); + unset($parameters); //prepare to page the results $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $param = "&search=".$search; + if ($_GET['show'] == "all" && permission_exists('call_forward_all')) { + $param .= "&show=all"; + } $page = $_GET['page']; if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); @@ -122,7 +135,15 @@ //get the list $sql = "select * from view_call_block "; - $sql .= "where domain_uuid = :domain_uuid "; + $sql .= "where true "; + if ($_GET['show'] == "all" && permission_exists('call_forward_all')) { + $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + } + else { + $sql .= "and (domain_uuid = :domain_uuid) "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + } if (!permission_exists('call_block_all') && is_array($_SESSION['user']['extension']) && count($_SESSION['user']['extension']) > 0) { $sql .= "and extension_uuid in ("; $x = 0; @@ -168,6 +189,14 @@ echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'btn_delete','onclick'=>"modal_open('modal-delete','btn_delete');"]); } echo "