3
0
mirror of https://github.com/snipe/snipe-it.git synced 2025-10-29 11:21:21 +00:00

Fixed #17674 - added odp, ods, odt to accepted files

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2025-08-20 14:11:20 +01:00
parent 312be98132
commit 618106c103
6 changed files with 38 additions and 5 deletions

View File

@ -1197,19 +1197,30 @@ class Helper
'webp' => 'far fa-image',
'avif' => 'far fa-image',
'svg' => 'fas fa-vector-square',
// word
'doc' => 'far fa-file-word',
'docx' => 'far fa-file-word',
// Excel
'xls' => 'far fa-file-excel',
'xlsx' => 'far fa-file-excel',
'ods' => 'far fa-file-excel',
// Presentation
'ppt' => 'far fa-file-powerpoint',
'odp' => 'far fa-file-powerpoint',
// archive
'zip' => 'fas fa-file-archive',
'rar' => 'fas fa-file-archive',
//Text
'odt' => 'far fa-file-alt',
'txt' => 'far fa-file-alt',
'rtf' => 'far fa-file-alt',
'xml' => 'fas fa-code',
// Misc
'pdf' => 'far fa-file-pdf',
'lic' => 'far fa-save',

View File

@ -29,7 +29,7 @@ class StorageHelper
public static function getMediaType($file_with_path) {
// The file exists and is allowed to be displayed inline
// Get the file extension and determine the media type
if (Storage::exists($file_with_path)) {
$fileinfo = pathinfo($file_with_path);
$extension = strtolower($fileinfo['extension']);
@ -51,6 +51,15 @@ class StorageHelper
case 'webm':
case 'mov':
return 'video';
case 'doc':
case 'docx':
return 'document';
case 'txt':
return 'text';
case 'xls':
case 'xlsx':
case 'ods':
return 'spreadsheet';
default:
return $extension; // Default for unknown types
}
@ -87,9 +96,11 @@ class StorageHelper
'webp',
];
\Log::error(pathinfo($file_with_path, PATHINFO_EXTENSION));
// The file exists and is allowed to be displayed inline
if (Storage::exists($file_with_path) && (in_array(pathinfo($file_with_path, PATHINFO_EXTENSION), $allowed_inline))) {
\Log::error('File is allowed inline: ' . $file_with_path);
return true;
}
return false;

View File

@ -45,7 +45,7 @@ class UploadedFilesTransformer
] : null,
'created_at' => Helper::getFormattedDateObject($file->created_at, 'datetime'),
'deleted_at' => Helper::getFormattedDateObject($file->deleted_at, 'datetime'),
'inlineable' => StorageHelper::allowSafeInline($file->uploads_file_path()),
'inlineable' => StorageHelper::allowSafeInline($file->uploads_file_path()) ?? false,
'exists_on_disk' => (Storage::exists($file->uploads_file_path()) ? true : false),
];

View File

@ -123,6 +123,9 @@ $config['allowed_upload_extensions_array'] = [
'mov',
'mp3',
'mp4',
'odp',
'ods',
'odt',
'ogg',
'pdf',
'png',
@ -140,12 +143,15 @@ $config['allowed_upload_extensions_array'] = [
];
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types/Common_types
$config['allowed_upload_mimetypes_array'] = [
'application/json',
'application/msword',
'application/pdf',
'application/vnd.ms-excel',
'application/vnd.oasis.opendocument.presentation',
'application/vnd.oasis.opendocument.spreadsheet',
'application/vnd.oasis.opendocument.text',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/x-rar-compressed',

View File

@ -337,6 +337,7 @@ return [
'zip' => 'Zip',
'noimage' => 'No image uploaded or image not found.',
'file_does_not_exist' => 'The requested file does not exist on the server.',
'file_not_inlineable' => 'The requested file cannot be opened inline in your browser. You can download it instead.',
'open_new_window' => 'Open this file in a new window',
'file_upload_success' => 'File upload success!',
'no_files_uploaded' => 'File upload success!',

View File

@ -966,10 +966,14 @@
var download_button = '<a href="' + download_url + '" class="btn btn-sm btn-default" data-tooltip="true" title="{{ trans('general.download') }}"><x-icon type="download" /></a>';
var download_button_disabled = '<span data-tooltip="true" title="{{ trans('general.file_does_not_exist') }}"><a class="btn btn-sm btn-default disabled"><x-icon type="download" /></a></span>';
var inline_button = '<a href="'+ download_url +'?inline=true" class="btn btn-sm btn-default" target="_blank" data-tooltip="true" title="{{ trans('general.open_new_window') }}"><x-icon type="external-link" /></a>';
var inline_button_disabled = '<span data-tooltip="true" title="{{ trans('general.file_does_not_exist') }}"><a class="btn btn-sm btn-default disabled" target="_blank" data-tooltip="true" title="{{ trans('general.file_does_not_exist') }}"><x-icon type="external-link" /></a></span>';
var inline_button_disabled = '<span data-tooltip="true" title="{{ trans('general.file_not_inlineable') }}"><a class="btn btn-sm btn-default disabled" target="_blank" data-tooltip="true" title="{{ trans('general.file_does_not_exist') }}"><x-icon type="external-link" /></a></span>';
if (exists_on_disk === true) {
return '<span style="white-space: nowrap;">' + download_button + ' ' + inline_button + '</span>';
if (inlinable === true) {
return '<span style="white-space: nowrap;">' + download_button + ' ' + inline_button + '</span>';
} else {
return '<span style="white-space: nowrap;">' + download_button + ' ' + inline_button_disabled + '</span>';
}
} else {
return '<span style="white-space: nowrap;">' + download_button_disabled + ' ' + inline_button_disabled + '</span>';
}