Documents: Hide/Show upload file to current file. - refs BT#17861

pull/3556/head
carlos alvarado 5 years ago
parent b1a2489b06
commit 563b0d008c
  1. 13
      main/document/document.php
  2. 28
      main/inc/lib/document.lib.php

@ -292,8 +292,6 @@ switch ($action) {
} }
} }
break; break;
exit();
break;
case 'delete_item': case 'delete_item':
if ($isAllowedToEdit || if ($isAllowedToEdit ||
$groupMemberWithUploadRights || $groupMemberWithUploadRights ||
@ -2281,21 +2279,16 @@ if (false === $disableQuotaMessage && count($documentAndFolders) > 1) {
echo '<script> echo '<script>
$(function() { $(function() {
$(".removeHiddenFile").click(function(){ $(".removeHiddenFile").click(function(){
data = $(this).data("id"); $.each($(".replaceIndividualFile"),function(a,b){
$(".upload_element_"+data).removeClass("hidden"); $(b).addClass("hidden");
$.each($(".currentFile"),function(a,b){
$(b).val(data);
}); });
});
$(".btnSendFile").click(function(){
data = $(this).data("id"); data = $(this).data("id");
$(".upload_element_"+data).removeClass("hidden"); $(".upload_element_"+data).removeClass("hidden");
$.each($(".currentFile"),function(a,b){ $.each($(".currentFile"),function(a,b){
$(b).val(data); $(b).val(data);
}); });
}); });
$("form[name=form_teacher_table]").prop("enctype","multipart/form-data")
$("form[name=form_teacher_table]").prop("enctype","multipart/form-data")
}); });
</script> </script>
'; ';

@ -5650,7 +5650,7 @@ class DocumentManager
] ]
); );
$html = " $html = "
<div class='upload_element_".$randomUploadName." hidden'> <div class='replaceIndividualFile upload_element_".$randomUploadName." hidden'>
<div class='form-group ' id='file_file'> <div class='form-group ' id='file_file'>
<label class='col-sm-2 control-label' for='file_".$randomUploadName."'> <label class='col-sm-2 control-label' for='file_".$randomUploadName."'>
".get_lang('File')." ".get_lang('File')."
@ -6743,14 +6743,6 @@ class DocumentManager
return false; return false;
} }
// File was already deleted.
if ($itemInfo['lastedit_type'] == 'DocumentReplaced' ||
$itemInfo['lastedit_type'] == 'replace' ||
$itemInfo['visibility'] == 2
) {
return false;
}
// Filtering by group. // Filtering by group.
if ($itemInfo['to_group_id'] != $groupId) { if ($itemInfo['to_group_id'] != $groupId) {
return false; return false;
@ -6761,26 +6753,26 @@ class DocumentManager
$document_exists_in_disk = file_exists($base_work_dir.$path); $document_exists_in_disk = file_exists($base_work_dir.$path);
$new_path = $path.'_REPLACED_DATE_'.$now.'_ID_'.$documentId; $new_path = $path.'_REPLACED_DATE_'.$now.'_ID_'.$documentId;
$file_deleted_from_disk = false; $fileMoved = false;
$file_deleted_from_disk = true;
$fileMoved = fale;
$file_renamed_from_disk = false; $file_renamed_from_disk = false;
if ($document_exists_in_disk) { if ($document_exists_in_disk) {
// Set visibility to 2 and rename file/folder to xxx_REPLACED_DATE_#date_ID_#id (soft delete) // Move old file to xxx_REPLACED_DATE_#date_ID_#id (soft delete)
if (is_file($base_work_dir.$path) || is_dir($base_work_dir.$path)) { if (is_file($base_work_dir.$path) || is_dir($base_work_dir.$path)) {
if (rename($base_work_dir.$path, $base_work_dir.$new_path)) { if (rename($base_work_dir.$path, $base_work_dir.$new_path)) {
$file_renamed_from_disk = true; $file_renamed_from_disk = true;
} else { } else {
// Couldn't rename - file permissions problem? // Couldn't rename - file permissions problem?
error_log( error_log(
__FILE__.' '.__LINE__.': Error renaming '.$base_work_dir.$path.' to '.$base_work_dir.$new_path.'. This is probably due to file permissions', __FILE__.' '.__LINE__.': Error renaming '.$base_work_dir.$path.' to '
.$base_work_dir.$new_path.'. This is probably due to file permissions',
0 0
); );
} }
} }
if (move_uploaded_file($file['tmp_name'], $base_work_dir.$path)) { if (move_uploaded_file($file['tmp_name'], $base_work_dir.$path)) {
//update file size into db
$size = filesize($base_work_dir.$path); $size = filesize($base_work_dir.$path);
$sql = "UPDATE $TABLE_DOCUMENT $sql = "UPDATE $TABLE_DOCUMENT
SET size = '".$size."' SET size = '".$size."'
@ -6793,7 +6785,7 @@ class DocumentManager
} }
} }
// Checking inconsistency // Checking inconsistency
if ($file_deleted_from_disk || if ($fileMoved ||
$file_renamed_from_disk $file_renamed_from_disk
) { ) {
return true; return true;
@ -6804,7 +6796,11 @@ class DocumentManager
// blocking error from happening, we drop the related items from the // blocking error from happening, we drop the related items from the
// item_property and the document table. // item_property and the document table.
error_log( error_log(
__FILE__.' '.__LINE__.': System inconsistency detected. The file or directory '.$base_work_dir.$path.' seems to have been removed from the filesystem independently from the web platform. To restore consistency, the elements using the same path will be removed from the database', __FILE__.' '.__LINE__.': System inconsistency detected. '.
'The file or directory '.$base_work_dir.$path.
' seems to have been removed from the filesystem independently from '.
'the web platform. To restore consistency, the elements using the same '.
'path will be removed from the database',
0 0
); );

Loading…
Cancel
Save