diff --git a/app/devices/app_config.php b/app/devices/app_config.php index 6f3f3cfaac..e92e7eb465 100644 --- a/app/devices/app_config.php +++ b/app/devices/app_config.php @@ -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"; diff --git a/app/devices/app_languages.php b/app/devices/app_languages.php index c0667a6139..fe7dbea165 100644 --- a/app/devices/app_languages.php +++ b/app/devices/app_languages.php @@ -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"; diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 20fc4e00c1..6039ea02bb 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -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"; }); } + \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 ""; + } + //show the content echo "
\n"; //echo ""; + echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
"; @@ -528,7 +583,27 @@ require_once "resources/require.php"; echo "

"; echo "
\n"; - echo " \n"; + echo " \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 " "; + echo " "; + echo " \n"; + //echo " "; + } if (permission_exists('device_add') && $action != "add") { echo " \n"; } diff --git a/app/provision/index.php b/app/provision/index.php index 73f2f73915..366ed87183 100644 --- a/app/provision/index.php +++ b/app/provision/index.php @@ -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();