Update follow_me.php

This commit is contained in:
FusionPBX 2019-03-04 13:03:31 -07:00 committed by GitHub
parent bc6fdadb29
commit ddc46f8901
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 23 deletions

View File

@ -32,6 +32,7 @@ include "root.php";
//define the follow me class
class follow_me {
public $domain_uuid;
private $domain_name;
public $db_type;
public $follow_me_uuid;
public $cid_name_prefix;
@ -235,6 +236,7 @@ include "root.php";
} //function
public function set() {
//set the global variable
global $db;
@ -255,14 +257,16 @@ include "root.php";
}
//determine whether to update the dial string
$sql = "select * from v_follow_me ";
$sql .= "where domain_uuid = '".$this->domain_uuid."' ";
$sql .= "and follow_me_uuid = '".$this->follow_me_uuid."' ";
$sql = "select d.domain_name, f.* from v_follow_me as f, v_domains as d ";
$sql .= "where f.domain_uuid = '".$this->domain_uuid."' ";
$sql .= "and f.follow_me_uuid = '".$this->follow_me_uuid."' ";
$sql .= "and d.domain_uuid = f.domain_uuid ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
if (is_array($result)) foreach ($result as &$row) {
$follow_me_uuid = $row["follow_me_uuid"];
$this->domain_name = $row["domain_name"];
$this->follow_me_enabled = $row["follow_me_enabled"];
$this->cid_name_prefix = $row["cid_name_prefix"];
$this->cid_number_prefix = $row["cid_number_prefix"];
@ -311,7 +315,7 @@ include "root.php";
$dial_string .= ",";
}
if (($presence_id = extension_presence_id($row["follow_me_destination"])) !== false) {
$variables[] = "presence_id=".$presence_id."@".$_SESSION['domain_name'];
$variables[] = "presence_id=".$presence_id."@".$this->domain_name;
if ($row["follow_me_prompt"] == "1") {
$variables[] = "group_confirm_key=exec";
$variables[] = "group_confirm_file=lua confirm.lua";
@ -335,23 +339,23 @@ include "root.php";
$variables[] = "instant_ringback=true";
$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[] = "domain_uuid=".$this->domain_uuid;
$variables[] = "sip_invite_domain=".$this->domain_name;
$variables[] = "domain_name=".$this->domain_name;
$variables[] = "domain=".$this->domain_name;
$variables[] = "extension_uuid=".$this->extension_uuid;
$variables[] = "leg_delay_start=".$row["follow_me_delay"];
$variables[] = "originate_delay_start=".$row["follow_me_delay"];
$variables[] = "leg_timeout=".$row["follow_me_timeout"];
$dial_string .= "[".implode(",", $variables)."]\${sofia_contact(".$row["follow_me_destination"]."@".$_SESSION['domain_name'].")}";
//$dial_string .= "[".implode(",", $variables)."]user/".$row["follow_me_destination"]."@".$_SESSION['domain_name'];
//$dial_string .= "loopback/export:".implode("\,export:", $variables)."\,transfer:".$row["follow_me_destination"]."/".$_SESSION['domain_name']."/inline";
$dial_string .= "[".implode(",", $variables)."]\${sofia_contact(".$row["follow_me_destination"]."@".$this->domain_name.")}";
//$dial_string .= "[".implode(",", $variables)."]user/".$row["follow_me_destination"]."@".$this->domain_name;
//$dial_string .= "loopback/export:".implode("\,export:", $variables)."\,transfer:".$row["follow_me_destination"]."/".$this->domain_name."/inline";
unset($variables);
}
else {
$presence_id = extension_presence_id($this->extension, $this->number_alias);
$variables[] = "presence_id=".$presence_id."@".$_SESSION['domain_name'];
$variables[] = "presence_id=".$presence_id."@".$this->domain_name;
/*
//set the caller id
@ -410,10 +414,10 @@ include "root.php";
$variables[] = "instant_ringback=true";
$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[] = "domain_uuid=".$this->domain_uuid;
$variables[] = "sip_invite_domain=".$this->domain_name;
$variables[] = "domain_name=".$this->domain_name;
$variables[] = "domain=".$this->domain_name;
$variables[] = "extension_uuid=".$this->extension_uuid;
$variables[] = "leg_delay_start=".$row["follow_me_delay"];
$variables[] = "originate_delay_start=".$row["follow_me_delay"];
@ -423,19 +427,19 @@ include "root.php";
if (is_numeric($row["follow_me_destination"])) {
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 ($this->domain_uuid, $row["follow_me_destination"]);
$dial_string .= "[".implode(",", $variables)."]".$bridge[0];
}
elseif ($_SESSION['domain']['bridge']['text'] == "loopback") {
//$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";
//$dial_string .= "loopback/".$row["follow_me_destination"]."/".$this->domain_name;
$dial_string .= "loopback/export:".implode("\,export:", $variables)."\,transfer:".$row["follow_me_destination"]."/".$this->domain_name."/inline";
}
elseif ($_SESSION['domain']['bridge']['text'] == "lcr") {
$dial_string .= "[".implode(",", $variables)."]lcr/".$_SESSION['lcr']['profile']['text']."/".$_SESSION['domain_name']."/".$row["follow_me_destination"];
$dial_string .= "[".implode(",", $variables)."]lcr/".$_SESSION['lcr']['profile']['text']."/".$this->domain_name."/".$row["follow_me_destination"];
}
else {
//$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";
//$dial_string .= "loopback/".$row["follow_me_destination"]."/".$this->domain_name;
$dial_string .= "loopback/export:".implode("\,export:", $variables)."\,transfer:".$row["follow_me_destination"]."/".$this->domain_name."/inline";
}
}
else {
@ -465,7 +469,7 @@ include "root.php";
}
$sql = "update v_extensions set ";
$sql .= "dial_domain = '".$_SESSION['domain_name']."', ";
$sql .= "dial_domain = '".$this->domain_name."', ";
$sql .= "dial_string = '".$dial_string."', ";
$sql .= "follow_me_destinations = '".$dial_string."', ";
$sql .= "follow_me_enabled = '".$this->follow_me_enabled."' ";