diff --git a/app/calls/call_edit.php b/app/calls/call_edit.php index 87cd86dd7d..9fdd5d85c7 100644 --- a/app/calls/call_edit.php +++ b/app/calls/call_edit.php @@ -219,8 +219,31 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $call_forward->extension_uuid = $extension_uuid; $call_forward->forward_all_destination = $forward_all_destination; $call_forward->forward_all_enabled = $forward_all_enabled; - $call_forward->set(); - unset($call_forward); + //$call_forward->set(); + //unset($call_forward); + } + + //do not disturb (dnd) config + if (permission_exists('do_not_disturb')) { + $dnd = new do_not_disturb; + $dnd->domain_uuid = $_SESSION['domain_uuid']; + $dnd->domain_name = $_SESSION['domain_name']; + $dnd->extension_uuid = $extension_uuid; + $dnd->enabled = $dnd_enabled; + //$dnd->set(); + //$dnd->user_status(); + //unset($dnd); + } + + //if follow me is enabled then process it last + if ($follow_me_enabled == "true") { + //call forward + $call_forward->set(); + unset($call_forward); + //dnd + $dnd->set(); + $dnd->user_status(); + unset($dnd); } //follow me config @@ -277,22 +300,32 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { } if ($follow_me_action == "update") { $follow_me->follow_me_uuid = $follow_me_uuid; - $follow_me->set(); $follow_me->follow_me_update(); + $follow_me->set(); } unset($follow_me); } - //do not disturb (dnd) config - if (permission_exists('do_not_disturb')) { - $dnd = new do_not_disturb; - $dnd->domain_uuid = $_SESSION['domain_uuid']; - $dnd->domain_name = $_SESSION['domain_name']; - $dnd->extension_uuid = $extension_uuid; - $dnd->enabled = $dnd_enabled; - $dnd->set(); - $dnd->user_status(); - unset($dnd); + //if dnd or call forward are enabled process it last + if ($follow_me_enabled != "true") { + if ($forward_all_enabled == "true") { + //dnd + $dnd->set(); + $dnd->user_status(); + unset($dnd); + //call forward + $call_forward->set(); + unset($call_forward); + } + else{ + //call forward + $call_forward->set(); + unset($call_forward); + //dnd + $dnd->set(); + $dnd->user_status(); + unset($dnd); + } } //redirect the user diff --git a/app/calls/set_call_forward_all.php b/app/calls/set_call_forward_all.php deleted file mode 100644 index 5952647602..0000000000 --- a/app/calls/set_call_forward_all.php +++ /dev/null @@ -1,137 +0,0 @@ - - Portions created by the Initial Developer are Copyright (C) 2008-2012 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ -require_once "root.php"; -require_once "includes/require.php"; -require_once "includes/checkauth.php"; -if (permission_exists('call_forward')) { - //access granted -} -else { - echo "access denied"; - exit; -} - -//define the destination_select function - function destination_select($select_name, $select_value, $select_default) { - if (strlen($select_value) == 0) { $select_value = $select_default; } - echo " \n"; - } - -//get the extension_uuid - $extension_uuid = check_str($_REQUEST["id"]); - -//get the extension number - $sql = "select * from v_extensions "; - $sql .= "where domain_uuid = '$domain_uuid' "; - $sql .= "and extension_uuid = '$extension_uuid' "; - if (!(if_group("admin") || if_group("superadmin"))) { - if (count($_SESSION['user']['extension']) > 0) { - $sql .= "and ("; - $x = 0; - foreach($_SESSION['user']['extension'] as $row) { - if ($x > 0) { $sql .= "or "; } - $sql .= "extension = '".$row['user']."' "; - $x++; - } - $sql .= ")"; - } - else { - //hide any results when a user has not been assigned an extension - $sql .= "and extension = 'disabled' "; - } - } - $sql .= "and enabled = 'true' "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - if (count($result)== 0) { - echo "access denied"; - exit; - } - else { - foreach ($result as &$row) { - $extension = $row["extension"]; - $effective_caller_id_name = $row["effective_caller_id_name"]; - $effective_caller_id_number = $row["effective_caller_id_number"]; - $outbound_caller_id_name = $row["outbound_caller_id_name"]; - $outbound_caller_id_number = $row["outbound_caller_id_number"]; - $do_not_disturb = $row["do_not_disturb"]; - $call_forward_all = $row["call_forward_all"]; - $dial_string = $row["dial_string"]; - $call_forward_busy = $row["call_forward_busy"]; - $description = $row["description"]; - } - if (strlen($do_not_disturb) == 0) { - $do_not_disturb = "false"; - } - } - unset ($prep_statement); - -//get http post variables and set them to php variables - if (count($_POST)>0) { - $call_forward_all_enabled = check_str($_POST["call_forward_all_enabled"]); - $call_forward_all = check_str($_POST["call_forward_all"]); - if (strlen($call_forward_all) > 0) { - $call_forward_all = preg_replace("~[^0-9]~", "",$call_forward_all); - } - } - -//include the classes - include "includes/classes/switch_call_forward.php"; - -//call forward config - $call_forward = new call_forward; - $call_forward->domain_uuid = $_SESSION['domain_uuid']; - $call_forward->domain_name = $_SESSION['domain_name']; - $call_forward->extension = $extension; - $call_forward->number = $call_forward_all; - $call_forward->enabled = $call_forward_all_enabled; - $call_forward->set_all(); - unset($call_forward); - -//redirect the user - require_once "includes/header.php"; - echo "\n"; - echo "
\n"; - echo "Update Complete
\n"; - echo "
\n"; - require_once "includes/footer.php"; - return; - -?> \ No newline at end of file diff --git a/app/calls/set_do_not_disturb.php b/app/calls/set_do_not_disturb.php deleted file mode 100644 index ed853ce3d3..0000000000 --- a/app/calls/set_do_not_disturb.php +++ /dev/null @@ -1,114 +0,0 @@ - - Portions created by the Initial Developer are Copyright (C) 2008-2012 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ -require_once "root.php"; -require_once "includes/require.php"; -require_once "includes/checkauth.php"; -if (permission_exists('do_not_disturb')) { - //access granted -} -else { - echo "access denied"; - exit; -} - -//get the extension_uuid - $extension_uuid = check_str($_REQUEST["id"]); - -//get the extension number - $sql = "select * from v_extensions "; - $sql .= "where domain_uuid = '$domain_uuid' "; - $sql .= "and extension_uuid = '$extension_uuid' "; - if (!(if_group("admin") || if_group("superadmin"))) { - if (count($_SESSION['user']['extension']) > 0) { - $sql .= "and ("; - $x = 0; - foreach($_SESSION['user']['extension'] as $row) { - if ($x > 0) { $sql .= "or "; } - $sql .= "extension = '".$row['user']."' "; - $x++; - } - $sql .= ")"; - } - else { - //hide any results when a user has not been assigned an extension - $sql .= "and extension = 'disabled' "; - } - } - $sql .= "and enabled = 'true' "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - if (count($result)== 0) { - echo "access denied"; - exit; - } - else { - foreach ($result as &$row) { - $extension = $row["extension"]; - $effective_caller_id_name = $row["effective_caller_id_name"]; - $effective_caller_id_number = $row["effective_caller_id_number"]; - $outbound_caller_id_name = $row["outbound_caller_id_name"]; - $outbound_caller_id_number = $row["outbound_caller_id_number"]; - $do_not_disturb = $row["do_not_disturb"]; - $call_forward_all = $row["call_forward_all"]; - $dial_string = $row["dial_string"]; - $call_forward_busy = $row["call_forward_busy"]; - $description = $row["description"]; - } - if (strlen($do_not_disturb) == 0) { - $do_not_disturb = "false"; - } - } - unset ($prep_statement); - -//get http post variables and set them to php variables - if (count($_POST)>0) { - $dnd_enabled = check_str($_POST["dnd_enabled"]); - } - -//include the classes - include "includes/classes/switch_do_not_disturb.php"; - -//do not disturb (dnd) config - $dnd = new do_not_disturb; - $dnd->domain_uuid = $_SESSION['domain_uuid']; - $dnd->domain_name = $_SESSION['domain_name']; - $dnd->extension = $extension; - $dnd->enabled = $dnd_enabled; - $dnd->set(); - $dnd->user_status(); - unset($dnd); - -//redirect the user - require_once "includes/header.php"; - echo "\n"; - echo "
\n"; - echo "Update Complete
\n"; - echo "
\n"; - require_once "includes/footer.php"; - return; - -?> \ No newline at end of file