mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Update fax_edit.php
This commit is contained in:
@@ -196,167 +196,168 @@
|
||||
//clear file status cache
|
||||
clearstatcache();
|
||||
|
||||
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
//process the data
|
||||
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
|
||||
$msg = '';
|
||||
if ($action == "update" && permission_exists('fax_extension_edit')) {
|
||||
$fax_uuid = $_POST["fax_uuid"];
|
||||
}
|
||||
|
||||
//check for all required data
|
||||
if (strlen($fax_extension) == 0) { $msg .= "".$text['confirm-ext']."<br>\n"; }
|
||||
if (strlen($fax_name) == 0) { $msg .= "".$text['confirm-fax']."<br>\n"; }
|
||||
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
require_once "resources/header.php";
|
||||
require_once "resources/persist_form_var.php";
|
||||
echo "<div align='center'>\n";
|
||||
echo "<table><tr><td>\n";
|
||||
echo $msg."<br />";
|
||||
echo "</td></tr></table>\n";
|
||||
persistformvar($_POST);
|
||||
echo "</div>\n";
|
||||
require_once "resources/footer.php";
|
||||
return;
|
||||
$msg = '';
|
||||
if ($action == "update" && permission_exists('fax_extension_edit')) {
|
||||
$fax_uuid = $_POST["fax_uuid"];
|
||||
}
|
||||
|
||||
//replace the spaces with a dash
|
||||
$fax_name = str_replace(" ", "-", $fax_name);
|
||||
|
||||
//escape the commas with a backslash and remove the spaces
|
||||
$fax_email = str_replace(" ", "", $fax_email);
|
||||
|
||||
//set the $php_bin
|
||||
//if (file_exists(PHP_BINDIR."/php")) { $php_bin = 'php'; }
|
||||
if (substr(strtoupper(PHP_OS), 0, 3) == "WIN") {
|
||||
$php_bin = 'php.exe';
|
||||
}
|
||||
elseif (file_exists(PHP_BINDIR."/php5")) {
|
||||
$php_bin = 'php5';
|
||||
}
|
||||
else {
|
||||
$php_bin = 'php';
|
||||
}
|
||||
|
||||
//add or update the database
|
||||
if ($_POST["persistformvar"] != "true") {
|
||||
|
||||
//prep authorized senders
|
||||
if (sizeof($fax_email_outbound_authorized_senders) > 0) {
|
||||
foreach ($fax_email_outbound_authorized_senders as $sender_num => $sender) {
|
||||
if ($sender == '' || !valid_email($sender)) { unset($fax_email_outbound_authorized_senders[$sender_num]); }
|
||||
}
|
||||
$fax_email_outbound_authorized_senders = implode(',', $fax_email_outbound_authorized_senders);
|
||||
}
|
||||
|
||||
if ($action == "add" && permission_exists('fax_extension_add')) {
|
||||
//prepare the unique identifiers
|
||||
$fax_uuid = uuid();
|
||||
$dialplan_uuid = uuid();
|
||||
|
||||
//begin insert array
|
||||
$array['fax'][0]['fax_uuid'] = $fax_uuid;
|
||||
$array['fax'][0]['dialplan_uuid'] = $dialplan_uuid;
|
||||
|
||||
//assign temp permission
|
||||
$p = new permissions;
|
||||
$p->add('fax_add', 'temp');
|
||||
|
||||
//set the dialplan action
|
||||
$dialplan_type = "add";
|
||||
}
|
||||
|
||||
if ($action == "update" && permission_exists('fax_extension_edit')) {
|
||||
//begin update array
|
||||
$array['fax'][0]['fax_uuid'] = $fax_uuid;
|
||||
|
||||
//assign temp permission
|
||||
$p = new permissions;
|
||||
$p->add('fax_edit', 'temp');
|
||||
}
|
||||
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//add common columns to array
|
||||
$array['fax'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$array['fax'][0]['fax_extension'] = $fax_extension;
|
||||
$array['fax'][0]['accountcode'] = $fax_accountcode;
|
||||
$array['fax'][0]['fax_destination_number'] = $fax_destination_number;
|
||||
$array['fax'][0]['fax_prefix'] = $fax_prefix;
|
||||
$array['fax'][0]['fax_name'] = $fax_name;
|
||||
$array['fax'][0]['fax_email'] = $fax_email;
|
||||
if (permission_exists('fax_extension_advanced') && function_exists("imap_open") && file_exists("fax_files_remote.php")) {
|
||||
$array['fax'][0]['fax_email_connection_type'] = $fax_email_connection_type;
|
||||
$array['fax'][0]['fax_email_connection_host'] = $fax_email_connection_host;
|
||||
$array['fax'][0]['fax_email_connection_port'] = $fax_email_connection_port;
|
||||
$array['fax'][0]['fax_email_connection_security'] = $fax_email_connection_security;
|
||||
$array['fax'][0]['fax_email_connection_validate'] = $fax_email_connection_validate;
|
||||
$array['fax'][0]['fax_email_connection_username'] = $fax_email_connection_username;
|
||||
$array['fax'][0]['fax_email_connection_password'] = $fax_email_connection_password;
|
||||
$array['fax'][0]['fax_email_connection_mailbox'] = $fax_email_connection_mailbox;
|
||||
$array['fax'][0]['fax_email_inbound_subject_tag'] = $fax_email_inbound_subject_tag;
|
||||
$array['fax'][0]['fax_email_outbound_subject_tag'] = $fax_email_outbound_subject_tag;
|
||||
$array['fax'][0]['fax_email_outbound_authorized_senders'] = $fax_email_outbound_authorized_senders;
|
||||
}
|
||||
$array['fax'][0]['fax_caller_id_name'] = $fax_caller_id_name;
|
||||
$array['fax'][0]['fax_caller_id_number'] = $fax_caller_id_number;
|
||||
if ($action == "add" && strlen($fax_forward_number) > 0) {
|
||||
$array['fax'][0]['fax_forward_number'] = $fax_forward_number;
|
||||
}
|
||||
if ($action == "update") {
|
||||
$array['fax'][0]['fax_forward_number'] = strlen($fax_forward_number) > 0 ? $fax_forward_number : null;
|
||||
}
|
||||
if (permission_exists('fax_send_greeting')) {
|
||||
$array['fax'][0]['fax_send_greeting'] = strlen($fax_send_greeting) != 0 ? $fax_send_greeting : null;
|
||||
}
|
||||
$array['fax'][0]['fax_send_channels'] = strlen($fax_send_channels) != 0 ? $fax_send_channels : null;
|
||||
$array['fax'][0]['fax_description'] = $fax_description;
|
||||
|
||||
//execute
|
||||
$database = new database;
|
||||
$database->app_name = 'fax';
|
||||
$database->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
//revoke temp permissions
|
||||
$p->delete('fax_add', 'temp');
|
||||
$p->delete('fax_edit', 'temp');
|
||||
}
|
||||
|
||||
//get the dialplan_uuid
|
||||
$sql = "select dialplan_uuid from v_fax ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$sql .= "and fax_uuid = :fax_uuid ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$parameters['fax_uuid'] = $fax_uuid;
|
||||
$database = new database;
|
||||
$dialplan_uuid = $database->select($sql, $parameters, 'column');
|
||||
unset($sql, $parameters);
|
||||
|
||||
//dialplan add or update
|
||||
$c = new fax;
|
||||
$c->db = $db;
|
||||
$c->domain_uuid = $_SESSION['domain_uuid'];
|
||||
$c->dialplan_uuid = $dialplan_uuid;
|
||||
$c->fax_name = $fax_name;
|
||||
$c->fax_uuid = $fax_uuid;
|
||||
$c->fax_extension = $fax_extension;
|
||||
$c->fax_forward_number = $fax_forward_number;
|
||||
$c->destination_number = $fax_destination_number;
|
||||
$c->fax_description = $fax_description;
|
||||
$a = $c->dialplan();
|
||||
|
||||
//redirect the browser
|
||||
if ($action == "update" && permission_exists('fax_extension_edit')) {
|
||||
message::add($text['confirm-update']);
|
||||
}
|
||||
if ($action == "add" && permission_exists('fax_extension_add')) {
|
||||
message::add($text['confirm-add']);
|
||||
}
|
||||
header("Location: fax.php");
|
||||
//check for all required data
|
||||
if (strlen($fax_extension) == 0) { $msg .= "".$text['confirm-ext']."<br>\n"; }
|
||||
if (strlen($fax_name) == 0) { $msg .= "".$text['confirm-fax']."<br>\n"; }
|
||||
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
require_once "resources/header.php";
|
||||
require_once "resources/persist_form_var.php";
|
||||
echo "<div align='center'>\n";
|
||||
echo "<table><tr><td>\n";
|
||||
echo $msg."<br />";
|
||||
echo "</td></tr></table>\n";
|
||||
persistformvar($_POST);
|
||||
echo "</div>\n";
|
||||
require_once "resources/footer.php";
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//replace the spaces with a dash
|
||||
$fax_name = str_replace(" ", "-", $fax_name);
|
||||
|
||||
//escape the commas with a backslash and remove the spaces
|
||||
$fax_email = str_replace(" ", "", $fax_email);
|
||||
|
||||
//set the $php_bin
|
||||
//if (file_exists(PHP_BINDIR."/php")) { $php_bin = 'php'; }
|
||||
if (substr(strtoupper(PHP_OS), 0, 3) == "WIN") {
|
||||
$php_bin = 'php.exe';
|
||||
}
|
||||
elseif (file_exists(PHP_BINDIR."/php5")) {
|
||||
$php_bin = 'php5';
|
||||
}
|
||||
else {
|
||||
$php_bin = 'php';
|
||||
}
|
||||
|
||||
//add or update the database
|
||||
if ($_POST["persistformvar"] != "true") {
|
||||
|
||||
//prep authorized senders
|
||||
if (sizeof($fax_email_outbound_authorized_senders) > 0) {
|
||||
foreach ($fax_email_outbound_authorized_senders as $sender_num => $sender) {
|
||||
if ($sender == '' || !valid_email($sender)) { unset($fax_email_outbound_authorized_senders[$sender_num]); }
|
||||
}
|
||||
$fax_email_outbound_authorized_senders = implode(',', $fax_email_outbound_authorized_senders);
|
||||
}
|
||||
|
||||
if ($action == "add" && permission_exists('fax_extension_add')) {
|
||||
//prepare the unique identifiers
|
||||
$fax_uuid = uuid();
|
||||
$dialplan_uuid = uuid();
|
||||
|
||||
//begin insert array
|
||||
$array['fax'][0]['fax_uuid'] = $fax_uuid;
|
||||
$array['fax'][0]['dialplan_uuid'] = $dialplan_uuid;
|
||||
|
||||
//assign temp permission
|
||||
$p = new permissions;
|
||||
$p->add('fax_add', 'temp');
|
||||
|
||||
//set the dialplan action
|
||||
$dialplan_type = "add";
|
||||
}
|
||||
|
||||
if ($action == "update" && permission_exists('fax_extension_edit')) {
|
||||
//begin update array
|
||||
$array['fax'][0]['fax_uuid'] = $fax_uuid;
|
||||
|
||||
//assign temp permission
|
||||
$p = new permissions;
|
||||
$p->add('fax_edit', 'temp');
|
||||
}
|
||||
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//add common columns to array
|
||||
$array['fax'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$array['fax'][0]['fax_extension'] = $fax_extension;
|
||||
$array['fax'][0]['accountcode'] = $fax_accountcode;
|
||||
$array['fax'][0]['fax_destination_number'] = $fax_destination_number;
|
||||
$array['fax'][0]['fax_prefix'] = $fax_prefix;
|
||||
$array['fax'][0]['fax_name'] = $fax_name;
|
||||
$array['fax'][0]['fax_email'] = $fax_email;
|
||||
if (permission_exists('fax_extension_advanced') && function_exists("imap_open") && file_exists("fax_files_remote.php")) {
|
||||
$array['fax'][0]['fax_email_connection_type'] = $fax_email_connection_type;
|
||||
$array['fax'][0]['fax_email_connection_host'] = $fax_email_connection_host;
|
||||
$array['fax'][0]['fax_email_connection_port'] = $fax_email_connection_port;
|
||||
$array['fax'][0]['fax_email_connection_security'] = $fax_email_connection_security;
|
||||
$array['fax'][0]['fax_email_connection_validate'] = $fax_email_connection_validate;
|
||||
$array['fax'][0]['fax_email_connection_username'] = $fax_email_connection_username;
|
||||
$array['fax'][0]['fax_email_connection_password'] = $fax_email_connection_password;
|
||||
$array['fax'][0]['fax_email_connection_mailbox'] = $fax_email_connection_mailbox;
|
||||
$array['fax'][0]['fax_email_inbound_subject_tag'] = $fax_email_inbound_subject_tag;
|
||||
$array['fax'][0]['fax_email_outbound_subject_tag'] = $fax_email_outbound_subject_tag;
|
||||
$array['fax'][0]['fax_email_outbound_authorized_senders'] = $fax_email_outbound_authorized_senders;
|
||||
}
|
||||
$array['fax'][0]['fax_caller_id_name'] = $fax_caller_id_name;
|
||||
$array['fax'][0]['fax_caller_id_number'] = $fax_caller_id_number;
|
||||
if ($action == "add" && strlen($fax_forward_number) > 0) {
|
||||
$array['fax'][0]['fax_forward_number'] = $fax_forward_number;
|
||||
}
|
||||
if ($action == "update") {
|
||||
$array['fax'][0]['fax_forward_number'] = strlen($fax_forward_number) > 0 ? $fax_forward_number : null;
|
||||
}
|
||||
if (permission_exists('fax_send_greeting')) {
|
||||
$array['fax'][0]['fax_send_greeting'] = strlen($fax_send_greeting) != 0 ? $fax_send_greeting : null;
|
||||
}
|
||||
$array['fax'][0]['fax_send_channels'] = strlen($fax_send_channels) != 0 ? $fax_send_channels : null;
|
||||
$array['fax'][0]['fax_description'] = $fax_description;
|
||||
|
||||
//execute
|
||||
$database = new database;
|
||||
$database->app_name = 'fax';
|
||||
$database->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
//revoke temp permissions
|
||||
$p->delete('fax_add', 'temp');
|
||||
$p->delete('fax_edit', 'temp');
|
||||
}
|
||||
|
||||
//get the dialplan_uuid
|
||||
$sql = "select dialplan_uuid from v_fax ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$sql .= "and fax_uuid = :fax_uuid ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$parameters['fax_uuid'] = $fax_uuid;
|
||||
$database = new database;
|
||||
$dialplan_uuid = $database->select($sql, $parameters, 'column');
|
||||
unset($sql, $parameters);
|
||||
|
||||
//dialplan add or update
|
||||
$c = new fax;
|
||||
$c->db = $db;
|
||||
$c->domain_uuid = $_SESSION['domain_uuid'];
|
||||
$c->dialplan_uuid = $dialplan_uuid;
|
||||
$c->fax_name = $fax_name;
|
||||
$c->fax_uuid = $fax_uuid;
|
||||
$c->fax_extension = $fax_extension;
|
||||
$c->fax_forward_number = $fax_forward_number;
|
||||
$c->destination_number = $fax_destination_number;
|
||||
$c->fax_description = $fax_description;
|
||||
$a = $c->dialplan();
|
||||
|
||||
//redirect the browser
|
||||
if ($action == "update" && permission_exists('fax_extension_edit')) {
|
||||
message::add($text['confirm-update']);
|
||||
}
|
||||
if ($action == "add" && permission_exists('fax_extension_add')) {
|
||||
message::add($text['confirm-add']);
|
||||
}
|
||||
header("Location: fax.php");
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//pre-populate the form
|
||||
if (is_uuid($_GET['id']) && $_POST["persistformvar"] != "true") {
|
||||
@@ -400,9 +401,38 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
$fax_send_channels = 10;
|
||||
}
|
||||
|
||||
//get the fax users
|
||||
$sql = "select * from v_fax_users as e, v_users as u ";
|
||||
$sql .= "where e.user_uuid = u.user_uuid ";
|
||||
$sql .= "and e.domain_uuid = :domain_uuid ";
|
||||
$sql .= "and e.fax_uuid = :fax_uuid ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$parameters['fax_uuid'] = $fax_uuid;
|
||||
$database = new database;
|
||||
$fax_users = $database->select($sql, $parameters, 'all');
|
||||
unset($sql, $parameters);
|
||||
|
||||
//get the users that are not assigned to this fax server
|
||||
$sql = "select * from v_users \n";
|
||||
$sql .= "where domain_uuid = :domain_uuid \n";
|
||||
$sql .= "and user_uuid not in (\n";
|
||||
$sql .= " select user_uuid from v_fax_users ";
|
||||
$sql .= " where domain_uuid = :domain_uuid ";
|
||||
$sql .= " and fax_uuid = :fax_uuid ";
|
||||
$sql .= " and user_uuid is not null ";
|
||||
$sql .= ")\n";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$parameters['fax_uuid'] = $fax_uuid;
|
||||
$database = new database;
|
||||
$available_users = $database->select($sql, $parameters, 'all');
|
||||
unset($sql, $parameters);
|
||||
|
||||
//replace the dash with a space
|
||||
$fax_name = str_replace("-", " ", $fax_name);
|
||||
|
||||
//build the fax_emails array
|
||||
$fax_emails = explode(',',$fax_email);
|
||||
|
||||
//set the dialplan_uuid
|
||||
if (!is_uuid($dialplan_uuid)) {
|
||||
$dialplan_uuid = uuid();
|
||||
@@ -519,7 +549,6 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
echo "<table border='0' cellpadding='2' cellspacing='0'>\n";
|
||||
$fax_emails = explode(',',$fax_email);
|
||||
$x = 0;
|
||||
foreach($fax_emails as $email) {
|
||||
echo "<tr>\n";
|
||||
@@ -581,51 +610,29 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
echo " <td class='vncell' valign='top'>".$text['label-user-list']."</td>";
|
||||
echo " <td class='vtable'>";
|
||||
|
||||
$sql = "select * from v_fax_users as e, v_users as u ";
|
||||
$sql .= "where e.user_uuid = u.user_uuid ";
|
||||
$sql .= "and e.domain_uuid = :domain_uuid ";
|
||||
$sql .= "and e.fax_uuid = :fax_uuid ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$parameters['fax_uuid'] = $fax_uuid;
|
||||
$database = new database;
|
||||
$result = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
if (is_array($fax_users) && @sizeof($fax_users) != 0) {
|
||||
echo " <table width='52%'>\n";
|
||||
foreach($result as $field) {
|
||||
foreach($fax_users as $field) {
|
||||
echo " <tr>\n";
|
||||
echo " <td class='vtable'>".escape($field['username'])."</td>\n";
|
||||
echo " <td>\n";
|
||||
echo " <a href='fax_edit.php?id=".escape($fax_uuid)."&domain_uuid=".$_SESSION['domain_uuid']."&user_uuid=".$field['user_uuid']."&a=delete' alt='delete' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
$assigned_user_uuids[] = $field['user_uuid'];
|
||||
}
|
||||
echo " </table>\n";
|
||||
echo " <br />\n";
|
||||
}
|
||||
unset($sql, $parameters, $result, $field);
|
||||
$sql = "select * from v_users ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
if (is_array($assigned_user_uuids) && @sizeof($assigned_user_uuids) != 0) {
|
||||
foreach($assigned_user_uuids as $index => $assigned_user_uuid) {
|
||||
if (is_uuid($assigned_user_uuid)) {
|
||||
$sql .= "and user_uuid <> :user_uuid_".$index;
|
||||
$parameters['user_uuid_'.$index] = $assigned_user_uuid;
|
||||
}
|
||||
}
|
||||
unset($assigned_user_uuids, $index, $assigned_user_uuid);
|
||||
}
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$database = new database;
|
||||
$result = $database->select($sql, $parameters, 'all');
|
||||
unset($fax_users);
|
||||
|
||||
echo " <select name='user_uuid' class='formfld' style='width: auto;'>\n";
|
||||
echo " <option value=''></option>\n";
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
foreach($result as $field) {
|
||||
if (is_array($available_users) && @sizeof($available_users) != 0) {
|
||||
foreach($available_users as $field) {
|
||||
echo " <option value='".escape($field['user_uuid'])."'>".escape($field['username'])."</option>\n";
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $result, $field);
|
||||
unset($available_users);
|
||||
echo " </select>";
|
||||
echo " <input type=\"submit\" class='btn' value=\"".$text['button-add']."\">\n";
|
||||
echo " <br>\n";
|
||||
|
||||
Reference in New Issue
Block a user