mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Add Device Feature Sync (#2905)
* Update lua.conf.xml Hook the feature_event lua script to Freeswitch "PHONE_FEATURE_SUBSCRIBE" events. * Create index.lua * Create feature_event_notify.lua * Update call_forward.lua Add trigger for feature sync. * Update do_not_disturb.lua Add trigger for feature sync. * Update call_edit.php * Create feature_event_notify.php * Update index.lua disable logging
This commit is contained in:
@@ -326,6 +326,40 @@
|
||||
}
|
||||
}
|
||||
|
||||
//send feature event notify to the phone
|
||||
if ($_SESSION['device']['feature_sync']['boolean'] == "true") {
|
||||
$ring_count = ceil($call_timeout / 6);
|
||||
$feature_event_notify = new feature_event_notify;
|
||||
$feature_event_notify->domain_name = $_SESSION['domain_name'];
|
||||
$feature_event_notify->extension = $extension;
|
||||
$feature_event_notify->do_not_disturb = $dnd_enabled;
|
||||
$feature_event_notify->ring_count = $ring_count;
|
||||
$feature_event_notify->forward_all_enabled = $forward_all_enabled;
|
||||
$feature_event_notify->forward_busy_enabled = $forward_busy_enabled;
|
||||
$feature_event_notify->forward_no_answer_enabled = $forward_no_answer_enabled;
|
||||
//workaround for freeswitch not sending NOTIFY when destination values are nil. Send 0.
|
||||
if ($forward_all_destination == "") {
|
||||
$feature_event_notify->forward_all_destination = "0";
|
||||
} else {
|
||||
$feature_event_notify->forward_all_destination = $forward_all_destination;
|
||||
}
|
||||
|
||||
if ($forward_busy_destination == "") {
|
||||
$feature_event_notify->forward_busy_destination = "0";
|
||||
} else {
|
||||
$feature_event_notify->forward_busy_destination = $forward_busy_destination;
|
||||
}
|
||||
|
||||
if ($forward_no_answer_destination == "") {
|
||||
$feature_event_notify->forward_no_answer_destination = "0";
|
||||
} else {
|
||||
$feature_event_notify->forward_no_answer_destination = $forward_no_answer_destination;
|
||||
}
|
||||
|
||||
$feature_event_notify->send_notify();
|
||||
unset($feature_event_notify);
|
||||
}
|
||||
|
||||
//synchronize configuration
|
||||
if (is_readable($_SESSION['switch']['extensions']['dir'])) {
|
||||
require_once "app/extensions/resources/classes/extension.php";
|
||||
|
||||
82
app/calls/resources/classes/feature_event_notify.php
Normal file
82
app/calls/resources/classes/feature_event_notify.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2017
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
KonradSC <konrd@yahoo.com>
|
||||
*/
|
||||
include "root.php";
|
||||
|
||||
//define the feature_event_notify class
|
||||
class feature_event_notify {
|
||||
|
||||
public $debug;
|
||||
public $domain_name;
|
||||
public $extension;
|
||||
public $forward_all_destination;
|
||||
public $forward_all_enabled;
|
||||
public $forward_busy_destination;
|
||||
public $forward_busy_enabled;
|
||||
public $forward_no_answer_destination;
|
||||
public $forward_no_answer_enabled;
|
||||
public $do_not_disturb;
|
||||
public $ring_count;
|
||||
|
||||
//feature_event method
|
||||
public function send_notify() {
|
||||
|
||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||
if ($fp) {
|
||||
//get the sip profile name
|
||||
$command = "sofia_contact */".$this->extension."@".$this->domain_name;
|
||||
$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';
|
||||
}
|
||||
//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);
|
||||
}
|
||||
} //function
|
||||
|
||||
} //class
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user