Files
Chamilo/main/common_cartridge/export/Cc13ExportConvert.php
T
Xes 73154ae174
Behat tests 1.11.x 🐞 / PHP 7.4 Test on ubuntu-latest (push) Canceled after 0s
PHP-CS-Fixer / composer_install (7.4) (push) Canceled after 0s
Chamilo 1.11.40 (ZIP oficial v1.11.40)
Fuente: https://github.com/chamilo/chamilo-lms/releases/download/v1.11.40/chamilo-1.11.40.zip
sha256: 1cf4bf2cc7bae1ef1a1eff643235db1d552f78ddf4b6dd1e2d2dac9868679439
Snapshot independiente (rama huerfana); diffable vs 1.11.38. vendor incluido.
2026-08-06 17:59:45 +02:00

62 lines
1.7 KiB
PHP

<?php
/* For licensing terms, see /license.txt */
use Chamilo\CourseBundle\Component\CourseCopy\CourseArchiver;
class Cc13ExportConvert
{
/**
* Export the CommonCartridge object to the app/cache/course_backups/CourseCC13Archiver_[hash] directory.
*
* @param \Chamilo\CourseBundle\Component\CourseCopy\Course $objCourse
*
* @return false|string
*/
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;
}
/**
* @param $backupDir
* @param $objCourse
*
* @throws Exception
*
* @return string Filename of the created .imscc (zip) file
*/
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;
}
}