mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Added toll allow and ability to enable it in outbound routes
This commit is contained in:
@@ -1,7 +0,0 @@
|
|||||||
<context name="{v_context}">
|
|
||||||
<extension name="toll_type_assignment" continue="true" app_uuid="742714e5-8cdf-32fd-462c-cbe7e3d655db" enabled="false">
|
|
||||||
<condition field="destination_number" expression="^.*$">
|
|
||||||
<action application="set" data="toll_type=${luarun toll_type_assignment.lua ${uuid}}" inline="true"/>
|
|
||||||
</condition>
|
|
||||||
</extension>
|
|
||||||
</context>
|
|
||||||
@@ -302,6 +302,16 @@
|
|||||||
$text['description-accountcode']['pt-pt'] = "Introduza a conta.";
|
$text['description-accountcode']['pt-pt'] = "Introduza a conta.";
|
||||||
$text['description-accountcode']['fr-fr'] = "";
|
$text['description-accountcode']['fr-fr'] = "";
|
||||||
|
|
||||||
|
$text['label-toll_allow']['en-us'] = "Toll allow";
|
||||||
|
$text['label-toll_allow']['es-cl'] = "Permitir Tarifas Especiales";
|
||||||
|
$text['label-toll_allow']['pt-pt'] = "Permissões";
|
||||||
|
$text['label-toll_allow']['fr-fr'] = "Droits";
|
||||||
|
|
||||||
|
$text['description-enable-toll_allow']['en-us'] = "Set to true to enable toll allow";
|
||||||
|
$text['description-enable-toll_allow']['es-cl'] = "Seleccione verdadero para activar permitir Tarifas Especiales";
|
||||||
|
$text['description-enable-toll_allow']['pt-pt'] = "scolha 'sim' para activar permissões";
|
||||||
|
$text['description-enable-toll_allow']['fr-fr'] = "Choisir Oui pour activer droits";
|
||||||
|
|
||||||
$text['label-order']['en-us'] = "Order";
|
$text['label-order']['en-us'] = "Order";
|
||||||
$text['label-order']['es-cl'] = "Orden";
|
$text['label-order']['es-cl'] = "Orden";
|
||||||
$text['label-order']['pt-pt'] = "Ordem";
|
$text['label-order']['pt-pt'] = "Ordem";
|
||||||
|
|||||||
@@ -62,7 +62,11 @@ else {
|
|||||||
$gateway = check_str($_POST["gateway"]);
|
$gateway = check_str($_POST["gateway"]);
|
||||||
$limit = check_str($_POST["limit"]);
|
$limit = check_str($_POST["limit"]);
|
||||||
$accountcode = check_str($_POST["accountcode"]);
|
$accountcode = check_str($_POST["accountcode"]);
|
||||||
|
|
||||||
|
$toll_allow_enable = check_str($_POST["toll_allow_enabled"]);
|
||||||
|
//set default to enabled
|
||||||
|
if (strlen($toll_allow_enable) == 0) { $toll_allow_enable = "false"; }
|
||||||
|
|
||||||
//set the default type
|
//set the default type
|
||||||
$gateway_type = 'gateway';
|
$gateway_type = 'gateway';
|
||||||
$gateway_2_type = 'gateway';
|
$gateway_2_type = 'gateway';
|
||||||
@@ -267,7 +271,7 @@ else {
|
|||||||
$tmp_prefix == $dialplan_expression
|
$tmp_prefix == $dialplan_expression
|
||||||
? $outbound_prefix = ""
|
? $outbound_prefix = ""
|
||||||
: $outbound_prefix = $tmp_prefix;
|
: $outbound_prefix = $tmp_prefix;
|
||||||
|
|
||||||
if ($gateway_type == "gateway") {
|
if ($gateway_type == "gateway") {
|
||||||
$dialplan_name = $gateway_name.".".$abbrv;
|
$dialplan_name = $gateway_name.".".$abbrv;
|
||||||
$action_data = "sofia/gateway/".$gateway_uuid."/".$prefix_number."\$1";
|
$action_data = "sofia/gateway/".$gateway_uuid."/".$prefix_number."\$1";
|
||||||
@@ -482,10 +486,21 @@ else {
|
|||||||
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data, $dialplan_detail_break, $dialplan_detail_inline);
|
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data, $dialplan_detail_break, $dialplan_detail_inline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($toll_allow_enable == "true") {
|
||||||
|
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
||||||
|
$dialplan_detail_type = 'lua';
|
||||||
|
$dialplan_detail_data = 'app.lua toll_allow ${uuid}';
|
||||||
|
$dialplan_detail_order = '065';
|
||||||
|
$dialplan_detail_group = '';
|
||||||
|
$dialplan_detail_break = '';
|
||||||
|
$dialplan_detail_inline = 'true';
|
||||||
|
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data, $dialplan_detail_break, $dialplan_detail_inline);
|
||||||
|
}
|
||||||
|
|
||||||
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
||||||
$dialplan_detail_type = 'bridge';
|
$dialplan_detail_type = 'bridge';
|
||||||
$dialplan_detail_data = $action_data;
|
$dialplan_detail_data = $action_data;
|
||||||
$dialplan_detail_order = '065';
|
$dialplan_detail_order = '070';
|
||||||
$dialplan_detail_group = '';
|
$dialplan_detail_group = '';
|
||||||
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
||||||
|
|
||||||
@@ -493,7 +508,7 @@ else {
|
|||||||
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
||||||
$dialplan_detail_type = 'bridge';
|
$dialplan_detail_type = 'bridge';
|
||||||
$dialplan_detail_data = $bridge_2_data;
|
$dialplan_detail_data = $bridge_2_data;
|
||||||
$dialplan_detail_order = '070';
|
$dialplan_detail_order = '075';
|
||||||
$dialplan_detail_group = '';
|
$dialplan_detail_group = '';
|
||||||
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
||||||
}
|
}
|
||||||
@@ -502,7 +517,7 @@ else {
|
|||||||
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
||||||
$dialplan_detail_type = 'bridge';
|
$dialplan_detail_type = 'bridge';
|
||||||
$dialplan_detail_data = $bridge_3_data;
|
$dialplan_detail_data = $bridge_3_data;
|
||||||
$dialplan_detail_order = '075';
|
$dialplan_detail_order = '080';
|
||||||
$dialplan_detail_group = '';
|
$dialplan_detail_group = '';
|
||||||
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
||||||
}
|
}
|
||||||
@@ -913,6 +928,20 @@ function type_onchange(dialplan_detail_type) {
|
|||||||
echo "</td>\n";
|
echo "</td>\n";
|
||||||
echo "</tr>\n";
|
echo "</tr>\n";
|
||||||
|
|
||||||
|
echo "<tr>\n";
|
||||||
|
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
|
||||||
|
echo " ".$text['label-toll_allow'].":\n";
|
||||||
|
echo "</td>\n";
|
||||||
|
echo "<td class='vtable' align='left'>\n";
|
||||||
|
echo " <select class='formfld' name='toll_allow_enabled' style='width: 60%;'>\n";
|
||||||
|
echo " <option value='true' >".$text['label-true']."</option>\n";
|
||||||
|
echo " <option value='false' selected='true'>".$text['label-false']."</option>\n";
|
||||||
|
echo " </select>\n";
|
||||||
|
echo "<br />\n";
|
||||||
|
echo $text['description-enable-toll_allow']."\n";
|
||||||
|
echo "</td>\n";
|
||||||
|
echo "</tr>\n";
|
||||||
|
|
||||||
echo "<tr>\n";
|
echo "<tr>\n";
|
||||||
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
|
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
|
||||||
echo " ".$text['label-order'].":\n";
|
echo " ".$text['label-order'].":\n";
|
||||||
|
|||||||
@@ -23,19 +23,20 @@
|
|||||||
-- Riccardo Granchi <riccardo.granchi@nems.it>
|
-- Riccardo Granchi <riccardo.granchi@nems.it>
|
||||||
|
|
||||||
--debug
|
--debug
|
||||||
debug["toll_type"] = false
|
debug["toll_type"] = true
|
||||||
|
|
||||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1))
|
dofile(scripts_dir.."/resources/functions/explode.lua");
|
||||||
dofile(scripts_dir .. "/resources/functions/explode.lua")
|
|
||||||
|
|
||||||
--create the api object and get variables
|
--create the api object and get variables
|
||||||
api = freeswitch.API()
|
api = freeswitch.API()
|
||||||
uuid = argv[1]
|
uuid = argv[2]
|
||||||
|
|
||||||
if not uuid or uuid == "" then
|
if not uuid or uuid == "" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
template_indexes = { "mobile", "landline", "international", "tollfree", "sharedcharge", "premium", "unknown"}
|
||||||
|
|
||||||
--Define templates for every toll type for your country
|
--Define templates for every toll type for your country
|
||||||
function get_toll_types_it()
|
function get_toll_types_it()
|
||||||
if (debug["toll_type"]) then
|
if (debug["toll_type"]) then
|
||||||
@@ -63,8 +64,17 @@
|
|||||||
called = api:executeString("uuid_getvar " .. uuid .. " destination_number")
|
called = api:executeString("uuid_getvar " .. uuid .. " destination_number")
|
||||||
prefix = api:executeString("uuid_getvar " .. uuid .. " outbound_prefix")
|
prefix = api:executeString("uuid_getvar " .. uuid .. " outbound_prefix")
|
||||||
country = api:executeString("uuid_getvar " .. uuid .. " default_country")
|
country = api:executeString("uuid_getvar " .. uuid .. " default_country")
|
||||||
|
toll_allow = api:executeString("uuid_getvar " .. uuid .. " toll_allow")
|
||||||
|
domain_name = api:executeString("uuid_getvar " .. uuid .. " domain_name")
|
||||||
|
caller = api:executeString("uuid_getvar " .. uuid .. " caller_id_number")
|
||||||
|
|
||||||
template_indexes = { "mobile", "landline", "international", "tollfree", "sharedcharge", "premium", "unknown"}
|
if (debug["toll_type"]) then
|
||||||
|
freeswitch.consoleLog("NOTICE", "[toll_type_assignment] called: " .. called .. "\n")
|
||||||
|
freeswitch.consoleLog("NOTICE", "[toll_type_assignment] prefix: " .. prefix .. "\n")
|
||||||
|
freeswitch.consoleLog("NOTICE", "[toll_type_assignment] country: " .. country .. "\n")
|
||||||
|
freeswitch.consoleLog("NOTICE", "[toll_type_assignment] tollAllow: " .. toll_allow .. "\n")
|
||||||
|
end
|
||||||
|
|
||||||
templates = {}
|
templates = {}
|
||||||
local toll_type = "unknown"
|
local toll_type = "unknown"
|
||||||
|
|
||||||
@@ -78,11 +88,13 @@
|
|||||||
if country == "IT" then get_toll_types_it()
|
if country == "IT" then get_toll_types_it()
|
||||||
elseif country == "US" then get_toll_types_us()
|
elseif country == "US" then get_toll_types_us()
|
||||||
else
|
else
|
||||||
freeswitch.consoleLog("NOTICE", "[toll_type_assignment] toll type: " .. toll_type .. "\n")
|
if (debug["toll_type"]) then
|
||||||
|
freeswitch.consoleLog("NOTICE", "[toll_type_assignment] toll type: " .. toll_type .. "\n")
|
||||||
|
end
|
||||||
return toll_type
|
return toll_type
|
||||||
end
|
end
|
||||||
|
|
||||||
--test templates matching to set correct toll_type
|
--set toll_type
|
||||||
local found = false
|
local found = false
|
||||||
for i,label in pairs(template_indexes) do
|
for i,label in pairs(template_indexes) do
|
||||||
template = templates[label]
|
template = templates[label]
|
||||||
@@ -113,7 +125,41 @@
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
freeswitch.consoleLog("NOTICE", "[toll_type_assignment] toll type: " .. toll_type .. "\n")
|
||||||
|
-- api:executeString("uuid_setvar " .. uuid .. " toll_type " .. toll_type);
|
||||||
|
-- session:setVariable('toll_type', toll_type);
|
||||||
|
|
||||||
|
|
||||||
|
--check toll allow
|
||||||
|
allow = false
|
||||||
|
|
||||||
|
if ((toll_allow ~= nil) and (string.len(toll_allow) > 0) and (toll_allow ~= "_undef_")) then
|
||||||
|
parts = explode(",", toll_allow)
|
||||||
|
|
||||||
|
for i,part in pairs(parts) do
|
||||||
|
if (debug["toll_type"]) then
|
||||||
|
freeswitch.consoleLog("NOTICE", "[toll_type_assignment] checking toll allow part " .. part .. "\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
if ( part == toll_type ) then
|
||||||
|
allow = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
freeswitch.consoleLog("WARNING", domain_name .. " - toll_allow not defined for extension " .. caller .. "\n")
|
||||||
|
|
||||||
|
-- Uncomment following line to allow all calls for extensions without toll_allow
|
||||||
|
-- allow = true
|
||||||
|
end
|
||||||
|
|
||||||
|
--hangup not allowed calls
|
||||||
|
if ( not allow ) then
|
||||||
|
freeswitch.consoleLog("WARNING", domain_name .. " - " .. toll_type .. " call not authorized from " .. caller .. " to " .. called .. " : REJECTING!\n")
|
||||||
|
session:hangup("OUTGOING_CALL_BARRED")
|
||||||
|
else
|
||||||
|
freeswitch.consoleLog("NOTICE", domain_name .. " - " .. toll_type .. " call authorized from " .. caller .. " to " .. called .. "\n")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
freeswitch.consoleLog("NOTICE", "[toll_type_assignment] toll type: " .. toll_type .. "\n")
|
|
||||||
return toll_type
|
|
||||||
Reference in New Issue
Block a user