|
|
|
|
@ -384,13 +384,13 @@ class CourseRestorer |
|
|
|
|
} elseif ($document->file_type == DOCUMENT) { |
|
|
|
|
//Checking if folder exists in the database otherwise we created it |
|
|
|
|
$dir_to_create = dirname($document->path); |
|
|
|
|
|
|
|
|
|
if (!empty($dir_to_create) && $dir_to_create != 'document' && $dir_to_create != '/') { |
|
|
|
|
if (is_dir($path.dirname($document->path))) { |
|
|
|
|
$sql = "SELECT id FROM $table |
|
|
|
|
WHERE |
|
|
|
|
c_id = ".$this->destination_course_id." AND |
|
|
|
|
path = '/".self::DBUTF8escapestring(substr(dirname($document->path), 9))."'"; |
|
|
|
|
|
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
if (Database::num_rows($res) == 0) { |
|
|
|
|
//continue; |
|
|
|
|
@ -437,11 +437,13 @@ class CourseRestorer |
|
|
|
|
WHERE |
|
|
|
|
c_id = ".$this->destination_course_id." AND |
|
|
|
|
path = '/".self::DBUTF8escapestring(substr($document->path, 9))."'"; |
|
|
|
|
|
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
$count = Database::num_rows($res); |
|
|
|
|
|
|
|
|
|
if ($count == 0) { |
|
|
|
|
$params = [ |
|
|
|
|
'path' => self::DBUTF8("/".substr($document->path, 9)), |
|
|
|
|
'path' => "/".self::DBUTF8(substr($document->path, 9)), |
|
|
|
|
'c_id' => $this->destination_course_id, |
|
|
|
|
'comment'=> self::DBUTF8($document->comment), |
|
|
|
|
'title' => self::DBUTF8($document->title), |
|
|
|
|
@ -449,15 +451,16 @@ class CourseRestorer |
|
|
|
|
'size' => self::DBUTF8($document->size), |
|
|
|
|
'session_id' => $my_session_id |
|
|
|
|
]; |
|
|
|
|
$document_id = Database::insert($table, $params); |
|
|
|
|
error_log('1'); |
|
|
|
|
error_log(print_r($params, 1)); |
|
|
|
|
$document_id = Database::insert($table, $params, true); |
|
|
|
|
|
|
|
|
|
if ($document_id) { |
|
|
|
|
$sql = "UPDATE $table SET id = iid WHERE iid = $document_id"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $document_id; |
|
|
|
|
|
|
|
|
|
api_item_property_update( |
|
|
|
|
$course_info, |
|
|
|
|
TOOL_DOCUMENT, |
|
|
|
|
@ -473,20 +476,8 @@ class CourseRestorer |
|
|
|
|
} else { |
|
|
|
|
$obj = Database::fetch_object($res); |
|
|
|
|
$document_id = $obj->id; |
|
|
|
|
/*$sql = "UPDATE ".$table." SET |
|
|
|
|
path = '/".self::DBUTF8escapestring(substr($document->path, 9))."', |
|
|
|
|
c_id = ".$this->destination_course_id.", |
|
|
|
|
comment = '".self::DBUTF8escapestring($document->comment)."', |
|
|
|
|
title = '".self::DBUTF8escapestring($document->title)."' , |
|
|
|
|
filetype ='".$document->file_type."', |
|
|
|
|
size = '".$document->size."', |
|
|
|
|
session_id = '$my_session_id' |
|
|
|
|
WHERE |
|
|
|
|
c_id = ".$this->destination_course_id." AND |
|
|
|
|
path = '/".self::DBUTF8escapestring(substr($document->path, 9))."'";*/ |
|
|
|
|
|
|
|
|
|
$params = [ |
|
|
|
|
'path' => self::DBUTF8("/".substr($document->path, 9)), |
|
|
|
|
'path' => "/".self::DBUTF8(substr($document->path, 9)), |
|
|
|
|
'c_id' => $this->destination_course_id, |
|
|
|
|
'comment'=> self::DBUTF8($document->comment), |
|
|
|
|
'title' => self::DBUTF8($document->title), |
|
|
|
|
@ -494,7 +485,8 @@ class CourseRestorer |
|
|
|
|
'size' => self::DBUTF8($document->size), |
|
|
|
|
'session_id' => $my_session_id |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
error_log('2'); |
|
|
|
|
error_log(print_r($params, 1)); |
|
|
|
|
Database::update( |
|
|
|
|
$table, |
|
|
|
|
$params, |
|
|
|
|
@ -538,15 +530,6 @@ class CourseRestorer |
|
|
|
|
file_put_contents($path.$document->path,$content); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*$sql = "UPDATE $table SET |
|
|
|
|
comment = '".self::DBUTF8escapestring($document->comment)."', |
|
|
|
|
title='".self::DBUTF8escapestring($document->title)."', |
|
|
|
|
size='".$document->size."' |
|
|
|
|
WHERE |
|
|
|
|
c_id = ".$this->destination_course_id." AND |
|
|
|
|
id = '".$document_id."'"; |
|
|
|
|
Database::query($sql);*/ |
|
|
|
|
|
|
|
|
|
$params = [ |
|
|
|
|
'comment'=> self::DBUTF8($document->comment), |
|
|
|
|
'title' => self::DBUTF8($document->title), |
|
|
|
|
@ -635,7 +618,6 @@ class CourseRestorer |
|
|
|
|
|
|
|
|
|
$dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png" |
|
|
|
|
$basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1" |
|
|
|
|
//$dest_filename = basename($dest_document_path); // e.g: "collaborative.png" |
|
|
|
|
$base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document" |
|
|
|
|
|
|
|
|
|
$path_title = '/'.$new_base_foldername.'/'.$document_path[2]; |
|
|
|
|
@ -672,15 +654,6 @@ class CourseRestorer |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*$sql = "INSERT INTO $table SET |
|
|
|
|
path = '$path_title', |
|
|
|
|
c_id = ".$this->destination_course_id.", |
|
|
|
|
comment = '".self::DBUTF8escapestring($document->comment)."', |
|
|
|
|
title = '".self::DBUTF8escapestring(basename($path_title))."' , |
|
|
|
|
filetype ='".$document->file_type."', |
|
|
|
|
size = '".$document->size."', |
|
|
|
|
session_id = '$my_session_id'";*/ |
|
|
|
|
|
|
|
|
|
$params = [ |
|
|
|
|
'path' => self::DBUTF8($path_title), |
|
|
|
|
'c_id' => $this->destination_course_id, |
|
|
|
|
@ -737,17 +710,6 @@ class CourseRestorer |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*$sql = "INSERT INTO ".$table." SET |
|
|
|
|
c_id = ".$this->destination_course_id.", |
|
|
|
|
path = '/".self::DBUTF8escapestring(substr($new_file_name, 9))."', |
|
|
|
|
comment = '".self::DBUTF8escapestring($document->comment)."', |
|
|
|
|
title = '".self::DBUTF8escapestring($document->title)."' , |
|
|
|
|
filetype ='".$document->file_type."', |
|
|
|
|
size = '".$document->size."', |
|
|
|
|
session_id = '$my_session_id'"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
$document_id = Database::insert_id();*/ |
|
|
|
|
|
|
|
|
|
$params = [ |
|
|
|
|
'path' => "/".self::DBUTF8escapestring(substr($new_file_name, 9)), |
|
|
|
|
'c_id' => $this->destination_course_id, |
|
|
|
|
@ -804,18 +766,6 @@ class CourseRestorer |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*$sql = "INSERT INTO ".$table." SET |
|
|
|
|
c_id = ".$this->destination_course_id.", |
|
|
|
|
path = '/".self::DBUTF8escapestring(substr($new_file_name, 9))."', |
|
|
|
|
comment = '".self::DBUTF8escapestring($document->comment)."', |
|
|
|
|
title = '".self::DBUTF8escapestring($document->title)."' , |
|
|
|
|
filetype ='".$document->file_type."', |
|
|
|
|
size = '".$document->size."', |
|
|
|
|
session_id = '$my_session_id'"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
$document_id = Database::insert_id();*/ |
|
|
|
|
|
|
|
|
|
$params = [ |
|
|
|
|
'c_id' => $this->destination_course_id, |
|
|
|
|
'path' => "/".self::DBUTF8escapestring(substr($new_file_name, 9)), |
|
|
|
|
@ -880,20 +830,9 @@ class CourseRestorer |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*$sql = "INSERT INTO ".$table." SET |
|
|
|
|
c_id = ".$this->destination_course_id.", |
|
|
|
|
path = '/".substr($document->path, 9)."', |
|
|
|
|
comment = '".self::DBUTF8escapestring($document->comment)."', |
|
|
|
|
title = '".self::DBUTF8escapestring($document->title)."' , |
|
|
|
|
filetype='".$document->file_type."', |
|
|
|
|
size= '".$document->size."', |
|
|
|
|
session_id = '$my_session_id'"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
$document_id = Database::insert_id();*/ |
|
|
|
|
|
|
|
|
|
$params = [ |
|
|
|
|
'c_id' => $this->destination_course_id, |
|
|
|
|
'path' => "/".self::DBUTF8("/".substr($document->path, 9)), |
|
|
|
|
'path' => "/".self::DBUTF8(substr($document->path, 9)), |
|
|
|
|
'comment'=> self::DBUTF8($document->comment), |
|
|
|
|
'title' => self::DBUTF8($document->title), |
|
|
|
|
'filetype' => self::DBUTF8($document->file_type), |
|
|
|
|
|