Fix small problem in course copy when directory not registered in original course (CT#3059)

skala
ywarnier 15 years ago
parent d6048e9d1e
commit d410d03d13
  1. 11
      main/coursecopy/classes/CourseRestorer.class.php
  2. 3
      main/inc/lib/fileUpload.lib.php

@ -233,9 +233,14 @@ class CourseRestorer
if (!is_dir($path.'document/'.$new)) {
$created_dir = create_unexisting_directory($destination_course,api_get_user_id(),0, 0 ,$path.'document',$new,basename($new),$visibility);
}
}
if ($document->file_type == DOCUMENT) {
} elseif ($document->file_type == DOCUMENT) {
if (!is_dir($path.dirname($document->path))) {
$visibility = $document->item_properties[0]['visibility'];
$new = substr($document->path, 8);
// This code fixes the possibility for a file without a directory entry to be
$created_dir = create_unexisting_directory($destination_course,api_get_user_id(),0, 0 ,$path.'document',$new,basename($new),$visibility,true);
}
if (file_exists($path.$document->path)) {
switch ($this->file_option) {

@ -1035,11 +1035,14 @@ function search_img_from_html($html_file) {
* @param array $_course current course information
* @param int $user_id current user id
* @param string $desiredDirName complete path of the desired name
* @param string The visible name of the directory
* @param int Visibility (0 for invisible, 1 for visible, 2 for deleted)
* @return string actual directory name if it succeeds,
* boolean false otherwise
*/
function create_unexisting_directory($_course, $user_id, $to_group_id, $to_user_id, $base_work_dir, $desired_dir_name, $title = null, $visibility = '') {
$nb = '';
// add numerical suffix to directory if another one of the same number already exists
while (file_exists($base_work_dir.$desired_dir_name.$nb)) {
$nb += 1;
}

Loading…
Cancel
Save