* @package chamilo.include.export */ // name of the language file that needs to be included $language_file = array('admin'); // including the global file $cidReset = true; require_once '../inc/global.inc.php'; // setting the section (for the tabs) $this_section = SECTION_PLATFORM_ADMIN; // setting breadcrumbs $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin')); // Access restrictions api_protect_admin_script(true); $nameTools = get_lang('SpecialExports'); // include additional libraries require_once '../document/document.inc.php'; // include additional libraries require_once '../coursecopy/classes/CourseBuilder.class.php'; require_once '../coursecopy/classes/CourseArchiver.class.php'; require_once '../coursecopy/classes/CourseRestorer.class.php'; require_once '../coursecopy/classes/CourseSelectForm.class.php'; if (function_exists('ini_set')) { api_set_memory_limit('256M'); ini_set('max_execution_time',0); } // Displaying the header Display::display_header($nameTools); // Display the tool title echo Display::page_header($nameTools); if (count($_POST) == 0) { Display::display_normal_message(get_lang('SpecialExportsIntroduction')); } $error =0; /* MAIN CODE */ $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (isset ($_POST['backup_option']) && $_POST['backup_option'] == 'full_backup')) { $export = false; if (isset ($_POST['action']) && $_POST['action'] == 'course_select_form') { $FileZip = create_zip(); $to_group_id = 0; $sql_session = "SELECT id, name FROM $tbl_session "; $query_session = Database::query($sql_session); $ListSession = array(); while ($rows_session = Database::fetch_assoc($query_session)) { $ListSession[$rows_session['id']] = $rows_session['name']; } $zip_folder=new PclZip($FileZip['TEMP_FILE_ZIP']); if(!isset($_POST['resource']) || count($_POST['resource']) == 0 ) { Display::display_error_message(get_lang('ErrorMsgSpecialExport')); } else { $Resource = $_POST['resource']; foreach ($Resource as $Code_course => $Sessions) { $_course = api_get_course_info($Code_course); $tbl_document = Database::get_course_table(TABLE_DOCUMENT); $tbl_property = Database::get_course_table(TABLE_ITEM_PROPERTY); $course_id = $_course['real_id']; //Add item to the zip file course $sql = "SELECT path FROM $tbl_document AS docs, $tbl_property AS props WHERE props.tool='".TOOL_DOCUMENT."' AND docs.id=props.ref AND docs.path LIKE '".$querypath."/%' AND docs.filetype='file' AND docs.session_id = '0' AND props.visibility<>'2' AND props.to_group_id= $to_group_id AND docs.c_id = $course_id AND props.c_id = $course_id"; $query = Database::query($sql ); while ($rows_course_file = Database::fetch_assoc($query)) { $zip_folder->add($FileZip['PATH_COURSE'].$_course['directory']."/document".$rows_course_file['path'], PCLZIP_OPT_ADD_PATH, $_course['directory'], PCLZIP_OPT_REMOVE_PATH, $FileZip['PATH_COURSE'].$_course['directory']."/document".$FileZip['PATH_REMOVE'] ); } foreach ($Sessions as $IdSession => $value){ $session_id = Security::remove_XSS($IdSession); //Add tem to the zip file session course $sql_session_doc = "SELECT path FROM $tbl_document AS docs, $tbl_property AS props WHERE props.tool='".TOOL_DOCUMENT."' AND docs.id=props.ref AND docs.path LIKE '".$querypath."/%' AND docs.filetype='file' AND docs.session_id = '$session_id' AND props.visibility<>'2' AND props.to_group_id= $to_group_id AND docs.c_id = $course_id AND props.c_id = $course_id"; $query_session_doc = Database::query($sql_session_doc); while ($rows_course_session_file = Database::fetch_assoc($query_session_doc)) { $zip_folder->add( $FileZip['PATH_COURSE'].$_course['directory'].'/document'.$rows_course_session_file['path'], PCLZIP_OPT_ADD_PATH, $_course['directory']."/".$ListSession[$session_id], PCLZIP_OPT_REMOVE_PATH, $FileZip['PATH_COURSE'].$_course['directory'].'/document'.$FileZip['PATH_REMOVE'] ); } } } $name = rename_zip($FileZip); $export = true; } } else { $name = fullexportspecial(); } ?> '.get_lang('Download').''; } else { // Display forms especial export if (isset ($_POST['backup_option']) && $_POST['backup_option'] == 'select_items') { $cb = new CourseBuilder(); $course = $cb->build_session_course(); if($course === false){ Display::display_error_message(get_lang('ErrorMsgSpecialExport')); form_special_export(); } else { Display::display_normal_message(get_lang('ToExportSpecialSelect')); CourseSelectForm :: display_form_session_export($course); } } else { form_special_export(); } } /* FOOTER */ Display::display_footer(); function form_special_export() { $form = new FormValidator('special_exports','post'); $renderer = $form->defaultRenderer(); $renderer->setElementTemplate('