From 540221104714ad05d57e7f989a17ef33855f0c0b Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Thu, 24 Oct 2019 03:02:13 -0600 Subject: [PATCH] Update index.php --- app/basic_operator_panel/index.php | 71 ++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 4 deletions(-) diff --git a/app/basic_operator_panel/index.php b/app/basic_operator_panel/index.php index 4e961a62cd..1d3a726e02 100644 --- a/app/basic_operator_panel/index.php +++ b/app/basic_operator_panel/index.php @@ -66,7 +66,7 @@ //update the status if (permission_exists("user_account_setting_edit")) { $array['users'][0]['user_uuid'] = $_SESSION['user']['user_uuid']; - $array['users'][0]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['users'][0]['domain_uuid'] = $_SESSION['user']['domain_uuid']; $array['users'][0]['user_status'] = $user_status; $database = new database; $database->app_name = 'operator_panel'; @@ -81,24 +81,85 @@ $sql = "select call_center_agent_uuid from v_call_center_agents "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and user_uuid = :user_uuid "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $_SESSION['user']['domain_uuid']; $parameters['user_uuid'] = $_SESSION['user']['user_uuid']; $database = new database; $call_center_agent_uuid = $database->select($sql, $parameters, 'column'); unset($sql, $parameters); //update the user_status - if (isset($call_center_agent_uuid)) { + if (is_uuid($call_center_agent_uuid)) { $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); $switch_cmd .= "callcenter_config agent set status ".$call_center_agent_uuid." '".$user_status."'"; $switch_result = event_socket_request($fp, 'api '.$switch_cmd); } //update the user state - if (isset($call_center_agent_uuid)) { + if (is_uuid($call_center_agent_uuid)) { $cmd = "api callcenter_config agent set state ".$call_center_agent_uuid." Waiting"; $response = event_socket_request($fp, $cmd); } + + //update do not disturb + if ($user_status == "Do Not Disturb") { + $x = 0; + foreach($_SESSION['user']['extension'] as $row) { + //build the array + $array['extensions'][$x]['extension_uuid'] = $row['extension_uuid']; + $array['extensions'][$x]['dial_string'] = 'error/user_busy'; + $array['extensions'][$x]['do_not_disturb'] = 'true'; + + //delete extension from the cache + $cache = new cache; + $cache->delete("directory:".$row['extension']."@".$_SESSION['user']['domain_name']); + if(strlen($number_alias) > 0){ + $cache->delete("directory:".$row['number_alias']."@".$_SESSION['user']['domain_name']); + } + + //incrment + $x++; + } + } + else { + $x = 0; + foreach($_SESSION['user']['extension'] as $row) { + //build the array + $array['extensions'][$x]['extension_uuid'] = $row['extension_uuid']; + $array['extensions'][$x]['dial_string'] = null; + $array['extensions'][$x]['do_not_disturb'] = 'false'; + + //delete extension from the cache + $cache = new cache; + $cache->delete("directory:".$row['extension']."@".$_SESSION['user']['domain_name']); + if(strlen($number_alias) > 0){ + $cache->delete("directory:".$row['number_alias']."@".$_SESSION['user']['domain_name']); + } + + //incrment + $x++; + } + } + + //grant temporary permissions + $p = new permissions; + $p->add('extension_edit', 'temp'); + + //execute update + $database = new database; + $database->app_name = 'calls'; + $database->app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d'; + $database->save($array); + unset($array); + + //revoke temporary permissions + $p->delete('extension_edit', 'temp'); + + //delete extension from the cache + $cache = new cache; + $cache->delete("directory:".$extension."@".$this->domain_name); + if(strlen($number_alias) > 0){ + $cache->delete("directory:".$number_alias."@".$this->domain_name); + } } //stop execution @@ -493,6 +554,8 @@ if (is_array($_SESSION['user']['extension'])) {