From eca9854b239a0674b7ec09cbb6794a9b0a756949 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Tue, 31 Jul 2012 04:56:18 +0000 Subject: [PATCH] Add caller id prefix to ring groups to the dev branch. --- app/ring_groups/app_config.php | 4 ++++ app/ring_groups/ring_groups_edit.php | 17 +++++++++++++++++ includes/install/scripts/ring_group.lua | 14 +++++++++++--- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/ring_groups/app_config.php b/app/ring_groups/app_config.php index ee0c1de965..84f08f350a 100644 --- a/app/ring_groups/app_config.php +++ b/app/ring_groups/app_config.php @@ -65,6 +65,10 @@ $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; $apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'Enter the context.'; $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = 'ring_group_cid_name_prefix'; + $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; + $apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'Enter the caller ID prefix.'; + $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = 'ring_group_strategy'; $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; $apps[$x]['db'][$y]['fields'][$z]['description']['en'] = 'Select the strategy.'; diff --git a/app/ring_groups/ring_groups_edit.php b/app/ring_groups/ring_groups_edit.php index d1521e12f2..80f25cdedb 100644 --- a/app/ring_groups/ring_groups_edit.php +++ b/app/ring_groups/ring_groups_edit.php @@ -70,6 +70,7 @@ else { $ring_group_strategy = check_str($_POST["ring_group_strategy"]); $ring_group_timeout_sec = check_str($_POST["ring_group_timeout_sec"]); $ring_group_timeout_action = check_str($_POST["ring_group_timeout_action"]); + $ring_group_cid_name_prefix = check_str($_POST["ring_group_cid_name_prefix"]); $ring_group_enabled = check_str($_POST["ring_group_enabled"]); $ring_group_description = check_str($_POST["ring_group_description"]); $dialplan_uuid = check_str($_POST["dialplan_uuid"]); @@ -93,6 +94,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { if (strlen($ring_group_strategy) == 0) { $msg .= "Please provide: Strategy
\n"; } if (strlen($ring_group_timeout_sec) == 0) { $msg .= "Please provide: Timeout
\n"; } if (strlen($ring_group_timeout_app) == 0) { $msg .= "Please provide: Timeout Action
\n"; } + //if (strlen($ring_group_cid_name_prefix) == 0) { $msg .= "Please provide: Caller ID Prefix
\n"; } if (strlen($ring_group_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } //if (strlen($ring_group_description) == 0) { $msg .= "Please provide: Description
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { @@ -136,6 +138,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "ring_group_timeout_sec, "; $sql .= "ring_group_timeout_app, "; $sql .= "ring_group_timeout_data, "; + $sql .= "ring_group_cid_name_prefix, "; $sql .= "ring_group_enabled, "; $sql .= "ring_group_description, "; $sql .= "dialplan_uuid "; @@ -151,6 +154,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "'$ring_group_timeout_sec', "; $sql .= "'$ring_group_timeout_app', "; $sql .= "'$ring_group_timeout_data', "; + $sql .= "'$ring_group_cid_name_prefix', "; $sql .= "'$ring_group_enabled', "; $sql .= "'$ring_group_description', "; $sql .= "'$dialplan_uuid' "; @@ -170,6 +174,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "ring_group_timeout_sec = '$ring_group_timeout_sec', "; $sql .= "ring_group_timeout_app = '$ring_group_timeout_app', "; $sql .= "ring_group_timeout_data = '$ring_group_timeout_data', "; + $sql .= "ring_group_cid_name_prefix = '$ring_group_cid_name_prefix', "; $sql .= "ring_group_enabled = '$ring_group_enabled', "; $sql .= "ring_group_description = '$ring_group_description' "; //$sql .= "dialplan_uuid = '$dialplan_uuid' "; @@ -295,6 +300,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $ring_group_timeout_sec = $row["ring_group_timeout_sec"]; $ring_group_timeout_app = $row["ring_group_timeout_app"]; $ring_group_timeout_data = $row["ring_group_timeout_data"]; + $ring_group_cid_name_prefix = $row["ring_group_cid_name_prefix"]; $ring_group_enabled = $row["ring_group_enabled"]; $ring_group_description = $row["ring_group_description"]; $dialplan_uuid = $row["dialplan_uuid"]; @@ -479,6 +485,17 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; + echo "\n"; + echo "\n"; + echo " CID Prefix:\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Set a prefix on the caller ID name. \n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo " Enabled:\n"; diff --git a/includes/install/scripts/ring_group.lua b/includes/install/scripts/ring_group.lua index 228853ebb6..72867e2db5 100644 --- a/includes/install/scripts/ring_group.lua +++ b/includes/install/scripts/ring_group.lua @@ -42,11 +42,13 @@ --get the variables domain_name = session:getVariable("domain_name"); ring_group_uuid = session:getVariable("ring_group_uuid"); + caller_id_name = session:getVariable("caller_id_name"); + caller_id_number = session:getVariable("caller_id_number"); --get the extension list sql = [[ SELECT g.ring_group_extension_uuid, e.extension_uuid, e.extension, - r.ring_group_strategy, r.ring_group_timeout_sec, r.ring_group_timeout_app, r.ring_group_timeout_data + r.ring_group_strategy, r.ring_group_timeout_sec, r.ring_group_timeout_app, r.ring_group_timeout_data, r.ring_group_cid_name_prefix FROM v_ring_groups as r, v_ring_group_extensions as g, v_extensions as e where g.ring_group_uuid = r.ring_group_uuid and g.ring_group_uuid = ']]..ring_group_uuid..[[' @@ -61,6 +63,12 @@ ring_group_timeout_sec = row.ring_group_timeout_sec; ring_group_timeout_app = row.ring_group_timeout_app; ring_group_timeout_data = row.ring_group_timeout_data; + ring_group_cid_name_prefix = row.ring_group_cid_name_prefix; + + if (string.len(ring_group_cid_name_prefix) > 0) then + caller_id_name = ring_group_cid_name_prefix .. "#" .. caller_id_name; + end + if (row.ring_group_strategy == "sequence") then delimiter = "|"; end @@ -68,9 +76,9 @@ delimiter = ","; end if (x == 0) then - app_data = "[leg_timeout="..ring_group_timeout_sec.."]user/" .. row.extension .. "@" .. domain_name; + app_data = "[leg_timeout="..ring_group_timeout_sec..",origination_caller_id_name="..caller_id_name.."]user/" .. row.extension .. "@" .. domain_name; else - app_data = app_data .. delimiter .. "[leg_timeout="..ring_group_timeout_sec.."]user/" .. row.extension .. "@" .. domain_name; + app_data = app_data .. delimiter .. "[leg_timeout="..ring_group_timeout_sec..",origination_caller_id_name="..caller_id_name.."]user/" .. row.extension .. "@" .. domain_name; end x = x + 1; end);