Merge branch 'master' into Fix-DND-Feature-Sync-Loop
This commit is contained in:
@@ -43,38 +43,40 @@ include "root.php";
|
|||||||
|
|
||||||
//feature_event method
|
//feature_event method
|
||||||
public function send_notify() {
|
public function send_notify() {
|
||||||
|
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
if ($fp) {
|
||||||
if ($fp) {
|
// Get the SIP profiles for the extension
|
||||||
//get the sip profile name
|
$command = "sofia_contact */{$this->extension}@{$this->domain_name}";
|
||||||
$command = "sofia_contact */".$this->extension."@".$this->domain_name;
|
$contact_string = event_socket_request($fp, "api ".$command);
|
||||||
$contact_string = event_socket_request($fp, "api ".$command);
|
// The first value in the array will be full matching text, the second one will be the array of profile matches
|
||||||
if (substr($contact_string, 0, 5) == "sofia") {
|
preg_match_all('/sofia\/([^,]+)\/(?:[^,]+)/', $contact_string, $matches);
|
||||||
$contact_array = explode("/", $contact_string);
|
if (sizeof($matches) != 2 || sizeof($matches[1]) < 1) {
|
||||||
$sip_profile_name = $contact_array[1];
|
$profiles = array("internal");
|
||||||
}
|
} else {
|
||||||
else {
|
// We have at least one profile, get all of the unique profiles
|
||||||
$sip_profile_name = 'internal';
|
$profiles = array_unique($matches[1]);
|
||||||
}
|
|
||||||
//send the event
|
|
||||||
$event = "sendevent SWITCH_EVENT_PHONE_FEATURE\n";
|
|
||||||
$event .= "profile: ".$sip_profile_name."\n";
|
|
||||||
$event .= "user: ".$this->extension."\n";
|
|
||||||
$event .= "host: ".$this->domain_name."\n";
|
|
||||||
$event .= "device: \n";
|
|
||||||
$event .= "Feature-Event: init\n";
|
|
||||||
$event .= "forward_immediate_enabled: ".$this->forward_all_enabled."\n";
|
|
||||||
$event .= "forward_immediate: ".$this->forward_all_destination."\n";
|
|
||||||
$event .= "forward_busy_enabled: ".$this->forward_busy_enabled."\n";
|
|
||||||
$event .= "forward_busy: ".$this->forward_busy_destination."\n";
|
|
||||||
$event .= "forward_no_answer_enabled: ".$this->forward_no_answer_enabled."\n";
|
|
||||||
$event .= "forward_no_answer: ".$this->forward_no_answer_destination."\n";
|
|
||||||
$event .= "doNotDisturbOn: ".$this->do_not_disturb."\n";
|
|
||||||
$event .= "ringCount: ".$this->ring_count."\n";
|
|
||||||
event_socket_request($fp, $event);
|
|
||||||
|
|
||||||
fclose($fp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($profiles as $profile) {
|
||||||
|
//send the event
|
||||||
|
$event = "sendevent SWITCH_EVENT_PHONE_FEATURE\n";
|
||||||
|
$event .= "profile: " . $profile . "\n";
|
||||||
|
$event .= "user: " . $this->extension . "\n";
|
||||||
|
$event .= "host: " . $this->domain_name . "\n";
|
||||||
|
$event .= "device: \n";
|
||||||
|
$event .= "Feature-Event: init\n";
|
||||||
|
$event .= "forward_immediate_enabled: " . $this->forward_all_enabled . "\n";
|
||||||
|
$event .= "forward_immediate: " . $this->forward_all_destination . "\n";
|
||||||
|
$event .= "forward_busy_enabled: " . $this->forward_busy_enabled . "\n";
|
||||||
|
$event .= "forward_busy: " . $this->forward_busy_destination . "\n";
|
||||||
|
$event .= "forward_no_answer_enabled: " . $this->forward_no_answer_enabled . "\n";
|
||||||
|
$event .= "forward_no_answer: " . $this->forward_no_answer_destination . "\n";
|
||||||
|
$event .= "doNotDisturbOn: " . $this->do_not_disturb . "\n";
|
||||||
|
$event .= "ringCount: " . $this->ring_count . "\n";
|
||||||
|
event_socket_request($fp, $event);
|
||||||
|
}
|
||||||
|
fclose($fp);
|
||||||
|
}
|
||||||
} //function
|
} //function
|
||||||
|
|
||||||
} //class
|
} //class
|
||||||
|
|||||||
+21
-9
@@ -41,7 +41,6 @@ else {
|
|||||||
//set the variables
|
//set the variables
|
||||||
$cmd = check_str($_GET['cmd']);
|
$cmd = check_str($_GET['cmd']);
|
||||||
$rdr = check_str($_GET['rdr']);
|
$rdr = check_str($_GET['rdr']);
|
||||||
$profile = check_str($_GET['profile']);
|
|
||||||
$domain = check_str($_GET['domain']);
|
$domain = check_str($_GET['domain']);
|
||||||
$show = check_str($_GET['show']);
|
$show = check_str($_GET['show']);
|
||||||
$user = check_str($_GET['user']);
|
$user = check_str($_GET['user']);
|
||||||
@@ -51,26 +50,39 @@ else {
|
|||||||
//create the event socket connection
|
//create the event socket connection
|
||||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||||
if ($fp) {
|
if ($fp) {
|
||||||
|
// Get the SIP profiles for the user
|
||||||
|
$command = "sofia_contact */{$user}";
|
||||||
|
$contact_string = event_socket_request($fp, "api ".$command);
|
||||||
|
// The first value in the array will be full matching text, the second one will be the array of profile matches
|
||||||
|
preg_match_all('/sofia\/([^,]+)\/(?:[^,]+)/', $contact_string, $matches);
|
||||||
|
if (sizeof($matches) != 2 || sizeof($matches[1]) < 1) {
|
||||||
|
$profiles = array("internal");
|
||||||
|
} else {
|
||||||
|
// We have at least one profile, get all of the unique profiles
|
||||||
|
$profiles = array_unique($matches[1]);
|
||||||
|
}
|
||||||
|
|
||||||
//prepare the command
|
foreach ($profiles as $profile) {
|
||||||
|
//prepare the command
|
||||||
if ($cmd == "unregister") {
|
if ($cmd == "unregister") {
|
||||||
$command = "sofia profile ".$profile." flush_inbound_reg ".$user." reboot";
|
$command = "sofia profile {$profile} flush_inbound_reg {$user} reboot";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$command = "lua app.lua event_notify ".$profile." ".$cmd." ".$user." ".$vendor;
|
$command = "lua app.lua event_notify {$profile} {$cmd} {$user} {$vendor}";
|
||||||
//if ($cmd == "check_sync") {
|
//if ($cmd == "check_sync") {
|
||||||
// $command = "sofia profile ".$profile." check_sync ".$user;
|
// $command = "sofia profile ".$profile." check_sync ".$user;
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
//send the command
|
//send the command
|
||||||
$response = event_socket_request($fp, "api ".$command);
|
$response = event_socket_request($fp, "api {$command}");
|
||||||
$response = event_socket_request($fp, "api log notice ".$command);
|
event_socket_request($fp, "api log notice {$command}");
|
||||||
|
|
||||||
//show the response
|
//show the response
|
||||||
message::add($text['label-event']." ".ucwords($cmd)." ".$text['label-response'].htmlentities($response));
|
message::add($text['label-event']." ".ucwords($cmd)." ".$text['label-response'].htmlentities($response));
|
||||||
|
}
|
||||||
|
|
||||||
//close the connection
|
//close the connection
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
//redirect the user
|
//redirect the user
|
||||||
|
|||||||
@@ -625,20 +625,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the sip profile name
|
|
||||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
|
||||||
if ($fp) {
|
|
||||||
$command = "sofia_contact */".$user_id."@".$server_address;
|
|
||||||
$contact_string = event_socket_request($fp, "api ".$command);
|
|
||||||
if (substr($contact_string, 0, 5) == "sofia") {
|
|
||||||
$contact_array = explode("/", $contact_string);
|
|
||||||
$sip_profile_name = $contact_array[1];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$sip_profile_name = 'internal';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//create token
|
//create token
|
||||||
$object = new token;
|
$object = new token;
|
||||||
$token = $object->create($_SERVER['PHP_SELF']);
|
$token = $object->create($_SERVER['PHP_SELF']);
|
||||||
@@ -816,7 +802,7 @@
|
|||||||
echo button::create(['type'=>'button','label'=>$text['button-qr_code'],'icon'=>'qrcode','style'=>$button_margin,'onclick'=>"$('#qr_code_container').fadeIn(400);"]);
|
echo button::create(['type'=>'button','label'=>$text['button-qr_code'],'icon'=>'qrcode','style'=>$button_margin,'onclick'=>"$('#qr_code_container').fadeIn(400);"]);
|
||||||
unset($button_margin);
|
unset($button_margin);
|
||||||
}
|
}
|
||||||
echo button::create(['type'=>'button','label'=>$text['button-provision'],'icon'=>'fax','style'=>$button_margin,'link'=>PROJECT_PATH."/app/devices/cmd.php?cmd=check_sync&profile=".urlencode($sip_profile_name)."&user=".urlencode($user_id)."@".urlencode($server_address)."&domain=".urlencode($server_address)."&agent=".urlencode($device_vendor)]);
|
echo button::create(['type'=>'button','label'=>$text['button-provision'],'icon'=>'fax','style'=>$button_margin,'link'=>PROJECT_PATH."/app/devices/cmd.php?cmd=check_sync"."&user=".urlencode($user_id)."@".urlencode($server_address)."&domain=".urlencode($server_address)."&agent=".urlencode($device_vendor)]);
|
||||||
unset($button_margin);
|
unset($button_margin);
|
||||||
if (permission_exists("device_files")) {
|
if (permission_exists("device_files")) {
|
||||||
//get the template directory
|
//get the template directory
|
||||||
|
|||||||
@@ -153,7 +153,17 @@
|
|||||||
$database->app_name = 'extension settings';
|
$database->app_name = 'extension settings';
|
||||||
$database->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
|
$database->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
|
||||||
$database->save($array);
|
$database->save($array);
|
||||||
|
|
||||||
|
//clear the cache
|
||||||
|
$sql = "select extension, number_alias, user_context from v_extensions ";
|
||||||
|
$sql .= "where extension_uuid = :extension_uuid ";
|
||||||
|
$parameters['extension_uuid'] = $extension_uuid;
|
||||||
|
$database = new database;
|
||||||
|
$extension = $database->select($sql, $parameters, 'row');
|
||||||
|
$cache = new cache;
|
||||||
|
$cache->delete("directory:".$extension["extension"]."@".$extension["user_context"]);
|
||||||
|
$cache->delete("directory:".$extension["number_alias"]."@".$extension["user_context"]);
|
||||||
|
|
||||||
//redirect the user
|
//redirect the user
|
||||||
if (isset($action)) {
|
if (isset($action)) {
|
||||||
if ($action == "add") {
|
if ($action == "add") {
|
||||||
|
|||||||
@@ -112,6 +112,16 @@ if (!class_exists('extension_settings')) {
|
|||||||
$database->app_uuid = $this->app_uuid;
|
$database->app_uuid = $this->app_uuid;
|
||||||
$database->delete($array);
|
$database->delete($array);
|
||||||
unset($array);
|
unset($array);
|
||||||
|
|
||||||
|
//clear the cache
|
||||||
|
$sql = "select extension, number_alias, user_context from v_extensions ";
|
||||||
|
$sql .= "where extension_uuid = :extension_uuid ";
|
||||||
|
$parameters['extension_uuid'] = $extension_uuid;
|
||||||
|
$database = new database;
|
||||||
|
$extension = $database->select($sql, $parameters, 'row');
|
||||||
|
$cache = new cache;
|
||||||
|
$cache->delete("directory:".$extension["extension"]."@".$extension["user_context"]);
|
||||||
|
$cache->delete("directory:".$extension["number_alias"]."@".$extension["user_context"]);
|
||||||
|
|
||||||
//set message
|
//set message
|
||||||
message::add($text['message-delete']);
|
message::add($text['message-delete']);
|
||||||
|
|||||||
@@ -38,6 +38,14 @@
|
|||||||
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
|
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
|
||||||
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Call Waiting 0-default, 1-enabled, 2-disable.";
|
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Call Waiting 0-default, 1-enabled, 2-disable.";
|
||||||
$y++;
|
$y++;
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "3efa97d6-a35a-4371-b3db-efca7ef9b9b5";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_category'] = "provision";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "grandstream_call_waiting_ring";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_name'] = "text";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_value'] = "0";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Call waiting ringing instead of playing call waiting tone when call waiting is on. 0-disabled (default), 1-enabled";
|
||||||
|
$y++;
|
||||||
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "3a8841f3-e1c0-4eb1-abd3-068a3e3701a5";
|
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "3a8841f3-e1c0-4eb1-abd3-068a3e3701a5";
|
||||||
$apps[$x]['default_settings'][$y]['default_setting_category'] = "provision";
|
$apps[$x]['default_settings'][$y]['default_setting_category'] = "provision";
|
||||||
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "grandstream_gxp_time_zone";
|
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "grandstream_gxp_time_zone";
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
--get the events
|
--get the events
|
||||||
--if (user == nil) then
|
--if (user == nil) then
|
||||||
--serialize the data for the console
|
--serialize the data for the console
|
||||||
--freeswitch.consoleLog("notice","[events] " .. event:serialize("xml") .. "\n");
|
--freeswitch.consoleLog("notice","[events] " .. event:serialize("xml") .. "\n");
|
||||||
--freeswitch.consoleLog("notice","[evnts] " .. event:serialize("json") .. "\n");
|
--freeswitch.consoleLog("notice","[evnts] " .. event:serialize("json") .. "\n");
|
||||||
@@ -115,13 +115,13 @@
|
|||||||
|
|
||||||
--get sip profile
|
--get sip profile
|
||||||
if (user ~= nil and host ~= nil) then
|
if (user ~= nil and host ~= nil) then
|
||||||
sip_profile = notify.get_profile(user, host);
|
sip_profiles = notify.get_profiles(user, host);
|
||||||
end
|
end
|
||||||
|
|
||||||
--DND
|
--DND
|
||||||
|
if (sip_profiles ~= nil) then
|
||||||
--DND enabled
|
--DND enabled
|
||||||
if (feature_action == "SetDoNotDisturb" and feature_enabled == "true" and sip_profile ~= nil) then
|
if (feature_action == "SetDoNotDisturb" and feature_enabled == "true") then
|
||||||
--set a variable
|
--set a variable
|
||||||
dial_string = "error/user_busy";
|
dial_string = "error/user_busy";
|
||||||
do_not_disturb = "true";
|
do_not_disturb = "true";
|
||||||
@@ -155,11 +155,11 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
--send notify to the phone
|
--send notify to the phone
|
||||||
notify.dnd(user, host, sip_profile, do_not_disturb);
|
notify.dnd(user, host, sip_profiles, do_not_disturb);
|
||||||
end
|
end
|
||||||
|
|
||||||
--DND disabled
|
--DND disabled
|
||||||
if (feature_action == "SetDoNotDisturb" and feature_enabled == "false" and sip_profile ~= nil ) then
|
if (feature_action == "SetDoNotDisturb" and feature_enabled == "false") then
|
||||||
--set a variable
|
--set a variable
|
||||||
do_not_disturb = "false";
|
do_not_disturb = "false";
|
||||||
|
|
||||||
@@ -177,14 +177,14 @@
|
|||||||
dbh:query(sql, params);
|
dbh:query(sql, params);
|
||||||
|
|
||||||
--send notify to the phone
|
--send notify to the phone
|
||||||
notify.dnd(user, host, sip_profile, do_not_disturb);
|
notify.dnd(user, host, sip_profiles, do_not_disturb);
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--Call Forward
|
--Call Forward
|
||||||
|
|
||||||
--Call Formward All enabled
|
--Call Formward All enabled
|
||||||
if (feature_action == "SetCallForward" and feature_enabled == "true" and action_name == "forward_immediate" and sip_profile ~= nil) then
|
if (feature_action == "SetCallForward" and feature_enabled == "true" and action_name == "forward_immediate") then
|
||||||
--set a variable
|
--set a variable
|
||||||
forward_all_destination = action_value;
|
forward_all_destination = action_value;
|
||||||
forward_all_enabled = "true";
|
forward_all_enabled = "true";
|
||||||
@@ -247,11 +247,11 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
--send notify to the phone
|
--send notify to the phone
|
||||||
notify.forward_immediate(user, host, sip_profile, forward_immediate_enabled, forward_immediate_destination);
|
notify.forward_immediate(user, host, sip_profiles, forward_immediate_enabled, forward_immediate_destination);
|
||||||
end
|
end
|
||||||
|
|
||||||
--Call Formward All disable
|
--Call Formward All disable
|
||||||
if (feature_action == "SetCallForward" and feature_enabled == "false" and action_name == "forward_immediate" and sip_profile ~= nil) then
|
if (feature_action == "SetCallForward" and feature_enabled == "false" and action_name == "forward_immediate") then
|
||||||
--set a variable
|
--set a variable
|
||||||
forward_all_destination = action_value;
|
forward_all_destination = action_value;
|
||||||
forward_all_enabled = "false";
|
forward_all_enabled = "false";
|
||||||
@@ -277,14 +277,14 @@
|
|||||||
dbh:query(sql, params);
|
dbh:query(sql, params);
|
||||||
|
|
||||||
--send notify to the phone
|
--send notify to the phone
|
||||||
if (forward_immediate_destination == nil) then
|
if (forward_immediate_destination == nil) then
|
||||||
forward_immediate_destination = " ";
|
forward_immediate_destination = " ";
|
||||||
end
|
end
|
||||||
notify.forward_immediate(user, host, sip_profile, forward_immediate_enabled, forward_immediate_destination);
|
notify.forward_immediate(user, host, sip_profiles, forward_immediate_enabled, forward_immediate_destination);
|
||||||
end
|
end
|
||||||
|
|
||||||
--Call Formward BUSY enable
|
--Call Formward BUSY enable
|
||||||
if (feature_action == "SetCallForward" and feature_enabled == "true" and action_name == "forward_busy" and sip_profile ~= nil) then
|
if (feature_action == "SetCallForward" and feature_enabled == "true" and action_name == "forward_busy") then
|
||||||
--set a variable
|
--set a variable
|
||||||
forward_busy_destination = action_value;
|
forward_busy_destination = action_value;
|
||||||
forward_busy_enabled = "true";
|
forward_busy_enabled = "true";
|
||||||
@@ -303,11 +303,11 @@
|
|||||||
dbh:query(sql, params);
|
dbh:query(sql, params);
|
||||||
|
|
||||||
--send notify to the phone
|
--send notify to the phone
|
||||||
notify.forward_busy(user, host, sip_profile, forward_busy_enabled, forward_busy_destination);
|
notify.forward_busy(user, host, sip_profiles, forward_busy_enabled, forward_busy_destination);
|
||||||
end
|
end
|
||||||
|
|
||||||
--Call Formward BUSY disable
|
--Call Formward BUSY disable
|
||||||
if (feature_action == "SetCallForward" and feature_enabled == "false" and action_name == "forward_busy" and sip_profile ~= nil) then
|
if (feature_action == "SetCallForward" and feature_enabled == "false" and action_name == "forward_busy") then
|
||||||
--set a variable
|
--set a variable
|
||||||
forward_busy_destination = action_value;
|
forward_busy_destination = action_value;
|
||||||
forward_busy_enabled = "false";
|
forward_busy_enabled = "false";
|
||||||
@@ -330,11 +330,11 @@
|
|||||||
dbh:query(sql, params);
|
dbh:query(sql, params);
|
||||||
|
|
||||||
--send notify to the phone
|
--send notify to the phone
|
||||||
notify.forward_busy(user, host, sip_profile, forward_busy_enabled, forward_busy_destination);
|
notify.forward_busy(user, host, sip_profiles, forward_busy_enabled, forward_busy_destination);
|
||||||
end
|
end
|
||||||
|
|
||||||
--Call Formward NO ANSWER enable
|
--Call Formward NO ANSWER enable
|
||||||
if (feature_action == "SetCallForward" and feature_enabled == "true" and action_name == "forward_no_answer" and sip_profile ~= nil) then
|
if (feature_action == "SetCallForward" and feature_enabled == "true" and action_name == "forward_no_answer") then
|
||||||
--set a variable
|
--set a variable
|
||||||
forward_no_answer_destination = action_value;
|
forward_no_answer_destination = action_value;
|
||||||
forward_no_answer_enabled = "true";
|
forward_no_answer_enabled = "true";
|
||||||
@@ -355,11 +355,11 @@
|
|||||||
dbh:query(sql, params);
|
dbh:query(sql, params);
|
||||||
|
|
||||||
--send notify to the phone
|
--send notify to the phone
|
||||||
notify.forward_no_answer(user, host, sip_profile, forward_no_answer_enabled, forward_no_answer_destination, ring_count);
|
notify.forward_no_answer(user, host, sip_profiles, forward_no_answer_enabled, forward_no_answer_destination, ring_count);
|
||||||
end
|
end
|
||||||
|
|
||||||
--Call Formward NO ANSWER disable
|
--Call Formward NO ANSWER disable
|
||||||
if (feature_action == "SetCallForward" and feature_enabled == "false" and action_name == "forward_no_answer" and sip_profile ~= nil) then
|
if (feature_action == "SetCallForward" and feature_enabled == "false" and action_name == "forward_no_answer") then
|
||||||
--set a variable
|
--set a variable
|
||||||
forward_no_answer_destination = action_value;
|
forward_no_answer_destination = action_value;
|
||||||
forward_no_answer_enabled = "false";
|
forward_no_answer_enabled = "false";
|
||||||
@@ -382,28 +382,28 @@
|
|||||||
dbh:query(sql, params);
|
dbh:query(sql, params);
|
||||||
|
|
||||||
--send notify to the phone
|
--send notify to the phone
|
||||||
notify.forward_no_answer(user, host, sip_profile, forward_no_answer_enabled, forward_no_answer_destination, ring_count);
|
notify.forward_no_answer(user, host, sip_profiles, forward_no_answer_enabled, forward_no_answer_destination, ring_count);
|
||||||
end
|
end
|
||||||
|
|
||||||
--No feature event (phone boots): Send all values
|
--No feature event (phone boots): Send all values
|
||||||
if (feature_enabled == nil) then
|
if (feature_enabled == nil) then
|
||||||
--Do Not Disturb
|
--Do Not Disturb
|
||||||
--notify.dnd(user, host, sip_profile, do_not_disturb);
|
--notify.dnd(user, host, sip_profiles, do_not_disturb);
|
||||||
|
|
||||||
--Forward all
|
--Forward all
|
||||||
forward_immediate_enabled = forward_all_enabled;
|
forward_immediate_enabled = forward_all_enabled;
|
||||||
forward_immediate_destination = forward_all_destination;
|
forward_immediate_destination = forward_all_destination;
|
||||||
--notify.forward_immediate(user, host, sip_profile, forward_immediate_enabled, forward_immediate_destination);
|
--notify.forward_immediate(user, host, sip_profiles, forward_immediate_enabled, forward_immediate_destination);
|
||||||
|
|
||||||
--Forward busy
|
--Forward busy
|
||||||
--notify.forward_busy(user, host, sip_profile, forward_busy_enabled, forward_busy_destination);
|
--notify.forward_busy(user, host, sip_profiles, forward_busy_enabled, forward_busy_destination);
|
||||||
|
|
||||||
--Forward No Answer
|
--Forward No Answer
|
||||||
ring_count = math.ceil (call_timeout / 6);
|
ring_count = math.ceil (call_timeout / 6);
|
||||||
--notify.forward_no_answer(user, host, sip_profile, forward_no_answer_enabled, forward_no_answer_destination, ring_count);
|
--notify.forward_no_answer(user, host, sip_profiles, forward_no_answer_enabled, forward_no_answer_destination, ring_count);
|
||||||
notify.init(user,
|
notify.init(user,
|
||||||
host,
|
host,
|
||||||
sip_profile,
|
sip_profiles,
|
||||||
forward_immediate_enabled,
|
forward_immediate_enabled,
|
||||||
forward_immediate_destination,
|
forward_immediate_destination,
|
||||||
forward_busy_enabled,
|
forward_busy_enabled,
|
||||||
@@ -414,8 +414,8 @@
|
|||||||
do_not_disturb);
|
do_not_disturb);
|
||||||
end
|
end
|
||||||
|
|
||||||
-- feature_event_notify.init(user, host, sip_profile, forward_immediate_enabled, forward_immediate_destination, forward_busy_enabled, forward_busy_destination, forward_no_answer_enabled, forward_no_answer_destination, ring_count, do_not_disturb)
|
-- feature_event_notify.init(user, host, sip_profiles, forward_immediate_enabled, forward_immediate_destination, forward_busy_enabled, forward_busy_destination, forward_no_answer_enabled, forward_no_answer_destination, ring_count, do_not_disturb)
|
||||||
|
end
|
||||||
--clear the cache
|
--clear the cache
|
||||||
if (feature_enabled ~= nil) then
|
if (feature_enabled ~= nil) then
|
||||||
cache.del("directory:"..user.."@"..host)
|
cache.del("directory:"..user.."@"..host)
|
||||||
|
|||||||
+40
-17
@@ -56,22 +56,36 @@ function feature_event_notify.get_db_values(user, domain_name)
|
|||||||
return do_not_disturb, forward_all_enabled, forward_all_destination, forward_busy_enabled, forward_busy_destination, forward_no_answer_enabled, forward_no_answer_destination, call_timeout
|
return do_not_disturb, forward_all_enabled, forward_all_destination, forward_busy_enabled, forward_busy_destination, forward_no_answer_enabled, forward_no_answer_destination, call_timeout
|
||||||
end
|
end
|
||||||
|
|
||||||
function feature_event_notify.get_profile(user, host)
|
---@return table, nil
|
||||||
|
function feature_event_notify.get_profiles(user, domain)
|
||||||
--includes
|
--includes
|
||||||
require "resources.functions.explode"
|
|
||||||
require "resources.functions.trim"
|
require "resources.functions.trim"
|
||||||
|
|
||||||
local account = user.."@"..host
|
local account = user.."@"..domain
|
||||||
--create the api object
|
--create the api object
|
||||||
api = freeswitch.API();
|
api = freeswitch.API();
|
||||||
local sofia_contact = trim(api:executeString("sofia_contact */"..account));
|
local sofia_contact = trim(api:executeString("sofia_contact */"..account));
|
||||||
local array = explode("/", sofia_contact);
|
--get all profiles for the user account
|
||||||
local sip_profile = array[2];
|
local profile_iterator = string.gmatch(sofia_contact, "sofia/([^,]+)/[^,]+");
|
||||||
return sip_profile
|
|
||||||
|
--remove any duplicates and check if we have any profiles
|
||||||
|
local unique_profiles = {}
|
||||||
|
local has_profile = false
|
||||||
|
for profile in profile_iterator do
|
||||||
|
has_profile = true
|
||||||
|
unique_profiles[profile] = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
-- return nil if we have no profiles
|
||||||
|
if not has_profile then return nil end
|
||||||
|
|
||||||
|
return unique_profiles
|
||||||
end
|
end
|
||||||
|
|
||||||
function feature_event_notify.dnd(user, host, sip_profile, do_not_disturb)
|
|
||||||
--set the event and send it
|
function feature_event_notify.dnd(user, host, sip_profiles, do_not_disturb)
|
||||||
|
--set the event and send it to each profile
|
||||||
|
for sip_profile, _ in pairs(sip_profiles) do
|
||||||
local event = freeswitch.Event("SWITCH_EVENT_PHONE_FEATURE")
|
local event = freeswitch.Event("SWITCH_EVENT_PHONE_FEATURE")
|
||||||
event:addHeader("profile", sip_profile)
|
event:addHeader("profile", sip_profile)
|
||||||
event:addHeader("user", user)
|
event:addHeader("user", user)
|
||||||
@@ -83,10 +97,12 @@ function feature_event_notify.dnd(user, host, sip_profile, do_not_disturb)
|
|||||||
local socket = require 'socket'
|
local socket = require 'socket'
|
||||||
socket.sleep(0.2)
|
socket.sleep(0.2)
|
||||||
event:fire()
|
event:fire()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function feature_event_notify.forward_immediate(user, host, sip_profile, forward_immediate_enabled, forward_immediate_destination)
|
function feature_event_notify.forward_immediate(user, host, sip_profiles, forward_immediate_enabled, forward_immediate_destination)
|
||||||
--set the event and send it
|
--set the event and send it to each profile
|
||||||
|
for sip_profile, _ in pairs(sip_profiles) do
|
||||||
local event = freeswitch.Event("SWITCH_EVENT_PHONE_FEATURE")
|
local event = freeswitch.Event("SWITCH_EVENT_PHONE_FEATURE")
|
||||||
event:addHeader("profile", sip_profile)
|
event:addHeader("profile", sip_profile)
|
||||||
event:addHeader("user", user)
|
event:addHeader("user", user)
|
||||||
@@ -99,10 +115,12 @@ function feature_event_notify.forward_immediate(user, host, sip_profile, forward
|
|||||||
local socket = require 'socket'
|
local socket = require 'socket'
|
||||||
socket.sleep(0.2)
|
socket.sleep(0.2)
|
||||||
event:fire()
|
event:fire()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function feature_event_notify.forward_busy(user, host, sip_profile, forward_busy_enabled, forward_busy_destination)
|
function feature_event_notify.forward_busy(user, host, sip_profiles, forward_busy_enabled, forward_busy_destination)
|
||||||
--set the event and send it
|
--set the event and send it to each profile
|
||||||
|
for sip_profile, _ in pairs(sip_profiles) do
|
||||||
local event = freeswitch.Event("SWITCH_EVENT_PHONE_FEATURE")
|
local event = freeswitch.Event("SWITCH_EVENT_PHONE_FEATURE")
|
||||||
event:addHeader("profile", sip_profile)
|
event:addHeader("profile", sip_profile)
|
||||||
event:addHeader("user", user)
|
event:addHeader("user", user)
|
||||||
@@ -114,10 +132,12 @@ function feature_event_notify.forward_busy(user, host, sip_profile, forward_busy
|
|||||||
local socket = require 'socket'
|
local socket = require 'socket'
|
||||||
socket.sleep(0.2)
|
socket.sleep(0.2)
|
||||||
event:fire()
|
event:fire()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function feature_event_notify.forward_no_answer(user, host, sip_profile, forward_no_answer_enabled, forward_no_answer_destination, ring_count)
|
function feature_event_notify.forward_no_answer(user, host, sip_profiles, forward_no_answer_enabled, forward_no_answer_destination, ring_count)
|
||||||
--set the event and send it
|
--set the event and send it to each profile
|
||||||
|
for sip_profile, _ in pairs(sip_profiles) do
|
||||||
local event = freeswitch.Event("SWITCH_EVENT_PHONE_FEATURE")
|
local event = freeswitch.Event("SWITCH_EVENT_PHONE_FEATURE")
|
||||||
event:addHeader("profile", sip_profile)
|
event:addHeader("profile", sip_profile)
|
||||||
event:addHeader("user", user)
|
event:addHeader("user", user)
|
||||||
@@ -130,10 +150,12 @@ function feature_event_notify.forward_no_answer(user, host, sip_profile, forward
|
|||||||
local socket = require 'socket'
|
local socket = require 'socket'
|
||||||
socket.sleep(0.2)
|
socket.sleep(0.2)
|
||||||
event:fire()
|
event:fire()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function feature_event_notify.init(user, host, sip_profile, forward_immediate_enabled, forward_immediate_destination, forward_busy_enabled, forward_busy_destination, forward_no_answer_enabled, forward_no_answer_destination, ring_count, do_not_disturb)
|
function feature_event_notify.init(user, host, sip_profiles, forward_immediate_enabled, forward_immediate_destination, forward_busy_enabled, forward_busy_destination, forward_no_answer_enabled, forward_no_answer_destination, ring_count, do_not_disturb)
|
||||||
--set the event and send it
|
--set the event and send it to each profile
|
||||||
|
for sip_profile, _ in pairs(sip_profiles) do
|
||||||
local event = freeswitch.Event("SWITCH_EVENT_PHONE_FEATURE")
|
local event = freeswitch.Event("SWITCH_EVENT_PHONE_FEATURE")
|
||||||
event:addHeader("profile", sip_profile)
|
event:addHeader("profile", sip_profile)
|
||||||
event:addHeader("user", user)
|
event:addHeader("user", user)
|
||||||
@@ -153,6 +175,7 @@ function feature_event_notify.init(user, host, sip_profile, forward_immediate_en
|
|||||||
local socket = require 'socket'
|
local socket = require 'socket'
|
||||||
socket.sleep(0.2)
|
socket.sleep(0.2)
|
||||||
event:fire()
|
event:fire()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return feature_event_notify
|
return feature_event_notify
|
||||||
|
|||||||
@@ -262,14 +262,14 @@
|
|||||||
|
|
||||||
-- Get the sip_profile
|
-- Get the sip_profile
|
||||||
if (extension ~= nil and domain_name ~= nil) then
|
if (extension ~= nil and domain_name ~= nil) then
|
||||||
sip_profile = notify.get_profile(extension, domain_name);
|
sip_profiles = notify.get_profiles(extension, domain_name);
|
||||||
end
|
end
|
||||||
|
|
||||||
if (sip_profile ~= nil) then
|
if (sip_profiles ~= nil) then
|
||||||
freeswitch.consoleLog("NOTICE", "[feature_event] SIP NOTIFY: CFWD set to "..forward_all_enabled.."\n");
|
freeswitch.consoleLog("NOTICE", "[feature_event] SIP NOTIFY: CFWD set to "..forward_all_enabled.."\n");
|
||||||
|
|
||||||
--Do Not Disturb
|
--Do Not Disturb
|
||||||
notify.dnd(extension, domain_name, sip_profile, do_not_disturb);
|
notify.dnd(extension, domain_name, sip_profiles, do_not_disturb);
|
||||||
|
|
||||||
--Forward all
|
--Forward all
|
||||||
forward_immediate_enabled = forward_all_enabled;
|
forward_immediate_enabled = forward_all_enabled;
|
||||||
@@ -281,7 +281,7 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
freeswitch.consoleLog("NOTICE", "[feature_event] forward_immediate_destination "..forward_immediate_destination.."\n");
|
freeswitch.consoleLog("NOTICE", "[feature_event] forward_immediate_destination "..forward_immediate_destination.."\n");
|
||||||
notify.forward_immediate(extension, domain_name, sip_profile, forward_immediate_enabled, forward_immediate_destination);
|
notify.forward_immediate(extension, domain_name, sip_profiles, forward_immediate_enabled, forward_immediate_destination);
|
||||||
|
|
||||||
--Forward busy
|
--Forward busy
|
||||||
--workaround for freeswitch not sending NOTIFY when destination values are nil. Send 0.
|
--workaround for freeswitch not sending NOTIFY when destination values are nil. Send 0.
|
||||||
@@ -290,7 +290,7 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
freeswitch.consoleLog("NOTICE", "[feature_event] forward_busy_destination "..forward_busy_destination.."\n");
|
freeswitch.consoleLog("NOTICE", "[feature_event] forward_busy_destination "..forward_busy_destination.."\n");
|
||||||
notify.forward_busy(extension, domain_name, sip_profile, forward_busy_enabled, forward_busy_destination);
|
notify.forward_busy(extension, domain_name, sip_profiles, forward_busy_enabled, forward_busy_destination);
|
||||||
|
|
||||||
--Forward No Answer
|
--Forward No Answer
|
||||||
ring_count = math.ceil (call_timeout / 6);
|
ring_count = math.ceil (call_timeout / 6);
|
||||||
@@ -300,7 +300,7 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
freeswitch.consoleLog("NOTICE", "[feature_event] forward_no_answer_destination "..forward_no_answer_destination.."\n");
|
freeswitch.consoleLog("NOTICE", "[feature_event] forward_no_answer_destination "..forward_no_answer_destination.."\n");
|
||||||
notify.forward_no_answer(extension, domain_name, sip_profile, forward_no_answer_enabled, forward_no_answer_destination, ring_count);
|
notify.forward_no_answer(extension, domain_name, sip_profiles, forward_no_answer_enabled, forward_no_answer_destination, ring_count);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -227,15 +227,15 @@
|
|||||||
|
|
||||||
-- Get the sip_profile
|
-- Get the sip_profile
|
||||||
if (extension ~= nil and domain_name ~= nil) then
|
if (extension ~= nil and domain_name ~= nil) then
|
||||||
sip_profile = notify.get_profile(extension, domain_name);
|
sip_profiles = notify.get_profiles(extension, domain_name);
|
||||||
end
|
end
|
||||||
|
|
||||||
-- check if not nil
|
-- check if not nil
|
||||||
if (sip_profile ~= nil) then
|
if (sip_profiles ~= nil) then
|
||||||
freeswitch.consoleLog("NOTICE", "[feature_event] SIP NOTIFY: CFWD set to "..forward_all_enabled.."\n");
|
freeswitch.consoleLog("NOTICE", "[feature_event] SIP NOTIFY: CFWD set to "..forward_all_enabled.."\n");
|
||||||
|
|
||||||
--Do Not Disturb
|
--Do Not Disturb
|
||||||
notify.dnd(extension, domain_name, sip_profile, do_not_disturb);
|
notify.dnd(extension, domain_name, sip_profiles, do_not_disturb);
|
||||||
|
|
||||||
--Forward all
|
--Forward all
|
||||||
forward_immediate_enabled = forward_all_enabled;
|
forward_immediate_enabled = forward_all_enabled;
|
||||||
@@ -246,7 +246,7 @@
|
|||||||
forward_immediate_destination = '0';
|
forward_immediate_destination = '0';
|
||||||
end
|
end
|
||||||
|
|
||||||
notify.forward_immediate(extension, domain_name, sip_profile, forward_immediate_enabled, forward_immediate_destination);
|
notify.forward_immediate(extension, domain_name, sip_profiles, forward_immediate_enabled, forward_immediate_destination);
|
||||||
|
|
||||||
--Forward busy
|
--Forward busy
|
||||||
--workaround for freeswitch not sending NOTIFY when destination values are nil. Send 0.
|
--workaround for freeswitch not sending NOTIFY when destination values are nil. Send 0.
|
||||||
@@ -254,7 +254,7 @@
|
|||||||
forward_busy_destination = '0';
|
forward_busy_destination = '0';
|
||||||
end
|
end
|
||||||
|
|
||||||
notify.forward_busy(extension, domain_name, sip_profile, forward_busy_enabled, forward_busy_destination);
|
notify.forward_busy(extension, domain_name, sip_profiles, forward_busy_enabled, forward_busy_destination);
|
||||||
|
|
||||||
--Forward No Answer
|
--Forward No Answer
|
||||||
ring_count = math.ceil (call_timeout / 6);
|
ring_count = math.ceil (call_timeout / 6);
|
||||||
@@ -263,7 +263,7 @@
|
|||||||
forward_no_answer_destination = '0';
|
forward_no_answer_destination = '0';
|
||||||
end
|
end
|
||||||
|
|
||||||
notify.forward_no_answer(extension, domain_name, sip_profile, forward_no_answer_enabled, forward_no_answer_destination, ring_count);
|
notify.forward_no_answer(extension, domain_name, sip_profiles, forward_no_answer_enabled, forward_no_answer_destination, ring_count);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -267,6 +267,10 @@
|
|||||||
echo " </td>\n";
|
echo " </td>\n";
|
||||||
echo " <td class='no-link center'>\n";
|
echo " <td class='no-link center'>\n";
|
||||||
echo " <a href='".PROJECT_PATH."/core/domains/domains.php?domain_uuid=".escape($row['domain_uuid'])."&domain_change=true'>".$text['label-manage']."</a>";
|
echo " <a href='".PROJECT_PATH."/core/domains/domains.php?domain_uuid=".escape($row['domain_uuid'])."&domain_change=true'>".$text['label-manage']."</a>";
|
||||||
|
if (permission_exists('domain_setting_view')) {
|
||||||
|
$list_setting_url = PROJECT_PATH."/core/domain_settings/domain_settings.php?id=".urlencode($row['domain_uuid']);
|
||||||
|
echo " | <a href='".$list_setting_url."'\">".$text['button-settings'];
|
||||||
|
}
|
||||||
echo " </td>\n";
|
echo " </td>\n";
|
||||||
if (permission_exists('domain_edit')) {
|
if (permission_exists('domain_edit')) {
|
||||||
echo " <td class='no-link center'>\n";
|
echo " <td class='no-link center'>\n";
|
||||||
|
|||||||
@@ -94,8 +94,15 @@
|
|||||||
//get the count
|
//get the count
|
||||||
$sql = "select count(user_log_uuid) ";
|
$sql = "select count(user_log_uuid) ";
|
||||||
$sql .= "from v_user_logs ";
|
$sql .= "from v_user_logs ";
|
||||||
|
if (permission_exists('user_log_all') && $_GET['show'] == 'all') {
|
||||||
|
$sql .= "where true ";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||||
|
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||||
|
}
|
||||||
if (isset($search)) {
|
if (isset($search)) {
|
||||||
$sql .= "where (";
|
$sql .= "and (";
|
||||||
$sql .= " lower(username) like :search ";
|
$sql .= " lower(username) like :search ";
|
||||||
$sql .= " or lower(type) like :search ";
|
$sql .= " or lower(type) like :search ";
|
||||||
$sql .= " or lower(result) like :search ";
|
$sql .= " or lower(result) like :search ";
|
||||||
@@ -104,13 +111,6 @@
|
|||||||
$sql .= ") ";
|
$sql .= ") ";
|
||||||
$parameters['search'] = '%'.$search.'%';
|
$parameters['search'] = '%'.$search.'%';
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
|
||||||
if (isset($sql_search)) {
|
|
||||||
$sql .= "and ".$sql_search;
|
|
||||||
}
|
|
||||||
$parameters['domain_uuid'] = $domain_uuid;
|
|
||||||
}
|
|
||||||
$database = new database;
|
$database = new database;
|
||||||
$num_rows = $database->select($sql, $parameters, 'column');
|
$num_rows = $database->select($sql, $parameters, 'column');
|
||||||
unset($sql, $parameters);
|
unset($sql, $parameters);
|
||||||
@@ -135,8 +135,15 @@
|
|||||||
$sql .= "remote_address, ";
|
$sql .= "remote_address, ";
|
||||||
$sql .= "user_agent ";
|
$sql .= "user_agent ";
|
||||||
$sql .= "from v_user_logs ";
|
$sql .= "from v_user_logs ";
|
||||||
if (isset($_GET["search"])) {
|
if (permission_exists('user_log_all') && $_GET['show'] == 'all') {
|
||||||
$sql .= "where (";
|
$sql .= "where true ";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||||
|
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||||
|
}
|
||||||
|
if (isset($search)) {
|
||||||
|
$sql .= "and ( ";
|
||||||
$sql .= " lower(username) like :search ";
|
$sql .= " lower(username) like :search ";
|
||||||
$sql .= " or lower(type) like :search ";
|
$sql .= " or lower(type) like :search ";
|
||||||
$sql .= " or lower(result) like :search ";
|
$sql .= " or lower(result) like :search ";
|
||||||
|
|||||||
@@ -834,6 +834,8 @@ remote_phonebook.data.4.url = {$yealink_remote_phonebook_4_url}
|
|||||||
remote_phonebook.data.5.name = {$yealink_remote_phonebook_5_name}
|
remote_phonebook.data.5.name = {$yealink_remote_phonebook_5_name}
|
||||||
remote_phonebook.data.5.url = {$yealink_remote_phonebook_5_url}
|
remote_phonebook.data.5.url = {$yealink_remote_phonebook_5_url}
|
||||||
|
|
||||||
|
features.remote_phonebook.enable = {$yealink_remote_phonebook_enable}
|
||||||
|
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
## LDAP ##
|
## LDAP ##
|
||||||
@@ -1139,7 +1141,7 @@ features.no_answer_code=
|
|||||||
#######################################################################################
|
#######################################################################################
|
||||||
## DND ##
|
## DND ##
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
features.dnd.allow=
|
features.dnd.allow= {$yealink_dnd_allow}
|
||||||
features.dnd_mode=
|
features.dnd_mode=
|
||||||
features.dnd.enable=
|
features.dnd.enable=
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user