From 95f2b6d100643a630b3e92f702cd71bddc364036 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Wed, 21 Nov 2012 05:59:07 +0000 Subject: [PATCH] Add the new follow me. Needs a little more refinement. --- app/calls/app_languages.php | 9 + app/calls/v_call_edit.php | 376 +++++++-------------- app/follow_me/app_config.php | 120 +++++++ app/follow_me/root.php | 50 +++ includes/classes/switch_do_not_disturb.php | 2 +- includes/classes/switch_follow_me.php | 270 ++++++--------- 6 files changed, 398 insertions(+), 429 deletions(-) create mode 100644 app/follow_me/app_config.php create mode 100644 app/follow_me/root.php diff --git a/app/calls/app_languages.php b/app/calls/app_languages.php index 441a67f58a..4024194de2 100644 --- a/app/calls/app_languages.php +++ b/app/calls/app_languages.php @@ -21,6 +21,9 @@ $text['label-enable']['en-us'] = 'Enable'; $text['label-enable']['pt-pt'] = 'Activar'; + $text['label-disable']['en-us'] = 'Disable'; + $text['label-disable']['pt-pt'] = 'Desactivo'; + $text['label-disabled']['en-us'] = 'Disabled'; $text['label-disabled']['pt-pt'] = 'Desactivo'; @@ -48,6 +51,12 @@ $text['label-ring-order']['en-us'] = 'Ring Order'; $text['label-ring-order']['pt-pt'] = 'Pedir Chamada'; + $text['label-ring-delay']['en-us'] = 'Delay'; + $text['label-ring-delay']['pt-pt'] = ''; + + $text['label-ring-timeout']['en-us'] = 'Timeout'; + $text['label-ring-timeout']['pt-pt'] = ''; + $text['check-sequence']['en-us'] = 'sequence'; $text['ckeck-sequence']['pt-pt'] = 'sequĂȘncial'; diff --git a/app/calls/v_call_edit.php b/app/calls/v_call_edit.php index ad3131222c..e61c5980d4 100644 --- a/app/calls/v_call_edit.php +++ b/app/calls/v_call_edit.php @@ -46,15 +46,15 @@ else { echo " \n"; } @@ -100,7 +100,7 @@ else { $do_not_disturb = $row["do_not_disturb"]; $call_forward_all = $row["call_forward_all"]; $call_forward_busy = $row["call_forward_busy"]; - $description = $row["description"]; + $follow_me_uuid = $row["follow_me_uuid"]; break; //limit to 1 row } if (strlen($do_not_disturb) == 0) { @@ -116,21 +116,28 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $call_forward_enabled = check_str($_POST["call_forward_enabled"]); $call_forward_number = check_str($_POST["call_forward_number"]); $follow_me_enabled = check_str($_POST["follow_me_enabled"]); - $follow_me_type = check_str($_POST["follow_me_type"]); - $destination_data_1 = check_str($_POST["destination_data_1"]); - $destination_timeout_1 = check_str($_POST["destination_timeout_1"]); - $destination_data_2 = check_str($_POST["destination_data_2"]); - $destination_timeout_2 = check_str($_POST["destination_timeout_2"]); - $destination_data_3 = check_str($_POST["destination_data_3"]); - $destination_timeout_3 = check_str($_POST["destination_timeout_3"]); - $destination_data_4 = check_str($_POST["destination_data_4"]); - $destination_timeout_4 = check_str($_POST["destination_timeout_4"]); - $destination_data_5 = check_str($_POST["destination_data_5"]); - $destination_timeout_5 = check_str($_POST["destination_timeout_5"]); - $dnd_enabled = check_str($_POST["dnd_enabled"]); - $hunt_group_call_prompt = check_str($_POST["hunt_group_call_prompt"]); - if (strlen($follow_me_type) == 0) { $follow_me_type = "follow_me_sequence"; } + $destination_data_1 = check_str($_POST["destination_data_1"]); + $destination_delay_1 = check_str($_POST["destination_delay_1"]); + $destination_timeout_1 = check_str($_POST["destination_timeout_1"]); + + $destination_data_2 = check_str($_POST["destination_data_2"]); + $destination_delay_2 = check_str($_POST["destination_delay_2"]); + $destination_timeout_2 = check_str($_POST["destination_timeout_2"]); + + $destination_data_3 = check_str($_POST["destination_data_3"]); + $destination_delay_3 = check_str($_POST["destination_delay_3"]); + $destination_timeout_3 = check_str($_POST["destination_timeout_3"]); + + $destination_data_4 = check_str($_POST["destination_data_4"]); + $destination_delay_4 = check_str($_POST["destination_delay_4"]); + $destination_timeout_4 = check_str($_POST["destination_timeout_4"]); + + $destination_data_5 = check_str($_POST["destination_data_5"]); + $destination_delay_5 = check_str($_POST["destination_delay_5"]); + $destination_timeout_5 = check_str($_POST["destination_timeout_5"]); + + $dnd_enabled = check_str($_POST["dnd_enabled"]); if (strlen($call_forward_number) > 0) { $call_forward_number = preg_replace("~[^0-9]~", "",$call_forward_number); @@ -150,49 +157,6 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { if (strlen($destination_data_5) > 0) { $destination_data_5 = preg_replace("~[^0-9]~", "",$destination_data_5); } - - //set the default - if (strlen($hunt_group_call_prompt) == 0) { - $hunt_group_call_prompt = 'false'; - } - - //destination_1 - if (strlen($destination_data_1) > 0) { - if (extension_exists($destination_data_1)) { - $destination_type_1 = 'extension'; - } - else { - $destination_type_1 = 'sip uri'; - } - } - //destination_2 - if (extension_exists($destination_data_2)) { - $destination_type_2 = 'extension'; - } - else { - $destination_type_2 = 'sip uri'; - } - //destination_3 - if (extension_exists($destination_data_3)) { - $destination_type_3 = 'extension'; - } - else { - $destination_type_3 = 'sip uri'; - } - //destination_4 - if (extension_exists($destination_data_4)) { - $destination_type_4 = 'extension'; - } - else { - $destination_type_4 = 'sip uri'; - } - //destination_5 - if (extension_exists($destination_data_5)) { - $destination_type_5 = 'extension'; - } - else { - $destination_type_5 = 'sip uri'; - } } //check for all required data @@ -229,68 +193,14 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { //set the default action to add $call_forward_action = "add"; - $follow_me_action = "add"; - //get the hunt group timeout - //add the destination timeouts together to create the hunt group timeout - if ($follow_me_type == "follow_me_sequence") { - if (strlen($destination_data_1) > 0) { - $hunt_group_timeout = $destination_timeout_1; - } - if (strlen($destination_data_2) > 0) { - $hunt_group_timeout = $hunt_group_timeout + $destination_timeout_2; - } - if (strlen($destination_data_3) > 0) { - $hunt_group_timeout = $hunt_group_timeout + $destination_timeout_3; - } - if (strlen($destination_data_4) > 0) { - $hunt_group_timeout = $hunt_group_timeout + $destination_timeout_4; - } - if (strlen($destination_data_5) > 0) { - $hunt_group_timeout = $hunt_group_timeout + $destination_timeout_5; - } - } - //find the highest timeout and set that as the hunt_group_timeout - if ($follow_me_type == "follow_me_simultaneous") { - if (strlen($destination_data_1) > 0) { - $hunt_group_timeout = $destination_timeout_1; - } - if (strlen($destination_data_2) > 0 && $hunt_group_timeout < $destination_timeout_2) { - $hunt_group_timeout = $destination_timeout_2; - } - if (strlen($destination_data_3) > 0 && $hunt_group_timeout < $destination_timeout_3) { - $hunt_group_timeout = $destination_timeout_3; - } - if (strlen($destination_data_4) > 0 && $hunt_group_timeout < $destination_timeout_4) { - $hunt_group_timeout = $destination_timeout_4; - } - if (strlen($destination_data_5) > 0 && $hunt_group_timeout < $destination_timeout_5) { - $hunt_group_timeout = $destination_timeout_5; - } - } - - //hunt_group information used to determine if this is an add or an update - $sql = "select * from v_hunt_groups "; - $sql .= "where domain_uuid = '$domain_uuid' "; - $sql .= "and hunt_group_extension = '$extension' "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - foreach ($result as &$row) { - if ($row["hunt_group_type"] == 'call_forward') { - $call_forward_action = "update"; - $call_forward_uuid = $row["hunt_group_uuid"]; - } - if ($row["hunt_group_type"] == 'follow_me_sequence') { - $follow_me_action = "update"; - $follow_me_uuid = $row["hunt_group_uuid"]; - } - if ($row["hunt_group_type"] == 'follow_me_simultaneous') { - $follow_me_action = "update"; - $follow_me_uuid = $row["hunt_group_uuid"]; - } + //determine if this is an add or an update + if (strlen($follow_me_uuid) == 0) { + $follow_me_action = "add"; + } + else { + $follow_me_action = "update"; } - unset ($prep_statement); //include the classes include "includes/classes/switch_call_forward.php"; @@ -325,51 +235,61 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { } //follow me config + if (permission_exists('follow_me')) { $follow_me = new follow_me; $follow_me->domain_uuid = $_SESSION['domain_uuid']; $follow_me->db_type = $db_type; - $follow_me->extension = $extension; $follow_me->follow_me_enabled = $follow_me_enabled; - $follow_me->follow_me_type = $follow_me_type; - $follow_me->hunt_group_call_prompt = $hunt_group_call_prompt; - $follow_me->hunt_group_timeout = $hunt_group_timeout; $follow_me->destination_data_1 = $destination_data_1; $follow_me->destination_type_1 = $destination_type_1; + $follow_me->destination_delay_1 = $destination_delay_1; $follow_me->destination_timeout_1 = $destination_timeout_1; $follow_me->destination_data_2 = $destination_data_2; $follow_me->destination_type_2 = $destination_type_2; + $follow_me->destination_delay_2 = $destination_delay_2; $follow_me->destination_timeout_2 = $destination_timeout_2; $follow_me->destination_data_3 = $destination_data_3; $follow_me->destination_type_3 = $destination_type_3; + $follow_me->destination_delay_3 = $destination_delay_3; $follow_me->destination_timeout_3 = $destination_timeout_3; $follow_me->destination_data_4 = $destination_data_4; $follow_me->destination_type_4 = $destination_type_4; + $follow_me->destination_delay_4 = $destination_delay_4; $follow_me->destination_timeout_4 = $destination_timeout_4; $follow_me->destination_data_5 = $destination_data_5; $follow_me->destination_type_5 = $destination_type_5; + $follow_me->destination_delay_5 = $destination_delay_5; $follow_me->destination_timeout_5 = $destination_timeout_5; if ($follow_me_enabled == "true") { if ($follow_me_action == "add") { - $follow_me->follow_me_uuid = uuid(); + $follow_me_uuid = uuid(); + + $sql = "update v_extensions set "; + $sql .= "follow_me_uuid = '$follow_me_uuid' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and extension_uuid = '$extension_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + + $follow_me->follow_me_uuid = $follow_me_uuid; $follow_me->follow_me_add(); + $follow_me->set(); } } if ($follow_me_action == "update") { $follow_me->follow_me_uuid = $follow_me_uuid; $follow_me->follow_me_update(); + $follow_me->set(); } unset($follow_me); - //synchronize the xml config - save_hunt_group_xml(); - //synchronize the xml config save_dialplan_xml(); } @@ -401,82 +321,52 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { require_once "includes/header.php"; //pre-populate the form - $sql = "select * from v_hunt_groups "; - $sql .= "where hunt_group_extension = '$extension' "; - $sql .= "and domain_uuid = '$domain_uuid' "; + $sql = "select * from v_follow_me "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and follow_me_uuid = '$follow_me_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { - $hunt_group_uuid = $row["hunt_group_uuid"]; - $hunt_group_extension = $row["hunt_group_extension"]; - $huntgroup_name = $row["hunt_group_name"]; - $hunt_group_type = $row["hunt_group_type"]; - $hunt_group_context = $row["hunt_group_context"]; - $hunt_group_timeout = $row["hunt_group_timeout"]; - $hunt_group_timeout_destination = $row["hunt_group_timeout_destination"]; - $hunt_group_timeout_type = $row["hunt_group_timeout_type"]; - $hunt_group_ring_back = $row["hunt_group_ringback"]; - $hunt_group_cid_name_prefix = $row["hunt_group_cid_name_prefix"]; - $hunt_group_pin = $row["hunt_group_pin"]; - $hunt_group_call_prompt = $row["hunt_group_call_prompt"]; - $huntgroup_caller_announce = $row["hunt_group_caller_announce"]; - $hunt_group_user_list = $row["hunt_group_user_list"]; - $hunt_group_enabled = $row["hunt_group_enabled"]; - $hunt_group_description = $row["hunt_group_description"]; + $follow_me_enabled = $row["follow_me_enabled"]; - if ($row["hunt_group_type"] == 'call_forward') { - $call_forward_enabled = $hunt_group_enabled; - } - if ($row["hunt_group_type"] == 'follow_me_simultaneous') { - $follow_me_enabled = $hunt_group_enabled; - $follow_me_type = 'follow_me_simultaneous'; - } - if ($row["hunt_group_type"] == 'follow_me_sequence') { - $follow_me_enabled = $hunt_group_enabled; - $follow_me_type = 'follow_me_sequence'; - } - - if ($row["hunt_group_type"] == 'call_forward' || $row["hunt_group_type"] == 'follow_me_sequence' || $row["hunt_group_type"] == 'follow_me_simultaneous') { - $sql = "select * from v_hunt_group_destinations "; - $sql .= "where hunt_group_uuid = '$hunt_group_uuid' "; - $sql .= "order by destination_order asc "; - $prep_statement_2 = $db->prepare(check_sql($sql)); - $prep_statement_2->execute(); - $result2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED); - $x=1; - foreach ($result2 as &$row2) { - if ($row["hunt_group_type"] == 'call_forward') { - if (strlen($row2["destination_data"]) > 0) { - $call_forward_number = $row2["destination_data"]; - } - } - if ($row["hunt_group_type"] == 'follow_me_sequence' || $row["hunt_group_type"] == 'follow_me_simultaneous') { - if ($x == 1) { - $destination_data_1 = $row2["destination_data"]; - $destination_timeout_1 = $row2["destination_timeout"]; - } - if ($x == 2) { - $destination_data_2 = $row2["destination_data"]; - $destination_timeout_2 = $row2["destination_timeout"]; - } - if ($x == 3) { - $destination_data_3 = $row2["destination_data"]; - $destination_timeout_3 = $row2["destination_timeout"]; - } - if ($x == 4) { - $destination_data_4 = $row2["destination_data"]; - $destination_timeout_4 = $row2["destination_timeout"]; - } - if ($x == 5) { - $destination_data_5 = $row2["destination_data"]; - $destination_timeout_5 = $row2["destination_timeout"]; - } - $x++; - } + $sql = "select * from v_follow_me_destinations "; + $sql .= "where follow_me_uuid = '$follow_me_uuid' "; + $sql .= "order by follow_me_order asc "; + $prep_statement_2 = $db->prepare(check_sql($sql)); + $prep_statement_2->execute(); + $result2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED); + $x = 1; + foreach ($result2 as &$row2) { + //$call_forward_number = $row2["destination_data"]; + if ($x == 1) { + $destination_data_1 = $row2["follow_me_destination"]; + $destination_delay_1 = $row2["follow_me_delay"]; + $destination_timeout_1 = $row2["follow_me_timeout"]; } - unset ($prep_statement_2); + if ($x == 2) { + $destination_data_2 = $row2["follow_me_destination"]; + $destination_delay_2 = $row2["follow_me_delay"]; + $destination_timeout_2 = $row2["follow_me_timeout"]; + } + if ($x == 3) { + $destination_data_3 = $row2["follow_me_destination"]; + $destination_delay_3 = $row2["follow_me_delay"]; + $destination_timeout_3 = $row2["follow_me_timeout"]; + } + if ($x == 4) { + $destination_data_4 = $row2["follow_me_destination"]; + $destination_delay_4 = $row2["follow_me_delay"]; + $destination_timeout_4 = $row2["follow_me_timeout"]; + } + if ($x == 5) { + $destination_data_5 = $row2["follow_me_destination"]; + $destination_delay_5 = $row2["follow_me_delay"]; + $destination_timeout_5 = $row2["follow_me_timeout"]; + } + $x++; } + unset ($prep_statement_2); } unset ($prep_statement); @@ -496,7 +386,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "
\n"; echo "\n"; echo "\n"; - echo "\n"; echo "\n"; echo "\n"; - echo "\n"; echo "\n"; echo "\n"; - echo "\n"; echo "\n"; echo "\n"; - echo "\n"; echo "\n"; echo "\n"; - echo "\n"; echo "\n"; echo "\n"; - echo "\n"; echo "\n"; echo "\n"; - echo "\n"; echo "\n"; echo "\n"; - echo "\n"; echo "\n"; echo "\n"; - echo "\n"; echo "\n"; echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; echo "\n"; echo "\n"; - echo "\n"; echo "
\n"; + echo "\n"; echo " ".$text['title']."\n"; echo "\n"; @@ -510,7 +400,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "
\n"; + echo "\n"; echo " ".$text['label-call-forward'].":\n"; echo "\n"; @@ -538,7 +428,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "
\n"; + echo "\n"; echo " ".$text['label-number'].":\n"; echo "\n"; @@ -555,7 +445,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "
\n"; + echo "\n"; echo " ".$text['label-follow-me'].":\n"; echo "\n"; @@ -582,12 +472,14 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "
\n"; + echo "\n"; echo " ".$text['label-ring-1'].":\n"; echo "\n"; echo " \n"; - echo " Sec \n"; + echo " ".$text['label-ring-delay']."\n"; + destination_select('destination_delay_1', $destination_delay_1, '0'); + echo " ".$text['label-ring-timeout']."\n"; destination_select('destination_timeout_1', $destination_timeout_1, '10'); //echo "
\n"; //echo "This number rings first.\n"; @@ -595,12 +487,14 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "
\n"; + echo "\n"; echo " ".$text['label-ring-2'].":\n"; echo "\n"; echo " \n"; - echo " Sec \n"; + echo " ".$text['label-ring-delay']."\n"; + destination_select('destination_delay_2', $destination_delay_2, '0'); + echo " ".$text['label-ring-timeout']."\n"; destination_select('destination_timeout_2', $destination_timeout_2, '30'); //echo "
\n"; //echo "Enter the destination number.\n"; @@ -608,12 +502,14 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "
\n"; + echo "\n"; echo " ".$text['label-ring-3'].":\n"; echo "\n"; echo " \n"; - echo " Sec \n"; + echo " ".$text['label-ring-delay']."\n"; + destination_select('destination_delay_3', $destination_delay_3, '0'); + echo " ".$text['label-ring-timeout']."\n"; destination_select('destination_timeout_3', $destination_timeout_3, '30'); //echo "
\n"; //echo "Enter the destination number.\n"; @@ -621,12 +517,14 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "
\n"; + echo "\n"; echo " ".$text['label-ring-4'].":\n"; echo "\n"; echo " \n"; - echo " Sec \n"; + echo " ".$text['label-ring-delay']."\n"; + destination_select('destination_delay_4', $destination_delay_4, '0'); + echo " ".$text['label-ring-timeout']."\n"; destination_select('destination_timeout_4', $destination_timeout_4, '30'); //echo "
\n"; //echo "Enter the destination number.\n"; @@ -634,68 +532,20 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "
\n"; + echo "\n"; echo " ".$text['label-ring-5'].":\n"; echo "\n"; echo " \n"; - echo " Sec \n"; + echo " ".$text['label-ring-delay']."\n"; + destination_select('destination_delay_5', $destination_delay_5, '0'); + echo " ".$text['label-ring-timeout']."\n"; destination_select('destination_timeout_5', $destination_timeout_5, '30'); //echo "
\n"; //echo "Enter the destination number.\n"; echo "
\n"; - echo " ".$text['label-ring-order'].":\n"; - echo "\n"; - echo "\n"; - //echo "
\n"; - //echo "Enter the destination number.\n"; - echo "
\n"; - echo " ".$text['label-prompt'].":\n"; - echo "\n"; - echo "\n"; - //echo "
\n"; - //echo "Enter the destination number.\n"; - echo "
\n"; echo "
\n"; @@ -703,7 +553,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "
\n"; + echo "\n"; echo " ".$text['label-dnd'].":\n"; echo "\n"; diff --git a/app/follow_me/app_config.php b/app/follow_me/app_config.php new file mode 100644 index 0000000000..04f244cc72 --- /dev/null +++ b/app/follow_me/app_config.php @@ -0,0 +1,120 @@ + \ No newline at end of file diff --git a/app/follow_me/root.php b/app/follow_me/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/follow_me/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/includes/classes/switch_do_not_disturb.php b/includes/classes/switch_do_not_disturb.php index 83a56ccdfa..f428df2bef 100644 --- a/includes/classes/switch_do_not_disturb.php +++ b/includes/classes/switch_do_not_disturb.php @@ -67,7 +67,7 @@ include "root.php"; } $sql = "update v_extensions set "; $sql .= "do_not_disturb = '".$this->enabled."', "; - $sql .= "dial_string = '".$this->dial_string."', "; +// $sql .= "dial_string = '".$this->dial_string."', "; $sql .= "dial_domain = '".$this->domain_name."' "; $sql .= "where domain_uuid = '".$this->domain_uuid."' "; $sql .= "and extension = '".$this->extension."' "; diff --git a/includes/classes/switch_follow_me.php b/includes/classes/switch_follow_me.php index bc4a0b924b..f8ec286c71 100644 --- a/includes/classes/switch_follow_me.php +++ b/includes/classes/switch_follow_me.php @@ -30,95 +30,50 @@ include "root.php"; public $domain_uuid; public $db_type; public $follow_me_uuid; - public $extension; public $follow_me_enabled; - public $follow_me_type; - public $hunt_group_call_prompt; - public $hunt_group_timeout; public $destination_data_1; public $destination_type_1; + public $destination_delay_1; public $destination_timeout_1; public $destination_data_2; public $destination_type_2; + public $destination_delay_2; public $destination_timeout_2; public $destination_data_3; public $destination_type_3; + public $destination_delay_3; public $destination_timeout_3; public $destination_data_4; public $destination_type_4; + public $destination_delay_4; public $destination_timeout_4; public $destination_data_5; public $destination_type_5; + public $destination_delay_5; public $destination_timeout_5; - public $destination_profile = 'internal'; - public $destination_timeout = ''; + public $destination_timeout = 0; public $destination_order = 1; - public $destination_enabled = 'true'; - public $destination_description = 'follow me'; public function follow_me_add() { global $db; - $hunt_group_extension = $this->extension; - $hunt_group_name = 'follow_me_'.$this->extension; - $hunt_group_type = $this->follow_me_type; - $hunt_group_context = $_SESSION['context']; - $hunt_group_timeout = $this->hunt_group_timeout; - $hunt_group_timeout_destination = $this->extension; - $hunt_group_timeout_type = 'voicemail'; - $hunt_group_ring_back = 'us-ring'; - //$hunt_group_cid_name_prefix = ''; - //$hunt_group_pin = ''; - $huntgroup_caller_announce = 'false'; - //$hunt_group_user_list = ''; - $hunt_group_enabled = $this->follow_me_enabled; - $hunt_group_description = 'follow me '.$this->extension; - - $sql = "insert into v_hunt_groups "; + $sql = "insert into v_follow_me "; $sql .= "("; $sql .= "domain_uuid, "; - $sql .= "hunt_group_uuid, "; - $sql .= "hunt_group_extension, "; - $sql .= "hunt_group_name, "; - $sql .= "hunt_group_type, "; - $sql .= "hunt_group_context, "; - $sql .= "hunt_group_timeout, "; - $sql .= "hunt_group_timeout_destination, "; - $sql .= "hunt_group_timeout_type, "; - $sql .= "hunt_group_ringback, "; - $sql .= "hunt_group_cid_name_prefix, "; - $sql .= "hunt_group_pin, "; - $sql .= "hunt_group_call_prompt, "; - $sql .= "hunt_group_caller_announce, "; - $sql .= "hunt_group_user_list, "; - $sql .= "hunt_group_enabled, "; - $sql .= "hunt_group_description "; + $sql .= "follow_me_uuid, "; + $sql .= "follow_me_enabled "; $sql .= ")"; $sql .= "values "; $sql .= "("; $sql .= "'$this->domain_uuid', "; $sql .= "'$this->follow_me_uuid', "; - $sql .= "'$hunt_group_extension', "; - $sql .= "'$hunt_group_name', "; - $sql .= "'$hunt_group_type', "; - $sql .= "'$hunt_group_context', "; - $sql .= "'$hunt_group_timeout', "; - $sql .= "'$hunt_group_timeout_destination', "; - $sql .= "'$hunt_group_timeout_type', "; - $sql .= "'$hunt_group_ring_back', "; - $sql .= "'$hunt_group_cid_name_prefix', "; - $sql .= "'$hunt_group_pin', "; - $sql .= "'$hunt_group_call_prompt', "; - $sql .= "'$huntgroup_caller_announce', "; - $sql .= "'$hunt_group_user_list', "; - $sql .= "'$hunt_group_enabled', "; - $sql .= "'$hunt_group_description' "; + $sql .= "'$this->follow_me_enabled' "; $sql .= ")"; if ($v_debug) { echo $sql."
"; @@ -131,39 +86,10 @@ include "root.php"; public function follow_me_update() { global $db; - $hunt_group_extension = $this->extension; - $hunt_group_name = 'follow_me_'.$this->extension; - $hunt_group_type = $this->follow_me_type; - $hunt_group_context = $_SESSION['context']; - $hunt_group_timeout = $this->hunt_group_timeout; - $hunt_group_timeout_destination = $this->extension; - $hunt_group_timeout_type = 'voicemail'; - $hunt_group_ring_back = 'us-ring'; - //$hunt_group_cid_name_prefix = ''; - //$hunt_group_pin = ''; - $huntgroup_caller_announce = 'false'; - //$hunt_group_user_list = ''; - $hunt_group_enabled = $this->follow_me_enabled; - $hunt_group_description = 'follow me '.$this->extension; - - $sql = "update v_hunt_groups set "; - $sql .= "hunt_group_extension = '$hunt_group_extension', "; - $sql .= "hunt_group_name = '$hunt_group_name', "; - $sql .= "hunt_group_type = '$hunt_group_type', "; - $sql .= "hunt_group_context = '$hunt_group_context', "; - $sql .= "hunt_group_timeout = '$hunt_group_timeout', "; - $sql .= "hunt_group_timeout_destination = '$hunt_group_timeout_destination', "; - $sql .= "hunt_group_timeout_type = '$hunt_group_timeout_type', "; - $sql .= "hunt_group_ringback = '$hunt_group_ring_back', "; - $sql .= "hunt_group_cid_name_prefix = '$hunt_group_cid_name_prefix', "; - $sql .= "hunt_group_pin = '$hunt_group_pin', "; - $sql .= "hunt_group_call_prompt = '$this->hunt_group_call_prompt', "; - $sql .= "hunt_group_caller_announce = '$huntgroup_caller_announce', "; - $sql .= "hunt_group_user_list = '$hunt_group_user_list', "; - $sql .= "hunt_group_enabled = '$hunt_group_enabled', "; - $sql .= "hunt_group_description = '$hunt_group_description' "; + $sql = "update follow_me set "; + $sql .= "follow_me_enabled = '$this->follow_me_enabled' "; $sql .= "where domain_uuid = '$this->domain_uuid' "; - $sql .= "and hunt_group_uuid = '$this->follow_me_uuid' "; + $sql .= "and follow_me_uuid = '$this->follow_me_uuid' "; $db->exec(check_sql($sql)); unset($sql); $this->follow_me_destinations(); @@ -172,24 +98,21 @@ include "root.php"; public function follow_me_destinations() { global $db; - //delete related v_hunt_group_destinations - $sql = "delete from v_hunt_group_destinations where hunt_group_uuid = '$this->follow_me_uuid' "; + //delete related follow me destinations + $sql = "delete from v_follow_me_destinations where follow_me_uuid = '$this->follow_me_uuid' "; $db->exec(check_sql($sql)); - //insert the v_hunt_group_destinations set destination_data_1 + //insert the follow me destinations if (strlen($this->destination_data_1) > 0) { - $sql = "insert into v_hunt_group_destinations "; + $sql = "insert into v_follow_me_destinations "; $sql .= "("; - $sql .= "hunt_group_destination_uuid, "; + $sql .= "follow_me_destination_uuid, "; $sql .= "domain_uuid, "; - $sql .= "hunt_group_uuid, "; - $sql .= "destination_data, "; - $sql .= "destination_type, "; - $sql .= "destination_profile, "; - $sql .= "destination_timeout, "; - $sql .= "destination_order, "; - $sql .= "destination_enabled, "; - $sql .= "destination_description "; + $sql .= "follow_me_uuid, "; + $sql .= "follow_me_destination, "; + $sql .= "follow_me_timeout, "; + $sql .= "follow_me_delay, "; + $sql .= "follow_me_order "; $sql .= ") "; $sql .= "values "; $sql .= "("; @@ -197,30 +120,24 @@ include "root.php"; $sql .= "'$this->domain_uuid', "; $sql .= "'$this->follow_me_uuid', "; $sql .= "'$this->destination_data_1', "; - $sql .= "'$this->destination_type_1', "; - $sql .= "'$this->destination_profile', "; $sql .= "'$this->destination_timeout_1', "; - $sql .= "'$this->destination_order', "; - $sql .= "'$this->destination_enabled', "; - $sql .= "'$this->destination_description' "; + $sql .= "'$this->destination_delay_1', "; + $sql .= "'1' "; $sql .= ")"; $db->exec(check_sql($sql)); $this->destination_order++; unset($sql); } if (strlen($this->destination_data_2) > 0) { - $sql = "insert into v_hunt_group_destinations "; + $sql = "insert into v_follow_me_destinations "; $sql .= "("; - $sql .= "hunt_group_destination_uuid, "; + $sql .= "follow_me_destination_uuid, "; $sql .= "domain_uuid, "; - $sql .= "hunt_group_uuid, "; - $sql .= "destination_data, "; - $sql .= "destination_type, "; - $sql .= "destination_profile, "; - $sql .= "destination_timeout, "; - $sql .= "destination_order, "; - $sql .= "destination_enabled, "; - $sql .= "destination_description "; + $sql .= "follow_me_uuid, "; + $sql .= "follow_me_destination, "; + $sql .= "follow_me_timeout, "; + $sql .= "follow_me_delay, "; + $sql .= "follow_me_order "; $sql .= ") "; $sql .= "values "; $sql .= "("; @@ -228,30 +145,24 @@ include "root.php"; $sql .= "'$this->domain_uuid', "; $sql .= "'$this->follow_me_uuid', "; $sql .= "'$this->destination_data_2', "; - $sql .= "'$this->destination_type_2', "; - $sql .= "'$this->destination_profile', "; $sql .= "'$this->destination_timeout_2', "; - $sql .= "'$this->destination_order', "; - $sql .= "'$this->destination_enabled', "; - $sql .= "'$this->destination_description' "; + $sql .= "'$this->destination_delay_2', "; + $sql .= "'2' "; $sql .= ")"; $db->exec(check_sql($sql)); $this->destination_order++; unset($sql); } if (strlen($this->destination_data_3) > 0) { - $sql = "insert into v_hunt_group_destinations "; + $sql = "insert into v_follow_me_destinations "; $sql .= "("; - $sql .= "hunt_group_destination_uuid, "; + $sql .= "follow_me_destination_uuid, "; $sql .= "domain_uuid, "; - $sql .= "hunt_group_uuid, "; - $sql .= "destination_data, "; - $sql .= "destination_type, "; - $sql .= "destination_profile, "; - $sql .= "destination_timeout, "; - $sql .= "destination_order, "; - $sql .= "destination_enabled, "; - $sql .= "destination_description "; + $sql .= "follow_me_uuid, "; + $sql .= "follow_me_destination, "; + $sql .= "follow_me_timeout, "; + $sql .= "follow_me_delay, "; + $sql .= "follow_me_order "; $sql .= ") "; $sql .= "values "; $sql .= "("; @@ -259,30 +170,24 @@ include "root.php"; $sql .= "'$this->domain_uuid', "; $sql .= "'$this->follow_me_uuid', "; $sql .= "'$this->destination_data_3', "; - $sql .= "'$this->destination_type_3', "; - $sql .= "'$this->destination_profile', "; $sql .= "'$this->destination_timeout_3', "; - $sql .= "'$this->destination_order', "; - $sql .= "'$this->destination_enabled', "; - $sql .= "'$this->destination_description' "; + $sql .= "'$this->destination_delay_3', "; + $sql .= "'3' "; $sql .= ")"; $db->exec(check_sql($sql)); $this->destination_order++; unset($sql); } if (strlen($this->destination_data_4) > 0) { - $sql = "insert into v_hunt_group_destinations "; + $sql = "insert into v_follow_me_destinations "; $sql .= "("; - $sql .= "hunt_group_destination_uuid, "; + $sql .= "follow_me_destination_uuid, "; $sql .= "domain_uuid, "; - $sql .= "hunt_group_uuid, "; - $sql .= "destination_data, "; - $sql .= "destination_type, "; - $sql .= "destination_profile, "; - $sql .= "destination_timeout, "; - $sql .= "destination_order, "; - $sql .= "destination_enabled, "; - $sql .= "destination_description "; + $sql .= "follow_me_uuid, "; + $sql .= "follow_me_destination, "; + $sql .= "follow_me_timeout, "; + $sql .= "follow_me_delay, "; + $sql .= "follow_me_order "; $sql .= ") "; $sql .= "values "; $sql .= "("; @@ -290,30 +195,24 @@ include "root.php"; $sql .= "'$this->domain_uuid', "; $sql .= "'$this->follow_me_uuid', "; $sql .= "'$this->destination_data_4', "; - $sql .= "'$this->destination_type_4', "; - $sql .= "'$this->destination_profile', "; $sql .= "'$this->destination_timeout_4', "; - $sql .= "'$this->destination_order', "; - $sql .= "'$this->destination_enabled', "; - $sql .= "'$this->destination_description' "; + $sql .= "'$this->destination_delay_4', "; + $sql .= "'4' "; $sql .= ")"; $db->exec(check_sql($sql)); $this->destination_order++; unset($sql); } if (strlen($this->destination_data_5) > 0) { - $sql = "insert into v_hunt_group_destinations "; + $sql = "insert into v_follow_me_destinations "; $sql .= "("; - $sql .= "hunt_group_destination_uuid, "; + $sql .= "follow_me_destination_uuid, "; $sql .= "domain_uuid, "; - $sql .= "hunt_group_uuid, "; - $sql .= "destination_data, "; - $sql .= "destination_type, "; - $sql .= "destination_profile, "; - $sql .= "destination_timeout, "; - $sql .= "destination_order, "; - $sql .= "destination_enabled, "; - $sql .= "destination_description "; + $sql .= "follow_me_uuid, "; + $sql .= "follow_me_destination, "; + $sql .= "follow_me_timeout, "; + $sql .= "follow_me_delay, "; + $sql .= "follow_me_order "; $sql .= ") "; $sql .= "values "; $sql .= "("; @@ -321,18 +220,59 @@ include "root.php"; $sql .= "'$this->domain_uuid', "; $sql .= "'$this->follow_me_uuid', "; $sql .= "'$this->destination_data_5', "; - $sql .= "'$this->destination_type_5', "; - $sql .= "'$this->destination_profile', "; $sql .= "'$this->destination_timeout_5', "; - $sql .= "'$this->destination_order', "; - $sql .= "'$this->destination_enabled', "; - $sql .= "'$this->destination_description' "; + $sql .= "'$this->destination_delay_5', "; + $sql .= "'5' "; $sql .= ")"; $db->exec(check_sql($sql)); $this->destination_order++; unset($sql); } } //function + + public function set() { + global $db; + //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 .= "order by follow_me_order asc "; + $prep_statement_2 = $db->prepare(check_sql($sql)); + $prep_statement_2->execute(); + $result = $prep_statement_2->fetchAll(PDO::FETCH_NAMED); + $dial_string = "{group_confirm_key=exec,group_confirm_file=lua confirm.lua,sip_invite_domain=".$_SESSION['domain_name']."}"; + foreach ($result as &$row) { + $dial_string .= "[presence_id=".$row["follow_me_destination"]."@".$_SESSION['domain_name'].","; + $dial_string .= "leg_delay_start=".$row["follow_me_delay"].","; + $dial_string .= "leg_timeout=".$row["follow_me_timeout"]."]"; + if (extension_exists($row["follow_me_destination"])) { + $dial_string .= "\${sofia_contact(".$row["follow_me_destination"]."@".$_SESSION['domain_name'].")},"; + } + else { + $dial_string .= "loopback/".$row["follow_me_destination"].","; + } + } + $this->dial_string = trim($dial_string, ","); + } + else { +// $this->dial_string = ""; + } + $sql = "update v_extensions set "; + $sql .= "do_not_disturb = 'false', "; + $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."' "; + if ($this->debug) { + echo $sql."
"; + } + $db->exec($sql); + unset($sql); + + //syncrhonize configuration + save_extension_xml(); + } + } //class ?> \ No newline at end of file