pull/2487/head
jmontoyaa 9 years ago
parent 60caa45049
commit e6d7edff13
  1. 2
      main/coursecopy/import_backup.php
  2. 18
      src/Chamilo/CourseBundle/Component/CourseCopy/Course.php
  3. 18
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseArchiver.php

@ -3,6 +3,8 @@
use Chamilo\CourseBundle\Component\CourseCopy\CourseSelectForm;
use Chamilo\CourseBundle\Component\CourseCopy\CourseArchiver;
use Chamilo\CourseBundle\Component\CourseCopy\CourseRestorer;
/**
* Import a backup.

@ -70,22 +70,22 @@ class Course
*/
public function has_resources($resource_type = null)
{
if( $resource_type != null) {
return isset($this->resources[$resource_type]) && is_array($this->resources[$resource_type]) && (count(
$this->resources[$resource_type]
) > 0);
if ($resource_type != null) {
return
isset($this->resources[$resource_type]) && is_array($this->resources[$resource_type]) && (
count($this->resources[$resource_type]) > 0
);
}
return (count($this->resources) > 0);
return count($this->resources) > 0;
}
/**
* @inheritdoc
*/
public function show()
{ /*
echo '<pre>';
print_r($this);
echo '</pre>';*/
{
}
/**

@ -211,20 +211,28 @@ class CourseArchiver
if ($delete) {
@unlink(api_get_path(SYS_ARCHIVE_PATH) . '' . $filename);
}
// read the course
if (!is_file('course_info.dat')) {
return new Course();
}
$fp = @fopen('course_info.dat', "r");
$contents = @fread($fp, filesize('course_info.dat'));
@fclose($fp);
// CourseCopyLearnpath class appeared in Chamilo 1.8.7, it is the former Learnpath class in the "Copy course" tool.
// For backward comaptibility with archives created on Chamilo 1.8.6.2 or older systems, we have to do the following:
// Before unserialization, if class name "Learnpath" was found, it should be renamed as "CourseCopyLearnpath".
$course = unserialize(str_replace('O:9:"Learnpath":', 'O:19:"CourseCopyLearnpath":', base64_decode($contents)));
if (get_class($course) != 'Course') {
class_alias('Chamilo\CourseBundle\Component\CourseCopy\Course', 'Course');
class_alias('Chamilo\CourseBundle\Component\CourseCopy\Resources\Document', 'Document');
class_alias('Chamilo\CourseBundle\Component\CourseCopy\Resources\QuizQuestion', 'QuizQuestion');
$course = unserialize(base64_decode($contents));
if (!in_array(
get_class($course), ['Course', 'Chamilo\CourseBundle\Component\CourseCopy\Course'])
) {
return new Course();
}
$course->backup_path = $unzip_dir;
return $course;

Loading…
Cancel
Save