mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Update call forward to use the dial string. Make call forward, dnd and follow me work better together.
This commit is contained in:
@@ -213,10 +213,11 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
if (permission_exists('call_forward')) {
|
||||
$call_forward = new call_forward;
|
||||
$call_forward->domain_uuid = $_SESSION['domain_uuid'];
|
||||
$call_forward->domain_name = $_SESSION['domain_name'];
|
||||
$call_forward->extension_uuid = $extension_uuid;
|
||||
$call_forward->forward_all_destination = $forward_all_destination;
|
||||
$call_forward->forward_all_enabled = $forward_all_enabled;
|
||||
$call_forward->update();
|
||||
$call_forward->set();
|
||||
unset($call_forward);
|
||||
}
|
||||
|
||||
@@ -224,6 +225,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
if (permission_exists('follow_me')) {
|
||||
$follow_me = new follow_me;
|
||||
$follow_me->domain_uuid = $_SESSION['domain_uuid'];
|
||||
$follow_me->domain_name = $_SESSION['domain_name'];
|
||||
$follow_me->extension_uuid = $extension_uuid;
|
||||
$follow_me->db_type = $db_type;
|
||||
$follow_me->follow_me_enabled = $follow_me_enabled;
|
||||
|
||||
@@ -270,8 +273,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
}
|
||||
if ($follow_me_action == "update") {
|
||||
$follow_me->follow_me_uuid = $follow_me_uuid;
|
||||
$follow_me->follow_me_update();
|
||||
$follow_me->set();
|
||||
$follow_me->follow_me_update();
|
||||
}
|
||||
unset($follow_me);
|
||||
}
|
||||
@@ -281,7 +284,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
$dnd = new do_not_disturb;
|
||||
$dnd->domain_uuid = $_SESSION['domain_uuid'];
|
||||
$dnd->domain_name = $_SESSION['domain_name'];
|
||||
$dnd->extension = $extension;
|
||||
$dnd->extension_uuid = $extension_uuid;
|
||||
$dnd->enabled = $dnd_enabled;
|
||||
$dnd->set();
|
||||
$dnd->user_status();
|
||||
@@ -417,7 +420,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
echo "</tr>\n";
|
||||
echo "<tr>\n";
|
||||
echo "<td align='left' colspan='2'>\n";
|
||||
echo " ".$text['description']." $extension.<br /><br />\n";
|
||||
echo " ".$text['description']." $extension.<br /><br />\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
@@ -444,8 +447,6 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
}
|
||||
unset($on_click);
|
||||
echo "<br />\n";
|
||||
echo "<br />\n";
|
||||
//echo "Enable or disable call forward.\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
@@ -456,7 +457,6 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
echo " <input class='formfld' type='text' name='forward_all_destination' maxlength='255' value=\"$forward_all_destination\">\n";
|
||||
echo "<br />\n";
|
||||
//echo "Enter the call forward number.\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
@@ -472,7 +472,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
$on_click = "document.getElementById('forward_all_enabled').checked=true;";
|
||||
$on_click .= "document.getElementById('call_forward_disabled').checked=true;";
|
||||
$on_click .= "document.getElementById('forward_all_disabled').checked=true;";
|
||||
$on_click .= "document.getElementById('dnd_enabled').checked=false;";
|
||||
$on_click .= "document.getElementById('dnd_disabled').checked=true;";
|
||||
if ($follow_me_enabled == "true") {
|
||||
@@ -582,7 +582,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
$on_click = "document.getElementById('forward_all_enabled').checked=true;";
|
||||
$on_click .= "document.getElementById('call_forward_disabled').checked=true;";
|
||||
$on_click .= "document.getElementById('forward_all_disabled').checked=true;";
|
||||
$on_click .= "document.getElementById('follow_me_enabled').checked=true;";
|
||||
$on_click .= "document.getElementById('follow_me_disabled').checked=true;";
|
||||
if ($dnd_enabled == "true") {
|
||||
|
||||
@@ -27,22 +27,77 @@ include "root.php";
|
||||
|
||||
//define the call_forward class
|
||||
class call_forward {
|
||||
public $debug;
|
||||
public $domain_uuid;
|
||||
public $domain_name;
|
||||
public $extension_uuid;
|
||||
private $extension;
|
||||
public $forward_all_destination;
|
||||
public $forward_all_enabled;
|
||||
private $dial_string;
|
||||
private $dial_string_update = false;
|
||||
|
||||
public function update() {
|
||||
global $db;
|
||||
$sql = "update v_extensions set ";
|
||||
$sql .= "forward_all_destination = '$this->forward_all_destination', ";
|
||||
$sql .= "forward_all_enabled = '$this->forward_all_enabled' ";
|
||||
$sql .= "where domain_uuid = '$this->domain_uuid' ";
|
||||
$sql .= "and extension_uuid = '$this->extension_uuid' ";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
} //end function
|
||||
public function set() {
|
||||
//set the global variable
|
||||
global $db;
|
||||
|
||||
}
|
||||
//set the dial string
|
||||
if ($this->forward_all_enabled == "true") {
|
||||
$this->dial_string = "loopback/".$this->forward_all_destination;
|
||||
}
|
||||
else {
|
||||
$this->dial_string = '';
|
||||
}
|
||||
|
||||
//determine whether to update the dial string
|
||||
$sql = "select * from v_extensions ";
|
||||
$sql .= "where domain_uuid = '".$this->domain_uuid."' ";
|
||||
$sql .= "and extension_uuid = '".$this->extension_uuid."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as &$row) {
|
||||
$this->extension = $row["extension"];
|
||||
if ($this->forward_all_enabled == "false" && $row["forward_all_enabled"] == "true") {
|
||||
$this->dial_string_update = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset ($prep_statement);
|
||||
if ($this->forward_all_enabled == "true") {
|
||||
$this->dial_string_update = true;
|
||||
}
|
||||
|
||||
//update the extension
|
||||
$sql = "update v_extensions set ";
|
||||
$sql .= "forward_all_destination = '$this->forward_all_destination', ";
|
||||
if ($this->dial_string_update) {
|
||||
$sql .= "dial_string = '".$this->dial_string."', ";
|
||||
}
|
||||
$sql .= "forward_all_enabled = '$this->forward_all_enabled' ";
|
||||
$sql .= "where domain_uuid = '$this->domain_uuid' ";
|
||||
$sql .= "and extension_uuid = '$this->extension_uuid' ";
|
||||
if ($this->debug) {
|
||||
echo $sql;
|
||||
}
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
|
||||
//delete extension from memcache
|
||||
if ($this->dial_string_update) {
|
||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||
if ($fp) {
|
||||
$switch_cmd .= "memcache delete ".$this->extension."@".$this->domain_name;
|
||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||
}
|
||||
}
|
||||
|
||||
//syncrhonize configuration
|
||||
if ($this->dial_string_update) {
|
||||
save_extension_xml();
|
||||
}
|
||||
} //function
|
||||
} //class
|
||||
|
||||
?>
|
||||
@@ -27,60 +27,103 @@ include "root.php";
|
||||
|
||||
//define the dnd class
|
||||
class do_not_disturb {
|
||||
public $debug;
|
||||
public $domain_uuid;
|
||||
public $domain_name;
|
||||
public $extension;
|
||||
public $extension_uuid;
|
||||
private $extension;
|
||||
public $enabled;
|
||||
private $dial_string;
|
||||
private $dial_string_update = false;
|
||||
|
||||
//update the user_status
|
||||
public function user_status() {
|
||||
global $db;
|
||||
if ($this->enabled == "true") {
|
||||
//update the call center status
|
||||
$user_status = "Logged Out";
|
||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||
if ($fp) {
|
||||
$switch_cmd .= "callcenter_config agent set status ".$_SESSION['username']."@".$this->domain_name." '".$user_status."'";
|
||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||
}
|
||||
//set the global variable
|
||||
global $db;
|
||||
|
||||
//update the database user_status
|
||||
$user_status = "Do Not Disturb";
|
||||
$sql = "update v_users set ";
|
||||
$sql .= "user_status = '$user_status' ";
|
||||
$sql .= "where domain_uuid = '".$this->domain_uuid."' ";
|
||||
$sql .= "and username = '".$_SESSION['username']."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
}
|
||||
//update the status
|
||||
if ($this->enabled == "true") {
|
||||
//update the call center status
|
||||
$user_status = "Logged Out";
|
||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||
if ($fp) {
|
||||
$switch_cmd .= "callcenter_config agent set status ".$_SESSION['username']."@".$this->domain_name." '".$user_status."'";
|
||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||
}
|
||||
|
||||
//update the database user_status
|
||||
$user_status = "Do Not Disturb";
|
||||
$sql = "update v_users set ";
|
||||
$sql .= "user_status = '$user_status' ";
|
||||
$sql .= "where domain_uuid = '".$this->domain_uuid."' ";
|
||||
$sql .= "and username = '".$_SESSION['username']."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
}
|
||||
}
|
||||
|
||||
public function set() {
|
||||
global $db;
|
||||
//update the extension
|
||||
//set the global variable
|
||||
global $db;
|
||||
|
||||
//determine whether to update the dial string
|
||||
$sql = "select * from v_extensions ";
|
||||
$sql .= "where domain_uuid = '".$this->domain_uuid."' ";
|
||||
$sql .= "and extension_uuid = '".$this->extension_uuid."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as &$row) {
|
||||
$this->extension = $row["extension"];
|
||||
if ($this->enabled == "false" && $row["do_not_disturb"] == "true") {
|
||||
$this->dial_string_update = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset ($prep_statement);
|
||||
if ($this->enabled == "true") {
|
||||
$this->dial_string_update = true;
|
||||
}
|
||||
|
||||
//set the dial string
|
||||
if ($this->enabled == "true") {
|
||||
$this->dial_string = "loopback/*99".$this->extension;
|
||||
}
|
||||
else {
|
||||
$this->dial_string = "";
|
||||
$this->dial_string = '';
|
||||
}
|
||||
|
||||
//update the extension
|
||||
$sql = "update v_extensions set ";
|
||||
$sql .= "do_not_disturb = '".$this->enabled."', ";
|
||||
// $sql .= "dial_string = '".$this->dial_string."', ";
|
||||
$sql .= "dial_domain = '".$this->domain_name."' ";
|
||||
if ($this->dial_string_update) {
|
||||
$sql .= "dial_string = '".$this->dial_string."', ";
|
||||
}
|
||||
//$sql .= "dial_domain = '".$this->domain_name."', ";
|
||||
$sql .= "do_not_disturb = '".$this->enabled."' ";
|
||||
$sql .= "where domain_uuid = '".$this->domain_uuid."' ";
|
||||
$sql .= "and extension = '".$this->extension."' ";
|
||||
$sql .= "and extension_uuid = '".$this->extension_uuid."' ";
|
||||
if ($this->debug) {
|
||||
echo $sql."<br />";
|
||||
}
|
||||
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
|
||||
//syncrhonize configuration
|
||||
save_extension_xml();
|
||||
} //function
|
||||
//delete extension from memcache
|
||||
if ($this->dial_string_update) {
|
||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||
if ($fp) {
|
||||
$switch_cmd .= "memcache delete ".$this->extension."@".$this->domain_name;
|
||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||
}
|
||||
}
|
||||
|
||||
//syncrhonize configuration
|
||||
if ($this->dial_string_update) {
|
||||
save_extension_xml();
|
||||
}
|
||||
} //function
|
||||
} //class
|
||||
|
||||
?>
|
||||
@@ -31,6 +31,8 @@ include "root.php";
|
||||
public $db_type;
|
||||
public $follow_me_uuid;
|
||||
public $follow_me_enabled;
|
||||
private $extension;
|
||||
private $dial_string_update = false;
|
||||
|
||||
public $destination_data_1;
|
||||
public $destination_type_1;
|
||||
@@ -61,42 +63,46 @@ include "root.php";
|
||||
public $destination_order = 1;
|
||||
|
||||
public function follow_me_add() {
|
||||
global $db;
|
||||
//set the global variable
|
||||
global $db;
|
||||
|
||||
$sql = "insert into v_follow_me ";
|
||||
$sql .= "(";
|
||||
$sql .= "domain_uuid, ";
|
||||
$sql .= "follow_me_uuid, ";
|
||||
$sql .= "follow_me_enabled ";
|
||||
$sql .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'$this->domain_uuid', ";
|
||||
$sql .= "'$this->follow_me_uuid', ";
|
||||
$sql .= "'$this->follow_me_enabled' ";
|
||||
$sql .= ")";
|
||||
if ($v_debug) {
|
||||
echo $sql."<br />";
|
||||
}
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
$this->follow_me_destinations();
|
||||
//add a new follow me
|
||||
$sql = "insert into v_follow_me ";
|
||||
$sql .= "(";
|
||||
$sql .= "domain_uuid, ";
|
||||
$sql .= "follow_me_uuid, ";
|
||||
$sql .= "follow_me_enabled ";
|
||||
$sql .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'$this->domain_uuid', ";
|
||||
$sql .= "'$this->follow_me_uuid', ";
|
||||
$sql .= "'$this->follow_me_enabled' ";
|
||||
$sql .= ")";
|
||||
if ($v_debug) {
|
||||
echo $sql."<br />";
|
||||
}
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
$this->follow_me_destinations();
|
||||
} //end function
|
||||
|
||||
public function follow_me_update() {
|
||||
global $db;
|
||||
|
||||
$sql = "update follow_me set ";
|
||||
$sql .= "follow_me_enabled = '$this->follow_me_enabled' ";
|
||||
$sql .= "where domain_uuid = '$this->domain_uuid' ";
|
||||
$sql .= "and follow_me_uuid = '$this->follow_me_uuid' ";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
$this->follow_me_destinations();
|
||||
//set the global variable
|
||||
global $db;
|
||||
//update follow me table
|
||||
$sql = "update v_follow_me set ";
|
||||
$sql .= "follow_me_enabled = '$this->follow_me_enabled' ";
|
||||
$sql .= "where domain_uuid = '$this->domain_uuid' ";
|
||||
$sql .= "and follow_me_uuid = '$this->follow_me_uuid' ";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
$this->follow_me_destinations();
|
||||
} //end function
|
||||
|
||||
public function follow_me_destinations() {
|
||||
global $db;
|
||||
//set the global variable
|
||||
global $db;
|
||||
|
||||
//delete related follow me destinations
|
||||
$sql = "delete from v_follow_me_destinations where follow_me_uuid = '$this->follow_me_uuid' ";
|
||||
@@ -231,11 +237,45 @@ include "root.php";
|
||||
} //function
|
||||
|
||||
public function set() {
|
||||
global $db;
|
||||
//set the global variable
|
||||
global $db;
|
||||
|
||||
//determine whether to update the dial string
|
||||
$sql = "select * from v_extensions ";
|
||||
$sql .= "where domain_uuid = '".$this->domain_uuid."' ";
|
||||
$sql .= "and extension_uuid = '".$this->extension_uuid."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as &$row) {
|
||||
$this->extension = $row["extension"];
|
||||
}
|
||||
}
|
||||
|
||||
//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."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as &$row) {
|
||||
if ($this->follow_me_enabled == "false" && $row["follow_me_enabled"] == "true") {
|
||||
$this->dial_string_update = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset ($prep_statement);
|
||||
if ($this->follow_me_enabled == "true") {
|
||||
$this->dial_string_update = true;
|
||||
}
|
||||
|
||||
//update the extension
|
||||
if ($this->follow_me_enabled == "true") {
|
||||
$sql = "select * from v_follow_me_destinations ";
|
||||
$sql .= "where follow_me_uuid = '$this->follow_me_uuid' ";
|
||||
$sql .= "where follow_me_uuid = '".$this->follow_me_uuid."' ";
|
||||
$sql .= "order by follow_me_order asc ";
|
||||
$prep_statement_2 = $db->prepare(check_sql($sql));
|
||||
$prep_statement_2->execute();
|
||||
@@ -255,11 +295,12 @@ include "root.php";
|
||||
$this->dial_string = trim($dial_string, ",");
|
||||
}
|
||||
else {
|
||||
// $this->dial_string = "";
|
||||
$this->dial_string = '';
|
||||
}
|
||||
$sql = "update v_extensions set ";
|
||||
$sql .= "do_not_disturb = 'false', ";
|
||||
$sql .= "dial_string = '".$this->dial_string."', ";
|
||||
if ($this->dial_string_update) {
|
||||
$sql .= "dial_string = '".$this->dial_string."', ";
|
||||
}
|
||||
$sql .= "dial_domain = '".$_SESSION['domain_name']."' ";
|
||||
$sql .= "where domain_uuid = '".$this->domain_uuid."' ";
|
||||
$sql .= "and follow_me_uuid = '".$this->follow_me_uuid."' ";
|
||||
@@ -269,8 +310,19 @@ include "root.php";
|
||||
$db->exec($sql);
|
||||
unset($sql);
|
||||
|
||||
//delete extension from memcache
|
||||
if ($this->dial_string_update) {
|
||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||
if ($fp) {
|
||||
$switch_cmd .= "memcache delete ".$this->extension."@".$this->domain_name;
|
||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||
}
|
||||
}
|
||||
|
||||
//syncrhonize configuration
|
||||
save_extension_xml();
|
||||
if ($this->dial_string_update) {
|
||||
save_extension_xml();
|
||||
}
|
||||
}
|
||||
|
||||
} //class
|
||||
|
||||
Reference in New Issue
Block a user