Update follow_me.php

This commit is contained in:
FusionPBX 2018-10-30 18:01:50 -06:00 committed by GitHub
parent b2e754789f
commit 036dd12654
1 changed files with 63 additions and 52 deletions

View File

@ -313,118 +313,128 @@ include "root.php";
$dial_string .= ","; $dial_string .= ",";
} }
if (($presence_id = extension_presence_id($row["follow_me_destination"])) !== false) { if (($presence_id = extension_presence_id($row["follow_me_destination"])) !== false) {
$dial_string .= "["; $variables[] = "presence_id=".$presence_id."@".$_SESSION['domain_name'];
$dial_string .= "presence_id=".$presence_id."@".$_SESSION['domain_name'];
if ($row["follow_me_prompt"] == "1") { if ($row["follow_me_prompt"] == "1") {
$dial_string .= ",group_confirm_key=exec,group_confirm_file=lua confirm.lua,confirm=true"; $variables[] = "group_confirm_key=exec";
$variables[] = "group_confirm_file=lua confirm.lua";
$variables[] = "confirm=true";
} }
if ($this->follow_me_ignore_busy != 'true') { if ($this->follow_me_ignore_busy != 'true') {
$dial_string .= ",fail_on_single_reject=USER_BUSY"; $variables[] = "fail_on_single_reject=USER_BUSY";
} }
//accountcode //accountcode
if (strlen($this->accountcode) == 0) { if (strlen($this->accountcode) == 0) {
$dial_string .= ",sip_h_X-accountcode=\${accountcode}"; $variables[] = "sip_h_X-accountcode=\${accountcode}";
} }
else { else {
$dial_string .= ",sip_h_X-accountcode=".$this->accountcode; $variables[] = "sip_h_X-accountcode=".$this->accountcode;
$dial_string .= ",accountcode=".$this->accountcode; $variables[] = "accountcode=".$this->accountcode;
} }
//toll allow //toll allow
if ($this->toll_allow != '') { if ($this->toll_allow != '') {
$dial_string .= ",toll_allow='".$this->toll_allow."'"; $variables[] = "toll_allow='".$this->toll_allow."'";
} }
$dial_string .= ",instant_ringback=true";
$dial_string .= ",ignore_early_media=true";
$dial_string .= ",domain_uuid=".$_SESSION['domain_uuid'];
$dial_string .= ",sip_invite_domain=".$_SESSION['domain_name'];
$dial_string .= ",domain_name=".$_SESSION['domain_name'];
$dial_string .= ",domain=".$_SESSION['domain_name'];
$dial_string .= ",extension_uuid=".$this->extension_uuid;
$dial_string .= ",leg_delay_start=".$row["follow_me_delay"]; $variables[] = "instant_ringback=true";
$dial_string .= ",leg_timeout=".$row["follow_me_timeout"]."]"; $variables[] = "ignore_early_media=true";
$variables[] = "domain_uuid=".$_SESSION['domain_uuid'];
$variables[] = "sip_invite_domain=".$_SESSION['domain_name'];
$variables[] = "domain_name=".$_SESSION['domain_name'];
$variables[] = "domain=".$_SESSION['domain_name'];
$variables[] = "extension_uuid=".$this->extension_uuid;
$variables[] = "leg_delay_start=".$row["follow_me_delay"];
$variables[] = "leg_timeout=".$row["follow_me_timeout"];
//$dial_string .= "\${sofia_contact(".$row["follow_me_destination"]."@".$_SESSION['domain_name'].")}"; //$dial_string .= "\${sofia_contact(".$row["follow_me_destination"]."@".$_SESSION['domain_name'].")}";
$dial_string .= "user/".$row["follow_me_destination"]."@".$_SESSION['domain_name']; $dial_string .= "[".implode(",", $variables)."]user/".$row["follow_me_destination"]."@".$_SESSION['domain_name'];
unset($variables);
} }
else { else {
$presence_id = extension_presence_id($this->extension, $this->number_alias); $presence_id = extension_presence_id($this->extension, $this->number_alias);
$dial_string .= "[presence_id=".$presence_id."@".$_SESSION['domain_name']; $variables[] = "presence_id=".$presence_id."@".$_SESSION['domain_name'];
/* /*
//set the caller id //set the caller id
if ($_SESSION['cdr']['follow_me_fix']['boolean'] == "true") { if ($_SESSION['cdr']['follow_me_fix']['boolean'] == "true") {
if (strlen($this->outbound_caller_id_name) > 0) { if (strlen($this->outbound_caller_id_name) > 0) {
$dial_string .= ",origination_caller_id_name=".$this->cid_name_prefix.$this->outbound_caller_id_name; $variables[] = "origination_caller_id_name=".$this->cid_name_prefix.$this->outbound_caller_id_name;
$dial_string .= ",effective_caller_id_name=".$this->cid_name_prefix.$this->outbound_caller_id_name; $variables[] = "effective_caller_id_name=".$this->cid_name_prefix.$this->outbound_caller_id_name;
} }
if (strlen($this->outbound_caller_id_number) > 0) { if (strlen($this->outbound_caller_id_number) > 0) {
$dial_string .= ",origination_caller_id_number=".$this->cid_number_prefix.$this->outbound_caller_id_number; $variables[] = "origination_caller_id_number=".$this->cid_number_prefix.$this->outbound_caller_id_number;
$dial_string .= ",effective_caller_id_number=".$this->cid_number_prefix.$this->outbound_caller_id_number; $variables[] = "effective_caller_id_number=".$this->cid_number_prefix.$this->outbound_caller_id_number;
} }
} }
else { else {
if (strlen($caller_id_number) > 0) { if (strlen($caller_id_number) > 0) {
//set the caller id if it is set //set the caller id if it is set
if (strlen($caller_id_name) > 0) { if (strlen($caller_id_name) > 0) {
$dial_string .= ",origination_caller_id_name=".$this->cid_name_prefix.$caller_id_name; $variables[] = "origination_caller_id_name=".$this->cid_name_prefix.$caller_id_name;
$dial_string .= ",effective_caller_id_name=".$this->cid_name_prefix.$caller_id_name; $variables[] = "effective_caller_id_name=".$this->cid_name_prefix.$caller_id_name;
} }
$dial_string .= ",origination_caller_id_number=".$this->cid_number_prefix.$caller_id_number; $variables[] = "origination_caller_id_number=".$this->cid_number_prefix.$caller_id_number;
$dial_string .= ",effective_caller_id_number=".$this->cid_number_prefix.$caller_id_number; $variables[] = "effective_caller_id_number=".$this->cid_number_prefix.$caller_id_number;
} }
else { else {
//set the outbound caller id number if the caller id number is a user //set the outbound caller id number if the caller id number is a user
$dial_string .=',origination_caller_id_number=${cond(${from_user_exists} == true ? ${outbound_caller_id_number} : ${origination_caller_id_number})}'; $variables[] = "origination_caller_id_number=${cond(${from_user_exists} == true ? ${outbound_caller_id_number} : ${origination_caller_id_number})}';
$dial_string .=',effective_caller_id_number=${cond(${from_user_exists} == true ? ${outbound_caller_id_number} : ${effective_caller_id_number})}'; $variables[] = "effective_caller_id_number=${cond(${from_user_exists} == true ? ${outbound_caller_id_number} : ${effective_caller_id_number})}';
$dial_string .=',origination_caller_id_name=${cond(${from_user_exists} == true ? ${outbound_caller_id_name} : ${origination_caller_id_name})}'; $variables[] = "origination_caller_id_name=${cond(${from_user_exists} == true ? ${outbound_caller_id_name} : ${origination_caller_id_name})}';
$dial_string .=',effective_caller_id_name=${cond(${from_user_exists} == true ? ${outbound_caller_id_name} : ${effective_caller_id_name})}'; $variables[] = "effective_caller_id_name=${cond(${from_user_exists} == true ? ${outbound_caller_id_name} : ${effective_caller_id_name})}';
} }
} }
*/ */
//accountcode //accountcode
if (strlen($this->accountcode) == 0) { if (strlen($this->accountcode) == 0) {
$dial_string .= ",sip_h_X-accountcode=\${accountcode}"; $variables[] = "sip_h_X-accountcode=\${accountcode}";
} }
else { else {
$dial_string .= ",sip_h_X-accountcode=".$this->accountcode; $variables[] = "sip_h_X-accountcode=".$this->accountcode;
$dial_string .= ",accountcode=".$this->accountcode; $variables[] = "accountcode=".$this->accountcode;
} }
//toll allow //toll allow
if ($this->toll_allow != '') { if ($this->toll_allow != '') {
$dial_string .= ",toll_allow='".$this->toll_allow."'"; $variables[] = "toll_allow='".$this->toll_allow."'";
} }
if ($this->follow_me_ignore_busy != 'true') { if ($this->follow_me_ignore_busy != 'true') {
$dial_string .= ",fail_on_single_reject=USER_BUSY"; $variables[] = "fail_on_single_reject=USER_BUSY";
} }
if ($row["follow_me_prompt"] == "1") { if ($row["follow_me_prompt"] == "1") {
$dial_string .= ",group_confirm_key=exec,group_confirm_file=lua confirm.lua,confirm=true"; $variables[] = "group_confirm_key=exec";
$variables[] = "group_confirm_file=lua confirm.lua";
$variables[] = "confirm=true";
} }
$dial_string .= ",instant_ringback=true";
$dial_string .= ",ignore_early_media=true"; $variables[] = "instant_ringback=true";
$dial_string .= ",domain_uuid=".$_SESSION['domain_uuid']; $variables[] = "ignore_early_media=true";
$dial_string .= ",sip_invite_domain=".$_SESSION['domain_name']; $variables[] = "domain_uuid=".$_SESSION['domain_uuid'];
$dial_string .= ",domain_name=".$_SESSION['domain_name']; $variables[] = "sip_invite_domain=".$_SESSION['domain_name'];
$dial_string .= ",domain=".$_SESSION['domain_name']; $variables[] = "domain_name=".$_SESSION['domain_name'];
$dial_string .= ",extension_uuid=".$this->extension_uuid; $variables[] = "domain=".$_SESSION['domain_name'];
$dial_string .= ",leg_delay_start=".$row["follow_me_delay"]; $variables[] = "extension_uuid=".$this->extension_uuid;
$dial_string .= ",leg_timeout=".$row["follow_me_timeout"]."]"; $variables[] = "leg_delay_start=".$row["follow_me_delay"];
$variables[] = "leg_timeout=".$row["follow_me_timeout"];
$variables[] = "outbound_caller_id_name=".$row["outbound_caller_id_name"];
$variables[] = "outbound_caller_id_number=".$row["outbound_caller_id_number"];
if (is_numeric($row["follow_me_destination"])) { if (is_numeric($row["follow_me_destination"])) {
if ($_SESSION['domain']['bridge']['text'] == "outbound" || $_SESSION['domain']['bridge']['text'] == "bridge") { if ($_SESSION['domain']['bridge']['text'] == "outbound" || $_SESSION['domain']['bridge']['text'] == "bridge") {
$bridge = outbound_route_to_bridge ($_SESSION['domain_uuid'], $row["follow_me_destination"]); $bridge = outbound_route_to_bridge ($_SESSION['domain_uuid'], $row["follow_me_destination"]);
$dial_string .= $bridge[0]; $dial_string .= "[".implode(",", $variables)."]".$bridge[0];
} }
elseif ($_SESSION['domain']['bridge']['text'] == "loopback") { elseif ($_SESSION['domain']['bridge']['text'] == "loopback") {
$dial_string .= "loopback/".$row["follow_me_destination"]."/".$_SESSION['domain_name']; //$dial_string .= "loopback/".$row["follow_me_destination"]."/".$_SESSION['domain_name'];
$dial_string .= "loopback/export:".implode("\,export:", $variables)."\,transfer:".$row["follow_me_destination"]."/".$_SESSION['domain_name']."/inline";
} }
elseif ($_SESSION['domain']['bridge']['text'] == "lcr") { elseif ($_SESSION['domain']['bridge']['text'] == "lcr") {
$dial_string .= "lcr/".$_SESSION['lcr']['profile']['text']."/".$_SESSION['domain_name']."/".$row["follow_me_destination"]; $dial_string .= "[".implode(",", $variables)."]lcr/".$_SESSION['lcr']['profile']['text']."/".$_SESSION['domain_name']."/".$row["follow_me_destination"];
} }
else { else {
$dial_string .= "loopback/".$row["follow_me_destination"]."/".$_SESSION['domain_name']; //$dial_string .= "loopback/".$row["follow_me_destination"]."/".$_SESSION['domain_name'];
$dial_string .= "loopback/export:".implode("\,export:", $variables)."\,transfer:".$row["follow_me_destination"]."/".$_SESSION['domain_name']."/inline";
} }
} }
else { else {
@ -434,7 +444,8 @@ include "root.php";
$x++; $x++;
} }
//$dial_string = str_replace(",]", "]", $dial_string); //$dial_string = str_replace(",]", "]", $dial_string);
$this->dial_string = $dial_string; $this->dial_string = "{ignore_early_media=true}".$dial_string;
unset($variables);
$sql = "update v_follow_me set "; $sql = "update v_follow_me set ";
$sql .= "dial_string = '".check_str($this->dial_string)."' "; $sql .= "dial_string = '".check_str($this->dial_string)."' ";