|
|
|
@ -288,6 +288,7 @@ class CourseRestorer |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$webEditorCss = api_get_path(WEB_CSS_PATH).'editor.css'; |
|
|
|
$table = Database::get_course_table(TABLE_DOCUMENT); |
|
|
|
$table = Database::get_course_table(TABLE_DOCUMENT); |
|
|
|
$resources = $this->course->resources; |
|
|
|
$resources = $this->course->resources; |
|
|
|
$path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
|
|
|
$path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
|
|
|
@ -450,6 +451,7 @@ class CourseRestorer |
|
|
|
$origin_path = $this->course->backup_path.'/'.$document->path; |
|
|
|
$origin_path = $this->course->backup_path.'/'.$document->path; |
|
|
|
if (file_exists($origin_path)) { |
|
|
|
if (file_exists($origin_path)) { |
|
|
|
copy($origin_path, $path.$document->path); |
|
|
|
copy($origin_path, $path.$document->path); |
|
|
|
|
|
|
|
$this->fixEditorHtmlContent($path.$document->path, $webEditorCss); |
|
|
|
$sql = "SELECT id FROM $table |
|
|
|
$sql = "SELECT id FROM $table |
|
|
|
WHERE |
|
|
|
WHERE |
|
|
|
c_id = ".$this->destination_course_id." AND |
|
|
|
c_id = ".$this->destination_course_id." AND |
|
|
|
@ -684,6 +686,7 @@ class CourseRestorer |
|
|
|
$this->course->info['path'] |
|
|
|
$this->course->info['path'] |
|
|
|
); |
|
|
|
); |
|
|
|
file_put_contents($dest_document_path, $content); |
|
|
|
file_put_contents($dest_document_path, $content); |
|
|
|
|
|
|
|
$this->fixEditorHtmlContent($dest_document_path, $webEditorCss); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -702,31 +705,31 @@ class CourseRestorer |
|
|
|
if ($document_id) { |
|
|
|
if ($document_id) { |
|
|
|
$sql = "UPDATE $table SET id = iid WHERE iid = $document_id"; |
|
|
|
$sql = "UPDATE $table SET id = iid WHERE iid = $document_id"; |
|
|
|
Database::query($sql); |
|
|
|
Database::query($sql); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $document_id; |
|
|
|
$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $document_id; |
|
|
|
|
|
|
|
|
|
|
|
$itemProperty = isset($document->item_properties[0]) ? $document->item_properties[0] : ''; |
|
|
|
$itemProperty = isset($document->item_properties[0]) ? $document->item_properties[0] : ''; |
|
|
|
$insertUserId = isset($itemProperty['insert_user_id']) ? $itemProperty['insert_user_id'] : api_get_user_id(); |
|
|
|
$insertUserId = isset($itemProperty['insert_user_id']) ? $itemProperty['insert_user_id'] : api_get_user_id(); |
|
|
|
$toGroupId = isset($itemProperty['to_group_id']) ? $itemProperty['to_group_id'] : 0; |
|
|
|
$toGroupId = isset($itemProperty['to_group_id']) ? $itemProperty['to_group_id'] : 0; |
|
|
|
$toUserId = isset($itemProperty['to_user_id']) ? $itemProperty['to_user_id'] : null; |
|
|
|
$toUserId = isset($itemProperty['to_user_id']) ? $itemProperty['to_user_id'] : null; |
|
|
|
|
|
|
|
|
|
|
|
$insertUserId = $this->checkUserId($insertUserId); |
|
|
|
$insertUserId = $this->checkUserId($insertUserId); |
|
|
|
$toUserId = $this->checkUserId($toUserId, true); |
|
|
|
$toUserId = $this->checkUserId($toUserId, true); |
|
|
|
$groupInfo = $this->checkGroupId($toGroupId); |
|
|
|
$groupInfo = $this->checkGroupId($toGroupId); |
|
|
|
|
|
|
|
|
|
|
|
api_item_property_update( |
|
|
|
api_item_property_update( |
|
|
|
$course_info, |
|
|
|
$course_info, |
|
|
|
TOOL_DOCUMENT, |
|
|
|
TOOL_DOCUMENT, |
|
|
|
$document_id, |
|
|
|
$document_id, |
|
|
|
'DocumentAdded', |
|
|
|
'DocumentAdded', |
|
|
|
$insertUserId, |
|
|
|
$insertUserId, |
|
|
|
$groupInfo, |
|
|
|
$groupInfo, |
|
|
|
$toUserId, |
|
|
|
$toUserId, |
|
|
|
null, |
|
|
|
null, |
|
|
|
null, |
|
|
|
null, |
|
|
|
$my_session_id |
|
|
|
$my_session_id |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (file_exists($path.$document->path)) { |
|
|
|
if (file_exists($path.$document->path)) { |
|
|
|
copy($path.$document->path, $path.$new_file_name); |
|
|
|
copy($path.$document->path, $path.$new_file_name); |
|
|
|
@ -747,6 +750,7 @@ class CourseRestorer |
|
|
|
$this->course->info['path'] |
|
|
|
$this->course->info['path'] |
|
|
|
); |
|
|
|
); |
|
|
|
file_put_contents($path.$new_file_name, $content); |
|
|
|
file_put_contents($path.$new_file_name, $content); |
|
|
|
|
|
|
|
$this->fixEditorHtmlContent($path.$new_file_name, $webEditorCss); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -813,6 +817,7 @@ class CourseRestorer |
|
|
|
$this->course->info['path'] |
|
|
|
$this->course->info['path'] |
|
|
|
); |
|
|
|
); |
|
|
|
file_put_contents($path.$new_file_name, $content); |
|
|
|
file_put_contents($path.$new_file_name, $content); |
|
|
|
|
|
|
|
$this->fixEditorHtmlContent($path.$new_file_name, $webEditorCss); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -887,6 +892,7 @@ class CourseRestorer |
|
|
|
$this->course->info['path'] |
|
|
|
$this->course->info['path'] |
|
|
|
); |
|
|
|
); |
|
|
|
file_put_contents($path.$document->path, $content); |
|
|
|
file_put_contents($path.$document->path, $content); |
|
|
|
|
|
|
|
$this->fixEditorHtmlContent($path.$document->path, $webEditorCss); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -3568,4 +3574,26 @@ class CourseRestorer |
|
|
|
|
|
|
|
|
|
|
|
return $userId; |
|
|
|
return $userId; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @param string $documentPath |
|
|
|
|
|
|
|
* @param string $webEditorCss |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function fixEditorHtmlContent($documentPath, $webEditorCss = '') |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$extension = pathinfo(basename($documentPath), PATHINFO_EXTENSION); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch ($extension) { |
|
|
|
|
|
|
|
case 'html': |
|
|
|
|
|
|
|
case 'htm': |
|
|
|
|
|
|
|
$contents = file_get_contents($documentPath); |
|
|
|
|
|
|
|
$contents = str_replace( |
|
|
|
|
|
|
|
'{{css_editor}}', |
|
|
|
|
|
|
|
$webEditorCss, |
|
|
|
|
|
|
|
$contents |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
file_put_contents($documentPath, $contents); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|