Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/main/common_cartridge/export/Cc13ExportConvert.php

46 lines
1.3 KiB

<?php
/* For licensing terms, see /license.txt */
use Chamilo\CourseBundle\Component\CourseCopy\CourseArchiver;
class Cc13ExportConvert
{
public static function export($objCourse)
{
$permDirs = api_get_permissions_for_new_directories();
$backupDirectory = CourseArchiver::getBackupDir();
// Create a temp directory
$backupDir = $backupDirectory.'CourseCC13Archiver_'.api_get_unique_id();
if (mkdir($backupDir, $permDirs, true)) {
$converted = Cc13Convert::convert($backupDirectory, $backupDir, $objCourse);
if ($converted) {
$imsccFileName = self::createImscc($backupDir, $objCourse);
return $imsccFileName;
}
}
return false;
}
public static function createImscc($backupDir, $objCourse)
{
$backupDirectory = CourseArchiver::getBackupDir();
$date = new \DateTime(api_get_local_time());
$imsccFileName = $objCourse->info['code'].'_'.$date->format('Ymd-His').'.imscc';
$imsccFilePath = $backupDirectory.$imsccFileName;
// Zip the course-contents
$zip = new \PclZip($imsccFilePath);
$zip->create($backupDir, PCLZIP_OPT_REMOVE_PATH, $backupDir);
// Remove the temp-dir.
rmdirr($backupDir);
return $imsccFileName;
}
}