Fax Server: Class updates.
This commit is contained in:
parent
89149c0dd4
commit
d1869c2895
|
|
@ -17,21 +17,17 @@
|
|||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Copyright (C) 2015-2016
|
||||
All Rights Reserved.
|
||||
Portions created by the Initial Developer are Copyright (C) 2008 - 2019
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* cache class provides an abstracted cache
|
||||
*
|
||||
* @method string dialplan - builds the dialplan for the fax servers
|
||||
*/
|
||||
//define the fax class
|
||||
if (!class_exists('fax')) {
|
||||
class fax {
|
||||
|
||||
/**
|
||||
* define the variables
|
||||
*/
|
||||
|
|
@ -233,36 +229,41 @@
|
|||
//delete multiple records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
|
||||
//build the delete array
|
||||
//filter out unchecked fax extensions, build where clause for below
|
||||
foreach ($records as $x => $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$uuids[] = "'".$record['uuid']."'";
|
||||
}
|
||||
}
|
||||
|
||||
//primary record
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
|
||||
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$array['fax_users'][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
|
||||
$array['fax_users'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
|
||||
//include the dialplan record
|
||||
$sql = "select dialplan_uuid from v_fax ";
|
||||
//get necessary fax details
|
||||
if (is_array($uuids) && @sizeof($uuids) != 0) {
|
||||
$sql = "select ".$this->uuid_prefix."uuid as uuid, dialplan_uuid from v_".$this->table." ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$sql .= "and fax_uuid = :fax_uuid ";
|
||||
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$parameters['fax_uuid'] = $record['uuid'];
|
||||
$database = new database;
|
||||
$dialplan_uuid = $database->select($sql, $parameters, 'column');
|
||||
if (is_uuid($dialplan_uuid)) {
|
||||
// dialplan entry
|
||||
$array['dialplans'][$x]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
foreach ($rows as $row) {
|
||||
$faxes[$row['uuid']]['dialplan_uuid'] = $row['dialplan_uuid'];
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $rows, $row);
|
||||
}
|
||||
|
||||
//build the delete array
|
||||
$x = 0;
|
||||
foreach ($faxes as $fax_uuid => $fax) {
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $fax_uuid;
|
||||
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$array['fax_users'][$x][$this->uuid_prefix.'uuid'] = $fax_uuid;
|
||||
$array['fax_users'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$array['dialplans'][$x]['dialplan_uuid'] = $fax['dialplan_uuid'];
|
||||
$array['dialplans'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
|
||||
//dialplan details
|
||||
$array['dialplan_details'][$x]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplan_details'][$x]['dialplan_uuid'] = $fax['dialplan_uuid'];
|
||||
$array['dialplan_details'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
}
|
||||
unset($sql, $parameters);
|
||||
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
|
||||
//delete the checked rows
|
||||
|
|
@ -334,6 +335,8 @@
|
|||
|
||||
//create insert array from existing data
|
||||
if (is_array($uuids) && @sizeof($uuids) != 0) {
|
||||
|
||||
//primary table
|
||||
$sql = "select * from v_".$this->table." ";
|
||||
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
||||
|
|
@ -343,14 +346,15 @@
|
|||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
$y = 0;
|
||||
foreach ($rows as $x => $row) {
|
||||
$primary_uuid = uuid();
|
||||
$new_fax_uuid = uuid();
|
||||
$new_dialplan_uuid = uuid();
|
||||
|
||||
//copy data
|
||||
$array[$this->table][$x] = $row;
|
||||
|
||||
//overwrite
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $primary_uuid;
|
||||
$array[$this->table][$x]['dialplan_uuid'] = uuid();
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $new_fax_uuid;
|
||||
$array[$this->table][$x]['dialplan_uuid'] = $new_dialplan_uuid;
|
||||
if ($row['fax_forward_number'] == '') {
|
||||
unset($array[$this->table][$x]['fax_forward_number']);
|
||||
}
|
||||
|
|
@ -373,7 +377,7 @@
|
|||
|
||||
//overwrite
|
||||
$array['fax_users'][$y]['fax_user_uuid'] = uuid();
|
||||
$array['fax_users'][$y]['fax_uuid'] = $primary_uuid;
|
||||
$array['fax_users'][$y]['fax_uuid'] = $new_fax_uuid;
|
||||
|
||||
//increment
|
||||
$y++;
|
||||
|
|
@ -381,6 +385,28 @@
|
|||
}
|
||||
}
|
||||
unset($sql_2, $parameters_2, $rows_2, $row_2);
|
||||
|
||||
//fax dialplan record
|
||||
$sql_3 = "select * from v_dialplans where dialplan_uuid = :dialplan_uuid";
|
||||
$parameters_3['dialplan_uuid'] = $row['dialplan_uuid'];
|
||||
$database = new database;
|
||||
$dialplan = $database->select($sql_3, $parameters_3, 'row');
|
||||
if (is_array($dialplan) && @sizeof($dialplan) != 0) {
|
||||
|
||||
//copy data
|
||||
$array['dialplans'][$x] = $dialplan;
|
||||
|
||||
//overwrite
|
||||
$array['dialplans'][$x]['dialplan_uuid'] = $new_dialplan_uuid;
|
||||
$dialplan_xml = $dialplan['dialplan_xml'];
|
||||
$dialplan_xml = str_replace($row['fax_uuid'], $new_fax_uuid, $dialplan_xml); //replace source fax_uuid with new
|
||||
$dialplan_xml = str_replace($dialplan['dialplan_uuid'], $new_dialplan_uuid, $dialplan_xml); //replace source dialplan_uuid with new
|
||||
$array['dialplans'][$x]['dialplan_xml'] = $dialplan_xml;
|
||||
$array['dialplans'][$x]['dialplan_description'] = trim($dialplan['dialplan_description'].' ('.$text['label-copy'].')');
|
||||
|
||||
}
|
||||
unset($sql_3, $parameters_3, $dialplan);
|
||||
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $rows, $row);
|
||||
|
|
@ -392,6 +418,7 @@
|
|||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('fax_add', 'temp');
|
||||
$p->add('dialplan_add', 'temp');
|
||||
|
||||
//save the array
|
||||
$database = new database;
|
||||
|
|
@ -402,6 +429,17 @@
|
|||
|
||||
//revoke temporary permissions
|
||||
$p->delete('fax_add', 'temp');
|
||||
$p->delete('dialplan_add', 'temp');
|
||||
|
||||
//syncrhonize configuration
|
||||
save_dialplan_xml();
|
||||
|
||||
//apply settings reminder
|
||||
$_SESSION["reload_xml"] = true;
|
||||
|
||||
//clear the cache
|
||||
$cache = new cache;
|
||||
$cache->delete("dialplan:".$_SESSION["context"]);
|
||||
|
||||
//set message
|
||||
message::add($text['message-copy']);
|
||||
|
|
|
|||
Loading…
Reference in New Issue