Call Block: Partial support for Country Code.

This commit is contained in:
Nate
2020-10-27 11:21:12 -06:00
parent 05588e0fe0
commit d5bc65111a
7 changed files with 98 additions and 12 deletions

View File

@@ -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";

View File

@@ -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";

View File

@@ -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'] = "";

View File

@@ -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 " </td>\n";
echo " <td>".escape($row['call_block_name'])."</td>\n";
echo " <td>";
if (permission_exists('call_block_edit')) {
echo "<a href='".$list_row_url."'>".escape($row['call_block_country_code'])."</a>";
}
else {
echo escape($row['call_block_country_code']);
}
echo " </td>\n";
echo " <td>";
if (permission_exists('call_block_edit')) {
echo "<a href='".$list_row_url."'>".escape(format_phone($row['call_block_number']))."</a>";
}
@@ -280,4 +290,4 @@
//include the footer
require_once "resources/footer.php";
?>
?>

View File

@@ -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 "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-country_code']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='call_block_country_code' maxlength='6' value=\"".escape($call_block_country_code)."\">\n";
echo "<br />\n";
echo $text['description-country_code']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-number']."\n";
@@ -639,4 +654,4 @@
//include the footer
require_once "resources/footer.php";
?>
?>

View File

@@ -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;

View File

@@ -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.' ';
}
}
}
}