// Set visibility to 2 and rename file/folder to xxx_REPLACED_DATE_#date_ID_#id (soft delete)
if (is_file($base_work_dir.$path) || is_dir($base_work_dir.$path)) {
if (rename($base_work_dir.$path, $base_work_dir.$new_path)) {
$file_renamed_from_disk = true;
} else {
// Couldn't rename - file permissions problem?
error_log(
__FILE__.' '.__LINE__.': Error renaming '.$base_work_dir.$path.' to '.$base_work_dir.$new_path.'. This is probably due to file permissions',
0
);
}
}
if (move_uploaded_file($file['tmp_name'], $base_work_dir.$path)) {
$size = filesize($base_work_dir.$path);
$sql = "UPDATE $TABLE_DOCUMENT
SET size = '".$size."'
WHERE
c_id = $course_id AND
session_id = $sessionId AND
id = ".$documentId;
Database::query($sql);
$fileMoved = true;
}
}
// Checking inconsistency
if ($file_deleted_from_disk ||
$file_renamed_from_disk
) {
return true;
} else {
//Something went wrong
//The file or directory isn't there anymore (on the filesystem)
// This means it has been removed externally. To prevent a
// blocking error from happening, we drop the related items from the
// item_property and the document table.
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',
0
);
return false;
}
}
/**
* Parse file information into a link.
*
@ -7104,160 +7256,4 @@ class DocumentManager
return $btn;
}
/**
* Writes the content of a sent file to an existing one in the system, backing up the previous one
*
* @param array $_course
* @param string $path Path stored in the database
* @param string $base_work_dir Path to the documents folder (if not defined, $documentId must be used)
* @param int $sessionId The ID of the session, if any
* @param int $documentId The document id, if available
// Set visibility to 2 and rename file/folder to xxx_REPLACED_DATE_#date_ID_#id (soft delete)
if (is_file($base_work_dir.$path) || is_dir($base_work_dir.$path)) {
if (rename($base_work_dir.$path, $base_work_dir.$new_path)) {
$file_renamed_from_disk = true;
} else {
// Couldn't rename - file permissions problem?
error_log(
__FILE__.' '.__LINE__.': Error renaming '.$base_work_dir.$path.' to '.$base_work_dir.$new_path.'. This is probably due to file permissions',
0
);
}
}
if (move_uploaded_file($file['tmp_name'], $base_work_dir.$path)) {
$size = filesize($base_work_dir.$path);
$sql = "UPDATE $TABLE_DOCUMENT
SET size = '".$size."'
WHERE
c_id = $course_id AND
session_id = $sessionId AND
id = ".$documentId;
Database::query($sql);
$fileMoved = true;
}
}
// Checking inconsistency
if ($file_deleted_from_disk ||
$file_renamed_from_disk
) {
return true;
} else {
//Something went wrong
//The file or directory isn't there anymore (on the filesystem)
// This means it has been removed externally. To prevent a
// blocking error from happening, we drop the related items from the
// item_property and the document table.
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',