* Some functions to write a course-object to a zip-file and to read a course-
@ -18,7 +17,7 @@ class CourseArchiver {
/**
* Delete old temp-dirs
*/
function clean_backup_dir() {
static function clean_backup_dir() {
$dir = api_get_path(SYS_ARCHIVE_PATH);
if ($handle = @ opendir($dir)) {
while (($file = readdir($handle)) !== false) {
@ -69,7 +68,9 @@ class CourseArchiver {
if ($res === false) {
error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
}
//Documents
// Copy all documents to the temp-dir
if (is_array($course->resources[RESOURCE_DOCUMENT])) {
foreach ($course->resources[RESOURCE_DOCUMENT] as $id => $document) {
@ -156,7 +157,7 @@ class CourseArchiver {
/**
*
*/
function import_uploaded_file($file) {
static function import_uploaded_file($file) {
$new_filename = uniqid('') . '.zip';
$new_dir = api_get_path(SYS_ARCHIVE_PATH);
if (is_dir($new_dir) && is_writable($new_dir)) {
@ -172,7 +173,7 @@ class CourseArchiver {
* @param boolean $delete Delete the file after reading the course?
* @todo Check if the archive is a correct Chamilo-export
*/
function read_course($filename, $delete = false) {
static function read_course($filename, $delete = false) {
" AND ".$table_post.".forum_id IN(".$forum_ids.");";
Database::query($sql);
$sql = "DELETE FROM ".$table_mail_queue." USING ".$table_mail_queue." INNER JOIN ".$table_post.
" WHERE c_id = ".$this->course_id." AND ".$table_mail_queue.".post_id = ".$table_post.".post_id".
" WHERE ".$table_post.".c_id = ".$this->course_id." AND ".$table_mail_queue.".c_id = ".$this->course_id." AND ".$table_mail_queue.".post_id = ".$table_post.".post_id".
" AND ".$table_post.".forum_id IN(".$forum_ids.");";
Database::query($sql);
// Just in case, deleting in the same table using thread_id as record-linker.
$sql = "DELETE FROM ".$table_mail_queue.
" USING ".$table_mail_queue." INNER JOIN ".$table_thread.
" WHERE c_id = ".$this->course_id." AND ".$table_mail_queue.".thread_id = ".$table_thread.".thread_id".
" WHERE $table_mail_queue.c_id = ".$this->course_id." AND $table_thread.c_id = ".$this->course_id." AND ".$table_mail_queue.".thread_id = ".$table_thread.".thread_id".
" AND ".$table_thread.".forum_id IN(".$forum_ids.");";
Database::query($sql);
$sql = "DELETE FROM ".$table_thread_qualify.
" USING ".$table_thread_qualify." INNER JOIN ".$table_thread.
" WHERE c_id = ".$this->course_id." AND ".$table_thread_qualify.".thread_id = ".$table_thread.".thread_id".
" WHERE $table_thread_qualify.c_id = ".$this->course_id." AND $table_thread.c_id = ".$this->course_id." AND ".$table_thread_qualify.".thread_id = ".$table_thread.".thread_id".
" AND ".$table_thread.".forum_id IN(".$forum_ids.");";
Database::query($sql);
$sql = "DELETE FROM ".$table_thread_qualify_log.
" USING ".$table_thread_qualify_log." INNER JOIN ".$table_thread.
" WHERE c_id = ".$this->course_id." AND ".$table_thread_qualify_log.".thread_id = ".$table_thread.".thread_id".
" WHERE $table_thread_qualify_log.c_id = ".$this->course_id." AND $table_thread.c_id = ".$this->course_id." AND ".$table_thread_qualify_log.".thread_id = ".$table_thread.".thread_id".
" AND ".$table_thread.".forum_id IN(".$forum_ids.");";