Add a missing file sip_profile_copy.php to the dev branch.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
class array_order {
|
||||
|
||||
var $sort_fields;
|
||||
var $backwards = false;
|
||||
var $numeric = false;
|
||||
|
||||
function sort() {
|
||||
$args = func_get_args();
|
||||
$array = $args[0];
|
||||
if (!$array) return array();
|
||||
$this->sort_fields = array_slice($args, 1);
|
||||
if (!$this->sort_fields) return $array();
|
||||
|
||||
if ($this->numeric) {
|
||||
usort($array, array($this, 'numericCompare'));
|
||||
} else {
|
||||
usort($array, array($this, 'stringCompare'));
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
function numericCompare($a, $b) {
|
||||
foreach($this->sort_fields as $sort_field) {
|
||||
if ($a[$sort_field] == $b[$sort_field]) {
|
||||
continue;
|
||||
}
|
||||
return ($a[$sort_field] < $b[$sort_field]) ? ($this->backwards ? 1 : -1) : ($this->backwards ? -1 : 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function stringCompare($a, $b) {
|
||||
foreach($this->sort_fields as $sort_field) {
|
||||
$cmp_result = strcasecmp($a[$sort_field], $b[$sort_field]);
|
||||
if ($cmp_result == 0) continue;
|
||||
return ($this->backwards ? -$cmp_result : $cmp_result);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//$order = new array_order();
|
||||
//$registrations = $order->sort($registrations, 'domain', 'user');
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,195 @@
|
||||
<?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>
|
||||
Copyright (C) 2010
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
|
||||
//define the call_forward class
|
||||
class call_forward {
|
||||
public $domain_uuid;
|
||||
public $db_type;
|
||||
public $call_forward_uuid;
|
||||
public $extension;
|
||||
public $call_forward_enabled;
|
||||
public $call_forward_number;
|
||||
|
||||
public function call_forward_add() {
|
||||
global $db;
|
||||
$hunt_group_extension = $this->extension;
|
||||
$huntgroup_name = 'call_forward_'.$this->extension;
|
||||
$hunt_group_type = 'call_forward';
|
||||
$hunt_group_context = $_SESSION['context'];
|
||||
$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->call_forward_enabled;
|
||||
$hunt_group_description = 'call forward '.$this->extension;
|
||||
|
||||
$sql = "insert into v_hunt_groups ";
|
||||
$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 .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'$this->domain_uuid', ";
|
||||
$sql .= "'".$this->call_forward_uuid."', ";
|
||||
$sql .= "'$hunt_group_extension', ";
|
||||
$sql .= "'$huntgroup_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 .= ")";
|
||||
if ($v_debug) {
|
||||
echo "add: ".$sql."<br />";
|
||||
}
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
$this->call_forward_destination();
|
||||
}
|
||||
|
||||
public function call_forward_update() {
|
||||
global $db;
|
||||
$hunt_group_extension = $this->extension;
|
||||
$huntgroup_name = 'call_forward_'.$this->extension;
|
||||
$hunt_group_type = 'call_forward';
|
||||
$hunt_group_context = $_SESSION['context'];
|
||||
$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->call_forward_enabled;
|
||||
$hunt_group_description = 'call forward '.$this->extension;
|
||||
|
||||
$sql = "update v_hunt_groups set ";
|
||||
$sql .= "hunt_group_extension = '$hunt_group_extension', ";
|
||||
$sql .= "hunt_group_name = '$huntgroup_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 = '$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 .= "where domain_uuid = '$this->domain_uuid' ";
|
||||
$sql .= "and hunt_group_uuid = '$this->call_forward_uuid' ";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
$this->call_forward_destination();
|
||||
} //end function
|
||||
|
||||
public function call_forward_destination() {
|
||||
global $db;
|
||||
//delete related v_hunt_group_destinations
|
||||
$sql = "delete from v_hunt_group_destinations where hunt_group_uuid = '$this->call_forward_uuid' ";
|
||||
$db->exec(check_sql($sql));
|
||||
//check whether the number is an extension or external number
|
||||
if (strlen($this->call_forward_number) > 7) {
|
||||
$destination_type = 'sip uri';
|
||||
$destination_profile = '';
|
||||
}
|
||||
else {
|
||||
$destination_type = 'extension';
|
||||
$destination_profile = 'internal';
|
||||
}
|
||||
//prepare the variables
|
||||
$destination_data = $this->call_forward_number;
|
||||
$destination_timeout = '';
|
||||
$destination_order = '1';
|
||||
$destination_enabled = 'true';
|
||||
$destination_description = 'call forward';
|
||||
//add the hunt group destination
|
||||
if ($this->call_forward_uuid) {
|
||||
$sql = "insert into v_hunt_group_destinations ";
|
||||
$sql .= "(";
|
||||
$sql .= "hunt_group_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 .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".uuid()."', ";
|
||||
$sql .= "'$this->domain_uuid', ";
|
||||
$sql .= "'$this->call_forward_uuid', ";
|
||||
$sql .= "'$destination_data', ";
|
||||
$sql .= "'$destination_type', ";
|
||||
$sql .= "'$destination_profile', ";
|
||||
$sql .= "'$destination_timeout', ";
|
||||
$sql .= "'$destination_order', ";
|
||||
$sql .= "'$destination_enabled', ";
|
||||
$sql .= "'$destination_description' ";
|
||||
$sql .= ")";
|
||||
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
}
|
||||
} //end function
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,469 @@
|
||||
<?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>
|
||||
Copyright (C) 2010
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
|
||||
//define the database class
|
||||
if (!class_exists('database')) {
|
||||
class database {
|
||||
public $db;
|
||||
public $result;
|
||||
public $type;
|
||||
public $table;
|
||||
public $where; //array
|
||||
public $order_by; //array
|
||||
public $order_type;
|
||||
public $limit;
|
||||
public $offset;
|
||||
public $fields;
|
||||
public $count;
|
||||
public $sql;
|
||||
|
||||
public function connect() {
|
||||
//include config.php
|
||||
include "root.php";
|
||||
include "includes/config.php";
|
||||
|
||||
//set defaults
|
||||
if (isset($db_type) > 0) { $this->db_type = $db_type; }
|
||||
if (isset($db_host) > 0) { $this->db_host = $db_host; }
|
||||
if (isset($db_port) > 0) { $this->db_port = $db_port; }
|
||||
if (isset($db_name) > 0) { $this->db_name = $db_name; }
|
||||
if (isset($db_username) > 0) { $this->db_username = $db_username; }
|
||||
if (isset($db_password) > 0) { $this->db_password = $db_password; }
|
||||
if (isset($db_path) > 0) { $this->db_path = $db_path; }
|
||||
if (isset($db_name) > 0) { $this->db_name = $db_name; }
|
||||
|
||||
//backwards compatibility
|
||||
if (isset($dbtype) > 0) { $db_type = $dbtype; }
|
||||
if (isset($dbhost) > 0) { $db_host = $dbhost; }
|
||||
if (isset($dbport) > 0) { $db_port = $dbport; }
|
||||
if (isset($dbname) > 0) { $db_name = $dbname; }
|
||||
if (isset($dbusername) > 0) { $db_username = $dbusername; }
|
||||
if (isset($dbpassword) > 0) { $db_password = $dbpassword; }
|
||||
if (isset($dbfilepath) > 0) { $db_path = $db_file_path; }
|
||||
if (isset($dbfilename) > 0) { $db_name = $dbfilename; }
|
||||
|
||||
if ($this->db_type == "sqlite") {
|
||||
if (strlen($this->db_name) == 0) {
|
||||
$server_name = $_SERVER["SERVER_NAME"];
|
||||
$server_name = str_replace ("www.", "", $server_name);
|
||||
$db_name_short = $server_name;
|
||||
$this->db_name = $server_name.'.db';
|
||||
}
|
||||
else {
|
||||
$db_name_short = $this->db_name;
|
||||
}
|
||||
$this->db_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure';
|
||||
$this->db_path = realpath($this->db_path);
|
||||
if (file_exists($this->db_path.'/'.$this->db_name)) {
|
||||
//echo "main file exists<br>";
|
||||
}
|
||||
else {
|
||||
$file_name = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/sql/sqlite.sql';
|
||||
$file_contents = file_get_contents($file_name);
|
||||
try {
|
||||
//$db = new PDO('sqlite2:example.db'); //sqlite 2
|
||||
//$db = new PDO('sqlite::memory:'); //sqlite 3
|
||||
$db = new PDO('sqlite:'.$this->db_path.'/'.$this->db_name); //sqlite 3
|
||||
$db->beginTransaction();
|
||||
}
|
||||
catch (PDOException $error) {
|
||||
print "error: " . $error->getMessage() . "<br/>";
|
||||
die();
|
||||
}
|
||||
|
||||
//replace \r\n with \n then explode on \n
|
||||
$file_contents = str_replace("\r\n", "\n", $file_contents);
|
||||
|
||||
//loop line by line through all the lines of sql code
|
||||
$stringarray = explode("\n", $file_contents);
|
||||
$x = 0;
|
||||
foreach($stringarray as $sql) {
|
||||
try {
|
||||
$db->query($sql);
|
||||
}
|
||||
catch (PDOException $error) {
|
||||
echo "error: " . $error->getMessage() . " sql: $sql<br/>";
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
unset ($file_contents, $sql);
|
||||
$db->commit();
|
||||
|
||||
if (is_writable($this->db_path.'/'.$this->db_name)) {
|
||||
//is writable - use database in current location
|
||||
}
|
||||
else {
|
||||
//not writable
|
||||
echo "The database ".$this->db_path."/".$this->db_name." is not writeable.";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
try {
|
||||
//$db = new PDO('sqlite2:example.db'); //sqlite 2
|
||||
//$db = new PDO('sqlite::memory:'); //sqlite 3
|
||||
$this->db = new PDO('sqlite:'.$this->db_path.'/'.$this->db_name); //sqlite 3
|
||||
|
||||
//add additional functions to SQLite so that they are accessible inside SQL
|
||||
//bool PDO::sqliteCreateFunction ( string function_name, callback callback [, int num_args] )
|
||||
$this->db->sqliteCreateFunction('md5', 'php_md5', 1);
|
||||
$this->db->sqliteCreateFunction('unix_timestamp', 'php_unix_time_stamp', 1);
|
||||
$this->db->sqliteCreateFunction('now', 'php_now', 0);
|
||||
$this->db->sqliteCreateFunction('str_left', 'php_left', 2);
|
||||
$this->db->sqliteCreateFunction('str_right', 'php_right', 2);
|
||||
}
|
||||
catch (PDOException $error) {
|
||||
print "error: " . $error->getMessage() . "<br/>";
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->db_type == "mysql") {
|
||||
try {
|
||||
//required for mysql_real_escape_string
|
||||
if (function_exists(mysql_connect)) {
|
||||
$mysql_connection = mysql_connect($this->db_host, $this->db_username, $this->db_password);
|
||||
}
|
||||
//mysql pdo connection
|
||||
if (strlen($this->db_host) == 0 && strlen($this->db_port) == 0) {
|
||||
//if both host and port are empty use the unix socket
|
||||
$this->db = new PDO("mysql:host=$this->db_host;unix_socket=/var/run/mysqld/mysqld.sock;dbname=$this->db_name", $this->db_username, $this->db_password);
|
||||
}
|
||||
else {
|
||||
if (strlen($this->db_port) == 0) {
|
||||
//leave out port if it is empty
|
||||
$this->db = new PDO("mysql:host=$this->db_host;dbname=$this->db_name;", $this->db_username, $this->db_password, array(
|
||||
PDO::ATTR_ERRMODE,
|
||||
PDO::ERRMODE_EXCEPTION
|
||||
));
|
||||
}
|
||||
else {
|
||||
$this->db = new PDO("mysql:host=$this->db_host;port=$this->db_port;dbname=$this->db_name;", $this->db_username, $this->db_password, array(
|
||||
PDO::ATTR_ERRMODE,
|
||||
PDO::ERRMODE_EXCEPTION
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (PDOException $error) {
|
||||
print "error: " . $error->getMessage() . "<br/>";
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->db_type == "pgsql") {
|
||||
//database connection
|
||||
try {
|
||||
if (strlen($this->db_host) > 0) {
|
||||
if (strlen($this->db_port) == 0) { $this->db_port = "5432"; }
|
||||
$this->db = new PDO("pgsql:host=$this->db_host port=$this->db_port dbname=$this->db_name user=$this->db_username password=$this->db_password");
|
||||
}
|
||||
else {
|
||||
$this->db = new PDO("pgsql:dbname=$this->db_name user=$this->db_username password=$this->db_password");
|
||||
}
|
||||
}
|
||||
catch (PDOException $error) {
|
||||
print "error: " . $error->getMessage() . "<br/>";
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//public function disconnect() {
|
||||
// return null;
|
||||
//}
|
||||
|
||||
public function find() {
|
||||
//connect;
|
||||
//table;
|
||||
//where;
|
||||
//order_by;
|
||||
//limit;
|
||||
//offset;
|
||||
|
||||
//connect to the database if needed
|
||||
if (!$this->db) {
|
||||
$this->connect();
|
||||
}
|
||||
//get data from the database
|
||||
$sql = "";
|
||||
$sql .= " select * from ".$this->table." ";
|
||||
if ($this->where) {
|
||||
$i = 0;
|
||||
foreach($this->where as $row) {
|
||||
if ($i == 0) {
|
||||
$sql .= 'where '.$row['name']." ".$row['operator']." '".$row['value']."' ";
|
||||
}
|
||||
else {
|
||||
$sql .= "and ".$row['name']." ".$row['operator']." '".$row['value']."' ";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
if ($this->order_by) {
|
||||
$sql .= "order by ";
|
||||
$i = 1;
|
||||
foreach($this->order_by as $row) {
|
||||
if (count($this->order_by) == $i) {
|
||||
$sql .= $row['name']." ";
|
||||
}
|
||||
else {
|
||||
$sql .= $row['name'].", ";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
if ($this->order_type) {
|
||||
$sql .= $this->order_type." ";
|
||||
}
|
||||
}
|
||||
if ($this->limit) {
|
||||
$sql .= " limit ".$this->limit." offset ".$this->offset." ";
|
||||
}
|
||||
//echo $sql;
|
||||
$prep_statement = $this->db->prepare($sql);
|
||||
if ($prep_statement) {
|
||||
$prep_statement->execute();
|
||||
return $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function add(){
|
||||
//connect to the database if needed
|
||||
if (!$this->db) {
|
||||
$this->connect();
|
||||
}
|
||||
//add data to the database
|
||||
$sql = "insert into ".$this->table;
|
||||
$sql .= "(";
|
||||
$i = 1;
|
||||
foreach($this->fields as $name => $value) {
|
||||
if (count($this->fields) == $i) {
|
||||
$sql .= $name." ";
|
||||
}
|
||||
else {
|
||||
$sql .= $name.", ";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$sql .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$i = 1;
|
||||
foreach($this->fields as $name => $value) {
|
||||
if (count($this->fields) == $i) {
|
||||
if (strlen($value) > 0) {
|
||||
$sql .= "'".$value."' ";
|
||||
}
|
||||
else {
|
||||
$sql .= "'".$value."' ";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (strlen($value) > 0) {
|
||||
$sql .= "'".$value."', ";
|
||||
}
|
||||
else {
|
||||
$sql .= "null, ";
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$sql .= ")";
|
||||
$this->sql = $sql;
|
||||
$this->db->exec($sql);
|
||||
unset($this->fields);
|
||||
unset($sql);
|
||||
}
|
||||
|
||||
public function update() {
|
||||
//connect to the database if needed
|
||||
if (!$this->db) {
|
||||
$this->connect();
|
||||
}
|
||||
//udate the database
|
||||
$sql = "update ".$this->table." set ";
|
||||
$i = 1;
|
||||
foreach($this->fields as $name => $value) {
|
||||
if (count($this->fields) == $i) {
|
||||
if (strlen($name) > 0 && $value == null) {
|
||||
$sql .= $name." = null ";
|
||||
}
|
||||
else {
|
||||
$sql .= $name." = '".$value."' ";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (strlen($name) > 0 && $value == null) {
|
||||
$sql .= $name." = null, ";
|
||||
}
|
||||
else {
|
||||
$sql .= $name." = '".$value."', ";
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$i = 0;
|
||||
foreach($this->where as $row) {
|
||||
if ($i == 0) {
|
||||
$sql .= 'where '.$row['name']." ".$row['operator']." '".$row['value']."' ";
|
||||
}
|
||||
else {
|
||||
$sql .= "and ".$row['name']." ".$row['operator']." '".$row['value']."' ";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$this->db->exec(check_sql($sql));
|
||||
unset($this->fields);
|
||||
unset($this->where);
|
||||
unset($sql);
|
||||
}
|
||||
|
||||
public function delete(){
|
||||
//connect to the database if needed
|
||||
if (!$this->db) {
|
||||
$this->connect();
|
||||
}
|
||||
//delete from the database
|
||||
$sql = "delete from ".$this->table." ";
|
||||
if ($this->where) {
|
||||
$i = 0;
|
||||
foreach($this->where as $row) {
|
||||
if ($i == 0) {
|
||||
$sql .= "where ".$row['name']." ".$row['operator']." '".$row['value']."' ";
|
||||
}
|
||||
else {
|
||||
$sql .= "and ".$row['name']." ".$row['operator']." '".$row['value']."' ";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
//echo $sql."<br>\n";
|
||||
$prep_statement = $this->db->prepare($sql);
|
||||
$prep_statement->execute();
|
||||
unset($sql);
|
||||
unset($this->where);
|
||||
}
|
||||
|
||||
public function count() {
|
||||
//connect to the database if needed
|
||||
if (!$this->db) {
|
||||
$this->connect();
|
||||
}
|
||||
//get the number of rows
|
||||
$sql = " select count(*) as num_rows from ".$this->table;
|
||||
if ($this->where) {
|
||||
$i = 0;
|
||||
foreach($this->where as $row) {
|
||||
if ($i == 0) {
|
||||
$sql .= "where ".$row['name']." ".$row['operator']." '".$row['value']."' ";
|
||||
}
|
||||
else {
|
||||
$sql .= "and ".$row['name']." ".$row['operator']." '".$row['value']."' ";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
unset($this->where);
|
||||
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||
if ($prep_statement) {
|
||||
$prep_statement->execute();
|
||||
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
||||
if ($row['num_rows'] > 0) {
|
||||
$this->result = $row['num_rows'];
|
||||
}
|
||||
else {
|
||||
$this->result = 0;
|
||||
}
|
||||
}
|
||||
unset($prep_statement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('php_md5')) {
|
||||
function php_md5($string) {
|
||||
return md5($string);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('php_unix_time_stamp')) {
|
||||
function php_unix_time_stamp($string) {
|
||||
return strtotime($string);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('php_now')) {
|
||||
function php_now() {
|
||||
return date("Y-m-d H:i:s");
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('php_left')) {
|
||||
function php_left($string, $num) {
|
||||
return substr($string, 0, $num);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('php_right')) {
|
||||
function php_right($string, $num) {
|
||||
return substr($string, (strlen($string)-$num), strlen($string));
|
||||
}
|
||||
}
|
||||
|
||||
//example usage
|
||||
/*
|
||||
//find
|
||||
require_once "includes/classes/database.php";
|
||||
$database = new database;
|
||||
$database->domain_uuid = $_SESSION["domain_uuid"];
|
||||
$database->type = $db_type;
|
||||
$database->table = "v_extensions";
|
||||
$where[0]['name'] = 'domain_uuid';
|
||||
$where[0]['value'] = $_SESSION["domain_uuid"];
|
||||
$where[0]['operator'] = '=';
|
||||
$database->where = $where;
|
||||
$order_by[0]['name'] = 'extension';
|
||||
$database->order_by = $order_by;
|
||||
$database->order_type = 'desc';
|
||||
$database->limit = '2';
|
||||
$database->offset = '0';
|
||||
$database->find();
|
||||
print_r($database->result);
|
||||
//insert
|
||||
require_once "includes/classes/database.php";
|
||||
$database = new database;
|
||||
$database->domain_uuid = $_SESSION["domain_uuid"];
|
||||
$database->type = $db_type;
|
||||
$database->table = "v_ivr_menus";
|
||||
$fields[0]['name'] = 'domain_uuid';
|
||||
$fields[0]['value'] = $_SESSION["domain_uuid"];
|
||||
$database->add();
|
||||
print_r($database->result);
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,343 @@
|
||||
<?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>
|
||||
Copyright (C) 2010
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
|
||||
//define the dialplan class
|
||||
if (!class_exists('dialplan')) {
|
||||
class dialplan {
|
||||
//variables
|
||||
public $result;
|
||||
public $domain_uuid;
|
||||
public $dialplan_uuid;
|
||||
public $xml;
|
||||
public $json;
|
||||
public $display_type;
|
||||
|
||||
//dialplans
|
||||
public $dialplan_name;
|
||||
public $dialplan_continue;
|
||||
public $dialplan_order;
|
||||
public $dialplan_context;
|
||||
public $dialplan_enabled;
|
||||
public $dialplan_description;
|
||||
|
||||
//dialplan_details
|
||||
public $dialplan_detail_tag;
|
||||
public $dialplan_detail_order;
|
||||
public $dialplan_detail_type;
|
||||
public $dialplan_detail_data;
|
||||
public $dialplan_detail_break;
|
||||
public $dialplan_detail_inline;
|
||||
public $dialplan_detail_group;
|
||||
|
||||
public function dialplan_add() {
|
||||
global $db;
|
||||
$sql = "insert into v_dialplans ";
|
||||
$sql .= "(";
|
||||
$sql .= "domain_uuid, ";
|
||||
$sql .= "app_uuid, ";
|
||||
$sql .= "dialplan_uuid, ";
|
||||
$sql .= "dialplan_name, ";
|
||||
$sql .= "dialplan_continue, ";
|
||||
$sql .= "dialplan_order, ";
|
||||
$sql .= "dialplan_context, ";
|
||||
$sql .= "dialplan_enabled, ";
|
||||
$sql .= "dialplan_description ";
|
||||
$sql .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".check_str($this->domain_uuid)."', ";
|
||||
$sql .= "'".check_str($this->app_uuid)."', ";
|
||||
$sql .= "'".check_str($this->dialplan_uuid)."', ";
|
||||
$sql .= "'".check_str($this->dialplan_name)."', ";
|
||||
$sql .= "'".check_str($this->dialplan_continue)."', ";
|
||||
$sql .= "'".check_str($this->dialplan_order)."', ";
|
||||
$sql .= "'".check_str($this->dialplan_context)."', ";
|
||||
$sql .= "'".check_str($this->dialplan_enabled)."', ";
|
||||
$sql .= "'".check_str($this->dialplan_description)."' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
} //end function
|
||||
|
||||
public function dialplan_update() {
|
||||
global $db;
|
||||
$sql = "update v_dialplans set ";
|
||||
$sql .= "dialplan_name = '".check_str($this->dialplan_name)."', ";
|
||||
if (strlen($this->dialplan_continue) > 0) {
|
||||
$sql .= "dialplan_continue = '".check_str($this->dialplan_continue)."', ";
|
||||
}
|
||||
$sql .= "dialplan_order = '".check_str($this->dialplan_order)."', ";
|
||||
$sql .= "dialplan_context = '".check_str($this->dialplan_context)."', ";
|
||||
$sql .= "dialplan_enabled = '".check_str($this->dialplan_enabled)."', ";
|
||||
$sql .= "dialplan_description = '".check_str($this->dialplan_description)."' ";
|
||||
$sql .= "where domain_uuid = '".check_str($this->domain_uuid)."' ";
|
||||
$sql .= "and dialplan_uuid = '".check_str($this->dialplan_uuid)."' ";
|
||||
//echo "sql: ".$sql."<br />";
|
||||
$db->query($sql);
|
||||
unset($sql);
|
||||
}
|
||||
|
||||
public function dialplan_detail_add() {
|
||||
global $db;
|
||||
$dialplan_detail_uuid = uuid();
|
||||
$sql = "insert into v_dialplan_details ";
|
||||
$sql .= "(";
|
||||
$sql .= "dialplan_detail_uuid, ";
|
||||
$sql .= "domain_uuid, ";
|
||||
$sql .= "dialplan_uuid, ";
|
||||
$sql .= "dialplan_detail_tag, ";
|
||||
$sql .= "dialplan_detail_order, ";
|
||||
$sql .= "dialplan_detail_type, ";
|
||||
$sql .= "dialplan_detail_data, ";
|
||||
$sql .= "dialplan_detail_break, ";
|
||||
$sql .= "dialplan_detail_inline, ";
|
||||
$sql .= "dialplan_detail_group ";
|
||||
$sql .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "( ";
|
||||
$sql .= "'".$dialplan_detail_uuid."', ";
|
||||
$sql .= "'".check_str($this->domain_uuid)."', ";
|
||||
$sql .= "'".check_str($this->dialplan_uuid)."', ";
|
||||
$sql .= "'".check_str($this->dialplan_detail_tag)."', ";
|
||||
$sql .= "'".check_str($this->dialplan_detail_order)."', ";
|
||||
$sql .= "'".check_str($this->dialplan_detail_type)."', ";
|
||||
$sql .= "'".check_str($this->dialplan_detail_data)."', ";
|
||||
if (strlen($this->dialplan_detail_break) == 0) {
|
||||
$sql .= "null, ";
|
||||
}
|
||||
else {
|
||||
$sql .= "'".check_str($this->dialplan_detail_break)."', ";
|
||||
}
|
||||
if (strlen($this->dialplan_detail_inline) == 0) {
|
||||
$sql .= "null, ";
|
||||
}
|
||||
else {
|
||||
$sql .= "'".check_str($this->dialplan_detail_inline)."', ";
|
||||
}
|
||||
if (strlen($this->dialplan_detail_group) == 0) {
|
||||
$sql .= "null ";
|
||||
}
|
||||
else {
|
||||
$sql .= "'".check_str($this->dialplan_detail_group)."' ";
|
||||
}
|
||||
$sql .= ")";
|
||||
//echo $sql."\n\n";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
} //end function
|
||||
|
||||
public function dialplan_detail_update() {
|
||||
global $db;
|
||||
$sql = "update v_dialplans set ";
|
||||
$sql .= "dialplan_detail_order = '".check_str($this->dialplan_detail_order)."', ";
|
||||
$sql .= "dialplan_detail_type = '".check_str($this->dialplan_detail_type)."', ";
|
||||
$sql .= "dialplan_detail_data = '".check_str($this->dialplan_detail_data)."', ";
|
||||
if (strlen($this->dialplan_detail_break) > 0) {
|
||||
$sql .= "dialplan_detail_break = '".check_str($this->dialplan_detail_break)."', ";
|
||||
}
|
||||
if (strlen($this->dialplan_detail_inline) > 0) {
|
||||
$sql .= "dialplan_detail_inline = '".check_str($this->dialplan_detail_inline)."', ";
|
||||
}
|
||||
if (strlen($this->dialplan_detail_group) > 0) {
|
||||
$sql .= "dialplan_detail_group = '".check_str($this->dialplan_detail_group)."', ";
|
||||
}
|
||||
$sql .= "dialplan_detail_tag = '".check_str($this->dialplan_detail_tag)."' ";
|
||||
$sql .= "where domain_uuid = '".check_str($this->domain_uuid)."' ";
|
||||
$sql .= "and dialplan_uuid = '".check_str($this->dialplan_uuid)."' ";
|
||||
//echo "sql: ".$sql."<br />";
|
||||
$db->query($sql);
|
||||
unset($sql);
|
||||
} //end function
|
||||
|
||||
public function restore_advanced_xml() {
|
||||
$switch_dialplan_dir = $this->switch_dialplan_dir;
|
||||
if (is_dir($switch_dialplan_dir)) {
|
||||
//get the contents of the dialplan/default.xml
|
||||
$file_default_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/templates/conf/dialplan/default.xml';
|
||||
$file_default_contents = file_get_contents($file_default_path);
|
||||
//prepare the file contents and the path
|
||||
if (count($_SESSION['domains']) < 2) {
|
||||
//replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number
|
||||
$file_default_contents = str_replace("{v_domain}", 'default', $file_default_contents);
|
||||
//set the file path
|
||||
$file_path = $switch_dialplan_dir.'/default.xml';
|
||||
}
|
||||
else {
|
||||
//replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number
|
||||
$file_default_contents = str_replace("{v_domain}", $_SESSION['domain_name'], $file_default_contents);
|
||||
//set the file path
|
||||
$file_path = $switch_dialplan_dir.'/'.$_SESSION['domain_name'].'.xml';
|
||||
}
|
||||
//write the default dialplan
|
||||
$fh = fopen($file_path,'w') or die('Unable to write to '.$file_path.'. Make sure the path exists and permissons are set correctly.');
|
||||
fwrite($fh, $file_default_contents);
|
||||
fclose($fh);
|
||||
//set the message
|
||||
$this->result['dialplan']['restore']['msg'] = "Default Restored";
|
||||
}
|
||||
}
|
||||
|
||||
private function app_uuid_exists() {
|
||||
global $db;
|
||||
$sql = "select count(*) as num_rows from v_dialplans ";
|
||||
$sql .= "where domain_uuid = '".$this->domain_uuid."' ";
|
||||
$sql .= "and app_uuid = '".$this->app_uuid."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
if ($prep_statement) {
|
||||
$prep_statement->execute();
|
||||
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
||||
if ($row['num_rows'] > 0) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
unset($prep_statement, $result);
|
||||
}
|
||||
|
||||
public function import() {
|
||||
if (strlen($this->xml) > 0) {
|
||||
//convert the xml string to an xml object
|
||||
$xml = simplexml_load_string($this->xml);
|
||||
//convert to json
|
||||
$json = json_encode($xml);
|
||||
//convert to an array
|
||||
$dialplan = json_decode($json, true);
|
||||
}
|
||||
if (strlen($this->json) > 0) {
|
||||
//convert to an array
|
||||
$dialplan = json_decode($json, true);
|
||||
}
|
||||
//ensure the condition array uniform
|
||||
if (!is_array($dialplan['condition'][0])) {
|
||||
$tmp = $dialplan['condition'];
|
||||
unset($dialplan['condition']);
|
||||
$dialplan['condition'][0] = $tmp;
|
||||
}
|
||||
//check if the dialplan app uuid exists
|
||||
$this->app_uuid = $dialplan['@attributes']['app_uuid'];
|
||||
if ($this->app_uuid_exists()) {
|
||||
//dialplan entry already exists do nothing
|
||||
}
|
||||
else {
|
||||
//get the attributes
|
||||
$this->dialplan_uuid = uuid();
|
||||
$this->dialplan_name = $dialplan['@attributes']['name'];
|
||||
if ($this->display_type == "text") {
|
||||
echo " ".$this->dialplan_name.": added\n";
|
||||
}
|
||||
if (strlen($dialplan['@attributes']['continue']) > 0) {
|
||||
$this->dialplan_continue = $dialplan['@attributes']['continue'];
|
||||
}
|
||||
if (strlen($dialplan['@attributes']['enabled']) > 0) {
|
||||
$this->dialplan_enabled = $dialplan['@attributes']['enabled'];
|
||||
}
|
||||
else {
|
||||
$this->dialplan_enabled = "true";
|
||||
}
|
||||
$this->dialplan_description = '';
|
||||
$this->dialplan_add();
|
||||
//loop through the condition array
|
||||
$x = 0;
|
||||
$group = 0;
|
||||
$order = 5;
|
||||
foreach ($dialplan['condition'] as &$row) {
|
||||
unset($this->dialplan_detail_break);
|
||||
unset($this->dialplan_detail_inline);
|
||||
$this->dialplan_detail_tag = 'condition';
|
||||
$this->dialplan_detail_type = $row['@attributes']['field'];
|
||||
$this->dialplan_detail_data = $row['@attributes']['expression'];
|
||||
$this->dialplan_detail_group = $group;
|
||||
$this->dialplan_detail_order = $order;
|
||||
if (strlen($row['@attributes']['break']) > 0) {
|
||||
$this->dialplan_detail_break = $row['@attributes']['break'];
|
||||
}
|
||||
$this->dialplan_detail_add();
|
||||
if (is_array($row['action']) || is_array($row['anti-action'])) {
|
||||
$condition_self_closing_tag = false;
|
||||
if (!is_array($row['action'][0])) {
|
||||
if ($row['action']['@attributes']['application']) {
|
||||
$tmp = $row['action'];
|
||||
unset($row['action']);
|
||||
$row['action'][0] = $tmp;
|
||||
}
|
||||
}
|
||||
if (!is_array($row['anti-action'][0])) {
|
||||
if ($row['anti-action']['@attributes']['application']) {
|
||||
$tmp = $row['anti-action'];
|
||||
unset($row['anti-action']);
|
||||
$row['anti-action'][0] = $tmp;
|
||||
}
|
||||
}
|
||||
$order = $order + 5;
|
||||
unset($this->dialplan_detail_break);
|
||||
unset($this->dialplan_detail_inline);
|
||||
foreach ($row['action'] as &$row2) {
|
||||
$this->dialplan_detail_tag = 'action';
|
||||
$this->dialplan_detail_type = $row2['@attributes']['application'];
|
||||
$this->dialplan_detail_data = $row2['@attributes']['data'];
|
||||
$this->dialplan_detail_data = str_replace("{v_pin_number}", generate_password(8, 1), $this->dialplan_detail_data);
|
||||
$this->dialplan_detail_data = str_replace("{v_context}", $this->dialplan_context, $this->dialplan_detail_data);
|
||||
$this->dialplan_detail_data = str_replace("{v_switch_recordings_dir}", $_SESSION['switch']['recordings']['dir'], $this->dialplan_detail_data);
|
||||
if (strlen($row2['@attributes']['inline']) > 0) {
|
||||
$this->dialplan_detail_inline = $row2['@attributes']['inline'];
|
||||
}
|
||||
$this->dialplan_detail_group = $group;
|
||||
$this->dialplan_detail_order = $order;
|
||||
$this->dialplan_detail_add();
|
||||
$order = $order + 5;
|
||||
}
|
||||
foreach ($row['anti-action'] as &$row2) {
|
||||
$this->dialplan_detail_tag = 'anti-action';
|
||||
$this->dialplan_detail_type = $row2['@attributes']['application'];
|
||||
$this->dialplan_detail_data = $row2['@attributes']['data'];
|
||||
$this->dialplan_detail_data = str_replace("{v_pin_number}", generate_password(8, 1), $this->dialplan_detail_data);
|
||||
$this->dialplan_detail_data = str_replace("{v_context}", $this->dialplan_context, $this->dialplan_detail_data);
|
||||
$this->dialplan_detail_data = str_replace("{v_switch_recordings_dir}", $_SESSION['switch']['recordings']['dir'], $this->dialplan_detail_data);
|
||||
$this->dialplan_detail_group = $group;
|
||||
$this->dialplan_detail_order = $order;
|
||||
$this->dialplan_detail_add();
|
||||
$order = $order + 5;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$condition_self_closing_tag = true;
|
||||
}
|
||||
//if not a self closing tag then increment the group
|
||||
if (!$condition_self_closing_tag) {
|
||||
$group++;
|
||||
}
|
||||
$row['group'] = $group;
|
||||
$order = $order + 5;
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,169 @@
|
||||
<?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>
|
||||
Copyright (C) 2010
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
|
||||
//define the dnd class
|
||||
class do_not_disturb {
|
||||
public $domain_uuid;
|
||||
public $dnd_uuid;
|
||||
public $domain_name;
|
||||
public $extension;
|
||||
public $dnd_enabled;
|
||||
|
||||
//update the user_status
|
||||
public function dnd_status() {
|
||||
global $db;
|
||||
if ($this->dnd_enabled == "true") {
|
||||
//update the call center status
|
||||
$user_status = "Logged Out";
|
||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||
if ($fp) {
|
||||
$switch_cmd .= "callcenter_config agent set status ".$_SESSION['username']."@".$domain_name." '".$user_status."'";
|
||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||
}
|
||||
|
||||
//update the database user_status
|
||||
$user_status = "Do Not Disturb";
|
||||
$sql = "update v_users set ";
|
||||
$sql .= "user_status = '$user_status' ";
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "and username = '".$_SESSION['username']."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
}
|
||||
} //function
|
||||
|
||||
public function dnd_add() {
|
||||
global $db;
|
||||
$hunt_group_extension = $this->extension;
|
||||
$huntgroup_name = 'dnd_'.$this->extension;
|
||||
$hunt_group_type = 'dnd';
|
||||
$hunt_group_context = $_SESSION['context'];
|
||||
$hunt_group_timeout = '1';
|
||||
$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 = '';
|
||||
//$hunt_group_call_prompt = 'false';
|
||||
$huntgroup_caller_announce = 'false';
|
||||
//$hunt_group_user_list = '';
|
||||
$hunt_group_enabled = $this->dnd_enabled;
|
||||
$hunt_group_description = 'dnd '.$this->extension;
|
||||
|
||||
$sql = "insert into v_hunt_groups ";
|
||||
$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 .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'$this->domain_uuid', ";
|
||||
$sql .= "'$this->dnd_uuid', ";
|
||||
$sql .= "'$hunt_group_extension', ";
|
||||
$sql .= "'$huntgroup_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 .= ")";
|
||||
if ($this->debug) {
|
||||
echo $sql."<br />";
|
||||
}
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
} //function
|
||||
|
||||
public function dnd_update() {
|
||||
global $db;
|
||||
|
||||
$hunt_group_extension = $this->extension;
|
||||
$huntgroup_name = 'dnd_'.$this->extension;
|
||||
$hunt_group_type = 'dnd';
|
||||
$hunt_group_context = $_SESSION['context'];
|
||||
$hunt_group_timeout = '1';
|
||||
$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 = '';
|
||||
//$hunt_group_call_prompt = 'false';
|
||||
$huntgroup_caller_announce = 'false';
|
||||
//$hunt_group_user_list = '';
|
||||
$hunt_group_enabled = $this->dnd_enabled;
|
||||
$hunt_group_description = 'dnd '.$this->extension;
|
||||
|
||||
$sql = "update v_hunt_groups set ";
|
||||
$sql .= "hunt_group_extension = '$hunt_group_extension', ";
|
||||
$sql .= "hunt_group_name = '$huntgroup_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 = '$hunt_group_call_prompt', ";
|
||||
$sql .= "hunt_group_caller_announce = 'false', ";
|
||||
//$sql .= "hunt_group_user_list = '$hunt_group_user_list', ";
|
||||
$sql .= "hunt_group_enabled = '$hunt_group_enabled', ";
|
||||
$sql .= "hunt_group_description = '$hunt_group_description' ";
|
||||
$sql .= "where domain_uuid = '$this->domain_uuid' ";
|
||||
$sql .= "and hunt_group_uuid = '$this->dnd_uuid' ";
|
||||
if ($this->debug) {
|
||||
echo $sql."<br />";
|
||||
}
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
} //function
|
||||
} //class
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,338 @@
|
||||
<?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>
|
||||
Copyright (C) 2010
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
|
||||
//define the follow me class
|
||||
class follow_me {
|
||||
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_timeout_1;
|
||||
|
||||
public $destination_data_2;
|
||||
public $destination_type_2;
|
||||
public $destination_timeout_2;
|
||||
|
||||
public $destination_data_3;
|
||||
public $destination_type_3;
|
||||
public $destination_timeout_3;
|
||||
|
||||
public $destination_data_4;
|
||||
public $destination_type_4;
|
||||
public $destination_timeout_4;
|
||||
|
||||
public $destination_data_5;
|
||||
public $destination_type_5;
|
||||
public $destination_timeout_5;
|
||||
|
||||
public $destination_profile = 'internal';
|
||||
public $destination_timeout = '';
|
||||
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 .= "(";
|
||||
$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 .= ")";
|
||||
$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 .= ")";
|
||||
if ($v_debug) {
|
||||
echo $sql."<br />";
|
||||
}
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
$this->follow_me_destinations();
|
||||
} //end function
|
||||
|
||||
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 .= "where domain_uuid = '$this->domain_uuid' ";
|
||||
$sql .= "and hunt_group_uuid = '$this->follow_me_uuid' ";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
$this->follow_me_destinations();
|
||||
} //end function
|
||||
|
||||
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' ";
|
||||
$db->exec(check_sql($sql));
|
||||
|
||||
//insert the v_hunt_group_destinations set destination_data_1
|
||||
if (strlen($this->destination_data_1) > 0) {
|
||||
$sql = "insert into v_hunt_group_destinations ";
|
||||
$sql .= "(";
|
||||
$sql .= "hunt_group_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 .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".uuid()."', ";
|
||||
$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 .= ")";
|
||||
$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 .= "(";
|
||||
$sql .= "hunt_group_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 .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".uuid()."', ";
|
||||
$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 .= ")";
|
||||
$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 .= "(";
|
||||
$sql .= "hunt_group_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 .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".uuid()."', ";
|
||||
$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 .= ")";
|
||||
$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 .= "(";
|
||||
$sql .= "hunt_group_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 .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".uuid()."', ";
|
||||
$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 .= ")";
|
||||
$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 .= "(";
|
||||
$sql .= "hunt_group_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 .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".uuid()."', ";
|
||||
$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 .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
$this->destination_order++;
|
||||
unset($sql);
|
||||
}
|
||||
} //function
|
||||
} //class
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,217 @@
|
||||
<?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>
|
||||
Copyright (C) 2010
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
|
||||
//define the install class
|
||||
class install {
|
||||
|
||||
var $result;
|
||||
var $domain_uuid;
|
||||
var $domain;
|
||||
var $switch_conf_dir;
|
||||
var $switch_scripts_dir;
|
||||
var $switch_sounds_dir;
|
||||
|
||||
function recursive_copy($src, $dst) {
|
||||
$dir = opendir($src);
|
||||
if (!$dir) {
|
||||
if (!mkdir($src, 0755, true)) {
|
||||
throw new Exception("recursive_copy() source directory '".$src."' does not exist.");
|
||||
}
|
||||
}
|
||||
if (!is_dir($dst)) {
|
||||
if (!mkdir($dst, 0755, true)) {
|
||||
//throw new Exception("recursive_copy() failed to create destination directory '".$dst."'");
|
||||
}
|
||||
}
|
||||
while(false !== ($file = readdir($dir))) {
|
||||
if (($file != '.') && ($file != '..')) {
|
||||
if (is_dir($src.'/'.$file)) {
|
||||
$this->recursive_copy($src.'/'.$file, $dst.'/'.$file);
|
||||
}
|
||||
else {
|
||||
if (!file_exists($dst.'/'.$file)) {
|
||||
//echo "copy(".$src."/".$file.", ".$dst."/".$file.");<br />\n";
|
||||
copy($src.'/'.$file, $dst.'/'.$file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
}
|
||||
|
||||
function recursive_delete($dir) {
|
||||
if (strlen($dir) > 0) {
|
||||
foreach (glob($dir) as $file) {
|
||||
if (is_dir($file)) {
|
||||
$this->recursive_delete("$file/*");
|
||||
rmdir($file);
|
||||
//echo "rm dir: ".$file."\n";
|
||||
} else {
|
||||
//echo "delete file: ".$file."\n";
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
clearstatcache();
|
||||
}
|
||||
|
||||
function copy() {
|
||||
$this->copy_scripts();
|
||||
$this->copy_sounds();
|
||||
$this->copy_swf();
|
||||
$this->copy_phrases();
|
||||
}
|
||||
|
||||
function copy_conf() {
|
||||
clearstatcache();
|
||||
$src_dir = $this->switch_conf_dir;
|
||||
$dst_dir = $this->switch_conf_dir.'.orig';
|
||||
if ($src_dir != "/conf") {
|
||||
mkdir($src_dir, 0755, true);
|
||||
}
|
||||
if (is_readable($src_dir)) {
|
||||
//make a backup copy of the conf directory
|
||||
if (substr(strtoupper(PHP_OS), 0, 3) == "WIN") {
|
||||
$this->recursive_copy($src_dir, $dst_dir);
|
||||
$this->recursive_delete($this->switch_conf_dir);
|
||||
}
|
||||
else {
|
||||
exec ('mv '.$src_dir.' '.$dst_dir);
|
||||
//exec ('cp -RLp '.$src_dir.' '.$dst_dir);
|
||||
}
|
||||
//make sure the conf directory exists
|
||||
if (!mkdir($this->switch_conf_dir, 0755, true)) {
|
||||
//throw new Exception("Failed to create the switch conf directory '".$this->switch_conf_dir."'. ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function copy_scripts() {
|
||||
clearstatcache();
|
||||
$src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/scripts';
|
||||
$dst_dir = $this->switch_scripts_dir;
|
||||
if (is_readable($this->switch_scripts_dir)) {
|
||||
if ($handle = opendir($src_dir)) {
|
||||
$i = 0;
|
||||
$files = array();
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != "." && $file != ".." && is_file($src_dir.'/'.$file)) {
|
||||
if (!file_exists($dst_dir.'/'.$file) ) {
|
||||
//copy the file if it does not exist in the destination directory
|
||||
if (copy($src_dir.'/'.$file, $dst_dir.'/'.$file)) {
|
||||
$this->result['copy']['scripts'][] = "copied from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n";
|
||||
}
|
||||
else {
|
||||
$this->result['copy']['scripts'][] = "copy failed from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($src_dir, $dst_dir);
|
||||
}
|
||||
}
|
||||
|
||||
function copy_sounds() {
|
||||
clearstatcache();
|
||||
$src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/sounds/en/us/callie/custom/8000';
|
||||
$dst_dir = $this->switch_sounds_dir.'/en/us/callie/custom/8000';
|
||||
if (is_readable($this->switch_sounds_dir)) {
|
||||
if ($handle = opendir($src_dir)) {
|
||||
$i = 0;
|
||||
$files = array();
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != "." && $file != ".." && is_file($src_dir.'/'.$file)) {
|
||||
if (!file_exists($dst_dir.'/'.$file) ) {
|
||||
//copy the file if it does not exist in the destination directory
|
||||
if (copy($src_dir.'/'.$file, $dst_dir.'/'.$file)) {
|
||||
$this->result['copy']['sounds']['8000'][] = "copied from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n";
|
||||
}
|
||||
else {
|
||||
$this->result['copy']['sounds']['8000'][] = "copy failed from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/sounds/en/us/callie/custom/16000';
|
||||
$dst_dir = $this->switch_sounds_dir.'/en/us/callie/custom/16000';
|
||||
if ($handle = opendir($src_dir)) {
|
||||
$i = 0;
|
||||
$files = array();
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != "." && $file != ".." && is_file($src_dir.'/'.$file)) {
|
||||
if (!file_exists($dst_dir.'/'.$file) ) {
|
||||
//copy the file if it does not exist in the destination directory
|
||||
if (copy($src_dir.'/'.$file, $dst_dir.'/'.$file)) {
|
||||
$this->result['copy']['sounds']['16000'][] = "copied from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n";
|
||||
}
|
||||
else {
|
||||
$this->result['copy']['sounds']['16000'][] = "copy failed from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function copy_swf() {
|
||||
clearstatcache();
|
||||
$file = "slim.swf";
|
||||
$src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/htdocs';
|
||||
$dst_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/recordings';
|
||||
if (copy($src_dir.'/'.$file, $dst_dir.'/'.$file)) {
|
||||
$this->result['copy']['swf'][] = "copied from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n";
|
||||
}
|
||||
else {
|
||||
$this->result['copy']['swf'][] = "copy failed from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n";
|
||||
}
|
||||
}
|
||||
|
||||
function copy_phrases() {
|
||||
clearstatcache();
|
||||
$src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/conf/lang";
|
||||
$dst_dir = $this->switch_conf_dir."/lang";
|
||||
if (is_readable($this->switch_conf_dir)) {
|
||||
$this->recursive_copy($src_dir, $dst_dir);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//how to use the class
|
||||
//include "includes/classes/install.php";
|
||||
//$install = new install;
|
||||
//$install->domain_uuid = $domain_uuid;
|
||||
//$install->switch_conf_dir = $switch_conf_dir;
|
||||
//$install->switch_scripts_dir = $switch_scripts_dir;
|
||||
//$install->switch_sounds_dir = $switch_sounds_dir;
|
||||
//$install->copy();
|
||||
//print_r($install->result);
|
||||
?>
|
||||
@@ -0,0 +1,340 @@
|
||||
<?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>
|
||||
Copyright (C) 2010
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
|
||||
//define the follow me class
|
||||
class menu {
|
||||
public $menu_uuid;
|
||||
|
||||
//delete items in the menu that are not protected
|
||||
function delete() {
|
||||
//set the variable
|
||||
$db = $this->db;
|
||||
//remove the old menu
|
||||
$sql = "delete from v_menu_items ";
|
||||
$sql .= "where menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and (menu_item_protected <> 'true' ";
|
||||
$sql .= "or menu_item_protected is null); ";
|
||||
$db->exec(check_sql($sql));
|
||||
}
|
||||
|
||||
//restore the menu
|
||||
function restore() {
|
||||
//set the variables
|
||||
$db = $this->db;
|
||||
|
||||
//get the $apps array from the installed apps from the core and mod directories
|
||||
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
|
||||
$x=0;
|
||||
foreach ($config_list as &$config_path) {
|
||||
include($config_path);
|
||||
$x++;
|
||||
}
|
||||
|
||||
//use the app array to restore the default menu
|
||||
//$db->beginTransaction();
|
||||
foreach ($apps as $row) {
|
||||
foreach ($row['menu'] as $menu) {
|
||||
//set the variables
|
||||
$menu_item_title = $menu['title']['en'];
|
||||
$menu_item_language = 'en';
|
||||
$menu_item_uuid = $menu['uuid'];
|
||||
$menu_item_parent_uuid = $menu['parent_uuid'];
|
||||
$menu_item_category = $menu['category'];
|
||||
$menu_item_path = $menu['path'];
|
||||
$menu_item_order = $menu['order'];
|
||||
$menu_item_description = $menu['desc'];
|
||||
|
||||
//if the item uuid is not currently in the db then add it
|
||||
$sql = "select * from v_menu_items ";
|
||||
$sql .= "where menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and menu_item_uuid = '$menu_item_uuid' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
if ($prep_statement) {
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (count($result) == 0) {
|
||||
//insert the default menu into the database
|
||||
$sql = "insert into v_menu_items ";
|
||||
$sql .= "(";
|
||||
$sql .= "menu_item_uuid, ";
|
||||
$sql .= "menu_uuid, ";
|
||||
//$sql .= "menu_item_language, ";
|
||||
$sql .= "menu_item_title, ";
|
||||
$sql .= "menu_item_link, ";
|
||||
$sql .= "menu_item_category, ";
|
||||
if (strlen($menu_item_order) > 0) {
|
||||
$sql .= "menu_item_order, ";
|
||||
}
|
||||
if (strlen($menu_item_parent_uuid) > 0) {
|
||||
$sql .= "menu_item_parent_uuid, ";
|
||||
}
|
||||
$sql .= "menu_item_description ";
|
||||
$sql .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".$menu_item_uuid."', ";
|
||||
$sql .= "'".$this->menu_uuid."', ";
|
||||
//$sql .= "'$menu_item_language', ";
|
||||
$sql .= "'$menu_item_title', ";
|
||||
$sql .= "'$menu_item_path', ";
|
||||
$sql .= "'$menu_item_category', ";
|
||||
if (strlen($menu_item_order) > 0) {
|
||||
$sql .= "'$menu_item_order', ";
|
||||
}
|
||||
if (strlen($menu_item_parent_uuid) > 0) {
|
||||
$sql .= "'$menu_item_parent_uuid', ";
|
||||
}
|
||||
$sql .= "'$menu_item_description' ";
|
||||
$sql .= ")";
|
||||
if ($menu_item_uuid == $menu_item_parent_uuid) {
|
||||
//echo $sql."<br />\n";
|
||||
}
|
||||
else {
|
||||
$db->exec(check_sql($sql));
|
||||
}
|
||||
unset($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if there are no groups listed in v_menu_item_groups under menu_uuid then add the default groups
|
||||
$sql = "select count(*) as count from v_menu_item_groups ";
|
||||
$sql .= "where menu_uuid = '".$this->menu_uuid."' ";
|
||||
$prep_statement = $db->prepare($sql);
|
||||
$prep_statement->execute();
|
||||
$sub_result = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
||||
unset ($prep_statement);
|
||||
if ($sub_result['count'] == 0) {
|
||||
//no menu item groups found add the defaults
|
||||
foreach($apps as $app) {
|
||||
foreach ($app['menu'] as $sub_row) {
|
||||
foreach ($sub_row['groups'] as $group) {
|
||||
//add the record
|
||||
$sql = "insert into v_menu_item_groups ";
|
||||
$sql .= "(";
|
||||
$sql .= "menu_uuid, ";
|
||||
$sql .= "menu_item_uuid, ";
|
||||
$sql .= "group_name ";
|
||||
$sql .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".$this->menu_uuid."', ";
|
||||
$sql .= "'".$sub_row['uuid']."', ";
|
||||
$sql .= "'".$group."' ";
|
||||
$sql .= ")";
|
||||
$db->exec($sql);
|
||||
unset($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//save the changes to the database
|
||||
//$db->commit();
|
||||
} //end function
|
||||
|
||||
//create the menu
|
||||
function build_html($sql, $menu_item_level) {
|
||||
|
||||
$db = $this->db;
|
||||
$db_menu_full = '';
|
||||
|
||||
if (!isset($_SESSION['groups'])) {
|
||||
$_SESSION['groups'][0]['group_name'] = 'public';
|
||||
}
|
||||
|
||||
if (strlen($sql) == 0) { //default sql for base of the menu
|
||||
$sql = "select * from v_menu_items ";
|
||||
$sql .= "where menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and menu_item_parent_uuid is null ";
|
||||
$sql .= "and menu_item_uuid in ";
|
||||
$sql .= "(select menu_item_uuid from v_menu_item_groups where menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and ( ";
|
||||
if (!isset($_SESSION['groups'])) {
|
||||
$sql .= "group_name = 'public' ";
|
||||
}
|
||||
else {
|
||||
$x = 0;
|
||||
foreach($_SESSION['groups'] as $row) {
|
||||
if ($x == 0) {
|
||||
$sql .= "group_name = '".$row['group_name']."' ";
|
||||
}
|
||||
else {
|
||||
$sql .= "or group_name = '".$row['group_name']."' ";
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
$sql .= ") ";
|
||||
$sql .= "and menu_item_uuid is not null ";
|
||||
$sql .= ") ";
|
||||
$sql .= "order by menu_item_order asc ";
|
||||
}
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach($result as $field) {
|
||||
$menu_tags = '';
|
||||
switch ($field['menu_item_category']) {
|
||||
case "internal":
|
||||
$menu_tags = "href='".PROJECT_PATH.$field['menu_item_link']."'";
|
||||
break;
|
||||
case "external":
|
||||
if (substr($field['menu_item_link'], 0,1) == "/") {
|
||||
$field['menu_item_link'] = PROJECT_PATH . $field['menu_item_link'];
|
||||
}
|
||||
$menu_tags = "href='".$field['menu_item_link']."' target='_blank'";
|
||||
break;
|
||||
case "email":
|
||||
$menu_tags = "href='mailto:".$field['menu_item_link']."'";
|
||||
break;
|
||||
}
|
||||
|
||||
if ($menu_item_level == "main") {
|
||||
$db_menu = "<ul class='menu_main'>\n";
|
||||
$db_menu .= "<li>\n";
|
||||
if (!isset($_SESSION["username"])) {
|
||||
$_SESSION["username"] = '';
|
||||
}
|
||||
if (strlen($_SESSION["username"]) == 0) {
|
||||
$db_menu .= "<a $menu_tags style='padding: 0px 0px; border-style: none; background: none;'><h2 align='center' style=''>".$field['menu_item_title']."</h2></a>\n";
|
||||
}
|
||||
else {
|
||||
if ($field['menu_item_link'] == "/login.php" || $field['menu_item_link'] == "/users/signup.php") {
|
||||
//hide login and sign-up when the user is logged in
|
||||
}
|
||||
else {
|
||||
$db_menu .= "<a ".$menu_tags." style='padding: 0px 0px; border-style: none; background: none;'><h2 align='center' style=''>".$field['menu_item_title']."</h2></a>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$menu_item_level = 0;
|
||||
if (strlen($field['menu_item_uuid']) > 0) {
|
||||
$db_menu .= $this->build_child_html($menu_item_level, $field['menu_item_uuid']);
|
||||
}
|
||||
|
||||
if ($menu_item_level == "main") {
|
||||
$db_menu .= "</li>\n";
|
||||
$db_menu .= "</ul>\n\n";
|
||||
}
|
||||
|
||||
$db_menu_full .= $db_menu;
|
||||
} //end for each
|
||||
|
||||
unset($prep_statement, $sql, $result);
|
||||
return $db_menu_full;
|
||||
}
|
||||
|
||||
//create the sub menus
|
||||
function build_child_html($menu_item_level, $menu_item_uuid) {
|
||||
|
||||
$db = $this->db;
|
||||
$menu_item_level = $menu_item_level+1;
|
||||
|
||||
if (count($_SESSION['groups']) == 0) {
|
||||
$_SESSION['groups'][0]['group_name'] = 'public';
|
||||
}
|
||||
|
||||
$sql = "select * from v_menu_items ";
|
||||
$sql .= "where menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and menu_item_parent_uuid = '$menu_item_uuid' ";
|
||||
$sql .= "and menu_item_uuid in ";
|
||||
$sql .= "(select menu_item_uuid from v_menu_item_groups where menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and ( ";
|
||||
if (count($_SESSION['groups']) == 0) {
|
||||
$sql .= "group_name = 'public' ";
|
||||
}
|
||||
else {
|
||||
$x = 0;
|
||||
foreach($_SESSION['groups'] as $row) {
|
||||
if ($x == 0) {
|
||||
$sql .= "group_name = '".$row['group_name']."' ";
|
||||
}
|
||||
else {
|
||||
$sql .= "or group_name = '".$row['group_name']."' ";
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
$sql .= ") ";
|
||||
$sql .= ") ";
|
||||
$sql .= "order by menu_item_order, menu_item_title asc ";
|
||||
$prep_statement_2 = $db->prepare($sql);
|
||||
$prep_statement_2->execute();
|
||||
$result_2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED);
|
||||
if (count($result_2) > 0) {
|
||||
//child menu found
|
||||
$db_menu_sub = "<ul class='menu_sub'>\n";
|
||||
|
||||
foreach($result_2 as $row) {
|
||||
$menu_item_link = $row['menu_item_link'];
|
||||
$menu_item_category = $row['menu_item_category'];
|
||||
$menu_item_uuid = $row['menu_item_uuid'];
|
||||
$menu_item_parent_uuid = $row['menu_item_parent_uuid'];
|
||||
|
||||
switch ($menu_item_category) {
|
||||
case "internal":
|
||||
$menu_tags = "href='".PROJECT_PATH.$menu_item_link."'";
|
||||
break;
|
||||
case "external":
|
||||
if (substr($menu_item_link, 0,1) == "/") {
|
||||
$menu_item_link = PROJECT_PATH . $menu_item_link;
|
||||
}
|
||||
$menu_tags = "href='".$menu_item_link."' target='_blank'";
|
||||
break;
|
||||
case "email":
|
||||
$menu_tags = "href='mailto:".$menu_item_link."'";
|
||||
break;
|
||||
}
|
||||
|
||||
$db_menu_sub .= "<li>";
|
||||
|
||||
//get sub menu for children
|
||||
if (strlen($menu_item_uuid) > 0) {
|
||||
$str_child_menu = $this->build_child_html($menu_item_level, $menu_item_uuid);
|
||||
}
|
||||
|
||||
if (strlen($str_child_menu) > 1) {
|
||||
$db_menu_sub .= "<a ".$menu_tags.">".$row['menu_item_title']."</a>";
|
||||
$db_menu_sub .= $str_child_menu;
|
||||
unset($str_child_menu);
|
||||
}
|
||||
else {
|
||||
$db_menu_sub .= "<a ".$menu_tags.">".$row['menu_item_title']."</a>";
|
||||
}
|
||||
$db_menu_sub .= "</li>\n";
|
||||
}
|
||||
unset($sql, $result_2);
|
||||
$db_menu_sub .="</ul>\n";
|
||||
return $db_menu_sub;
|
||||
}
|
||||
unset($prep_statement_2, $sql);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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-2012
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
|
||||
// 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"]."<br />\n";
|
||||
//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
|
||||
//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\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'] );
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,121 @@
|
||||
<?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>
|
||||
Copyright (C) 2010
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
|
||||
//define the follow me class
|
||||
class schema {
|
||||
public $db;
|
||||
public $apps;
|
||||
public $db_type;
|
||||
public $result;
|
||||
|
||||
//get the list of installed apps from the core and mod directories
|
||||
public function __construct() {
|
||||
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
|
||||
$x=0;
|
||||
foreach ($config_list as &$config_path) {
|
||||
include($config_path);
|
||||
$x++;
|
||||
}
|
||||
$this->apps = $apps;
|
||||
}
|
||||
|
||||
//create the database schema
|
||||
public function sql() {
|
||||
$sql = '';
|
||||
$sql_schema = '';
|
||||
foreach ($this->apps as $app) {
|
||||
if (count($app['db'])) {
|
||||
foreach ($app['db'] as $row) {
|
||||
//create the sql string
|
||||
$table_name = $row['table'];
|
||||
$sql = "CREATE TABLE " . $row['table'] . " (\n";
|
||||
$field_count = 0;
|
||||
foreach ($row['fields'] as $field) {
|
||||
if ($field['deprecated'] == "true") {
|
||||
//skip this field
|
||||
}
|
||||
else {
|
||||
if ($field_count > 0 ) { $sql .= ",\n"; }
|
||||
if (is_array($field['name'])) {
|
||||
$sql .= $field['name']['text']." ";
|
||||
}
|
||||
else {
|
||||
$sql .= $field['name']." ";
|
||||
}
|
||||
if (is_array($field['type'])) {
|
||||
$sql .= $field['type'][$this->db_type];
|
||||
}
|
||||
else {
|
||||
$sql .= $field['type'];
|
||||
}
|
||||
if ($field['key']['type'] == "primary") {
|
||||
$sql .= " PRIMARY KEY";
|
||||
}
|
||||
if ($field['key']['type'] == "foreign") {
|
||||
if ($this->db_type == "pgsql") {
|
||||
//$sql .= " references ".$field['key']['reference']['table']."(".$field['key']['reference']['field'].")";
|
||||
}
|
||||
if ($this->db_type == "sqlite") {
|
||||
//$sql .= " references ".$field['key']['reference']['table']."(".$field['key']['reference']['field'].")";
|
||||
}
|
||||
if ($this->db_type == "mysql") {
|
||||
//$sql .= " references ".$field['key']['reference']['table']."(".$field['key']['reference']['field'].")";
|
||||
}
|
||||
}
|
||||
$field_count++;
|
||||
}
|
||||
}
|
||||
if ($this->db_type == "mysql") {
|
||||
$sql .= ") ENGINE=INNODB;";
|
||||
}
|
||||
else {
|
||||
$sql .= ");";
|
||||
}
|
||||
$this->result['sql'][] = $sql;
|
||||
unset($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//create the database schema
|
||||
public function exec() {
|
||||
foreach ($this->result['sql'] as $sql) {
|
||||
//start the sql transaction
|
||||
$this->db->beginTransaction();
|
||||
//execute the sql query
|
||||
try {
|
||||
$this->db->query($sql);
|
||||
}
|
||||
catch (PDOException $error) {
|
||||
echo "error: " . $error->getMessage() . " sql: $sql<br/>";
|
||||
}
|
||||
//complete the transaction
|
||||
$this->db->commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,694 @@
|
||||
<?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>
|
||||
Copyright (C) 2010
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
|
||||
//define the directory class
|
||||
class switch_directory {
|
||||
public $domain_uuid;
|
||||
public $domain_name;
|
||||
public $db_type;
|
||||
public $extension;
|
||||
public $number_alias;
|
||||
public $password;
|
||||
public $vm_password;
|
||||
public $accountcode;
|
||||
public $effective_caller_id_name;
|
||||
public $effective_caller_id_number;
|
||||
public $outbound_caller_id_name;
|
||||
public $outbound_caller_id_number;
|
||||
public $limit_max=5;
|
||||
public $limit_destination;
|
||||
public $vm_enabled=1;
|
||||
public $vm_mailto;
|
||||
public $vm_attach_file;
|
||||
public $vm_keep_local_after_email;
|
||||
public $user_context;
|
||||
public $range;
|
||||
public $autogen_users;
|
||||
public $toll_allow;
|
||||
public $call_group;
|
||||
public $hold_music;
|
||||
public $auth_acl;
|
||||
public $cidr;
|
||||
public $sip_force_contact;
|
||||
public $sip_force_expires;
|
||||
public $nibble_account;
|
||||
public $mwi_account;
|
||||
public $sip_bypass_media;
|
||||
public $enabled;
|
||||
public $description;
|
||||
public $cidr;
|
||||
public $number_alias;
|
||||
|
||||
// get domain_uuid
|
||||
public function get_domain_uuid() {
|
||||
return $this->domain_uuid;
|
||||
}
|
||||
// set domain_uuid
|
||||
public function set_domain_uuid($domain_uuid){
|
||||
$this->domain_uuid = $domain_uuid;
|
||||
}
|
||||
|
||||
// get domain_name
|
||||
public function get_domain_name() {
|
||||
return $this->domain_name;
|
||||
}
|
||||
// set domain_name
|
||||
public function set_domain_name($domain_name){
|
||||
$this->domain_name = $domain_name;
|
||||
}
|
||||
|
||||
// get db_type
|
||||
public function get_db_type() {
|
||||
return $this->db_type;
|
||||
}
|
||||
// set db_type
|
||||
public function set_db_type($db_type){
|
||||
$this->db_type = $db_type;
|
||||
}
|
||||
|
||||
// get extension
|
||||
public function get_extension() {
|
||||
return $this->extension;
|
||||
}
|
||||
// set extension
|
||||
public function set_extension($extension){
|
||||
$this->extension = $extension;
|
||||
}
|
||||
|
||||
public function add() {
|
||||
global $db;
|
||||
$domain_uuid = $this->domain_uuid;
|
||||
$domain_name = $this->domain_name;
|
||||
$extension = $this->extension;
|
||||
$number_alias = $this->number_alias;
|
||||
$password = $this->password;
|
||||
$autogen_users = $this->autogen_users;
|
||||
$provisioning_list = $this->provisioning_list;
|
||||
$vm_password = $this->vm_password;
|
||||
$accountcode = $this->accountcode;
|
||||
$effective_caller_id_name = $this->effective_caller_id_name;
|
||||
$effective_caller_id_number = $this->effective_caller_id_number;
|
||||
$outbound_caller_id_name = $this->outbound_caller_id_name;
|
||||
$outbound_caller_id_number = $this->outbound_caller_id_number;
|
||||
$limit_max = $this->limit_max;
|
||||
$limit_destination = $this->limit_destination;
|
||||
$vm_enabled = $this->vm_enabled;
|
||||
$vm_mailto = $this->vm_mailto;
|
||||
$vm_attach_file = $this->vm_attach_file;
|
||||
$vm_keep_local_after_email = $this->vm_keep_local_after_email;
|
||||
$user_context = $this->user_context;
|
||||
$toll_allow = $this->toll_allow;
|
||||
$call_group = $this->call_group;
|
||||
$hold_music = $this->hold_music;
|
||||
$auth_acl = $this->auth_acl;
|
||||
$cidr = $this->cidr;
|
||||
$sip_force_contact = $this->sip_force_contact;
|
||||
$sip_force_expires = $this->sip_force_expires;
|
||||
$nibble_account = $this->nibble_account;
|
||||
$mwi_account = $this->mwi_account;
|
||||
$sip_bypass_media = $this->sip_bypass_media;
|
||||
$enabled = $this->enabled;
|
||||
$description = $this->description;
|
||||
|
||||
$db->beginTransaction();
|
||||
for ($i=1; $i<=$range; $i++) {
|
||||
if (extension_exists($extension)) {
|
||||
//extension exists
|
||||
}
|
||||
else {
|
||||
//extension does not exist add it
|
||||
$password = generate_password();
|
||||
$sql = "insert into v_extensions ";
|
||||
$sql .= "(";
|
||||
$sql .= "domain_uuid, ";
|
||||
$sql .= "extension_uuid, ";
|
||||
$sql .= "extension, ";
|
||||
$sql .= "number_alias, ";
|
||||
$sql .= "password, ";
|
||||
$sql .= "provisioning_list, ";
|
||||
$sql .= "vm_password, ";
|
||||
$sql .= "accountcode, ";
|
||||
$sql .= "effective_caller_id_name, ";
|
||||
$sql .= "effective_caller_id_number, ";
|
||||
$sql .= "outbound_caller_id_name, ";
|
||||
$sql .= "outbound_caller_id_number, ";
|
||||
$sql .= "limit_max, ";
|
||||
$sql .= "limit_destination, ";
|
||||
$sql .= "vm_enabled, ";
|
||||
$sql .= "vm_mailto, ";
|
||||
$sql .= "vm_attach_file, ";
|
||||
$sql .= "vm_keep_local_after_email, ";
|
||||
$sql .= "user_context, ";
|
||||
$sql .= "toll_allow, ";
|
||||
$sql .= "call_group, ";
|
||||
$sql .= "hold_music, ";
|
||||
$sql .= "auth_acl, ";
|
||||
$sql .= "cidr, ";
|
||||
$sql .= "sip_force_contact, ";
|
||||
if (strlen($sip_force_expires) > 0) {
|
||||
$sql .= "sip_force_expires, ";
|
||||
}
|
||||
if (strlen($nibble_account) > 0) {
|
||||
$sql .= "nibble_account, ";
|
||||
}
|
||||
if (strlen($mwi_account) > 0) {
|
||||
$sql .= "mwi_account, ";
|
||||
}
|
||||
$sql .= "sip_bypass_media, ";
|
||||
$sql .= "enabled, ";
|
||||
$sql .= "description ";
|
||||
$sql .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'$domain_uuid', ";
|
||||
$sql .= "'$extension_uuid', ";
|
||||
$sql .= "'$extension', ";
|
||||
$sql .= "'$number_alias', ";
|
||||
$sql .= "'$password', ";
|
||||
$sql .= "'$provisioning_list', ";
|
||||
$sql .= "'user-choose', ";
|
||||
$sql .= "'$accountcode', ";
|
||||
$sql .= "'$effective_caller_id_name', ";
|
||||
$sql .= "'$effective_caller_id_number', ";
|
||||
$sql .= "'$outbound_caller_id_name', ";
|
||||
$sql .= "'$outbound_caller_id_number', ";
|
||||
$sql .= "'$limit_max', ";
|
||||
$sql .= "'$limit_destination', ";
|
||||
$sql .= "'$vm_enabled', ";
|
||||
$sql .= "'$vm_mailto', ";
|
||||
$sql .= "'$vm_attach_file', ";
|
||||
$sql .= "'$vm_keep_local_after_email', ";
|
||||
$sql .= "'$user_context', ";
|
||||
$sql .= "'$toll_allow', ";
|
||||
$sql .= "'$call_group', ";
|
||||
$sql .= "'$hold_music', ";
|
||||
$sql .= "'$auth_acl', ";
|
||||
$sql .= "'$cidr', ";
|
||||
$sql .= "'$sip_force_contact', ";
|
||||
if (strlen($sip_force_expires) > 0) {
|
||||
$sql .= "'$sip_force_expires', ";
|
||||
}
|
||||
if (strlen($nibble_account) > 0) {
|
||||
$sql .= "'$nibble_account', ";
|
||||
}
|
||||
if (strlen($mwi_account) > 0) {
|
||||
if (strpos($mwi_account, '@') === false) {
|
||||
if (count($_SESSION["domains"]) > 1) {
|
||||
$mwi_account .= "@".$domain_name;
|
||||
}
|
||||
else {
|
||||
$mwi_account .= "@\$\${domain}";
|
||||
}
|
||||
}
|
||||
$sql .= "'$mwi_account', ";
|
||||
}
|
||||
$sql .= "'$sip_bypass_media', ";
|
||||
$sql .= "'$enabled', ";
|
||||
$sql .= "'$description' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
}
|
||||
$extension++;
|
||||
}
|
||||
$db->commit();
|
||||
}
|
||||
|
||||
public function update() {
|
||||
global $db;
|
||||
|
||||
$domain_uuid = $this->domain_uuid;
|
||||
$domain_name = $this->domain_name;
|
||||
$extension = $this->extension;
|
||||
$number_alias = $this->number_alias;
|
||||
$password = $this->password;
|
||||
$autogen_users = $this->autogen_users;
|
||||
$provisioning_list = $this->provisioning_list;
|
||||
$vm_password = $this->vm_password;
|
||||
$accountcode = $this->accountcode;
|
||||
$effective_caller_id_name = $this->effective_caller_id_name;
|
||||
$effective_caller_id_number = $this->effective_caller_id_number;
|
||||
$outbound_caller_id_name = $this->outbound_caller_id_name;
|
||||
$outbound_caller_id_number = $this->outbound_caller_id_number;
|
||||
$limit_max = $this->limit_max;
|
||||
$limit_destination = $this->limit_destination;
|
||||
$vm_enabled = $this->vm_enabled;
|
||||
$vm_mailto = $this->vm_mailto;
|
||||
$vm_attach_file = $this->vm_attach_file;
|
||||
$vm_keep_local_after_email = $this->vm_keep_local_after_email;
|
||||
$user_context = $this->user_context;
|
||||
$toll_allow = $this->toll_allow;
|
||||
$call_group = $this->call_group;
|
||||
$hold_music = $this->hold_music;
|
||||
$auth_acl = $this->auth_acl;
|
||||
$cidr = $this->cidr;
|
||||
$sip_force_contact = $this->sip_force_contact;
|
||||
$sip_force_expires = $this->sip_force_expires;
|
||||
$nibble_account = $this->nibble_account;
|
||||
$mwi_account = $this->mwi_account;
|
||||
$sip_bypass_media = $this->sip_bypass_media;
|
||||
$enabled = $this->enabled;
|
||||
$description = $this->description;
|
||||
|
||||
//$user_list_array = explode("|", $user_list);
|
||||
//foreach($user_list_array as $tmp_user){
|
||||
// $user_password = generate_password();
|
||||
// if (strlen($tmp_user) > 0) {
|
||||
// user_add($tmp_user, $user_password, $user_email);
|
||||
// }
|
||||
//}
|
||||
//unset($tmp_user);
|
||||
|
||||
if (strlen($password) == 0) {
|
||||
$password = generate_password();
|
||||
}
|
||||
|
||||
$sql = "update v_extensions set ";
|
||||
$sql .= "extension = '$extension', ";
|
||||
$sql .= "number_alias = '$number_alias', ";
|
||||
$sql .= "password = '$password', ";
|
||||
$sql .= "provisioning_list = '$provisioning_list', ";
|
||||
if (strlen($vm_password) > 0) {
|
||||
$sql .= "vm_password = '$vm_password', ";
|
||||
}
|
||||
else {
|
||||
$sql .= "vm_password = 'user-choose', ";
|
||||
}
|
||||
$sql .= "accountcode = '$accountcode', ";
|
||||
$sql .= "effective_caller_id_name = '$effective_caller_id_name', ";
|
||||
$sql .= "effective_caller_id_number = '$effective_caller_id_number', ";
|
||||
$sql .= "outbound_caller_id_name = '$outbound_caller_id_name', ";
|
||||
$sql .= "outbound_caller_id_number = '$outbound_caller_id_number', ";
|
||||
$sql .= "limit_max = '$limit_max', ";
|
||||
$sql .= "limit_destination = '$limit_destination', ";
|
||||
$sql .= "vm_enabled = '$vm_enabled', ";
|
||||
$sql .= "vm_mailto = '$vm_mailto', ";
|
||||
$sql .= "vm_attach_file = '$vm_attach_file', ";
|
||||
$sql .= "vm_keep_local_after_email = '$vm_keep_local_after_email', ";
|
||||
$sql .= "user_context = '$user_context', ";
|
||||
$sql .= "toll_allow = '$toll_allow', ";
|
||||
$sql .= "call_group = '$call_group', ";
|
||||
$sql .= "hold_music = '$hold_music', ";
|
||||
$sql .= "auth_acl = '$auth_acl', ";
|
||||
$sql .= "cidr = '$cidr', ";
|
||||
$sql .= "sip_force_contact = '$sip_force_contact', ";
|
||||
if (strlen($sip_force_expires) == 0) {
|
||||
$sql .= "sip_force_expires = null, ";
|
||||
}
|
||||
else {
|
||||
$sql .= "sip_force_expires = '$sip_force_expires', ";
|
||||
}
|
||||
if (strlen($nibble_account) == 0) {
|
||||
$sql .= "nibble_account = null, ";
|
||||
}
|
||||
else {
|
||||
$sql .= "nibble_account = '$nibble_account', ";
|
||||
}
|
||||
if (strlen($mwi_account) > 0) {
|
||||
if (strpos($mwi_account, '@') === false) {
|
||||
if (count($_SESSION["domains"]) > 1) {
|
||||
$mwi_account .= "@".$domain_name;
|
||||
}
|
||||
else {
|
||||
$mwi_account .= "@\$\${domain}";
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql .= "mwi_account = '$mwi_account', ";
|
||||
$sql .= "sip_bypass_media = '$sip_bypass_media', ";
|
||||
$sql .= "enabled = '$enabled', ";
|
||||
$sql .= "description = '$description' ";
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "and extension_uuid = '$extension_uuid'";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
}
|
||||
|
||||
function delete() {
|
||||
global $db;
|
||||
$domain_uuid = $this->domain_uuid;
|
||||
$extension_uuid = $this->extension_uuid;
|
||||
if (strlen($extension_uuid)>0) {
|
||||
$sql = "";
|
||||
$sql .= "delete from v_extensions ";
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "and extension_uuid = '$extension_uuid' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
unset($sql);
|
||||
}
|
||||
}
|
||||
|
||||
function import_sql($data){
|
||||
$count=count($data);
|
||||
$keys=$values=SplFixedArray($count);
|
||||
$keys=array_keys($data);
|
||||
$values=array_values($data);
|
||||
for($i=0;$i<$count;$i++){
|
||||
$keys[$i]= str_replace("-", "_", $keys[$i]);
|
||||
$this->{$keys[$i]}=$values[$i];
|
||||
}
|
||||
}
|
||||
|
||||
function set_bool(&$var,$default=null){
|
||||
$var=strtolower($var);
|
||||
if ($var==="true") return;
|
||||
elseif ($var==="false") return;
|
||||
elseif ($var==true) $var="true";
|
||||
elseif ($var==false) $var="false";
|
||||
elseif(!is_null($default)) {
|
||||
$var=$default;
|
||||
$this->set_bool($var);
|
||||
}
|
||||
}
|
||||
|
||||
function generate_xml($single=1){
|
||||
//switch_account_code!! How should we be passing this??
|
||||
|
||||
if ($this->enabled== "false" || !$this->enabled) {
|
||||
return false;//This the best way??
|
||||
}
|
||||
|
||||
$this->vm_password = str_replace("#", "", $this->vm_password); //preserves leading zeros//**Generic Validation!
|
||||
|
||||
/*if(!in_array($this->vm_enabled,array("false","true"))) {//**Generic Validation!
|
||||
$this->vm_enabled = "true";
|
||||
}
|
||||
if(!in_array($this->vm_attach_file,array("false","true"))) {//**Generic Validation!
|
||||
$this->vm_attach_file = "true";
|
||||
}
|
||||
if(!in_array($this->vm_keep_local_after_email,array("false","true"))) {//**Generic Validation!
|
||||
$this->vm_keep_local_after_email = "true";
|
||||
}
|
||||
*/
|
||||
$this->set_bool($this->vm_enabled,1);
|
||||
$this->set_bool($this->vm_attach_file,1);
|
||||
$this->set_bool($this->vm_keep_local_after_email,1);
|
||||
|
||||
//remove invalid characters from the file names //**Generic Validation!
|
||||
$this->extension = str_replace(" ", "_", $this->extension);
|
||||
$this->extension = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $this->extension);
|
||||
|
||||
/*if (!$extension_xml_condensed) { <--- what do I do with this??
|
||||
$fout = fopen($_SESSION['switch']['extensions']['dir']."/v_".$extension.".xml","w");
|
||||
$tmp_xml .= "<include>\n";
|
||||
}*/
|
||||
if (strlen($this->cidr)) {
|
||||
$this->cidr = " cidr=\"" . $this->cidr . "\"";
|
||||
}
|
||||
if (strlen($this->number_alias)) {
|
||||
$this->number_alias = " number-alias=\"".$this->number_alias."\"";
|
||||
}
|
||||
if($single) $tmp_xml = "<include>\n";
|
||||
else $tmp_xml = "";
|
||||
$tmp_xml .= " <user id=\"".$this->extension."\"".$this->cidr."".$this->number_alias.">\n";
|
||||
$tmp_xml .= " <params>\n";
|
||||
$tmp_xml .= " <param name=\"password\" value=\"" . $this->password . "\"/>\n";
|
||||
$tmp_xml .= " <param name=\"vm-enabled\" value=\"".$this->vm_enabled."\"/>\n";
|
||||
|
||||
if ($this->vm_enabled=="true"){
|
||||
$tmp_xml .= " <param name=\"vm-password\" value=\"" . $this->vm_password . "\"/>\n";
|
||||
if(strlen($this->vm_mailto)) {
|
||||
$tmp_xml .= " <param name=\"vm-email-all-messages\" value=\"true\"/>\n";
|
||||
$tmp_xml .= " <param name=\"vm-attach-file\" value=\"".$this->vm_attach_file."\"/>\n";
|
||||
$tmp_xml .= " <param name=\"vm-keep-local-after-email\" value=\"".$this->vm_keep_local_after_email."\"/>\n";
|
||||
$tmp_xml .= " <param name=\"vm-mailto\" value=\"" . $this->vm_mailto . "\"/>\n";
|
||||
}
|
||||
}
|
||||
if (strlen($this->mwi_account)) {
|
||||
$tmp_xml .= " <param name=\"MWI-Account\" value=\"" . $this->mwi_account . "\"/>\n";
|
||||
}
|
||||
if (strlen($this->auth_acl)) {
|
||||
$tmp_xml .= " <param name=\"auth-acl\" value=\"" . $this->auth_acl . "\"/>\n";
|
||||
}
|
||||
$tmp_xml .= " </params>\n";
|
||||
|
||||
$tmp_xml .= " <variables>\n";
|
||||
if (strlen($this->hold_music)) {
|
||||
$tmp_xml .= " <variable name=\"hold_music\" value=\"" . $this->hold_music . "\"/>\n";
|
||||
}
|
||||
if (strlen($this->toll_allow)){
|
||||
$tmp_xml .= " <variable name=\"toll_allow\" value=\"" . $this->toll_allow . "\"/>\n";
|
||||
}
|
||||
if (strlen($this->accountcode)){
|
||||
$tmp_xml .= " <variable name=\"accountcode\" value=\"" . $this->accountcode . "\"/>\n";
|
||||
}
|
||||
$tmp_xml .= " <variable name=\"user_context\" value=\"" . $this->user_context . "\"/>\n";
|
||||
if (strlen($this->effective_caller_id_name)) {
|
||||
$tmp_xml .= " <variable name=\"effective_caller_id_name\" value=\"" . $this->effective_caller_id_name . "\"/>\n";
|
||||
}
|
||||
if (strlen($this->outbound_caller_id_number)) {
|
||||
$tmp_xml .= " <variable name=\"effective_caller_id_number\" value=\"" . $this->effective_caller_id_number . "\"/>\n";
|
||||
}
|
||||
if (strlen($this->outbound_caller_id_name)) {
|
||||
$tmp_xml .= " <variable name=\"outbound_caller_id_name\" value=\"" . $this->outbound_caller_id_name . "\"/>\n";
|
||||
}
|
||||
if (strlen($this->outbound_caller_id_number)) {
|
||||
$tmp_xml .= " <variable name=\"outbound_caller_id_number\" value=\"" . $this->outbound_caller_id_number . "\"/>\n";
|
||||
}
|
||||
if (!strlen($this->limit_max)) {//**validation
|
||||
$this->limit_max=5;
|
||||
}
|
||||
$tmp_xml .= " <variable name=\"limit_max\" value=\"" . $this->limit_max . "\"/>\n";
|
||||
if (strlen($this->limit_destination)) {
|
||||
$tmp_xml .= " <variable name=\"limit_destination\" value=\"" . $this->limit_destination . "\"/>\n";
|
||||
}
|
||||
if (strlen($this->sip_force_contact)) {
|
||||
$tmp_xml .= " <variable name=\"sip-force-contact\" value=\"" . $this->sip_force_contact . "\"/>\n";
|
||||
}
|
||||
if (strlen($this->sip_force_expires)) {
|
||||
$tmp_xml .= " <variable name=\"sip-force-expires\" value=\"" . $this->sip_force_expires . "\"/>\n";
|
||||
}
|
||||
if (strlen($this->nibble_account)) {
|
||||
$tmp_xml .= " <variable name=\"nibble_account\" value=\"" . $this->nibble_account . "\"/>\n";
|
||||
}
|
||||
switch ($this->sip_bypass_media) {
|
||||
case "bypass-media":
|
||||
$tmp_xml .= " <variable name=\"bypass_media\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "bypass-media-after-bridge":
|
||||
$tmp_xml .= " <variable name=\"bypass_media_after_bridge\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "proxy-media":
|
||||
$tmp_xml .= " <variable name=\"proxy_media\" value=\"true\"/>\n";
|
||||
break;
|
||||
}
|
||||
$tmp_xml .= " </variables>\n";
|
||||
$tmp_xml .= " </user>\n";
|
||||
if($single) { $tmp_xml .= "</include>\n"; }
|
||||
|
||||
return $tmp_xml;
|
||||
}
|
||||
|
||||
function xml_save_all() {
|
||||
global $db, $config;
|
||||
$domain_uuid = $this->domain_uuid;
|
||||
$domain_name = $this->domain_name;
|
||||
|
||||
//get the system settings paths and set them as variables
|
||||
$settings_array = v_settings();
|
||||
foreach($settings_array as $name => $value) {
|
||||
$$name = $value;
|
||||
}
|
||||
|
||||
//determine the extensions parent directory
|
||||
$extension_parent_dir = realpath($_SESSION['switch']['extensions']['dir']."/..");
|
||||
|
||||
// delete all old extensions to prepare for new ones
|
||||
if($dh = opendir($_SESSION['switch']['extensions']['dir'])) {
|
||||
$files = Array();
|
||||
while($file = readdir($dh)) {
|
||||
if($file != "." && $file != ".." && $file[0] != '.') {
|
||||
if(is_dir($dir . "/" . $file)) {
|
||||
//this is a directory do nothing
|
||||
} else {
|
||||
//check if file is an extension; verify the file numeric and the extension is xml
|
||||
if (substr($file,0,2) == 'v_' && substr($file,-4) == '.xml') {
|
||||
unlink($_SESSION['switch']['extensions']['dir']."/".$file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
|
||||
$sql = "";
|
||||
$sql .= "select * from v_extensions ";
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "order by call_group asc ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$i = 0;
|
||||
$extension_xml_condensed = false;
|
||||
if ($extension_xml_condensed) {
|
||||
$fout = fopen($_SESSION['switch']['extensions']['dir']."/v_extensions.xml","w");
|
||||
$tmp_xml = "<include>\n";
|
||||
}
|
||||
while($row = $prep_statement->fetch(PDO::FETCH_ASSOC)) {
|
||||
$call_group = $row['call_group'];
|
||||
$call_group = str_replace(";", ",", $call_group);
|
||||
$tmp_array = explode(",", $call_group);
|
||||
foreach ($tmp_array as &$tmp_call_group) {
|
||||
if (strlen($tmp_call_group) > 0) {
|
||||
if (strlen($call_group_array[$tmp_call_group]) == 0) {
|
||||
$call_group_array[$tmp_call_group] = $row['extension'];
|
||||
}
|
||||
else {
|
||||
$call_group_array[$tmp_call_group] = $call_group_array[$tmp_call_group].','.$row['extension'];
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($row['enabled'] != "false") {
|
||||
//$this->import_sql($row);//Do I need to be worried about ghost values? Maybe I should make a new object?
|
||||
//if (strlen($switch_account_code)) $this->accountcode=$switch_account_code;
|
||||
//$tmp_xml.=$this->generate_xml(1);
|
||||
|
||||
$one_row=new fs_directory;
|
||||
$one_row->import_sql($row);//make a new object to flush ghost rows. And we can call this as static.
|
||||
if (strlen($switch_account_code)) $one_row->accountcode=$switch_account_code;
|
||||
$tmp_xml.=$one_row->generate_xml(false);
|
||||
|
||||
if (!$extension_xml_condensed) {
|
||||
$tmp_xml .= "</include>\n";
|
||||
fwrite($fout, $tmp_xml);
|
||||
unset($tmp_xml);
|
||||
fclose($fout);
|
||||
}
|
||||
}
|
||||
}
|
||||
unset ($prep_statement);
|
||||
if ($extension_xml_condensed) {
|
||||
$tmp_xml .= "</include>\n";
|
||||
fwrite($fout, $tmp_xml);
|
||||
unset($tmp_xml);
|
||||
fclose($fout);
|
||||
}
|
||||
|
||||
//define the group members
|
||||
$tmp_xml = "<!--\n";
|
||||
$tmp_xml .= " NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE\n";
|
||||
$tmp_xml .= "\n";
|
||||
$tmp_xml .= " FreeSWITCH works off the concept of users and domains just like email.\n";
|
||||
$tmp_xml .= " You have users that are in domains for example 1000@domain.com.\n";
|
||||
$tmp_xml .= "\n";
|
||||
$tmp_xml .= " When freeswitch gets a register packet it looks for the user in the directory\n";
|
||||
$tmp_xml .= " based on the from or to domain in the packet depending on how your sofia profile\n";
|
||||
$tmp_xml .= " is configured. Out of the box the default domain will be the IP address of the\n";
|
||||
$tmp_xml .= " machine running FreeSWITCH. This IP can be found by typing \"sofia status\" at the\n";
|
||||
$tmp_xml .= " CLI. You will register your phones to the IP and not the hostname by default.\n";
|
||||
$tmp_xml .= " If you wish to register using the domain please open vars.xml in the root conf\n";
|
||||
$tmp_xml .= " directory and set the default domain to the hostname you desire. Then you would\n";
|
||||
$tmp_xml .= " use the domain name in the client instead of the IP address to register\n";
|
||||
$tmp_xml .= " with FreeSWITCH.\n";
|
||||
$tmp_xml .= "\n";
|
||||
$tmp_xml .= " NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE\n";
|
||||
$tmp_xml .= "-->\n";
|
||||
$tmp_xml .= "\n";
|
||||
$tmp_xml .= "<include>\n";
|
||||
$tmp_xml .= " <!--the domain or ip (the right hand side of the @ in the addr-->\n";
|
||||
if ($extension_dir_name == "default") {
|
||||
$tmp_xml .= " <domain name=\"\$\${domain}\">\n";
|
||||
}
|
||||
else {
|
||||
$tmp_xml .= " <domain name=\"".$extension_dir_name."\">\n";
|
||||
}
|
||||
$tmp_xml .= " <params>\n";
|
||||
$tmp_xml .= " <param name=\"dial-string\" value=\"{sip_invite_domain=\${domain_name},presence_id=\${dialed_user}@\${dialed_domain}}\${sofia_contact(\${dialed_user}@\${dialed_domain})}\"/>\n";
|
||||
$tmp_xml .= " </params>\n";
|
||||
$tmp_xml .= "\n";
|
||||
$tmp_xml .= " <variables>\n";
|
||||
$tmp_xml .= " <variable name=\"record_stereo\" value=\"true\"/>\n";
|
||||
$tmp_xml .= " <variable name=\"default_gateway\" value=\"\$\${default_provider}\"/>\n";
|
||||
$tmp_xml .= " <variable name=\"default_areacode\" value=\"\$\${default_areacode}\"/>\n";
|
||||
$tmp_xml .= " <variable name=\"transfer_fallback_extension\" value=\"operator\"/>\n";
|
||||
$tmp_xml .= " <variable name=\"export_vars\" value=\"domain_name\"/>\n";
|
||||
$tmp_xml .= " </variables>\n";
|
||||
$tmp_xml .= "\n";
|
||||
$tmp_xml .= " <groups>\n";
|
||||
$tmp_xml .= " <group name=\"".$extension_dir_name."\">\n";
|
||||
$tmp_xml .= " <users>\n";
|
||||
$tmp_xml .= " <X-PRE-PROCESS cmd=\"include\" data=\"".$extension_dir_name."/*.xml\"/>\n";
|
||||
$tmp_xml .= " </users>\n";
|
||||
$tmp_xml .= " </group>\n";
|
||||
$tmp_xml .= "\n";
|
||||
$previous_call_group = "";
|
||||
foreach ($call_group_array as $key => $value) {
|
||||
$call_group = $key;
|
||||
$extension_list = $value;
|
||||
if (strlen($call_group) > 0) {
|
||||
if ($previous_call_group != $call_group) {
|
||||
$tmp_xml .= " <group name=\"$call_group\">\n";
|
||||
$tmp_xml .= " <users>\n";
|
||||
$tmp_xml .= " <!--\n";
|
||||
$tmp_xml .= " type=\"pointer\" is a pointer so you can have the\n";
|
||||
$tmp_xml .= " same user in multiple groups. It basically means\n";
|
||||
$tmp_xml .= " to keep searching for the user in the directory.\n";
|
||||
$tmp_xml .= " -->\n";
|
||||
$extension_array = explode(",", $extension_list);
|
||||
foreach ($extension_array as &$tmp_extension) {
|
||||
$tmp_xml .= " <user id=\"$tmp_extension\" type=\"pointer\"/>\n";
|
||||
}
|
||||
$tmp_xml .= " </users>\n";
|
||||
$tmp_xml .= " </group>\n";
|
||||
$tmp_xml .= "\n";
|
||||
}
|
||||
$previous_call_group = $call_group;
|
||||
}
|
||||
unset($call_group);
|
||||
}
|
||||
$tmp_xml .= " </groups>\n";
|
||||
$tmp_xml .= "\n";
|
||||
$tmp_xml .= " </domain>\n";
|
||||
$tmp_xml .= "</include>";
|
||||
|
||||
//remove invalid characters from the file names
|
||||
$extension_dir_name = str_replace(" ", "_", $extension_dir_name);
|
||||
$extension_dir_name = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $extension_dir_name);
|
||||
|
||||
//write the xml file
|
||||
$fout = fopen($extension_parent_dir."/".$extension_dir_name.".xml","w");
|
||||
fwrite($fout, $tmp_xml);
|
||||
unset($tmp_xml);
|
||||
fclose($fout);
|
||||
|
||||
//syncrhonize the phone directory
|
||||
sync_directory();
|
||||
|
||||
//apply settings reminder
|
||||
$_SESSION["reload_xml"] = true;
|
||||
|
||||
//call reloadxml direct
|
||||
//$cmd = "api reloadxml";
|
||||
//event_socket_request_cmd($cmd);
|
||||
//unset($cmd);
|
||||
|
||||
} //end function
|
||||
} //class
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,530 @@
|
||||
<?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>
|
||||
Copyright (C) 2010
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
|
||||
//define the directory class
|
||||
class switch_fax {
|
||||
|
||||
public $db;
|
||||
public $domain_uuid;
|
||||
public $domain_name;
|
||||
public $dialplan_uuid;
|
||||
public $context;
|
||||
public $fax_uuid;
|
||||
public $fax_name;
|
||||
public $fax_extension;
|
||||
public $fax_email;
|
||||
public $fax_pin_number;
|
||||
public $fax_caller_id_name;
|
||||
public $fax_caller_id_number;
|
||||
public $fax_forward_number;
|
||||
public $fax_user_list;
|
||||
public $fax_description;
|
||||
|
||||
public function __construct() {
|
||||
require_once "includes/classes/database.php";
|
||||
$this->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
foreach ($this as $key => $value) {
|
||||
unset($this->$key);
|
||||
}
|
||||
}
|
||||
|
||||
public function count() {
|
||||
$database = new database;
|
||||
$database->domain_uuid = $this->domain_uuid;
|
||||
$database->table = "v_fax";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
return $database->count();
|
||||
}
|
||||
|
||||
public function find() {
|
||||
$database = new database;
|
||||
$database->table = "v_fax";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
if ($this->fax_uuid) {
|
||||
$database->where[1]['name'] = 'fax_uuid';
|
||||
$database->where[1]['value'] = $this->fax_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
}
|
||||
if ($this->order_by) {
|
||||
$database->order_by = $this->order_by;
|
||||
}
|
||||
if ($this->order_type) {
|
||||
$database->order_type = $this->order_type;
|
||||
}
|
||||
return $database->find();
|
||||
}
|
||||
|
||||
public function add() {
|
||||
|
||||
//add the fax
|
||||
if (strlen($this->fax_extension) > 0) {
|
||||
//add the dialplan
|
||||
$database = new database;
|
||||
$database->table = "v_dialplans";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_name'] = $this->fax_name;
|
||||
$database->fields['dialplan_order'] = '333';
|
||||
$database->fields['dialplan_context'] = $this->context;
|
||||
$database->fields['dialplan_enabled'] = $this->fax_enabled;
|
||||
$database->fields['dialplan_description'] = $this->fax_description;
|
||||
$database->fields['app_uuid'] = $this->app_uuid;
|
||||
$database->add();
|
||||
|
||||
//add the dialplan details
|
||||
$detail_data = '^'.$this->fax_extension.'$';
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'condition'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'destination_number';
|
||||
$database->fields['dialplan_detail_data'] = $detail_data;
|
||||
$database->fields['dialplan_detail_order'] = '005';
|
||||
$database->add();
|
||||
|
||||
if (file_exists(PHP_BINDIR."/php")) { define(PHP_BIN, 'php'); }
|
||||
if (file_exists(PHP_BINDIR."/php.exe")) { define(PHP_BIN, 'php.exe'); }
|
||||
$dialplan_detail_data = "api_hangup_hook=system ".PHP_BINDIR."/".PHP_BIN." ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/fax_to_email.php ";
|
||||
$dialplan_detail_data .= "email=".$this->fax_email." ";
|
||||
$dialplan_detail_data .= "extension=".$this->fax_extension." ";
|
||||
$dialplan_detail_data .= "name=\\\\\\\${last_fax} ";
|
||||
$dialplan_detail_data .= "messages='result: \\\\\\\${fax_result_text} sender:\\\\\\\${fax_remote_station_id} pages:\\\\\\\${fax_document_total_pages}' ";
|
||||
$dialplan_detail_data .= "domain=".$domain_name." ";
|
||||
$dialplan_detail_data .= "caller_id_name='\\\\\\\${caller_id_name}' ";
|
||||
$dialplan_detail_data .= "caller_id_number=\\\\\\\${caller_id_number} ";
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'set';
|
||||
$database->fields['dialplan_detail_data'] = $dialplan_detail_data;
|
||||
$database->fields['dialplan_detail_order'] = '010';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'answer';
|
||||
$database->fields['dialplan_detail_data'] = '';
|
||||
$database->fields['dialplan_detail_order'] = '015';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'set';
|
||||
$database->fields['dialplan_detail_data'] = 'fax_enable_t38=true';
|
||||
$database->fields['dialplan_detail_order'] = '020';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'set';
|
||||
$database->fields['dialplan_detail_data'] = 'fax_enable_t38_request=true';
|
||||
$database->fields['dialplan_detail_order'] = '025';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'playback';
|
||||
$database->fields['dialplan_detail_data'] = 'silence_stream://2000';
|
||||
$database->fields['dialplan_detail_order'] = '030';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'set';
|
||||
$database->fields['dialplan_detail_data'] = 'last_fax=${caller_id_number}-${strftime(%Y-%m-%d-%H-%M-%S)}';
|
||||
$database->fields['dialplan_detail_order'] = '035';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'rxfax';
|
||||
if (count($_SESSION["domains"]) > 1) {
|
||||
$dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domains'][$row['domain_uuid']]['domain_name'].'/'.$this->fax_extension.'/inbox/${last_fax}.tif';
|
||||
}
|
||||
else {
|
||||
$dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$this->fax_extension.'/inbox/${last_fax}.tif';
|
||||
}
|
||||
$database->fields['dialplan_detail_data'] = $dialplan_detail_data;
|
||||
$database->fields['dialplan_detail_order'] = '040';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'hangup';
|
||||
$database->fields['dialplan_detail_data'] = '';
|
||||
$database->fields['dialplan_detail_order'] = '045';
|
||||
$database->add();
|
||||
}
|
||||
|
||||
//add the fax
|
||||
$fax_uuid = uuid();
|
||||
$database = new database;
|
||||
$database->table = "v_fax";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
if (strlen($this->fax_extension) > 0) {
|
||||
$database->fields['fax_extension'] = $this->fax_extension;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
}
|
||||
$database->fields['fax_uuid'] = $this->fax_uuid;
|
||||
$database->fields['fax_name'] = $this->fax_name;
|
||||
$database->fields['fax_email'] = $this->fax_email;
|
||||
$database->fields['fax_pin_number'] = $this->fax_pin_number;
|
||||
$database->fields['fax_caller_id_name'] = $this->fax_caller_id_name;
|
||||
$database->fields['fax_caller_id_number'] = $this->fax_caller_id_number;
|
||||
$database->fields['fax_forward_number'] = $this->fax_forward_number;
|
||||
$database->fields['fax_user_list'] = $this->fax_user_list;
|
||||
$database->fields['fax_description'] = $this->fax_description;
|
||||
$database->add();
|
||||
}
|
||||
|
||||
public function update() {
|
||||
|
||||
//udate the fax
|
||||
//get the dialplan uuid
|
||||
$database = new database;
|
||||
$database->table = "v_fax";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'fax_uuid';
|
||||
$database->where[1]['value'] = $this->fax_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$result = $database->find();
|
||||
foreach($result as $row) {
|
||||
$this->dialplan_uuid = $row['dialplan_uuid'];
|
||||
}
|
||||
|
||||
//if the extension number is empty and the dialplan exists then delete the dialplan
|
||||
if (strlen($this->fax_extension) == 0) {
|
||||
if (strlen($this->dialplan_uuid) > 0) {
|
||||
//delete dialplan entry
|
||||
$database = new database;
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'dialplan_uuid';
|
||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
|
||||
//delete the child dialplan information
|
||||
$database = new database;
|
||||
$database->table = "v_dialplans";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'dialplan_uuid';
|
||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
//update the table to remove the dialplan_uuid
|
||||
$this->dialplan_uuid = '';
|
||||
}
|
||||
}
|
||||
|
||||
//update the fax
|
||||
$fax_uuid = uuid();
|
||||
$database = new database;
|
||||
$database->table = "v_fax";
|
||||
$database->fields['fax_uuid'] = $this->fax_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['fax_name'] = $this->fax_name;
|
||||
$database->fields['fax_extension'] = $this->fax_extension;
|
||||
$database->fields['fax_email'] = $this->fax_email;
|
||||
$database->fields['fax_pin_number'] = $this->fax_pin_number;
|
||||
$database->fields['fax_caller_id_name'] = $this->fax_caller_id_name;
|
||||
$database->fields['fax_caller_id_number'] = $this->fax_caller_id_number;
|
||||
$database->fields['fax_forward_number'] = $this->fax_forward_number;
|
||||
$database->fields['fax_user_list'] = $this->fax_user_list;
|
||||
$database->fields['fax_description'] = $this->fax_description;
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'fax_uuid';
|
||||
$database->where[1]['value'] = $this->fax_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->update();
|
||||
|
||||
if (strlen($this->fax_extension) > 0) {
|
||||
//update the dialplan
|
||||
$database = new database;
|
||||
$database->table = "v_dialplans";
|
||||
$database->fields['dialplan_name'] = $this->fax_name;
|
||||
$database->fields['dialplan_order'] = '333';
|
||||
$database->fields['dialplan_context'] = $this->context;
|
||||
$database->fields['dialplan_enabled'] = $this->fax_enabled;
|
||||
$database->fields['dialplan_description'] = $this->dialplan_description;
|
||||
$database->fields['app_uuid'] = $this->app_uuid;
|
||||
if ($this->dialplan_uuid) {
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'dialplan_uuid';
|
||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->update();
|
||||
}
|
||||
else {
|
||||
// $this->dialplan_uuid = uuid();
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->add();
|
||||
}
|
||||
|
||||
//delete the old dialplan details to prepare for new details
|
||||
$database = new database;
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'dialplan_uuid';
|
||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
|
||||
//add the dialplan details
|
||||
$detail_data = '^'.$this->fax_extension.'$';
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'condition'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'destination_number';
|
||||
$database->fields['dialplan_detail_data'] = $detail_data;
|
||||
$database->fields['dialplan_detail_order'] = '005';
|
||||
$database->add();
|
||||
|
||||
if (file_exists(PHP_BINDIR."/php")) { define(PHP_BIN, 'php'); }
|
||||
if (file_exists(PHP_BINDIR."/php.exe")) { define(PHP_BIN, 'php.exe'); }
|
||||
$dialplan_detail_data = "api_hangup_hook=system ".PHP_BINDIR."/".PHP_BIN." ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/fax_to_email.php ";
|
||||
$dialplan_detail_data .= "email=".$this->fax_email." ";
|
||||
$dialplan_detail_data .= "extension=".$this->fax_extension." ";
|
||||
$dialplan_detail_data .= "name=\\\\\\\${last_fax} ";
|
||||
$dialplan_detail_data .= "messages='result: \\\\\\\${fax_result_text} sender:\\\\\\\${fax_remote_station_id} pages:\\\\\\\${fax_document_total_pages}' ";
|
||||
$dialplan_detail_data .= "domain=".$domain_name." ";
|
||||
$dialplan_detail_data .= "caller_id_name='\\\\\\\${caller_id_name}' ";
|
||||
$dialplan_detail_data .= "caller_id_number=\\\\\\\${caller_id_number} ";
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'set';
|
||||
$database->fields['dialplan_detail_data'] = $dialplan_detail_data;
|
||||
$database->fields['dialplan_detail_order'] = '010';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'answer';
|
||||
$database->fields['dialplan_detail_data'] = '';
|
||||
$database->fields['dialplan_detail_order'] = '015';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'set';
|
||||
$database->fields['dialplan_detail_data'] = 'fax_enable_t38=true';
|
||||
$database->fields['dialplan_detail_order'] = '020';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'set';
|
||||
$database->fields['dialplan_detail_data'] = 'fax_enable_t38_request=true';
|
||||
$database->fields['dialplan_detail_order'] = '025';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'playback';
|
||||
$database->fields['dialplan_detail_data'] = 'silence_stream://2000';
|
||||
$database->fields['dialplan_detail_order'] = '030';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'set';
|
||||
$database->fields['dialplan_detail_data'] = 'last_fax=${caller_id_number}-${strftime(%Y-%m-%d-%H-%M-%S)}';
|
||||
$database->fields['dialplan_detail_order'] = '035';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'rxfax';
|
||||
if (count($_SESSION["domains"]) > 1) {
|
||||
$dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domains'][$row['domain_uuid']]['domain_name'].'/'.$this->fax_extension.'/inbox/${last_fax}.tif';
|
||||
}
|
||||
else {
|
||||
$dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$this->fax_extension.'/inbox/${last_fax}.tif';
|
||||
}
|
||||
$database->fields['dialplan_detail_data'] = $dialplan_detail_data;
|
||||
$database->fields['dialplan_detail_order'] = '040';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'hangup';
|
||||
$database->fields['dialplan_detail_data'] = '';
|
||||
$database->fields['dialplan_detail_order'] = '045';
|
||||
$database->add();
|
||||
}
|
||||
}
|
||||
|
||||
function delete() {
|
||||
//create the database object
|
||||
$database = new database;
|
||||
|
||||
//start the transaction
|
||||
//$count = $database->db->exec("BEGIN;");
|
||||
|
||||
//delete the fax
|
||||
if (strlen($this->fax_uuid) > 0) {
|
||||
$database->table = "v_fax";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'fax_uuid';
|
||||
$database->where[1]['value'] = $this->fax_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
unset($this->fax_uuid);
|
||||
}
|
||||
|
||||
//delete the fax
|
||||
if (strlen($this->fax_uuid) == 0) {
|
||||
//select the dialplan entries
|
||||
$database->table = "v_fax";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'fax_uuid';
|
||||
$database->where[1]['value'] = $this->fax_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$result = $database->find();
|
||||
foreach($result as $row) {
|
||||
$this->dialplan_uuid = $row['dialplan_uuid'];
|
||||
//delete the child dialplan information
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'dialplan_uuid';
|
||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
//delete the dialplan information
|
||||
$database->table = "v_dialplans";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'dialplan_uuid';
|
||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
}
|
||||
|
||||
//delete the fax
|
||||
if (strlen($this->fax_uuid) > 0) {
|
||||
$database->table = "v_fax";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'fax_uuid';
|
||||
$database->where[1]['value'] = $this->fax_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
unset($this->fax_uuid);
|
||||
}
|
||||
|
||||
//commit the transaction
|
||||
//$count = $database->db->exec("COMMIT;");
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
require_once "includes/classes/database.php";
|
||||
require_once "includes/classes/switch_fax.php";
|
||||
$fax = new switch_fax;
|
||||
$fax->domain_uuid = $_SESSION["domain_uuid"];
|
||||
print_r($fax->find());
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,621 @@
|
||||
<?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>
|
||||
Copyright (C) 2010
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
|
||||
//define the directory class
|
||||
class switch_ivr_menu {
|
||||
public $db;
|
||||
public $domain_uuid;
|
||||
public $domain_name;
|
||||
public $dialplan_uuid;
|
||||
public $ivr_menu_uuid;
|
||||
public $ivr_menu_name;
|
||||
public $ivr_menu_extension;
|
||||
public $ivr_menu_greet_long;
|
||||
public $ivr_menu_greet_short;
|
||||
public $ivr_menu_invalid_sound;
|
||||
public $ivr_menu_exit_sound;
|
||||
public $ivr_menu_confirm_macro;
|
||||
public $ivr_menu_confirm_key;
|
||||
public $ivr_menu_tts_engine;
|
||||
public $ivr_menu_tts_voice;
|
||||
public $ivr_menu_confirm_attempts;
|
||||
public $ivr_menu_timeout;
|
||||
public $ivr_menu_exit_app;
|
||||
public $ivr_menu_exit_data;
|
||||
public $ivr_menu_inter_digit_timeout;
|
||||
public $ivr_menu_max_failures;
|
||||
public $ivr_menu_max_timeouts;
|
||||
public $ivr_menu_digit_len;
|
||||
public $ivr_menu_direct_dial;
|
||||
public $ivr_menu_enabled;
|
||||
public $ivr_menu_description;
|
||||
public $ivr_menu_option_uuid;
|
||||
public $ivr_menu_option_digits;
|
||||
public $ivr_menu_option_action;
|
||||
public $ivr_menu_option_param;
|
||||
public $ivr_menu_option_order;
|
||||
public $ivr_menu_option_description;
|
||||
|
||||
public function __construct() {
|
||||
require_once "includes/classes/database.php";
|
||||
$this->app_uuid = 'a5788e9b-58bc-bd1b-df59-fff5d51253ab';
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
foreach ($this as $key => $value) {
|
||||
unset($this->$key);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_domain_uuid() {
|
||||
return $this->domain_uuid;
|
||||
}
|
||||
public function set_domain_uuid($domain_uuid){
|
||||
$this->domain_uuid = $domain_uuid;
|
||||
}
|
||||
|
||||
public function get_fields($table) {
|
||||
//get the $apps array from the installed apps from the core and mod directories
|
||||
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
|
||||
$x=0;
|
||||
foreach ($config_list as &$config_path) {
|
||||
include($config_path);
|
||||
$x++;
|
||||
}
|
||||
|
||||
//update the app db array add exists true or false
|
||||
$sql = '';
|
||||
foreach ($apps as $x => &$app) {
|
||||
foreach ($app['db'] as $y => &$row) {
|
||||
if ($row['table'] == $table) {
|
||||
//check if the column exists
|
||||
foreach ($row['fields'] as $z => $field) {
|
||||
if ($field['deprecated'] == "true") {
|
||||
//skip this field
|
||||
}
|
||||
else {
|
||||
if (is_array($field['name'])) {
|
||||
$field_name = $field['name']['text'];
|
||||
}
|
||||
else {
|
||||
$field_name = $field['name'];
|
||||
}
|
||||
if (strlen(field_name) > 0) {
|
||||
$fields[$z]['name'] = $field_name;
|
||||
}
|
||||
unset($field_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public function count() {
|
||||
$database = new database;
|
||||
if ($this->db) {
|
||||
$database->db = $this->db;
|
||||
}
|
||||
$database->domain_uuid = $this->domain_uuid;
|
||||
$database->table = "v_ivr_menus";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
return $database->count();
|
||||
}
|
||||
|
||||
public function find() {
|
||||
$database = new database;
|
||||
if ($this->db) {
|
||||
$database->db = $this->db;
|
||||
}
|
||||
$database->table = "v_ivr_menus";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
if (isset($this->ivr_menu_uuid)) {
|
||||
$database->where[1]['name'] = 'ivr_menu_uuid';
|
||||
$database->where[1]['value'] = $this->ivr_menu_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
}
|
||||
if (isset($this->ivr_menu_option_uuid)) {
|
||||
$database->where[2]['name'] = 'ivr_menu_uuid';
|
||||
$database->where[2]['value'] = $this->ivr_menu_uuid;
|
||||
$database->where[2]['operator'] = '=';
|
||||
}
|
||||
if (isset($this->order_by)) {
|
||||
$database->order_by = $this->order_by;
|
||||
}
|
||||
if (isset($this->order_type)) {
|
||||
$database->order_type = $this->order_type;
|
||||
}
|
||||
return $database->find();
|
||||
}
|
||||
|
||||
public function add() {
|
||||
|
||||
//add the ivr menu
|
||||
if (strlen($this->ivr_menu_option_action) == 0) {
|
||||
|
||||
if (strlen($this->ivr_menu_extension) > 0) {
|
||||
//add the dialplan
|
||||
$database = new database;
|
||||
if ($this->db) {
|
||||
$database->db = $this->db;
|
||||
}
|
||||
$database->table = "v_dialplans";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_name'] = $this->ivr_menu_name;
|
||||
$database->fields['dialplan_order'] = '333';
|
||||
$database->fields['dialplan_context'] = $_SESSION['context'];
|
||||
$database->fields['dialplan_enabled'] = $this->ivr_menu_enabled;
|
||||
$database->fields['dialplan_description'] = $this->ivr_menu_description;
|
||||
$database->fields['app_uuid'] = $this->app_uuid;
|
||||
$database->add();
|
||||
|
||||
//add the dialplan details
|
||||
$detail_data = '^'.$this->ivr_menu_extension.'$';
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'condition'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'destination_number';
|
||||
$database->fields['dialplan_detail_data'] = $detail_data;
|
||||
$database->fields['dialplan_detail_order'] = '005';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'answer';
|
||||
$database->fields['dialplan_detail_data'] = '';
|
||||
$database->fields['dialplan_detail_order'] = '010';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'sleep';
|
||||
$database->fields['dialplan_detail_data'] = '1000';
|
||||
$database->fields['dialplan_detail_order'] = '015';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'set';
|
||||
$database->fields['dialplan_detail_data'] = 'hangup_after_bridge=true';
|
||||
$database->fields['dialplan_detail_order'] = '020';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'ivr';
|
||||
if (count($_SESSION["domains"]) > 1) {
|
||||
$database->fields['dialplan_detail_data'] = $_SESSION['domain_name'].'-'.$this->ivr_menu_name;
|
||||
}
|
||||
else {
|
||||
$database->fields['dialplan_detail_data'] = $this->ivr_menu_name;
|
||||
}
|
||||
$database->fields['dialplan_detail_order'] = '025';
|
||||
$database->add();
|
||||
|
||||
if (strlen($this->ivr_menu_exit_app) > 0) {
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = $this->ivr_menu_exit_app;
|
||||
$database->fields['dialplan_detail_data'] = $this->ivr_menu_exit_data;
|
||||
$database->fields['dialplan_detail_order'] = '030';
|
||||
$database->add();
|
||||
}
|
||||
}
|
||||
|
||||
//add the ivr menu
|
||||
$ivr_menu_uuid = uuid();
|
||||
$database = new database;
|
||||
if ($this->db) {
|
||||
$database->db = $this->db;
|
||||
}
|
||||
$database->table = "v_ivr_menus";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
if (strlen($this->ivr_menu_extension) > 0) {
|
||||
$database->fields['ivr_menu_extension'] = $this->ivr_menu_extension;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
}
|
||||
$database->fields['ivr_menu_uuid'] = $this->ivr_menu_uuid;
|
||||
$database->fields['ivr_menu_name'] = $this->ivr_menu_name;
|
||||
$database->fields['ivr_menu_greet_long'] = $this->ivr_menu_greet_long;
|
||||
$database->fields['ivr_menu_greet_short'] = $this->ivr_menu_greet_short;
|
||||
$database->fields['ivr_menu_invalid_sound'] = $this->ivr_menu_invalid_sound;
|
||||
$database->fields['ivr_menu_exit_sound'] = $this->ivr_menu_exit_sound;
|
||||
$database->fields['ivr_menu_confirm_macro'] = $this->ivr_menu_confirm_macro;
|
||||
$database->fields['ivr_menu_confirm_key'] = $this->ivr_menu_confirm_key;
|
||||
$database->fields['ivr_menu_tts_engine'] = $this->ivr_menu_tts_engine;
|
||||
$database->fields['ivr_menu_tts_voice'] = $this->ivr_menu_tts_voice;
|
||||
$database->fields['ivr_menu_confirm_attempts'] = $this->ivr_menu_confirm_attempts;
|
||||
$database->fields['ivr_menu_timeout'] = $this->ivr_menu_timeout;
|
||||
$database->fields['ivr_menu_exit_app'] = $this->ivr_menu_exit_app;
|
||||
$database->fields['ivr_menu_exit_data'] = $this->ivr_menu_exit_data;
|
||||
$database->fields['ivr_menu_inter_digit_timeout'] = $this->ivr_menu_inter_digit_timeout;
|
||||
$database->fields['ivr_menu_max_failures'] = $this->ivr_menu_max_failures;
|
||||
$database->fields['ivr_menu_max_timeouts'] = $this->ivr_menu_max_timeouts;
|
||||
$database->fields['ivr_menu_max_timeouts'] = $this->ivr_menu_max_timeouts;
|
||||
$database->fields['ivr_menu_digit_len'] = $this->ivr_menu_digit_len;
|
||||
$database->fields['ivr_menu_digit_len'] = $this->ivr_menu_digit_len;
|
||||
$database->fields['ivr_menu_direct_dial'] = $this->ivr_menu_direct_dial;
|
||||
$database->fields['ivr_menu_direct_dial'] = $this->ivr_menu_direct_dial;
|
||||
$database->fields['ivr_menu_enabled'] = $this->ivr_menu_enabled;
|
||||
$database->fields['ivr_menu_description'] = $this->ivr_menu_description;
|
||||
$database->add();
|
||||
}
|
||||
|
||||
//add the ivr menu option
|
||||
if (strlen($this->ivr_menu_option_action) > 0) {
|
||||
$ivr_menu_uuid = uuid();
|
||||
$database = new database;
|
||||
if ($this->db) {
|
||||
$database->db = $this->db;
|
||||
}
|
||||
$database->table = "v_ivr_menu_options";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['ivr_menu_uuid'] = $this->ivr_menu_uuid;
|
||||
$database->fields['ivr_menu_option_uuid'] = $this->ivr_menu_option_uuid;
|
||||
$database->fields['ivr_menu_option_digits'] = $this->ivr_menu_option_digits;
|
||||
$database->fields['ivr_menu_option_action'] = $this->ivr_menu_option_action;
|
||||
$database->fields['ivr_menu_option_param'] = $this->ivr_menu_option_param;
|
||||
$database->fields['ivr_menu_option_order'] = $this->ivr_menu_option_order;
|
||||
$database->fields['ivr_menu_option_description'] = $this->ivr_menu_option_description;
|
||||
$database->add();
|
||||
}
|
||||
}
|
||||
|
||||
public function update() {
|
||||
|
||||
//udate the ivr menu
|
||||
if (strlen($this->ivr_menu_option_action) == 0) {
|
||||
//get the dialplan uuid
|
||||
$database = new database;
|
||||
if ($this->db) {
|
||||
$database->db = $this->db;
|
||||
}
|
||||
$database->table = "v_ivr_menus";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'ivr_menu_uuid';
|
||||
$database->where[1]['value'] = $this->ivr_menu_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$result = $database->find();
|
||||
foreach($result as $row) {
|
||||
$this->dialplan_uuid = $row['dialplan_uuid'];
|
||||
}
|
||||
|
||||
//if the extension number is empty and the dialplan exists then delete the dialplan
|
||||
if (strlen($this->ivr_menu_extension) == 0) {
|
||||
if (strlen($this->dialplan_uuid) > 0) {
|
||||
//delete dialplan entry
|
||||
$database = new database;
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'dialplan_uuid';
|
||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
|
||||
//delete the child dialplan information
|
||||
$database = new database;
|
||||
$database->table = "v_dialplans";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'dialplan_uuid';
|
||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
//update the table to remove the dialplan_uuid
|
||||
$this->dialplan_uuid = '';
|
||||
}
|
||||
}
|
||||
|
||||
//update the ivr menu
|
||||
$ivr_menu_uuid = uuid();
|
||||
$database = new database;
|
||||
$database->table = "v_ivr_menus";
|
||||
$database->fields['ivr_menu_uuid'] = $this->ivr_menu_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['ivr_menu_name'] = $this->ivr_menu_name;
|
||||
$database->fields['ivr_menu_extension'] = $this->ivr_menu_extension;
|
||||
$database->fields['ivr_menu_greet_long'] = $this->ivr_menu_greet_long;
|
||||
$database->fields['ivr_menu_greet_short'] = $this->ivr_menu_greet_short;
|
||||
$database->fields['ivr_menu_invalid_sound'] = $this->ivr_menu_invalid_sound;
|
||||
$database->fields['ivr_menu_exit_sound'] = $this->ivr_menu_exit_sound;
|
||||
$database->fields['ivr_menu_confirm_macro'] = $this->ivr_menu_confirm_macro;
|
||||
$database->fields['ivr_menu_confirm_key'] = $this->ivr_menu_confirm_key;
|
||||
$database->fields['ivr_menu_tts_engine'] = $this->ivr_menu_tts_engine;
|
||||
$database->fields['ivr_menu_tts_voice'] = $this->ivr_menu_tts_voice;
|
||||
$database->fields['ivr_menu_confirm_attempts'] = $this->ivr_menu_confirm_attempts;
|
||||
$database->fields['ivr_menu_timeout'] = $this->ivr_menu_timeout;
|
||||
$database->fields['ivr_menu_exit_app'] = $this->ivr_menu_exit_app;
|
||||
$database->fields['ivr_menu_exit_data'] = $this->ivr_menu_exit_data;
|
||||
$database->fields['ivr_menu_inter_digit_timeout'] = $this->ivr_menu_inter_digit_timeout;
|
||||
$database->fields['ivr_menu_max_failures'] = $this->ivr_menu_max_failures;
|
||||
$database->fields['ivr_menu_max_timeouts'] = $this->ivr_menu_max_timeouts;
|
||||
$database->fields['ivr_menu_max_timeouts'] = $this->ivr_menu_max_timeouts;
|
||||
$database->fields['ivr_menu_digit_len'] = $this->ivr_menu_digit_len;
|
||||
$database->fields['ivr_menu_digit_len'] = $this->ivr_menu_digit_len;
|
||||
$database->fields['ivr_menu_direct_dial'] = $this->ivr_menu_direct_dial;
|
||||
$database->fields['ivr_menu_direct_dial'] = $this->ivr_menu_direct_dial;
|
||||
$database->fields['ivr_menu_enabled'] = $this->ivr_menu_enabled;
|
||||
$database->fields['ivr_menu_description'] = $this->ivr_menu_description;
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'ivr_menu_uuid';
|
||||
$database->where[1]['value'] = $this->ivr_menu_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->update();
|
||||
|
||||
if (strlen($this->ivr_menu_extension) > 0) {
|
||||
//update the dialplan
|
||||
$database = new database;
|
||||
$database->table = "v_dialplans";
|
||||
$database->fields['dialplan_name'] = $this->ivr_menu_name;
|
||||
$database->fields['dialplan_order'] = '333';
|
||||
$database->fields['dialplan_context'] = $_SESSION['context'];
|
||||
$database->fields['dialplan_enabled'] = $this->ivr_menu_enabled;
|
||||
$database->fields['dialplan_description'] = $this->ivr_menu_description;
|
||||
$database->fields['app_uuid'] = $this->app_uuid;
|
||||
if ($this->dialplan_uuid) {
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'dialplan_uuid';
|
||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->update();
|
||||
}
|
||||
else {
|
||||
$this->dialplan_uuid = uuid();
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->add();
|
||||
}
|
||||
|
||||
//delete the old dialplan details to prepare for new details
|
||||
$database = new database;
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'dialplan_uuid';
|
||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
|
||||
//add the dialplan details
|
||||
$detail_data = '^'.$this->ivr_menu_extension.'$';
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'condition'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'destination_number';
|
||||
$database->fields['dialplan_detail_data'] = $detail_data;
|
||||
$database->fields['dialplan_detail_order'] = '005';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'answer';
|
||||
$database->fields['dialplan_detail_data'] = '';
|
||||
$database->fields['dialplan_detail_order'] = '010';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'sleep';
|
||||
$database->fields['dialplan_detail_data'] = '1000';
|
||||
$database->fields['dialplan_detail_order'] = '015';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'set';
|
||||
$database->fields['dialplan_detail_data'] = 'hangup_after_bridge=true';
|
||||
$database->fields['dialplan_detail_order'] = '020';
|
||||
$database->add();
|
||||
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = 'ivr';
|
||||
if (count($_SESSION["domains"]) > 1) {
|
||||
$database->fields['dialplan_detail_data'] = $_SESSION['domain_name'].'-'.$this->ivr_menu_name;
|
||||
}
|
||||
else {
|
||||
$database->fields['dialplan_detail_data'] = $this->ivr_menu_name;
|
||||
}
|
||||
$database->fields['dialplan_detail_order'] = '025';
|
||||
$database->add();
|
||||
|
||||
if (strlen($this->ivr_menu_exit_app) > 0) {
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->fields['domain_uuid'] = $this->domain_uuid;
|
||||
$database->fields['dialplan_uuid'] = $this->dialplan_uuid;
|
||||
$database->fields['dialplan_detail_uuid'] = uuid();
|
||||
$database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction
|
||||
$database->fields['dialplan_detail_type'] = $this->ivr_menu_exit_app;
|
||||
$database->fields['dialplan_detail_data'] = $this->ivr_menu_exit_data;
|
||||
$database->fields['dialplan_detail_order'] = '030';
|
||||
$database->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//update the ivr menu option
|
||||
if (strlen($this->ivr_menu_option_action) > 0) {
|
||||
$database = new database;
|
||||
$database->table = "v_ivr_menu_options";
|
||||
$database->fields['ivr_menu_option_digits'] = $this->ivr_menu_option_digits;
|
||||
$database->fields['ivr_menu_option_action'] = $this->ivr_menu_option_action;
|
||||
$database->fields['ivr_menu_option_param'] = $this->ivr_menu_option_param;
|
||||
$database->fields['ivr_menu_option_order'] = $this->ivr_menu_option_order;
|
||||
$database->fields['ivr_menu_option_description'] = $this->ivr_menu_option_description;
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'ivr_menu_uuid';
|
||||
$database->where[1]['value'] = $this->ivr_menu_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->where[2]['name'] = 'ivr_menu_option_uuid';
|
||||
$database->where[2]['value'] = $this->ivr_menu_option_uuid;
|
||||
$database->where[2]['operator'] = '=';
|
||||
$database->update();
|
||||
}
|
||||
}
|
||||
|
||||
function delete() {
|
||||
//create the database object
|
||||
$database = new database;
|
||||
if ($this->db) {
|
||||
$database->db = $this->db;
|
||||
}
|
||||
//start the transaction
|
||||
//$count = $database->db->exec("BEGIN;");
|
||||
|
||||
//delete the ivr menu option
|
||||
if (strlen($this->ivr_menu_option_uuid) > 0) {
|
||||
$database->table = "v_ivr_menu_options";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'ivr_menu_option_uuid';
|
||||
$database->where[1]['value'] = $this->ivr_menu_option_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
unset($this->ivr_menu_option_uuid);
|
||||
}
|
||||
|
||||
//delete the ivr menu
|
||||
if (strlen($this->ivr_menu_option_uuid) == 0) {
|
||||
//select the dialplan entries
|
||||
$database->table = "v_ivr_menus";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'ivr_menu_uuid';
|
||||
$database->where[1]['value'] = $this->ivr_menu_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$result = $database->find();
|
||||
foreach($result as $row) {
|
||||
$this->dialplan_uuid = $row['dialplan_uuid'];
|
||||
//delete the child dialplan information
|
||||
$database->table = "v_dialplan_details";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'dialplan_uuid';
|
||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
//delete the dialplan information
|
||||
$database->table = "v_dialplans";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'dialplan_uuid';
|
||||
$database->where[1]['value'] = $this->dialplan_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
}
|
||||
|
||||
//delete child data
|
||||
$database->table = "v_ivr_menu_options";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'ivr_menu_uuid';
|
||||
$database->where[1]['value'] = $this->ivr_menu_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
|
||||
//delete parent data
|
||||
$database->table = "v_ivr_menus";
|
||||
$database->where[0]['name'] = 'domain_uuid';
|
||||
$database->where[0]['value'] = $this->domain_uuid;
|
||||
$database->where[0]['operator'] = '=';
|
||||
$database->where[1]['name'] = 'ivr_menu_uuid';
|
||||
$database->where[1]['value'] = $this->ivr_menu_uuid;
|
||||
$database->where[1]['operator'] = '=';
|
||||
$database->delete();
|
||||
|
||||
//commit the transaction
|
||||
//$count = $database->db->exec("COMMIT;");
|
||||
}
|
||||
}
|
||||
|
||||
function get_xml(){
|
||||
return $xml;
|
||||
}
|
||||
|
||||
function save_xml($xml){
|
||||
return $xml;
|
||||
}
|
||||
|
||||
function xml_save_all() {
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,766 @@
|
||||
<?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>
|
||||
Copyright (C) 2010
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
|
||||
//add the database structure
|
||||
/*
|
||||
require_once "includes/classes/modules.php";
|
||||
$mod = new switch_modules;
|
||||
$mod->dir = $_SESSION['switch']['mod']['dir'];
|
||||
echo $mod->dir."\n";
|
||||
//database connection object
|
||||
$mod->db = $db;
|
||||
//get modules from the database
|
||||
$mod->get_modules();
|
||||
//module exists
|
||||
if ($mod->exists("mod_lua")) {
|
||||
echo "exists true\n";
|
||||
}
|
||||
else {
|
||||
echo "exists false\n";
|
||||
}
|
||||
//module active
|
||||
if ($mod->active("mod_lua")) {
|
||||
echo "active true\n";
|
||||
}
|
||||
else {
|
||||
echo "active false\n";
|
||||
}
|
||||
//synch
|
||||
$mod->synch();
|
||||
echo $mod->msg;
|
||||
//show module info
|
||||
$result = $mod->info("mod_lua");
|
||||
echo "<pre>\n";
|
||||
print_r($result);
|
||||
echo "</pre>\n";
|
||||
//list modules
|
||||
//$result = $mod->modules
|
||||
//echo "<pre>\n";
|
||||
//print_r($result);
|
||||
//echo "</pre>\n";
|
||||
*/
|
||||
|
||||
//define the directory class
|
||||
class switch_modules {
|
||||
public $db;
|
||||
public $dir;
|
||||
public $fp;
|
||||
public $modules;
|
||||
public $msg;
|
||||
|
||||
// get the additional information about a specific module
|
||||
public function info($name) {
|
||||
$module_label = substr($name, 4);
|
||||
$module_label = ucwords(str_replace("_", " ", $module_label));
|
||||
$mod['module_label'] = $module_label;
|
||||
$mod['module_name'] = $name;
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
$mod['module_description'] = '';
|
||||
switch ($name) {
|
||||
case "mod_amr":
|
||||
$mod['module_label'] = 'AMR';
|
||||
$mod['module_category'] = 'Codecs';
|
||||
$mod['module_description'] = 'AMR codec.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_avmd":
|
||||
$mod['module_label'] = 'AVMD';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Advanced voicemail beep detection.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_blacklist":
|
||||
$mod['module_label'] = 'Blacklist';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Blacklist.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_bv":
|
||||
$mod['module_label'] = 'BV';
|
||||
$mod['module_category'] = 'Codecs';
|
||||
$mod['module_description'] = 'BroadVoice16 and BroadVoice32 audio codecs.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_cdr_csv":
|
||||
$mod['module_label'] = 'CDR CSV';
|
||||
$mod['module_category'] = 'Event Handlers';
|
||||
$mod['module_description'] = 'CSV call detail record handler.';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
break;
|
||||
case "mod_cdr_sqlite":
|
||||
$mod['module_label'] = 'CDR SQLite';
|
||||
$mod['module_category'] = 'Event Handlers';
|
||||
$mod['module_description'] = 'SQLite call detail record handler.';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
break;
|
||||
case "mod_callcenter":
|
||||
$mod['module_label'] = 'Call Center';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Call queuing with agents and tiers for call centers.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_cepstral":
|
||||
$mod['module_label'] = 'Cepstral';
|
||||
$mod['module_category'] = 'Speech Recognition / Text to Speech';
|
||||
$mod['module_description'] = 'Text to Speech engine.';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
break;
|
||||
case "mod_cidlookup":
|
||||
$mod['module_label'] = 'CID Lookup';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Lookup caller id info.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_cluechoo":
|
||||
$mod['module_label'] = 'Cluechoo';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'A framework demo module.';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
break;
|
||||
case "mod_commands":
|
||||
$mod['module_label'] = 'Commands';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'API interface commands.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_conference":
|
||||
$mod['module_label'] = 'Conference';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Conference room module.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_console":
|
||||
$mod['module_label'] = 'Console';
|
||||
$mod['module_category'] = 'Loggers';
|
||||
$mod['module_description'] = 'Send logs to the console.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_curl":
|
||||
$mod['module_label'] = 'CURL';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Allows scripts to make HTTP requests and return responses in plain text or JSON.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_db":
|
||||
$mod['module_label'] = 'DB';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Database key / value storage functionality, dialing and limit backend.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_dialplan_asterisk":
|
||||
$mod['module_label'] = 'Dialplan Asterisk';
|
||||
$mod['module_category'] = 'Dialplan Interfaces';
|
||||
$mod['module_description'] = 'Allows Asterisk dialplans.';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
break;
|
||||
case "mod_dialplan_xml":
|
||||
$mod['module_label'] = 'Dialplan XML';
|
||||
$mod['module_category'] = 'Dialplan Interfaces';
|
||||
$mod['module_description'] = 'Provides dialplan functionality in XML.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_directory":
|
||||
$mod['module_label'] = 'Directory';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Dial by name directory.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_distributor":
|
||||
$mod['module_label'] = 'Distributor';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Round robin call distribution.';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
break;
|
||||
case "mod_dptools":
|
||||
$mod['module_label'] = 'Dialplan Plan Tools';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Provides a number of apps and utilities for the dialplan.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_enum":
|
||||
$mod['module_label'] = 'ENUM';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Route PSTN numbers over internet according to ENUM servers, such as e164.org.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_esf":
|
||||
$mod['module_label'] = 'ESF';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Holds the multi cast paging application for SIP.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_event_socket":
|
||||
$mod['module_label'] = 'Event Socket';
|
||||
$mod['module_category'] = 'Event Handlers';
|
||||
$mod['module_description'] = 'Sends events via a single socket.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_expr":
|
||||
$mod['module_label'] = 'Expr';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Expression evaluation library.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_fifo":
|
||||
$mod['module_label'] = 'FIFO';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'FIFO provides custom call queues including call park.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_flite":
|
||||
$mod['module_label'] = 'Flite';
|
||||
$mod['module_category'] = 'Speech Recognition / Text to Speech';
|
||||
$mod['module_description'] = 'Text to Speech engine.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_fsv":
|
||||
$mod['module_label'] = 'FSV';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Video application (Recording and playback).';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_g723_1":
|
||||
$mod['module_label'] = 'G.723.1';
|
||||
$mod['module_category'] = 'Codecs';
|
||||
$mod['module_description'] = 'G.723.1 codec.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_g729":
|
||||
$mod['module_label'] = 'G.729';
|
||||
$mod['module_category'] = 'Codecs';
|
||||
$mod['module_description'] = 'G729 codec supports passthrough mode';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_h26x":
|
||||
$mod['module_label'] = 'H26x';
|
||||
$mod['module_category'] = 'Codecs';
|
||||
$mod['module_description'] = 'Video codecs';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_hash":
|
||||
$mod['module_label'] = 'Hash';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Resource limitation.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_httapi":
|
||||
$mod['module_label'] = 'HT-TAPI';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'HT-TAPI Hypertext Telephony API';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
break;
|
||||
case "mod_http_cache":
|
||||
$mod['module_label'] = 'HTTP Cache';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'HTTP GET with caching';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
break;
|
||||
case "mod_ilbc":
|
||||
$mod['module_label'] = 'iLBC';
|
||||
$mod['module_category'] = 'Codecs';
|
||||
$mod['module_description'] = 'iLBC codec.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_ladspa":
|
||||
$mod['module_label'] = 'Ladspa';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Auto-tune calls.';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
break;
|
||||
case "mod_lcr":
|
||||
$mod['module_label'] = 'LCR';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Least cost routing.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_local_stream":
|
||||
$mod['module_label'] = 'Local Stream';
|
||||
$mod['module_category'] = 'Streams / Files';
|
||||
$mod['module_description'] = 'For local streams (play all the files in a directory).';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_logfile":
|
||||
$mod['module_label'] = 'Log File';
|
||||
$mod['module_category'] = 'Loggers';
|
||||
$mod['module_description'] = 'Send logs to the local file system.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_loopback":
|
||||
$mod['module_label'] = 'Loopback';
|
||||
$mod['module_category'] = 'Endpoints';
|
||||
$mod['module_description'] = 'A loopback channel driver to make an outbound call as an inbound call.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_lua":
|
||||
$mod['module_label'] = 'Lua';
|
||||
$mod['module_category'] = 'Languages';
|
||||
$mod['module_description'] = 'Lua script.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_memcache":
|
||||
$mod['module_label'] = 'Memcached';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'API for memcached.';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
break;
|
||||
case "mod_native_file":
|
||||
$mod['module_label'] = 'Native File';
|
||||
$mod['module_category'] = 'File Format Interfaces';
|
||||
$mod['module_description'] = 'File interface for codec specific file formats.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_nibblebill":
|
||||
$mod['module_label'] = 'Nibblebill';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Billing module.';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
break;
|
||||
case "mod_opus":
|
||||
$mod['module_label'] = 'Opus';
|
||||
$mod['module_category'] = 'Codecs';
|
||||
$mod['module_description'] = 'OPUS ultra-low delay audio codec';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
break;
|
||||
case "mod_park":
|
||||
$mod['module_label'] = 'Park';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Park Calls.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_pocketsphinx":
|
||||
$mod['module_label'] = 'PocketSphinx';
|
||||
$mod['module_category'] = 'Speech Recognition / Text to Speech';
|
||||
$mod['module_description'] = 'Speech Recognition.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_rtmp":
|
||||
$mod['module_label'] = 'RTMP';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Real Time Media Protocol';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_say_de":
|
||||
$mod['module_label'] = 'German';
|
||||
$mod['module_category'] = 'Say';
|
||||
$mod['module_description'] = '';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_say_en":
|
||||
$mod['module_label'] = 'English';
|
||||
$mod['module_category'] = 'Say';
|
||||
$mod['module_description'] = '';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_say_es":
|
||||
$mod['module_label'] = 'Spanish';
|
||||
$mod['module_category'] = 'Say';
|
||||
$mod['module_description'] = '';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_say_fr":
|
||||
$mod['module_label'] = 'French';
|
||||
$mod['module_category'] = 'Say';
|
||||
$mod['module_description'] = '';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_say_he":
|
||||
$mod['module_label'] = 'Hebrew';
|
||||
$mod['module_category'] = 'Say';
|
||||
$mod['module_description'] = '';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_say_hu":
|
||||
$mod['module_label'] = 'Hungarian';
|
||||
$mod['module_category'] = 'Say';
|
||||
$mod['module_description'] = '';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_say_it":
|
||||
$mod['module_label'] = 'Italian';
|
||||
$mod['module_category'] = 'Say';
|
||||
$mod['module_description'] = '';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_say_nl":
|
||||
$mod['module_label'] = 'Dutch';
|
||||
$mod['module_category'] = 'Say';
|
||||
$mod['module_description'] = '';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_say_pt":
|
||||
$mod['module_label'] = 'Portuguese';
|
||||
$mod['module_category'] = 'Say';
|
||||
$mod['module_description'] = '';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_say_ru":
|
||||
$mod['module_label'] = 'Russian';
|
||||
$mod['module_category'] = 'Say';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_say_th":
|
||||
$mod['module_label'] = 'Thai';
|
||||
$mod['module_category'] = 'Say';
|
||||
$mod['module_description'] = '';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_say_zh":
|
||||
$mod['module_label'] = 'Chinese';
|
||||
$mod['module_category'] = 'Say';
|
||||
$mod['module_description'] = '';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_shout":
|
||||
$mod['module_label'] = 'Shout';
|
||||
$mod['module_category'] = 'Streams / Files';
|
||||
$mod['module_description'] = 'MP3 files and shoutcast streams.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_siren":
|
||||
$mod['module_label'] = 'Siren';
|
||||
$mod['module_category'] = 'Codecs';
|
||||
$mod['module_description'] = 'Siren codec';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_sms":
|
||||
$mod['module_label'] = 'SMS';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Chat messages';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_sndfile":
|
||||
$mod['module_label'] = 'Sound File';
|
||||
$mod['module_category'] = 'File Format Interfaces';
|
||||
$mod['module_description'] = 'Multi-format file format transcoder (WAV, etc).';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_sofia":
|
||||
$mod['module_label'] = 'Sofia';
|
||||
$mod['module_category'] = 'Endpoints';
|
||||
$mod['module_description'] = 'SIP module.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_spandsp":
|
||||
$mod['module_label'] = 'SpanDSP';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'FAX provides fax send and receive.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_speex":
|
||||
$mod['module_label'] = 'Speex';
|
||||
$mod['module_category'] = 'Codecs';
|
||||
$mod['module_description'] = 'Speex codec.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_spidermonkey":
|
||||
$mod['module_label'] = 'SpiderMonkey';
|
||||
$mod['module_category'] = 'Languages';
|
||||
$mod['module_description'] = 'JavaScript support.';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
break;
|
||||
case "mod_spidermonkey_core_db":
|
||||
$mod['module_label'] = 'SpiderMonkey Core DB';
|
||||
$mod['module_category'] = 'Languages';
|
||||
$mod['module_description'] = 'Javascript support for SQLite.';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
break;
|
||||
case "mod_spidermonkey_curl":
|
||||
$mod['module_label'] = 'SpiderMonkey Curl';
|
||||
$mod['module_category'] = 'Languages';
|
||||
$mod['module_description'] = 'Javascript curl support.';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
break;
|
||||
case "mod_spidermonkey_socket":
|
||||
$mod['module_label'] = 'SpiderMonkey Socket';
|
||||
$mod['module_category'] = 'Languages';
|
||||
$mod['module_description'] = 'Javascript socket support.';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
break;
|
||||
case "mod_spidermonkey_teletone":
|
||||
$mod['module_label'] = 'SpiderMonkey Teletone';
|
||||
$mod['module_category'] = 'Languages';
|
||||
$mod['module_description'] = 'Javascript teletone support.';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
break;
|
||||
case "mod_syslog":
|
||||
$mod['module_label'] = 'Syslog';
|
||||
$mod['module_category'] = 'Loggers';
|
||||
$mod['module_description'] = 'Send logs to a remote syslog server.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_tone_stream":
|
||||
$mod['module_label'] = 'Tone Stream';
|
||||
$mod['module_category'] = 'Streams / Files';
|
||||
$mod['module_description'] = 'Generate tone streams.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_tts_commandline":
|
||||
$mod['module_label'] = 'TTS Commandline';
|
||||
$mod['module_category'] = 'Speech Recognition / Text to Speech';
|
||||
$mod['module_description'] = 'Commandline text to speech engine.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_unimrcp":
|
||||
$mod['module_label'] = 'MRCP';
|
||||
$mod['module_category'] = 'Speech Recognition / Text to Speech';
|
||||
$mod['module_description'] = 'Media Resource Control Protocol.';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
break;
|
||||
case "mod_valet_parking":
|
||||
$mod['module_label'] = 'Valet Parking';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Call parking';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_voicemail":
|
||||
$mod['module_label'] = 'Voicemail';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Full featured voicemail module.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_voicemail_ivr":
|
||||
$mod['module_label'] = 'Voicemail IVR';
|
||||
$mod['module_category'] = 'Applications';
|
||||
$mod['module_description'] = 'Voicemail IVR interface.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_xml_cdr":
|
||||
$mod['module_label'] = 'XML CDR';
|
||||
$mod['module_category'] = 'XML Interfaces';
|
||||
$mod['module_description'] = 'XML based call detail record handler.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
case "mod_xml_curl":
|
||||
$mod['module_label'] = 'XML Curl';
|
||||
$mod['module_category'] = 'XML Interfaces';
|
||||
$mod['module_description'] = 'Request XML config files dynamically.';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
break;
|
||||
case "mod_xml_rpc":
|
||||
$mod['module_label'] = 'XML RPC';
|
||||
$mod['module_category'] = 'XML Interfaces';
|
||||
$mod['module_description'] = 'XML Remote Procedure Calls. Issue commands from your web application.';
|
||||
$mod['module_enabled'] = 'true';
|
||||
$mod['module_default_enabled'] = 'true';
|
||||
break;
|
||||
default:
|
||||
$mod['module_category'] = 'Auto';
|
||||
$mod['module_enabled'] = 'false';
|
||||
$mod['module_default_enabled'] = 'false';
|
||||
}
|
||||
return $mod;
|
||||
}
|
||||
|
||||
//check to see if the module exists in the array
|
||||
public function exists($name) {
|
||||
//set the default
|
||||
$result = false;
|
||||
//look for the module
|
||||
foreach ($this->modules as &$row) {
|
||||
if ($row['module_name'] == $name) {
|
||||
$result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//return the result
|
||||
return $result;
|
||||
}
|
||||
|
||||
//check the status of the module
|
||||
public function active($name) {
|
||||
if (!$this->fp) {
|
||||
$this->fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||
}
|
||||
if ($this->fp) {
|
||||
$cmd = "api module_exists ".$name;
|
||||
$response = trim(event_socket_request($this->fp, $cmd));
|
||||
if ($response == "true") {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//get the list of modules
|
||||
public function get_modules() {
|
||||
$sql = " select * from v_modules ";
|
||||
$sql .= "order by module_category, module_label";
|
||||
$prep_statement = $this->db->prepare($sql);
|
||||
$prep_statement->execute();
|
||||
$this->modules = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
unset ($prep_statement, $sql);
|
||||
}
|
||||
|
||||
//add missing modules for more module info see http://wiki.freeswitch.com/wiki/Modules
|
||||
public function synch() {
|
||||
if ($handle = opendir($this->dir)) {
|
||||
$modules_new = '';
|
||||
$module_found = false;
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != "." && $file != "..") {
|
||||
if (substr($file, -3) == ".so" || substr($file, -4) == ".dll") {
|
||||
if (substr($file, -3) == ".so") {
|
||||
$name = substr($file, 0, -3);
|
||||
}
|
||||
if (substr($file, -4) == ".dll") {
|
||||
$name = substr($file, 0, -4);
|
||||
}
|
||||
if (!$this->exists($name)) {
|
||||
//set module found to true
|
||||
$module_found = true;
|
||||
//get the module array
|
||||
$mod = $this->info($name);
|
||||
//append the module label
|
||||
$modules_new .= "<li>".$mod['module_label']."</li>\n";
|
||||
//insert the data
|
||||
$module_uuid = uuid();
|
||||
$sql = "insert into v_modules ";
|
||||
$sql .= "(";
|
||||
$sql .= "module_uuid, ";
|
||||
$sql .= "module_label, ";
|
||||
$sql .= "module_name, ";
|
||||
$sql .= "module_description, ";
|
||||
$sql .= "module_category, ";
|
||||
$sql .= "module_enabled, ";
|
||||
$sql .= "module_default_enabled ";
|
||||
$sql .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".$module_uuid."', ";
|
||||
$sql .= "'".$mod['module_label']."', ";
|
||||
$sql .= "'".$mod['module_name']."', ";
|
||||
$sql .= "'".$mod['module_description']."', ";
|
||||
$sql .= "'".$mod['module_category']."', ";
|
||||
$sql .= "'".$mod['module_enabled']."', ";
|
||||
$sql .= "'".$mod['module_default_enabled']."' ";
|
||||
$sql .= ")";
|
||||
$this->db->exec($sql);
|
||||
unset($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
if ($module_found) {
|
||||
//save_module_xml();
|
||||
$msg = "<strong>Added New Modules:</strong><br />\n";
|
||||
$msg .= "<ul>\n";
|
||||
$msg .= $modules_new;
|
||||
$msg .= "</ul>\n";
|
||||
$this->msg = $msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
} //class
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user