Add more fax permissions

This commit is contained in:
FusionPBX 2024-02-05 13:35:06 -07:00 committed by GitHub
parent 42cf20a976
commit 951c36b70b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 172 additions and 107 deletions

View File

@ -217,6 +217,51 @@
$apps[$x]['permissions'][$y]['groups'][] = "admin"; $apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "user"; $apps[$x]['permissions'][$y]['groups'][] = "user";
$apps[$x]['permissions'][$y]['groups'][] = "fax"; $apps[$x]['permissions'][$y]['groups'][] = "fax";
$y++;
$apps[$x]['permissions'][$y]['name'] = "fax_extension";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "fax";
$y++;
$apps[$x]['permissions'][$y]['name'] = "fax_accountcode";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "fax";
$y++;
$apps[$x]['permissions'][$y]['name'] = "fax_destination_number";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "fax";
$y++;
$apps[$x]['permissions'][$y]['name'] = "fax_prefix";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "fax";
$y++;
$apps[$x]['permissions'][$y]['name'] = "fax_caller_id_name";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "fax";
$y++;
$apps[$x]['permissions'][$y]['name'] = "fax_caller_id_number";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "fax";
$y++;
$apps[$x]['permissions'][$y]['name'] = "fax_forward_number";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "fax";
$y++;
$apps[$x]['permissions'][$y]['name'] = "fax_toll_allow";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "fax";
$y++;
$apps[$x]['permissions'][$y]['name'] = "fax_send_channels";
//$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
//$apps[$x]['permissions'][$y]['groups'][] = "admin";
//$apps[$x]['permissions'][$y]['groups'][] = "fax";
//default settings //default settings
$y=0; $y=0;

View File

@ -17,7 +17,7 @@
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2023 Portions created by the Initial Developer are Copyright (C) 2008-2024
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
@ -118,7 +118,7 @@
$fax_accountcode = $_POST["accountcode"]; $fax_accountcode = $_POST["accountcode"];
$fax_destination_number = $_POST["fax_destination_number"]; $fax_destination_number = $_POST["fax_destination_number"];
$fax_prefix = $_POST["fax_prefix"]; $fax_prefix = $_POST["fax_prefix"];
$fax_email = implode(',',array_filter($_POST["fax_email"])); $fax_email = implode(',',array_filter($_POST["fax_email"] ?? []));
$fax_email_connection_type = $_POST["fax_email_connection_type"]; $fax_email_connection_type = $_POST["fax_email_connection_type"];
$fax_email_connection_host = $_POST["fax_email_connection_host"]; $fax_email_connection_host = $_POST["fax_email_connection_host"];
$fax_email_connection_port = $_POST["fax_email_connection_port"]; $fax_email_connection_port = $_POST["fax_email_connection_port"];
@ -222,9 +222,9 @@
clearstatcache(); clearstatcache();
//process the data //process the data
if (count($_POST) > 0 && empty($_POST["persistformvar"])) { if (!empty($_POST) && empty($_POST["persistformvar"])) {
$msg = ''; //get the fax_uuid
if ($action == "update" && is_uuid($_POST["fax_uuid"]) && permission_exists('fax_extension_edit')) { if ($action == "update" && is_uuid($_POST["fax_uuid"]) && permission_exists('fax_extension_edit')) {
$fax_uuid = $_POST["fax_uuid"]; $fax_uuid = $_POST["fax_uuid"];
} }
@ -238,7 +238,8 @@
} }
//check for all required data //check for all required data
if (empty($fax_extension)) { $msg .= "".$text['confirm-ext']."<br>\n"; } $msg = '';
if (permission_exists('fax_extension') && empty($fax_extension)) { $msg .= "".$text['confirm-ext']."<br>\n"; }
if (empty($fax_name)) { $msg .= "".$text['confirm-fax']."<br>\n"; } if (empty($fax_name)) { $msg .= "".$text['confirm-fax']."<br>\n"; }
if (!empty($msg) && empty($_POST["persistformvar"])) { if (!empty($msg) && empty($_POST["persistformvar"])) {
require_once "resources/header.php"; require_once "resources/header.php";
@ -316,12 +317,22 @@
if (is_array($array) && @sizeof($array) != 0) { if (is_array($array) && @sizeof($array) != 0) {
//add common columns to array //add common columns to array
$array['fax'][0]['domain_uuid'] = $_SESSION['domain_uuid']; $array['fax'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
if (permission_exists('fax_extension')) {
$array['fax'][0]['fax_extension'] = $fax_extension; $array['fax'][0]['fax_extension'] = $fax_extension;
}
if (permission_exists('fax_accountcode')) {
$array['fax'][0]['accountcode'] = $fax_accountcode; $array['fax'][0]['accountcode'] = $fax_accountcode;
}
if (permission_exists('fax_destination_number')) {
$array['fax'][0]['fax_destination_number'] = $fax_destination_number; $array['fax'][0]['fax_destination_number'] = $fax_destination_number;
}
if (permission_exists('fax_prefix')) {
$array['fax'][0]['fax_prefix'] = $fax_prefix; $array['fax'][0]['fax_prefix'] = $fax_prefix;
}
$array['fax'][0]['fax_name'] = $fax_name; $array['fax'][0]['fax_name'] = $fax_name;
if (permission_exists('fax_email')) {
$array['fax'][0]['fax_email'] = $fax_email; $array['fax'][0]['fax_email'] = $fax_email;
}
if (permission_exists('fax_extension_advanced') && function_exists("imap_open") && file_exists("fax_files_remote.php")) { 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_type'] = $fax_email_connection_type;
$array['fax'][0]['fax_email_connection_host'] = $fax_email_connection_host; $array['fax'][0]['fax_email_connection_host'] = $fax_email_connection_host;
@ -335,16 +346,26 @@
$array['fax'][0]['fax_email_outbound_subject_tag'] = $fax_email_outbound_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_email_outbound_authorized_senders'] = $fax_email_outbound_authorized_senders;
} }
if (permission_exists('fax_caller_id_name')) {
$array['fax'][0]['fax_caller_id_name'] = $fax_caller_id_name; $array['fax'][0]['fax_caller_id_name'] = $fax_caller_id_name;
}
if (permission_exists('fax_caller_id_number')) {
$array['fax'][0]['fax_caller_id_number'] = $fax_caller_id_number; $array['fax'][0]['fax_caller_id_number'] = $fax_caller_id_number;
}
if (permission_exists('fax_toll_allow')) {
$array['fax'][0]['fax_toll_allow'] = $fax_toll_allow; $array['fax'][0]['fax_toll_allow'] = $fax_toll_allow;
}
if (permission_exists('fax_forward_number')) {
if ($action == "add" && !empty($fax_forward_number)) { if ($action == "add" && !empty($fax_forward_number)) {
$array['fax'][0]['fax_forward_number'] = $fax_forward_number; $array['fax'][0]['fax_forward_number'] = $fax_forward_number;
} }
if ($action == "update") { if ($action == "update") {
$array['fax'][0]['fax_forward_number'] = !empty($fax_forward_number) ? $fax_forward_number : null; $array['fax'][0]['fax_forward_number'] = !empty($fax_forward_number) ? $fax_forward_number : null;
} }
}
if (permission_exists('fax_send_channels')) {
$array['fax'][0]['fax_send_channels'] = strlen($fax_send_channels) != 0 ? $fax_send_channels : null; $array['fax'][0]['fax_send_channels'] = strlen($fax_send_channels) != 0 ? $fax_send_channels : null;
}
$array['fax'][0]['fax_description'] = $fax_description; $array['fax'][0]['fax_description'] = $fax_description;
//execute //execute
@ -512,9 +533,17 @@
echo "<div class='action_bar' id='action_bar'>\n"; echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-fax_server_settings']."</b></div>\n"; echo " <div class='heading'><b>".$text['header-fax_server_settings']."</b></div>\n";
echo " <div class='actions'>\n"; echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','link'=>'fax.php']); echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','link'=>'fax.php']);
if ($action == "update") { if ($action == "update") {
$button_margin = 'margin-left: 15px;'; $button_margin = 'margin-left: 15px;';
if (permission_exists('fax_extension_advanced')) {
$button_margin = 'margin-left: 15px;';
if (function_exists("imap_open") && file_exists("fax_files_remote.php")) {
echo button::create(['type'=>'button','label'=>$text['button-advanced'],'icon'=>'tools','style'=>($button_margin ?? null),'onclick'=>"toggle_advanced('advanced_email_connection');"]);
}
unset($button_margin);
}
if (permission_exists('fax_extension_copy')) { if (permission_exists('fax_extension_copy')) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'name'=>'btn_copy','style'=>($button_margin ?? null),'onclick'=>"modal_open('modal-copy','btn_copy');"]); echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'name'=>'btn_copy','style'=>($button_margin ?? null),'onclick'=>"modal_open('modal-copy','btn_copy');"]);
unset($button_margin); unset($button_margin);
@ -524,6 +553,7 @@
unset($button_margin); unset($button_margin);
} }
} }
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','style'=>'margin-left: 15px;']); echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','style'=>'margin-left: 15px;']);
echo " </div>\n"; echo " </div>\n";
echo " <div style='clear: both;'></div>\n"; echo " <div style='clear: both;'></div>\n";
@ -539,23 +569,6 @@
} }
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
if (!permission_exists('fax_extension_delete')) {
echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-email']."\n";
echo "</td>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <input class='formfld' type='email' name='fax_email' maxlength='255' value=\"".escape($fax_email)."\">\n";
echo "<br />\n";
echo " ".$text['description-email']."\n";
echo "</td>\n";
echo "</tr>\n";
}
else { //admin, superadmin, etc
echo "<tr>\n"; echo "<tr>\n";
echo "<td width='30%' class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td width='30%' class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-name']."\n"; echo " ".$text['label-name']."\n";
@ -567,6 +580,7 @@
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
if (permission_exists('fax_extension')) {
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-extension']."\n"; echo " ".$text['label-extension']."\n";
@ -577,7 +591,9 @@
echo "".$text['description-extension']."\n"; echo "".$text['description-extension']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
}
if (permission_exists('fax_accountcode')) {
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-accountcode']."\n"; echo " ".$text['label-accountcode']."\n";
@ -589,7 +605,9 @@
echo $text['description-accountcode']."\n"; echo $text['description-accountcode']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
}
if (permission_exists('fax_destination_number')) {
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-destination-number']."\n"; echo " ".$text['label-destination-number']."\n";
@ -600,7 +618,9 @@
echo " ".$text['description-destination-number']."\n"; echo " ".$text['description-destination-number']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
}
if (permission_exists('fax_prefix')) {
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-fax_prefix']."\n"; echo " ".$text['label-fax_prefix']."\n";
@ -611,7 +631,9 @@
echo " ".$text['description-fax_prefix']."\n"; echo " ".$text['description-fax_prefix']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
}
if (permission_exists('fax_email')) {
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-email']."\n"; echo " ".$text['label-email']."\n";
@ -631,15 +653,13 @@
echo " <input class='formfld' type=\"text\" name=\"fax_email[".$x++."]\" maxlength='255' style=\"width: 90%;\"value=\"\">\n"; echo " <input class='formfld' type=\"text\" name=\"fax_email[".$x++."]\" maxlength='255' style=\"width: 90%;\"value=\"\">\n";
echo " </td>\n"; echo " </td>\n";
echo "</table>\n"; echo "</table>\n";
echo " ".$text['description-email']."\n";
if (permission_exists('fax_extension_advanced') && function_exists("imap_open") && file_exists("fax_files_remote.php")) {
echo "<br /><br />\n";
echo button::create(['type'=>'button','label'=>$text['button-advanced'],'icon'=>'tools','onclick'=>"toggle_advanced('advanced_email_connection');"]);
}
echo "<br />\n"; echo "<br />\n";
echo " ".$text['description-email']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
}
if (permission_exists('fax_caller_id_name')) {
echo "<tr>\n"; echo "<tr>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-caller-id-name']."\n"; echo " ".$text['label-caller-id-name']."\n";
@ -650,7 +670,9 @@
echo "".$text['description-caller-id-name']."\n"; echo "".$text['description-caller-id-name']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
}
if (permission_exists('fax_caller_id_number')) {
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-caller-id-number']."\n"; echo " ".$text['label-caller-id-number']."\n";
@ -661,7 +683,9 @@
echo "".$text['description-caller-id-number']."\n"; echo "".$text['description-caller-id-number']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
}
if (permission_exists('fax_forward_number')) {
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-forward']."\n"; echo " ".$text['label-forward']."\n";
@ -672,7 +696,9 @@
echo "".$text['description-forward-number']."\n"; echo "".$text['description-forward-number']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
}
if (permission_exists('fax_toll_allow')) {
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-toll_allow']."\n"; echo " ".$text['label-toll_allow']."\n";
@ -683,6 +709,7 @@
echo "".$text['description-toll_allow']."\n"; echo "".$text['description-toll_allow']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
}
if (permission_exists('fax_user_view')) { if (permission_exists('fax_user_view')) {
if ($action == "update") { if ($action == "update") {
@ -722,6 +749,7 @@
} }
} }
if (permission_exists('fax_send_channels')) {
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-fax_send_channels']."\n"; echo " ".$text['label-fax_send_channels']."\n";
@ -732,6 +760,7 @@
echo " ".$text['description-fax_send_channels']."\n"; echo " ".$text['description-fax_send_channels']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
}
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
@ -743,21 +772,11 @@
echo "".$text['description-info']."\n"; echo "".$text['description-info']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
}
echo " <tr>\n"; echo " <tr>\n";
echo " <td colspan='2' align='right'>\n"; echo " <td colspan='2' align='right'>\n";
echo " <br>"; echo " <br>";
if ($action == "update") { if ($action == "update") {
if (!permission_exists('fax_extension_delete')) {
echo " <input type='hidden' name='fax_name' value=\"".escape($fax_name)."\">\n";
echo " <input type='hidden' name='fax_extension' value=\"".escape($fax_extension)."\">\n";
echo " <input type='hidden' name='fax_destination_number' value=\"".escape($fax_destination_number)."\">\n";
echo " <input type='hidden' name='fax_caller_id_name' value=\"".escape($fax_caller_id_name)."\">\n";
echo " <input type='hidden' name='fax_caller_id_number' value=\"".escape($fax_caller_id_number)."\">\n";
echo " <input type='hidden' name='fax_forward_number' value=\"".(!empty($fax_forward_number) && is_numeric($fax_forward_number) ? format_phone($fax_forward_number) : escape($fax_forward_number))."\">\n";
echo " <input type='hidden' name='fax_description' value=\"".escape($fax_description)."\">\n";
}
echo " <input type='hidden' name='fax_uuid' value='".escape($fax_uuid)."'>\n"; echo " <input type='hidden' name='fax_uuid' value='".escape($fax_uuid)."'>\n";
echo " <input type='hidden' name='dialplan_uuid' value='".escape($dialplan_uuid)."'>\n"; echo " <input type='hidden' name='dialplan_uuid' value='".escape($dialplan_uuid)."'>\n";
} }
@ -975,3 +994,4 @@
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>