From 6b7bb9e1795c4c3a361bcff19ef660019386ba4d Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Mon, 22 Oct 2012 20:09:37 +0000 Subject: [PATCH] Add ringback to ring groups --- app/ring_groups/app_config.php | 4 ++ app/ring_groups/ring_groups_edit.php | 68 ++++++++++++++++++++++------ 2 files changed, 57 insertions(+), 15 deletions(-) diff --git a/app/ring_groups/app_config.php b/app/ring_groups/app_config.php index ad2ddd5fc2..0306391fa8 100644 --- a/app/ring_groups/app_config.php +++ b/app/ring_groups/app_config.php @@ -103,6 +103,10 @@ $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Select the timeout destination.'; $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = 'ring_group_ringback'; + $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Select the ringback.'; + $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = 'ring_group_enabled'; $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Select enable or disable the ring group.'; diff --git a/app/ring_groups/ring_groups_edit.php b/app/ring_groups/ring_groups_edit.php index 7662192d45..bc0ddeb2f4 100644 --- a/app/ring_groups/ring_groups_edit.php +++ b/app/ring_groups/ring_groups_edit.php @@ -72,6 +72,7 @@ else { $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_ringback = check_str($_POST["ring_group_ringback"]); $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"]); @@ -107,6 +108,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { 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_ringback) == 0) { $msg .= "Please provide: Ringback
\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) { @@ -141,6 +143,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "ring_group_timeout_app, "; $sql .= "ring_group_timeout_data, "; $sql .= "ring_group_cid_name_prefix, "; + $sql .= "ring_group_ringback, "; $sql .= "ring_group_enabled, "; $sql .= "ring_group_description, "; $sql .= "dialplan_uuid "; @@ -157,6 +160,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "'$ring_group_timeout_app', "; $sql .= "'$ring_group_timeout_data', "; $sql .= "'$ring_group_cid_name_prefix', "; + $sql .= "'$ring_group_ringback', "; $sql .= "'$ring_group_enabled', "; $sql .= "'$ring_group_description', "; $sql .= "'$dialplan_uuid' "; @@ -177,6 +181,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $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_ringback = '$ring_group_ringback', "; $sql .= "ring_group_enabled = '$ring_group_enabled', "; $sql .= "ring_group_description = '$ring_group_description' "; //$sql .= "dialplan_uuid = '$dialplan_uuid' "; @@ -212,12 +217,13 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $sql = "select count(*) as num_rows from v_dialplans "; $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "and dialplan_uuid = '".$dialplan_uuid."' "; + $db->exec(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql)); if ($prep_statement) { $prep_statement->execute(); $row = $prep_statement->fetch(PDO::FETCH_ASSOC); if ($row['num_rows'] == 0) { - //create the dialplan entry for fax + //add the dialplan entry $dialplan_name = $ring_group_name; $dialplan_order ='333'; $dialplan_context = $ring_group_context; @@ -242,14 +248,6 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $dialplan_detail_group = '1'; 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_tag = 'action'; //condition, action, antiaction - $dialplan_detail_type = 'set'; - $dialplan_detail_data = 'ringback=${us-ring}'; - $dialplan_detail_order = '020'; - $dialplan_detail_group = '1'; - 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_tag = 'action'; //condition, action, antiaction //$dialplan_detail_type = 'transfer'; @@ -303,6 +301,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $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_ringback = $row["ring_group_ringback"]; $ring_group_enabled = $row["ring_group_enabled"]; $ring_group_description = $row["ring_group_description"]; $dialplan_uuid = $row["dialplan_uuid"]; @@ -341,12 +340,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "
\n"; echo "\n"; echo "\n"; - if ($action == "add") { - echo "\n"; - } - if ($action == "update") { - echo "\n"; - } + echo "\n"; + echo "\n"; echo "\n"; echo "\n"; @@ -498,6 +493,49 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "
Ring Group AddRing Group EditRing Group
\n"; + echo " Ring Back:\n"; + echo "\n"; + + $select_options = ""; + if ($ring_group_ringback == "\${us-ring}" || $ring_group_ringback == "us-ring") { + $select_options .= " \n"; + } + else { + $select_options .= " \n"; + } + if ($ring_group_ringback == "\${fr-ring}" || $ring_group_ringback == "fr-ring") { + $select_options .= " \n"; + } + else { + $select_options .= " \n"; + } + if ($ring_group_ringback == "\${uk-ring}" || $ring_group_ringback == "uk-ring") { + $select_options .= " \n"; + } + else { + $select_options .= " \n"; + } + if ($ring_group_ringback == "\${rs-ring}" || $ring_group_ringback == "rs-ring") { + $select_options .= " \n"; + } + else { + $select_options .= " \n"; + } + require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php"; + $moh = new switch_music_on_hold; + $moh->select_name = "ring_group_ringback"; + $moh->select_value = $ring_group_ringback; + $moh->select_options = $select_options; + echo $moh->select(); + + echo "
\n"; + echo "Defines what the caller will hear while the destination is being called.\n"; + echo "
\n"; echo " Enabled:\n";