Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x

pull/4453/head
Yannick Warnier 3 years ago
commit 40c9d3fca6
  1. 2
      main/inc/lib/SortableTableFromArray.php
  2. 7
      tests/scripts/check_document_files_on_disk.php

@ -76,7 +76,7 @@ class SortableTableFromArray extends SortableTable
*/
public function get_total_number_of_items()
{
if (isset($this->total_number_of_items) && !empty($this->total_number_of_items)) {
if (isset($this->total_number_of_items) && !empty($this->total_number_of_items) && $this->total_number_of_items != -1) {
return $this->total_number_of_items;
} else {
if (!empty($this->table_data)) {

@ -59,14 +59,21 @@ function checkDocumentFilesOnDisk($courseCode, $removeFileNotFound)
// The file exists in other paths
foreach ($currentDocPaths as $currentPath) {
$log .= "Found on : {$currentPath}".PHP_EOL;
$sourceDir = dirname($sourcePath.$doc['path']);
// it checks if the current path is stored in document table
if (isPathInDocumentTable($currentPath, $course['id'], $sourcePath)) {
// to copy the file to the new doc path
if (!file_exists($sourceDir)) {
mkdir($sourceDir, api_get_permissions_for_new_directories(), true);
}
if (copy($currentPath, $sourcePath.$doc['path'])) {
$log .= "CASE 1 - Checking document table, it exists as document path, so it is copied to the new document path {$doc['path']}".PHP_EOL;
}
} else {
// to move the file to the new doc path
if (!file_exists($sourceDir)) {
mkdir($sourceDir, api_get_permissions_for_new_directories(), true);
}
if (rename($currentPath, $sourcePath.$doc['path'])) {
$log .= "CASE 2 - Checking document table, it doesn't exist in other path, so it is moved to the new doc path {$doc['path']}".PHP_EOL;
}

Loading…
Cancel
Save