mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-04 18:53:49 +00:00
Add ability to download the provisioning files from the device edit page for those users that have the device_files permission.
This commit is contained in:
@@ -51,6 +51,10 @@
|
||||
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
|
||||
$apps[$x]['permissions'][$y]['groups'][] = 'admin';
|
||||
$y++;
|
||||
$apps[$x]['permissions'][$y]['name'] = 'device_files';
|
||||
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
|
||||
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
|
||||
$y++;
|
||||
$apps[$x]['permissions'][$y]['name'] = "device_extension_view";
|
||||
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
|
||||
$apps[$x]['permissions'][$y]['groups'][] = "admin";
|
||||
|
||||
@@ -1378,6 +1378,19 @@ $text['label-device_mac_address']['de-at'] = "MAC Adresse";
|
||||
$text['label-device_mac_address']['ar-eg'] = "";
|
||||
$text['label-device_mac_address']['he'] = "";
|
||||
|
||||
$text['label-download']['en-us'] = "Download";
|
||||
$text['label-download']['es-cl'] = "";
|
||||
$text['label-download']['pt-pt'] = "";
|
||||
$text['label-download']['fr-fr'] = "";
|
||||
$text['label-download']['pt-br'] = "";
|
||||
$text['label-download']['pl'] = "";
|
||||
$text['label-download']['uk'] = "";
|
||||
$text['label-download']['sv-se'] = "";
|
||||
$text['label-download']['ro'] = "";
|
||||
$text['label-download']['de-at'] = "";
|
||||
$text['label-download']['ar-eg'] = "";
|
||||
$text['label-download']['he'] = "";
|
||||
|
||||
$text['label-device_label']['en-us'] = "Label";
|
||||
$text['label-device_label']['es-cl'] = "Etiqueta";
|
||||
$text['label-device_label']['pt-pt'] = "Rótulo";
|
||||
@@ -2599,6 +2612,32 @@ $text['button-copy']['de-at'] = "Kopieren";
|
||||
$text['button-copy']['ar-eg'] = "نسخ";
|
||||
$text['button-copy']['he'] = "העתקה";
|
||||
|
||||
$text['button-files']['en-us'] = "Files";
|
||||
$text['button-files']['es-cl'] = "";
|
||||
$text['button-files']['pt-pt'] = "";
|
||||
$text['button-files']['fr-fr'] = "";
|
||||
$text['button-files']['pt-br'] = "";
|
||||
$text['button-files']['pl'] = "";
|
||||
$text['button-files']['uk'] = "";
|
||||
$text['button-files']['sv-se'] = "";
|
||||
$text['button-files']['ro'] = "";
|
||||
$text['button-files']['de-at'] = "";
|
||||
$text['button-files']['ar-eg'] = "";
|
||||
$text['button-files']['he'] = "";
|
||||
|
||||
$text['button-download']['en-us'] = "Download";
|
||||
$text['button-download']['es-cl'] = "";
|
||||
$text['button-download']['pt-pt'] = "";
|
||||
$text['button-download']['fr-fr'] = "";
|
||||
$text['button-download']['pt-br'] = "";
|
||||
$text['button-download']['pl'] = "";
|
||||
$text['button-download']['uk'] = "";
|
||||
$text['button-download']['sv-se'] = "";
|
||||
$text['button-download']['ro'] = "";
|
||||
$text['button-download']['de-at'] = "";
|
||||
$text['button-download']['ar-eg'] = "";
|
||||
$text['button-download']['he'] = "";
|
||||
|
||||
$text['button-back']['en-us'] = "Back";
|
||||
$text['button-back']['es-cl'] = "Volver";
|
||||
$text['button-back']['pt-pt'] = "Voltar";
|
||||
|
||||
@@ -233,6 +233,9 @@ require_once "resources/require.php";
|
||||
//array cleanup
|
||||
$x = 0;
|
||||
//unset($_POST["autocomplete"]);
|
||||
unset($_POST["target_file"]);
|
||||
unset($_POST["file_action"]);
|
||||
|
||||
foreach ($_POST["device_lines"] as $row) {
|
||||
//unset the empty row
|
||||
if (strlen($row["line_number"]) == 0) {
|
||||
@@ -515,10 +518,62 @@ require_once "resources/require.php";
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
//select file download javascript
|
||||
if (permission_exists("device_files")) {
|
||||
echo "<script language='javascript' type='text/javascript'>\n";
|
||||
echo " var fade_speed = 400;\n";
|
||||
echo " function show_files() {\n";
|
||||
echo " document.getElementById('file_action').value = 'files';\n";
|
||||
echo " $('#button_files').fadeOut(fade_speed, function() {\n";
|
||||
echo " $('#button_back_location').fadeOut(fade_speed);\n";
|
||||
echo " $('#button_back').fadeIn(fade_speed);\n";
|
||||
echo " $('#target_file').fadeIn(fade_speed);\n";
|
||||
echo " $('#button_download').fadeIn(fade_speed);\n";
|
||||
echo " });";
|
||||
echo " }";
|
||||
echo " function hide_files() {\n";
|
||||
echo " document.getElementById('file_action').value = '';\n";
|
||||
echo " $('#button_back_location').fadeIn(fade_speed);\n";
|
||||
echo " $('#button_back').fadeOut(fade_speed);\n";
|
||||
echo " $('#target_file').fadeOut(fade_speed);\n";
|
||||
echo " $('#button_download').fadeOut(fade_speed, function() {\n";
|
||||
echo " $('#button_files').fadeIn(fade_speed);\n";
|
||||
echo " document.getElementById('target_file').selectedIndex = 0;\n";
|
||||
echo " });\n";
|
||||
echo " }\n";
|
||||
|
||||
echo " function download(d) {\n";
|
||||
echo " if (d == '".$text['label-download']."') return;\n";
|
||||
echo " window.location = 'https://".$_SESSION['domain_name']."/app/provision?mac=$device_mac_address&file=' + d + '&content_type=application/octet-stream';\n";
|
||||
echo " }\n";
|
||||
|
||||
echo "\n";
|
||||
echo " $( document ).ready(function() {\n";
|
||||
echo " $('#default_setting_search').focus();\n";
|
||||
if ($search == '') {
|
||||
echo " // scroll to previous category\n";
|
||||
echo " var category_span_id;\n";
|
||||
echo " var url = document.location.href;\n";
|
||||
echo " var hashindex = url.indexOf('#');\n";
|
||||
echo " if (hashindex == -1) { }\n";
|
||||
echo " else {\n";
|
||||
echo " category_span_id = url.substr(hashindex + 1);\n";
|
||||
echo " }\n";
|
||||
echo " if (category_span_id) {\n";
|
||||
echo " $('#page').animate({scrollTop: $('#anchor_'+category_span_id).offset().top - 200}, 'slow');\n";
|
||||
echo " }\n";
|
||||
}
|
||||
echo " });\n";
|
||||
echo "</script>";
|
||||
}
|
||||
|
||||
//show the content
|
||||
echo "<form method='post' name='frm' id='frm' action='' onsubmit='check_duplicates(); return false;'>\n";
|
||||
//echo "<input style='display:none;' type='password' name='autocomplete'>";
|
||||
echo "<input type='hidden' name='file_action' id='file_action' value=''>\n";
|
||||
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo "<tr>\n";
|
||||
echo "<td align='left' width='30%' nowrap='nowrap' valign='top'>";
|
||||
@@ -528,7 +583,27 @@ require_once "resources/require.php";
|
||||
echo " <br><br>";
|
||||
echo "</td>\n";
|
||||
echo "<td width='70%' align='right' valign='top'>\n";
|
||||
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='devices.php'\" value='".$text['button-back']."'>\n";
|
||||
echo " <input type='button' class='btn' id='button_back_location' name='' alt='".$text['button-back']."' onclick=\"window.location='devices.php'\" value='".$text['button-back']."'>\n";
|
||||
if (permission_exists("device_files")) {
|
||||
//get the template directory
|
||||
$prov = new provision;
|
||||
$prov->domain_uuid = $domain_uuid;
|
||||
$template_dir = $prov->template_dir;
|
||||
$files = glob($template_dir.'/'.$device_template.'/*');
|
||||
//add file buttons and the file list
|
||||
echo " <input type='button' class='btn' id='button_files' name='' alt='".$text['button-files']."' onclick='show_files();' value='".$text['button-files']."'>";
|
||||
echo " <input type='button' class='btn' style='display: none;' id='button_back' name='' alt='".$text['button-back']."' onclick='hide_files();' value='".$text['button-back']."'> ";
|
||||
echo " <select class='formfld' style='display: none; width: auto;' name='target_file' id='target_file' onchange='download(this.value)'>\n";
|
||||
echo " <option value=''>".$text['label-download']."</option>\n";
|
||||
foreach ($files as $file) {
|
||||
//render the file name
|
||||
$file_name = str_replace("{\$mac}",$device_mac_address,basename($file));
|
||||
//add the select option
|
||||
echo " <option value='".basename($file)."'>".$file_name."</option>\n";
|
||||
}
|
||||
echo " </select>\n";
|
||||
//echo " <input type='button' class='btn' id='button_download' style='display: none;' alt='".$text['button-download']."' value='".$text['button-download']."' onclick='document.forms.frm.submit();'>";
|
||||
}
|
||||
if (permission_exists('device_add') && $action != "add") {
|
||||
echo " <input type='button' class='btn' name='' alt='".$text['button-copy']."' onclick=\"var new_mac = prompt('".$text['message_device']."'); if (new_mac != null) { window.location='device_copy.php?id=".$device_uuid."&mac=' + new_mac; }\" value='".$text['button-copy']."'>\n";
|
||||
}
|
||||
|
||||
@@ -283,20 +283,33 @@ openlog("fusion-provisioning", LOG_PID | LOG_PERROR, LOG_LOCAL0);
|
||||
|
||||
//deliver the customized config over HTTP/HTTPS
|
||||
//need to make sure content-type is correct
|
||||
$cfg_ext = ".cfg";
|
||||
if ($device_vendor === "aastra" && strrpos($file, $cfg_ext, 0) === strlen($file) - strlen($cfg_ext)) {
|
||||
header("Content-Type: text/plain");
|
||||
header("Content-Length: ".strlen($file_contents));
|
||||
} else if ($device_vendor === "yealink") {
|
||||
header("Content-Type: text/plain");
|
||||
header("Content-Length: ".strval(strlen($file_contents)));
|
||||
} else if ($device_vendor === "snom" && $device_template === "snom/m3") {
|
||||
$file_contents = utf8_decode($file_contents);
|
||||
header("Content-Type: text/plain; charset=iso-8859-1");
|
||||
header("Content-Length: ".strlen($file_contents));
|
||||
} else {
|
||||
header("Content-Type: text/xml; charset=utf-8");
|
||||
header("Content-Length: ".strlen($file_contents));
|
||||
if ($_REQUEST['content_type'] = 'application/octet-stream') {
|
||||
$file_name = str_replace("{\$mac}",$mac,$file);
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename="'.basename($file_name).'"');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . filesize($file_contents));
|
||||
}
|
||||
else {
|
||||
$cfg_ext = ".cfg";
|
||||
if ($device_vendor === "aastra" && strrpos($file, $cfg_ext, 0) === strlen($file) - strlen($cfg_ext)) {
|
||||
header("Content-Type: text/plain");
|
||||
header("Content-Length: ".strlen($file_contents));
|
||||
} else if ($device_vendor === "yealink") {
|
||||
header("Content-Type: text/plain");
|
||||
header("Content-Length: ".strval(strlen($file_contents)));
|
||||
} else if ($device_vendor === "snom" && $device_template === "snom/m3") {
|
||||
$file_contents = utf8_decode($file_contents);
|
||||
header("Content-Type: text/plain; charset=iso-8859-1");
|
||||
header("Content-Length: ".strlen($file_contents));
|
||||
} else {
|
||||
header("Content-Type: text/xml; charset=utf-8");
|
||||
header("Content-Length: ".strlen($file_contents));
|
||||
}
|
||||
}
|
||||
echo $file_contents;
|
||||
closelog();
|
||||
|
||||
Reference in New Issue
Block a user