diff --git a/app/call_block/app_config.php b/app/call_block/app_config.php index 66240bd553..55de7f1379 100644 --- a/app/call_block/app_config.php +++ b/app/call_block/app_config.php @@ -113,11 +113,15 @@ $apps[$x]['db'][$y]['fields'][$z]['search'] = 'true'; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enter the name."; $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "call_block_country_code"; + $apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric"; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enter the country code."; + $z++; $apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "call_block_number"; $apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "blocked_caller_number"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['search'] = 'true'; - $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enter the full phone number."; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enter the phone number."; $z++; $apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "call_block_count"; $apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "blocked_call_count"; diff --git a/app/call_block/app_defaults.php b/app/call_block/app_defaults.php index ad9a9495fb..9160edc51e 100644 --- a/app/call_block/app_defaults.php +++ b/app/call_block/app_defaults.php @@ -30,7 +30,7 @@ if ($domains_processed == 1) { $database = new database; $database->execute("DROP VIEW view_call_block;", null); $sql = "CREATE VIEW view_call_block AS ( \n"; - $sql .= " select c.domain_uuid, call_block_uuid, c.extension_uuid, call_block_name, \n"; + $sql .= " select c.domain_uuid, call_block_uuid, c.extension_uuid, call_block_name, call_block_country_code, \n"; $sql .= " call_block_number, extension, number_alias, call_block_count, call_block_app, call_block_data, date_added, call_block_enabled, call_block_description \n"; $sql .= " from v_call_block as c \n"; $sql .= " left join v_extensions as e \n"; diff --git a/app/call_block/app_languages.php b/app/call_block/app_languages.php index 69c914bac4..d7495285c7 100644 --- a/app/call_block/app_languages.php +++ b/app/call_block/app_languages.php @@ -177,6 +177,27 @@ $text['label-provide-enabled']['ru-ru'] = "Пожалуйста, введите: $text['label-provide-enabled']['sv-se'] = "Ange: Aktiverad"; $text['label-provide-enabled']['uk-ua'] = "Включити/відключити"; +$text['label-country_code']['en-us'] = "Country Code"; +$text['label-country_code']['en-gb'] = "Country Code"; +$text['label-country_code']['ar-eg'] = ""; +$text['label-country_code']['de-at'] = ""; //copied from de-de +$text['label-country_code']['de-ch'] = ""; //copied from de-de +$text['label-country_code']['de-de'] = ""; +$text['label-country_code']['es-cl'] = ""; +$text['label-country_code']['es-mx'] = ""; //copied from es-cl +$text['label-country_code']['fr-ca'] = "Préfixe"; //copied from fr-fr +$text['label-country_code']['fr-fr'] = "Préfixe"; +$text['label-country_code']['he-il'] = ""; +$text['label-country_code']['it-it'] = ""; +$text['label-country_code']['nl-nl'] = "Voorloop"; +$text['label-country_code']['pl-pl'] = ""; +$text['label-country_code']['pt-br'] = "Prefixo"; //copied from pt-pt +$text['label-country_code']['pt-pt'] = ""; +$text['label-country_code']['ro-ro'] = ""; +$text['label-country_code']['ru-ru'] = ""; +$text['label-country_code']['sv-se'] = ""; +$text['label-country_code']['uk-ua'] = ""; + $text['label-number']['en-us'] = "Number"; $text['label-number']['en-gb'] = "Number"; $text['label-number']['ar-eg'] = "رقم"; @@ -595,6 +616,27 @@ $text['description-call_block_name']['ru-ru'] = ""; $text['description-call_block_name']['sv-se'] = ""; $text['description-call_block_name']['uk-ua'] = ""; +$text['description-country_code']['en-us'] = "Enter the Country Code prefix."; +$text['description-country_code']['en-gb'] = "Enter the Country Code prefix."; +$text['description-country_code']['ar-eg'] = ""; +$text['description-country_code']['de-at'] = ""; //copied from de-de +$text['description-country_code']['de-ch'] = ""; //copied from de-de +$text['description-country_code']['de-de'] = ""; +$text['description-country_code']['es-cl'] = ""; +$text['description-country_code']['es-mx'] = ""; //copied from es-cl +$text['description-country_code']['fr-ca'] = "Entrez le préfixe de destination."; //copied from fr-fr +$text['description-country_code']['fr-fr'] = "Entrez le préfixe de destination."; +$text['description-country_code']['he-il'] = ""; +$text['description-country_code']['it-it'] = ""; +$text['description-country_code']['nl-nl'] = "Voer de bestemming prefix in."; +$text['description-country_code']['pl-pl'] = ""; +$text['description-country_code']['pt-br'] = "Insira o prefixo do destino."; +$text['description-country_code']['pt-pt'] = ""; +$text['description-country_code']['ro-ro'] = ""; +$text['description-country_code']['ru-ru'] = ""; +$text['description-country_code']['sv-se'] = ""; +$text['description-country_code']['uk-ua'] = ""; + $text['description-call_block_number']['en-us'] = "Enter the Caller ID Number to block."; $text['description-call_block_number']['en-gb'] = "Enter the Caller ID Number to block."; $text['description-call_block_number']['ar-eg'] = ""; diff --git a/app/call_block/call_block.php b/app/call_block/call_block.php index bba27639d1..c9212fc585 100644 --- a/app/call_block/call_block.php +++ b/app/call_block/call_block.php @@ -83,6 +83,7 @@ if (strlen($search) > 0) { $sql_search = " ("; $sql_search .= "lower(call_block_name) like :search "; + $sql_search .= "or call_block_country_code like :search "; $sql_search .= "or lower(call_block_number) like :search "; $sql_search .= "or lower(call_block_description) like :search "; $sql_search .= ") "; @@ -136,7 +137,7 @@ if (isset($sql_search)) { $sql .= "and ".$sql_search; } - $sql .= order_by($order_by, $order, 'call_block_number'); + $sql .= order_by($order_by, $order, ['call_block_country_code','call_block_number']); $sql .= limit_offset($rows_per_page, $offset); $database = new database; $result = $database->select($sql, $parameters, 'all'); @@ -204,6 +205,7 @@ } echo th_order_by('extension', $text['label-extension'], $order_by, $order); echo th_order_by('call_block_name', $text['label-name'], $order_by, $order); + echo th_order_by('call_block_country_code', $text['label-country_code'], $order_by, $order); echo th_order_by('call_block_number', $text['label-number'], $order_by, $order); echo th_order_by('call_block_count', $text['label-count'], $order_by, $order, '', "class='center hide-sm-dn'"); echo th_order_by('call_block_action', $text['label-action'], $order_by, $order); @@ -238,6 +240,14 @@ echo " \n"; echo " ".escape($row['call_block_name'])."\n"; echo " "; + if (permission_exists('call_block_edit')) { + echo "".escape($row['call_block_country_code']).""; + } + else { + echo escape($row['call_block_country_code']); + } + echo " \n"; + echo " "; if (permission_exists('call_block_edit')) { echo "".escape(format_phone($row['call_block_number'])).""; } @@ -280,4 +290,4 @@ //include the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file diff --git a/app/call_block/call_block_edit.php b/app/call_block/call_block_edit.php index 33e6581b43..ba94d7b06d 100644 --- a/app/call_block/call_block_edit.php +++ b/app/call_block/call_block_edit.php @@ -54,6 +54,7 @@ if (count($_POST) > 0) { $extension_uuid = $_POST["extension_uuid"]; $call_block_name = $_POST["call_block_name"]; + $call_block_country_code = $_POST["call_block_country_code"]; $call_block_number = $_POST["call_block_number"]; $call_block_enabled = $_POST["call_block_enabled"]; $call_block_description = $_POST["call_block_description"]; @@ -164,6 +165,7 @@ $array['call_block'][0]['extension_uuid'] = $extension_uuid; } $array['call_block'][0]['call_block_name'] = $call_block_name; + $array['call_block'][0]['call_block_country_code'] = $call_block_country_code; $array['call_block'][0]['call_block_number'] = $call_block_number; $array['call_block'][0]['call_block_count'] = 0; $array['call_block'][0]['call_block_app'] = $call_block_app; @@ -184,7 +186,7 @@ return; } if ($action == "update") { - $sql = "select c.call_block_number, d.domain_name "; + $sql = "select c.call_block_country_code, c.call_block_number, d.domain_name "; $sql .= "from v_call_block as c "; $sql .= "join v_domains as d on c.domain_uuid = d.domain_uuid "; $sql .= "where c.domain_uuid = :domain_uuid "; @@ -199,7 +201,7 @@ //clear the cache $cache = new cache; - $cache->delete("app:call_block:".$domain_name.":".$call_block_number); + $cache->delete("app:call_block:".$domain_name.":".$call_block_country_code.$call_block_number); } unset($sql, $parameters); @@ -209,6 +211,7 @@ $array['call_block'][0]['extension_uuid'] = $extension_uuid; } $array['call_block'][0]['call_block_name'] = $call_block_name; + $array['call_block'][0]['call_block_country_code'] = $call_block_country_code; $array['call_block'][0]['call_block_number'] = $call_block_number; $array['call_block'][0]['call_block_app'] = $call_block_app; $array['call_block'][0]['call_block_data'] = $call_block_data; @@ -243,6 +246,7 @@ if (is_array($row) && sizeof($row) != 0) { $extension_uuid = $row["extension_uuid"]; $call_block_name = $row["call_block_name"]; + $call_block_country_code = $row["call_block_country_code"]; $call_block_number = $row["call_block_number"]; $call_block_app = $row["call_block_app"]; $call_block_data = $row["call_block_data"]; @@ -351,6 +355,17 @@ echo "\n"; echo "\n"; + echo "\n"; + echo "\n"; + echo " ".$text['label-country_code']."\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-country_code']."\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo " ".$text['label-number']."\n"; @@ -639,4 +654,4 @@ //include the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file diff --git a/app/call_block/resources/classes/call_block.php b/app/call_block/resources/classes/call_block.php index fcb61a6555..cbb3c419a5 100644 --- a/app/call_block/resources/classes/call_block.php +++ b/app/call_block/resources/classes/call_block.php @@ -318,6 +318,9 @@ if (!class_exists('call_block')) { if (is_array($rows) && @sizeof($rows) != 0) { foreach ($rows as $x => $row) { + //trim plus and any spaces + $row["caller_id_number"] = trim($row["caller_id_number"], '+ '); + //build insert array if (permission_exists('call_block_all')) { $array['call_block'][$x]['call_block_uuid'] = uuid(); @@ -326,7 +329,7 @@ if (!class_exists('call_block')) { $array['call_block'][$x]['extension_uuid'] = $this->extension_uuid; } $array['call_block'][$x]['call_block_name'] = trim($row["caller_id_name"]); - $array['call_block'][$x]['call_block_number'] = trim($row["caller_id_number"]); + $array['call_block'][$x]['call_block_number'] = $row["caller_id_number"]; $array['call_block'][$x]['call_block_count'] = 0; $array['call_block'][$x]['call_block_app'] = $this->call_block_app; $array['call_block'][$x]['call_block_data'] = $this->call_block_data; @@ -342,7 +345,7 @@ if (!class_exists('call_block')) { $array['call_block'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['call_block'][$x]['extension_uuid'] = $field['extension_uuid']; $array['call_block'][$x]['call_block_name'] = trim($row["caller_id_name"]); - $array['call_block'][$x]['call_block_number'] = trim($row["caller_id_number"]); + $array['call_block'][$x]['call_block_number'] = $row["caller_id_number"]; $array['call_block'][$x]['call_block_count'] = 0; $array['call_block'][$x]['call_block_app'] = $this->call_block_app; $array['call_block'][$x]['call_block_data'] = $this->call_block_data; diff --git a/resources/functions.php b/resources/functions.php index 9203a49788..65bcbdf6f7 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -2058,13 +2058,25 @@ function number_pad($number,$n) { //validate and format order by clause of select statement if (!function_exists('order_by')) { function order_by($col, $dir, $col_default = '', $dir_default = 'asc') { + $order_by = ' order by '; $col = preg_replace('#[^a-zA-Z0-9-_.]#', '', $col); $dir = strtolower($dir) == 'desc' ? 'desc' : 'asc'; if ($col != '') { - return ' order by '.$col.' '.$dir.' '; + return $order_by.$col.' '.$dir.' '; } - else if ($col_default != '') { - return ' order by '.$col_default.' '.$dir_default.' '; + else if (is_array($col_default) || $col_default != '') { + if (is_array($col_default) && @sizeof($col_default) != 0) { + foreach ($col_default as $k => $column) { + $direction = (is_array($dir_default) && @sizeof($dir_default) != 0 && (strtolower($dir_default[$k]) == 'asc' || strtolower($dir_default[$k]) == 'desc')) ? $dir_default[$k] : 'asc'; + $order_bys[] = $column.' '.$direction.' '; + } + if (is_array($order_bys) && @sizeof($order_bys) != 0) { + return $order_by.implode(', ', $order_bys); + } + } + else { + return $order_by.$col_default.' '.$dir_default.' '; + } } } }