Add Support for Validated Emergency Destinations/Caller ID

This adds emergency_caller_id_select permissions. and an "Emergency" checkbox to destinations. When emergency_caller_id_select permssion is added, the "Emergency Caller ID number" and name become a dropdown in the Extension and only show Destinations that have the "Emergency" checkbox selected to indicate they are valid for emergency calls.
This commit is contained in:
demonspork 2020-12-11 18:24:14 -06:00
parent 62887136b1
commit c3704c6172
5 changed files with 106 additions and 4 deletions

View File

@ -123,6 +123,9 @@
$apps[$x]['permissions'][$y]['name'] = "destination_fax";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "destination_emergency";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "destination_destinations";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
@ -287,6 +290,10 @@
$apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Number is used for fax calls.";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "destination_type_emergency";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Number is used to place emergency calls.";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "destination_type_text";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Number is used for text messages.";

View File

@ -883,6 +883,27 @@ $text['label-text']['ru-ru'] = "Текст";
$text['label-text']['sv-se'] = "Text";
$text['label-text']['uk-ua'] = "Текст";
$text['label-emergency']['en-us'] = "Emergency";
$text['label-emergency']['en-gb'] = "Emergency";
$text['label-emergency']['ar-eg'] = "";
$text['label-emergency']['de-at'] = "Anruferkennung"; //copied from de-de
$text['label-emergency']['de-ch'] = "Anruferkennung";
$text['label-emergency']['de-de'] = "Notruf Anruferkennung";
$text['label-emergency']['es-cl'] = "Emergencia";
$text['label-emergency']['es-mx'] = "Emergencia"; //copied from es-cl
$text['label-emergency']['fr-ca'] = "Urgence"; //copied from fr-fr
$text['label-emergency']['fr-fr'] = "Urgence";
$text['label-emergency']['he-il'] = "";
$text['label-emergency']['it-it'] = "Emergenze";
$text['label-emergency']['nl-nl'] = "Noodnummer";
$text['label-emergency']['pl-pl'] = "Prezentacja nazwy dzwoniącego (emergency)";
$text['label-emergency']['pt-br'] = "Emergência";
$text['label-emergency']['pt-pt'] = "Emergência";
$text['label-emergency']['ro-ro'] = "";
$text['label-emergency']['ru-ru'] = "Идентификатор (Caller ID) имени экстренного вызова";
$text['label-emergency']['sv-se'] = "Nöd Namnpresentation";
$text['label-emergency']['uk-ua'] = "";
$text['header-destinations']['en-us'] = "Destinations";
$text['header-destinations']['en-gb'] = "Destinations";
$text['header-destinations']['ar-eg'] = "جهات الأتصال";

View File

@ -107,6 +107,7 @@
$destination_type_voice = $_POST["destination_type_voice"];
$destination_type_fax = $_POST["destination_type_fax"];
$destination_type_text = $_POST["destination_type_text"];
$destination_type_emergency = $_POST["destination_type_emergency"];
$destination_carrier = trim($_POST["destination_carrier"]);
//get the destination app and data
@ -671,6 +672,9 @@
$array['destinations'][0]["destination_type_voice"] = $destination_type_voice ? 1 : null;
$array['destinations'][0]["destination_type_fax"] = $destination_type_fax ? 1 : null;
$array['destinations'][0]["destination_type_text"] = $destination_type_text ? 1 : null;
if (permission_exists('destination_emergency')){
$array['destinations'][0]["destination_type_emergency"] = $destination_type_emergency ? 1 : null;
}
if ($destination->valid($destination_app.':'.$destination_data)) {
$array['destinations'][0]["destination_app"] = $destination_app;
$array['destinations'][0]["destination_data"] = $destination_data;
@ -786,6 +790,7 @@
$destination_type_voice = $row["destination_type_voice"];
$destination_type_fax = $row["destination_type_fax"];
$destination_type_text = $row["destination_type_text"];
$destination_type_emergency = $row["destination_type_emergency"];
$destination_context = $row["destination_context"];
$destination_app = $row["destination_app"];
$destination_data = $row["destination_data"];
@ -1233,6 +1238,9 @@
echo " <label><input type='checkbox' name='destination_type_voice' id='destination_type_voice' value='1' ".($destination_type_voice ? "checked='checked'" : null)."> ".$text['label-voice']."</label>&nbsp;\n";
echo " <label><input type='checkbox' name='destination_type_fax' id='destination_type_fax' value='1' ".($destination_type_fax ? "checked='checked'" : null)."> ".$text['label-fax']."</label>&nbsp;\n";
echo " <label><input type='checkbox' name='destination_type_text' id='destination_type_text' value='1' ".($destination_type_text ? "checked='checked'" : null)."> ".$text['label-text']."</label>\n";
if (permission_exists('destination_emergency')){
echo " <label><input type='checkbox' name='destination_type_emergency' id='destination_type_emergency' value='1' ".($destination_type_emergency ? "checked='checked'" : null)."> ".$text['label-emergency']."</label>\n";
}
echo "<br />\n";
echo $text['description-usage']."\n";
echo "</td>\n";

View File

@ -169,6 +169,8 @@
$apps[$x]['permissions'][$y]['name'] = "emergency_caller_id_number";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "emergency_caller_id_select";
$y++;
$apps[$x]['permissions'][$y]['name'] = "extension_user_record";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;

View File

@ -800,6 +800,19 @@
$destinations = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//get the emergency destinations
if (permission_exists('emergency_caller_id_select')) {
$sql = "select * from v_destinations ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and destination_type = 'inbound' ";
$sql .= "and destination_type_emergency = 1 ";
$sql .= "order by destination_number asc ";
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$emergency_destinations = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
}
//change toll allow delimiter
$toll_allow = str_replace(':',',', $toll_allow);
@ -1298,7 +1311,31 @@
echo " ".$text['label-emergency_caller_id_name']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
if (permission_exists('outbound_caller_id_select')) {
if (permission_exists('emergency_caller_id_select')) {
if (count($emergency_destinations) > 0) {
echo " <select name='emergency_caller_id_name' id='emergency_caller_id_name' class='formfld'>\n";
echo " <option value=''></option>\n";
foreach ($emergency_destinations as &$row) {
$tmp = $row["destination_caller_id_name"];
if(strlen($tmp) == 0){
$tmp = $row["destination_description"];
}
if(strlen($tmp) > 0){
if ($emergency_caller_id_name == $tmp) {
echo " <option value='".escape($tmp)."' selected='selected'>".escape($tmp)."</option>\n";
}
else {
echo " <option value='".escape($tmp)."'>".escape($tmp)."</option>\n";
}
}
}
echo " </select>\n";
}
else {
echo " <input type=\"button\" class=\"btn\" name=\"\" alt=\"".$text['button-add']."\" onclick=\"window.location='".PROJECT_PATH."/app/destinations/destinations.php'\" value='".$text['button-add']."'>\n";
}
}
elseif (permission_exists('outbound_caller_id_select')) {
if (count($destinations) > 0) {
echo " <select name='emergency_caller_id_name' id='emergency_caller_id_name' class='formfld'>\n";
echo " <option value=''></option>\n";
@ -1342,14 +1379,38 @@
echo " ".$text['label-emergency_caller_id_number']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
if (permission_exists('outbound_caller_id_select')) {
if (permission_exists('emergency_caller_id_select')) {
if (count($emergency_destinations) > 0) {
echo " <select name='emergency_caller_id_number' id='emergency_caller_id_number' class='formfld'>\n";
//echo " <option value=''></option>\n"; Don't allow no selection when validating emergency numbers this way
foreach ($emergency_destinations as &$row) {
$tmp = $row["destination_caller_id_number"];
if(strlen($tmp) == 0){
$tmp = $row["destination_number"];
}
if(strlen($tmp) > 0){
if ($emergency_caller_id_number == $tmp) {
echo " <option value='".escape($tmp)."' selected='selected'>".escape($tmp)."</option>\n";
}
else {
echo " <option value='".escape($tmp)."'>".escape($tmp)."</option>\n";
}
}
}
echo " </select>\n";
}
else {
echo " <input type=\"button\" class=\"btn\" name=\"\" alt=\"".$text['button-add']."\" onclick=\"window.location='".PROJECT_PATH."/app/destinations/destinations.php'\" value='".$text['button-add']."'>\n";
}
}
elseif (permission_exists('outbound_caller_id_select')) {
if (count($destinations) > 0) {
echo " <select name='emergency_caller_id_number' id='emergency_caller_id_number' class='formfld'>\n";
echo " <option value=''></option>\n";
foreach ($destinations as &$row) {
$tmp = $row["destination_caller_id_number"];
if(strlen($tmp) == 0){
$tmp = $row["destination_description"];
$tmp = $row["destination_number"];
}
if(strlen($tmp) > 0){
if ($emergency_caller_id_number == $tmp) {
@ -1370,7 +1431,10 @@
echo " <input class='formfld' type='text' name='emergency_caller_id_number' maxlength='255' min='0' step='1' value=\"".escape($emergency_caller_id_number)."\">\n";
}
echo "<br />\n";
if (permission_exists('outbound_caller_id_select') && count($destinations) > 0) {
if (permission_exists('emergency_caller_id_select') && count($emergency_destinations) > 0){
echo $text['description-emergency_caller_id_number-select']."\n";
}
elseif (permission_exists('outbound_caller_id_select') && count($destinations) > 0) {
echo $text['description-emergency_caller_id_number-select']."\n";
}
else {