|
|
|
@ -22,6 +22,7 @@ $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAd |
|
|
|
|
api_protect_admin_script(true); |
|
|
|
|
$nameTools = get_lang('SpecialExports'); |
|
|
|
|
$export = ''; |
|
|
|
|
$querypath = ''; |
|
|
|
|
|
|
|
|
|
// include additional libraries |
|
|
|
|
if (function_exists('ini_set')) { |
|
|
|
@ -43,10 +44,10 @@ $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') |
|
|
|
|
(isset($_POST['backup_option']) && $_POST['backup_option'] == 'full_backup') |
|
|
|
|
) { |
|
|
|
|
$export = false; |
|
|
|
|
if (isset ($_POST['action']) && $_POST['action'] == 'course_select_form') { |
|
|
|
|
if (isset($_POST['action']) && $_POST['action'] == 'course_select_form') { |
|
|
|
|
$FileZip = create_zip(); |
|
|
|
|
$to_group_id = 0; |
|
|
|
|
$sql_session = "SELECT id, name FROM $tbl_session "; |
|
|
|
@ -61,7 +62,7 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') || |
|
|
|
|
$groupCondition = " (props.to_group_id = 0 OR props.to_group_id IS NULL)"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$zip_folder=new PclZip($FileZip['TEMP_FILE_ZIP']); |
|
|
|
|
$zip_folder = new PclZip($FileZip['TEMP_FILE_ZIP']); |
|
|
|
|
if (!isset($_POST['resource']) || count($_POST['resource']) == 0) { |
|
|
|
|
Display::display_error_message(get_lang('ErrorMsgSpecialExport')); |
|
|
|
|
} else { |
|
|
|
@ -130,7 +131,7 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') || |
|
|
|
|
|
|
|
|
|
if ($export && $name) { |
|
|
|
|
Display::display_confirmation_message(get_lang('BackupCreated')); |
|
|
|
|
echo '<br /><a class="btn btn-default" href="'.api_get_path(WEB_CODE_PATH).'course_info/download.php?archive='.urlencode($name).'&session=true">'.get_lang('Download').'</a>'; |
|
|
|
|
echo '<br /><a class="btn btn-default" href="'.api_get_path(WEB_CODE_PATH).'course_info/download.php?archive_path=&archive='.urlencode($name).'">'.get_lang('Download').'</a>'; |
|
|
|
|
} else { |
|
|
|
|
// Display forms especial export |
|
|
|
|
if (isset($_POST['backup_option']) && $_POST['backup_option'] == 'select_items') { |
|
|
|
@ -153,7 +154,7 @@ Display::display_footer(); |
|
|
|
|
|
|
|
|
|
function form_special_export() |
|
|
|
|
{ |
|
|
|
|
$form = new FormValidator('special_exports','post'); |
|
|
|
|
$form = new FormValidator('special_exports', 'post'); |
|
|
|
|
$renderer = $form->defaultRenderer(); |
|
|
|
|
$renderer->setCustomElementTemplate('<div>{element}</div> '); |
|
|
|
|
$form->addElement('radio', 'backup_option', '', get_lang('SpecialCreateFullBackup'), 'full_backup'); |
|
|
|
@ -173,9 +174,9 @@ function create_zip() |
|
|
|
|
$path = '/'; |
|
|
|
|
} |
|
|
|
|
$remove_dir = ($path != '/') ? substr($path, 0, strlen($path) - strlen(basename($path))) : '/'; |
|
|
|
|
$sys_archive_path = api_get_path(SYS_ARCHIVE_PATH); |
|
|
|
|
$sys_archive_path = api_get_path(SYS_ARCHIVE_PATH).'special_export/'; |
|
|
|
|
$sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
|
|
|
$temp_zip_dir = $sys_archive_path."temp"; |
|
|
|
|
$temp_zip_dir = $sys_archive_path; |
|
|
|
|
if (!is_dir($temp_zip_dir)) { |
|
|
|
|
mkdir($temp_zip_dir, api_get_permissions_for_new_directories()); |
|
|
|
|
} else { |
|
|
|
@ -237,8 +238,8 @@ function fullexportspecial() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (count($list_course) > 0) { |
|
|
|
|
foreach($list_course as $_course) { |
|
|
|
|
if($FileZip['PATH'] == '/') { |
|
|
|
|
foreach ($list_course as $_course) { |
|
|
|
|
if ($FileZip['PATH'] == '/') { |
|
|
|
|
$querypath=''; // to prevent ...path LIKE '//%'... in query |
|
|
|
|
} else { |
|
|
|
|
$querypath = $FileZip['PATH']; |
|
|
|
@ -256,23 +257,23 @@ function fullexportspecial() |
|
|
|
|
AND $groupCondition |
|
|
|
|
AND docs.c_id = $course_id |
|
|
|
|
AND props.c_id = $course_id"; |
|
|
|
|
$query = Database::query($sql ); |
|
|
|
|
$query = Database::query($sql); |
|
|
|
|
while ($rows_course_file = Database::fetch_assoc($query)) { |
|
|
|
|
$rows_course_file['path']; |
|
|
|
|
$zip_folder->add($FileZip['PATH_COURSE'].$_course['directory']."/document".$rows_course_file['path'], |
|
|
|
|
PCLZIP_OPT_ADD_PATH, $_course['directory'], |
|
|
|
|
$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'] |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//Add tem to the zip file session course |
|
|
|
|
$code_course = $_course['code']; |
|
|
|
|
$sql_session = "SELECT s.id, name, c_id |
|
|
|
|
$sql = "SELECT s.id, name, c_id |
|
|
|
|
FROM $tbl_session_course sc |
|
|
|
|
INNER JOIN $tbl_session s |
|
|
|
|
ON sc.session_id = s.id |
|
|
|
|
WHERE c_id = '$course_id' "; |
|
|
|
|
|
|
|
|
|
$query_session = Database::query($sql_session); |
|
|
|
|
$query_session = Database::query($sql); |
|
|
|
|
while ($rows_session = Database::fetch_assoc($query_session)) { |
|
|
|
|
$session_id = $rows_session['id']; |
|
|
|
|
$sql_session_doc = "SELECT path FROM $tbl_document AS docs, $tbl_property AS props |
|
|
|
@ -287,10 +288,13 @@ function fullexportspecial() |
|
|
|
|
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']."/".$rows_session['name'], |
|
|
|
|
PCLZIP_OPT_REMOVE_PATH, $FileZip['PATH_COURSE'].$_course['directory'].'/document'.$FileZip['PATH_REMOVE'] |
|
|
|
|
); |
|
|
|
|
$zip_folder->add( |
|
|
|
|
$FileZip['PATH_COURSE'].$_course['directory'].'/document'.$rows_course_session_file['path'], |
|
|
|
|
PCLZIP_OPT_ADD_PATH, |
|
|
|
|
$_course['directory']."/".$rows_session['name'], |
|
|
|
|
PCLZIP_OPT_REMOVE_PATH, |
|
|
|
|
$FileZip['PATH_COURSE'].$_course['directory'].'/document'.$FileZip['PATH_REMOVE'] |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|