From c0d758be8600d40c6a0171761d72fa0843e857e2 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sun, 4 Oct 2015 01:29:03 -0600 Subject: [PATCH] Add h hostname to option for the gateways. --- app/gateways/app_config.php | 5 ++++ app/gateways/app_languages.php | 18 +++++++++++++ app/gateways/gateway_edit.php | 26 +++++++++++++++++++ app/gateways/gateways.php | 2 ++ .../scripts/configuration/sofia.conf.lua | 1 + 5 files changed, 52 insertions(+) diff --git a/app/gateways/app_config.php b/app/gateways/app_config.php index 049daf4f95..672be36cc3 100644 --- a/app/gateways/app_config.php +++ b/app/gateways/app_config.php @@ -189,6 +189,11 @@ $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "hostname"; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(255)"; + $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = "enabled"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; diff --git a/app/gateways/app_languages.php b/app/gateways/app_languages.php index 414807c343..4af02a678b 100644 --- a/app/gateways/app_languages.php +++ b/app/gateways/app_languages.php @@ -442,6 +442,15 @@ $text['label-expire_seconds']['de-at'] = "Expire Seconds"; $text['label-expire_seconds']['ar-eg'] = ""; $text['label-expire_seconds']['he'] = ""; +$text['label-hostname']['en-us'] = "Hostname"; +$text['label-hostname']['pt-pt'] = "Hostname"; +$text['label-hostname']['fr-fr'] = "Nom d'hôte"; +$text['label-hostname']['pt-br'] = "Hostname"; +$text['label-hostname']['pl'] = "Nazwa hosta"; +$text['label-hostname']['sv-se'] = "Hostname"; +$text['label-hostname']['uk'] = "Назва хоста"; +$text['label-hostname']['de-at'] = "Hostname"; + $text['label-enabled']['en-us'] = "Enabled"; $text['label-enabled']['es-cl'] = "Activado"; $text['label-enabled']['pt-pt'] = "Habilitado"; @@ -870,6 +879,15 @@ $text['description-expire_seconds']['de-at'] = "Geben Sie an, nach wie vielen Se $text['description-expire_seconds']['ar-eg'] = ""; $text['description-expire_seconds']['he'] = ""; +$text['description-hostname']['en-us'] = "Enter the hostname / switchname."; +$text['description-hostname']['pt-pt'] = "Introduza o hostname"; +$text['description-hostname']['fr-fr'] = "Entrer le nom de l'hôte / du switch."; +$text['description-hostname']['pt-br'] = "Insira o hostname"; +$text['description-hostname']['pl'] = "Wprowadź nazwę hosta / PBXu."; +$text['description-hostname']['sv-se'] = "Fyll i hostname / switchname."; +$text['description-hostname']['uk'] = "Введіть назву хоста / switchname."; +$text['description-hostname']['de-at'] = "Geben Sie den Hostnamen / Switchnamen an."; + $text['description-enabled']['en-us'] = "Enable or Disable the Gateway"; $text['description-enabled']['es-cl'] = "Activar o Desactivar la Pasarela"; $text['description-enabled']['pt-pt'] = "Habilitar ou Desabilitar o Gateway"; diff --git a/app/gateways/gateway_edit.php b/app/gateways/gateway_edit.php index 0ddb0a4f9a..a60a801163 100644 --- a/app/gateways/gateway_edit.php +++ b/app/gateways/gateway_edit.php @@ -95,6 +95,7 @@ else { $extension_in_contact = check_str($_POST["extension_in_contact"]); $context = check_str($_POST["context"]); $profile = check_str($_POST["profile"]); + $hostname = check_str($_POST["hostname"]); $enabled = check_str($_POST["enabled"]); $description = check_str($_POST["description"]); } @@ -198,6 +199,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "extension_in_contact, "; $sql .= "context, "; $sql .= "profile, "; + $sql .= "hostname, "; $sql .= "enabled, "; $sql .= "description "; $sql .= ")"; @@ -232,6 +234,12 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "'$extension_in_contact', "; $sql .= "'$context', "; $sql .= "'$profile', "; + if (strlen($hostname) == 0) { + $sql .= "null, "; + } + else { + $sql .= "'$hostname', "; + } $sql .= "'$enabled', "; $sql .= "'$description' "; $sql .= ")"; @@ -278,6 +286,12 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { else { $sql .= "domain_uuid = '$domain_uuid', "; } + if (strlen($hostname) == 0) { + $sql .= "hostname = null, "; + } + else { + $sql .= "hostname = '$hostname', "; + } $sql .= "enabled = '$enabled', "; $sql .= "description = '$description' "; $sql .= "where gateway_uuid = '$gateway_uuid'"; @@ -374,6 +388,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $extension_in_contact = $row["extension_in_contact"]; $context = $row["context"]; $profile = $row["profile"]; + $hostname = $row["hostname"]; $enabled = $row["enabled"]; $description = $row["description"]; } @@ -871,6 +886,17 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; + echo "\n"; + echo "\n"; + echo " ".$text['label-hostname']."\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-hostname']."\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo " ".$text['label-enabled']."\n"; diff --git a/app/gateways/gateways.php b/app/gateways/gateways.php index bc890546dc..8ee5d35354 100644 --- a/app/gateways/gateways.php +++ b/app/gateways/gateways.php @@ -159,6 +159,7 @@ else { echo "".$text['label-action']."\n"; echo "".$text['label-state']."\n"; } + echo th_order_by('hostname', $text['label-hostname'], $order_by, $order); echo th_order_by('enabled', $text['label-enabled'], $order_by, $order); echo th_order_by('description', $text['label-description'], $order_by, $order); echo ""; @@ -183,6 +184,7 @@ else { } echo "\n"; echo " ".$row["context"]."\n"; + echo " ".$row["hostname"]."\n"; if ($fp) { if ($row["enabled"] == "true") { $response = switch_gateway_status($row["gateway_uuid"]); diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua index 6656f619f3..52e70dc563 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/sofia.conf.lua @@ -119,6 +119,7 @@ sql = "select * from v_gateways "; sql = sql .. "where enabled = 'true' and profile = '"..sip_profile_name.."' "; end + sql = sql .. "and (g.hostname = '" .. hostname.. "' or g.hostname is null or g.hostname = '') "; if (debug["sql"]) then freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n"); end