Update call forward to use the dial string. Make call forward, dnd and follow me work better together.

This commit is contained in:
Mark Crane
2012-12-17 21:30:49 +00:00
parent 16517b8214
commit ddf9a5a70f
4 changed files with 234 additions and 84 deletions
+9 -9
View File
@@ -213,10 +213,11 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
if (permission_exists('call_forward')) { if (permission_exists('call_forward')) {
$call_forward = new call_forward; $call_forward = new call_forward;
$call_forward->domain_uuid = $_SESSION['domain_uuid']; $call_forward->domain_uuid = $_SESSION['domain_uuid'];
$call_forward->domain_name = $_SESSION['domain_name'];
$call_forward->extension_uuid = $extension_uuid; $call_forward->extension_uuid = $extension_uuid;
$call_forward->forward_all_destination = $forward_all_destination; $call_forward->forward_all_destination = $forward_all_destination;
$call_forward->forward_all_enabled = $forward_all_enabled; $call_forward->forward_all_enabled = $forward_all_enabled;
$call_forward->update(); $call_forward->set();
unset($call_forward); unset($call_forward);
} }
@@ -224,6 +225,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
if (permission_exists('follow_me')) { if (permission_exists('follow_me')) {
$follow_me = new follow_me; $follow_me = new follow_me;
$follow_me->domain_uuid = $_SESSION['domain_uuid']; $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->db_type = $db_type;
$follow_me->follow_me_enabled = $follow_me_enabled; $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") { if ($follow_me_action == "update") {
$follow_me->follow_me_uuid = $follow_me_uuid; $follow_me->follow_me_uuid = $follow_me_uuid;
$follow_me->follow_me_update();
$follow_me->set(); $follow_me->set();
$follow_me->follow_me_update();
} }
unset($follow_me); unset($follow_me);
} }
@@ -281,7 +284,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$dnd = new do_not_disturb; $dnd = new do_not_disturb;
$dnd->domain_uuid = $_SESSION['domain_uuid']; $dnd->domain_uuid = $_SESSION['domain_uuid'];
$dnd->domain_name = $_SESSION['domain_name']; $dnd->domain_name = $_SESSION['domain_name'];
$dnd->extension = $extension; $dnd->extension_uuid = $extension_uuid;
$dnd->enabled = $dnd_enabled; $dnd->enabled = $dnd_enabled;
$dnd->set(); $dnd->set();
$dnd->user_status(); $dnd->user_status();
@@ -417,7 +420,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td align='left' colspan='2'>\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 "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
@@ -444,8 +447,6 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
} }
unset($on_click); unset($on_click);
echo "<br />\n"; echo "<br />\n";
echo "<br />\n";
//echo "Enable or disable call forward.\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
@@ -456,7 +457,6 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<td class='vtable' align='left'>\n"; 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 " <input class='formfld' type='text' name='forward_all_destination' maxlength='255' value=\"$forward_all_destination\">\n";
echo "<br />\n"; echo "<br />\n";
//echo "Enter the call forward number.\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
@@ -472,7 +472,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
$on_click = "document.getElementById('forward_all_enabled').checked=true;"; $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_enabled').checked=false;";
$on_click .= "document.getElementById('dnd_disabled').checked=true;"; $on_click .= "document.getElementById('dnd_disabled').checked=true;";
if ($follow_me_enabled == "true") { if ($follow_me_enabled == "true") {
@@ -582,7 +582,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
$on_click = "document.getElementById('forward_all_enabled').checked=true;"; $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_enabled').checked=true;";
$on_click .= "document.getElementById('follow_me_disabled').checked=true;"; $on_click .= "document.getElementById('follow_me_disabled').checked=true;";
if ($dnd_enabled == "true") { if ($dnd_enabled == "true") {
@@ -27,22 +27,77 @@ include "root.php";
//define the call_forward class //define the call_forward class
class call_forward { class call_forward {
public $debug;
public $domain_uuid; public $domain_uuid;
public $domain_name;
public $extension_uuid; public $extension_uuid;
private $extension;
public $forward_all_destination; public $forward_all_destination;
public $forward_all_enabled; public $forward_all_enabled;
private $dial_string;
private $dial_string_update = false;
public function update() { public function set() {
global $db; //set the global variable
$sql = "update v_extensions set "; global $db;
$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
} //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 //define the dnd class
class do_not_disturb { class do_not_disturb {
public $debug;
public $domain_uuid; public $domain_uuid;
public $domain_name; public $domain_name;
public $extension; public $extension_uuid;
private $extension;
public $enabled; public $enabled;
private $dial_string; private $dial_string;
private $dial_string_update = false;
//update the user_status //update the user_status
public function user_status() { public function user_status() {
global $db; //set the global variable
if ($this->enabled == "true") { global $db;
//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 //update the status
$user_status = "Do Not Disturb"; if ($this->enabled == "true") {
$sql = "update v_users set "; //update the call center status
$sql .= "user_status = '$user_status' "; $user_status = "Logged Out";
$sql .= "where domain_uuid = '".$this->domain_uuid."' "; $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
$sql .= "and username = '".$_SESSION['username']."' "; if ($fp) {
$prep_statement = $db->prepare(check_sql($sql)); $switch_cmd .= "callcenter_config agent set status ".$_SESSION['username']."@".$this->domain_name." '".$user_status."'";
$prep_statement->execute(); $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() { public function set() {
global $db; //set the global variable
//update the extension 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") { if ($this->enabled == "true") {
$this->dial_string = "loopback/*99".$this->extension; $this->dial_string = "loopback/*99".$this->extension;
} }
else { else {
$this->dial_string = ""; $this->dial_string = '';
} }
//update the extension
$sql = "update v_extensions set "; $sql = "update v_extensions set ";
$sql .= "do_not_disturb = '".$this->enabled."', "; if ($this->dial_string_update) {
// $sql .= "dial_string = '".$this->dial_string."', "; $sql .= "dial_string = '".$this->dial_string."', ";
$sql .= "dial_domain = '".$this->domain_name."' "; }
//$sql .= "dial_domain = '".$this->domain_name."', ";
$sql .= "do_not_disturb = '".$this->enabled."' ";
$sql .= "where domain_uuid = '".$this->domain_uuid."' "; $sql .= "where domain_uuid = '".$this->domain_uuid."' ";
$sql .= "and extension = '".$this->extension."' "; $sql .= "and extension_uuid = '".$this->extension_uuid."' ";
if ($this->debug) { if ($this->debug) {
echo $sql."<br />"; echo $sql."<br />";
} }
$db->exec(check_sql($sql)); $db->exec(check_sql($sql));
unset($sql); unset($sql);
//syncrhonize configuration //delete extension from memcache
save_extension_xml(); if ($this->dial_string_update) {
} //function $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 } //class
?> ?>
@@ -31,6 +31,8 @@ include "root.php";
public $db_type; public $db_type;
public $follow_me_uuid; public $follow_me_uuid;
public $follow_me_enabled; public $follow_me_enabled;
private $extension;
private $dial_string_update = false;
public $destination_data_1; public $destination_data_1;
public $destination_type_1; public $destination_type_1;
@@ -61,42 +63,46 @@ include "root.php";
public $destination_order = 1; public $destination_order = 1;
public function follow_me_add() { public function follow_me_add() {
global $db; //set the global variable
global $db;
$sql = "insert into v_follow_me "; //add a new follow me
$sql .= "("; $sql = "insert into v_follow_me ";
$sql .= "domain_uuid, "; $sql .= "(";
$sql .= "follow_me_uuid, "; $sql .= "domain_uuid, ";
$sql .= "follow_me_enabled "; $sql .= "follow_me_uuid, ";
$sql .= ")"; $sql .= "follow_me_enabled ";
$sql .= "values "; $sql .= ")";
$sql .= "("; $sql .= "values ";
$sql .= "'$this->domain_uuid', "; $sql .= "(";
$sql .= "'$this->follow_me_uuid', "; $sql .= "'$this->domain_uuid', ";
$sql .= "'$this->follow_me_enabled' "; $sql .= "'$this->follow_me_uuid', ";
$sql .= ")"; $sql .= "'$this->follow_me_enabled' ";
if ($v_debug) { $sql .= ")";
echo $sql."<br />"; if ($v_debug) {
} echo $sql."<br />";
$db->exec(check_sql($sql)); }
unset($sql); $db->exec(check_sql($sql));
$this->follow_me_destinations(); unset($sql);
$this->follow_me_destinations();
} //end function } //end function
public function follow_me_update() { public function follow_me_update() {
global $db; //set the global variable
global $db;
$sql = "update follow_me set "; //update follow me table
$sql .= "follow_me_enabled = '$this->follow_me_enabled' "; $sql = "update v_follow_me set ";
$sql .= "where domain_uuid = '$this->domain_uuid' "; $sql .= "follow_me_enabled = '$this->follow_me_enabled' ";
$sql .= "and follow_me_uuid = '$this->follow_me_uuid' "; $sql .= "where domain_uuid = '$this->domain_uuid' ";
$db->exec(check_sql($sql)); $sql .= "and follow_me_uuid = '$this->follow_me_uuid' ";
unset($sql); $db->exec(check_sql($sql));
$this->follow_me_destinations(); unset($sql);
$this->follow_me_destinations();
} //end function } //end function
public function follow_me_destinations() { public function follow_me_destinations() {
global $db; //set the global variable
global $db;
//delete related follow me destinations //delete related follow me destinations
$sql = "delete from v_follow_me_destinations where follow_me_uuid = '$this->follow_me_uuid' "; $sql = "delete from v_follow_me_destinations where follow_me_uuid = '$this->follow_me_uuid' ";
@@ -231,11 +237,45 @@ include "root.php";
} //function } //function
public function set() { 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 //update the extension
if ($this->follow_me_enabled == "true") { if ($this->follow_me_enabled == "true") {
$sql = "select * from v_follow_me_destinations "; $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 "; $sql .= "order by follow_me_order asc ";
$prep_statement_2 = $db->prepare(check_sql($sql)); $prep_statement_2 = $db->prepare(check_sql($sql));
$prep_statement_2->execute(); $prep_statement_2->execute();
@@ -255,11 +295,12 @@ include "root.php";
$this->dial_string = trim($dial_string, ","); $this->dial_string = trim($dial_string, ",");
} }
else { else {
// $this->dial_string = ""; $this->dial_string = '';
} }
$sql = "update v_extensions set "; $sql = "update v_extensions set ";
$sql .= "do_not_disturb = 'false', "; if ($this->dial_string_update) {
$sql .= "dial_string = '".$this->dial_string."', "; $sql .= "dial_string = '".$this->dial_string."', ";
}
$sql .= "dial_domain = '".$_SESSION['domain_name']."' "; $sql .= "dial_domain = '".$_SESSION['domain_name']."' ";
$sql .= "where domain_uuid = '".$this->domain_uuid."' "; $sql .= "where domain_uuid = '".$this->domain_uuid."' ";
$sql .= "and follow_me_uuid = '".$this->follow_me_uuid."' "; $sql .= "and follow_me_uuid = '".$this->follow_me_uuid."' ";
@@ -269,8 +310,19 @@ include "root.php";
$db->exec($sql); $db->exec($sql);
unset($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 //syncrhonize configuration
save_extension_xml(); if ($this->dial_string_update) {
save_extension_xml();
}
} }
} //class } //class