Adding progressbar & adding api_get_cidreq() see BT#7893

1.9.x
Julio Montoya 11 years ago
parent 4a2d7c6d5a
commit 31e875c9d5
  1. 22
      main/coursecopy/create_backup.php
  2. 18
      main/coursecopy/import_backup.php

@ -53,7 +53,11 @@ echo Display::page_header($nameTools);
/* MAIN CODE */
if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') || (isset($_POST['backup_option']) && $_POST['backup_option'] == 'full_backup')) {
if ((isset($_POST['action']) &&
$_POST['action'] == 'course_select_form') ||
(isset($_POST['backup_option']) &&
$_POST['backup_option'] == 'full_backup')
) {
if (isset ($_POST['action']) && $_POST['action'] == 'course_select_form') {
$course = CourseSelectForm::get_posted_course();
} else {
@ -74,24 +78,24 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') || (is
if (!$course->has_resources()) {
echo get_lang('NoResourcesToBackup');
} else {
$form = new FormValidator('create_backup_form', 'post');
$form = new FormValidator('create_backup_form', 'post', api_get_self().'?'.api_get_cidreq());
$form->addElement('header',get_lang('SelectOptionForBackup'));
$form->addElement('radio', 'backup_option', '', get_lang('CreateFullBackup'), 'full_backup');
$form->addElement('radio', 'backup_option', '', get_lang('LetMeSelectItems'), 'select_items');
$form->addElement('style_submit_button', null, get_lang('CreateBackup'), 'class="save"');
$form->add_progress_bar();
// When progress bar appears we have to hide the title "Please select a backup-option".
$form->updateAttributes(array('onsubmit' => str_replace('javascript: ', 'javascript: page_title = getElementById(\'page_title\'); if (page_title) { setTimeout(\'page_title.style.display = \\\'none\\\';\', 2000); } ', $form->getAttribute('onsubmit'))));
$form->updateAttributes(
array('onsubmit' => str_replace(
'javascript: ',
'javascript: page_title = getElementById(\'page_title\'); if (page_title) { setTimeout(\'page_title.style.display = \\\'none\\\';\', 2000); } ',
$form->getAttribute('onsubmit')
))
);
$values['backup_option'] = 'full_backup';
$form->setDefaults($values);
$form->display();
}
}
/* FOOTER */
Display::display_footer();

@ -52,7 +52,11 @@ echo Display::page_header($nameTools);
/* MAIN CODE */
if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form' ) || (isset($_POST['import_option']) && $_POST['import_option'] == 'full_backup' )) {
if ((isset($_POST['action']) &&
$_POST['action'] == 'course_select_form') ||
(isset($_POST['import_option']) &&
$_POST['import_option'] == 'full_backup')
) {
$error = false;
if (isset($_POST['action']) && $_POST['action'] == 'course_select_form') {
// Partial backup here we recover the documents posted
@ -105,6 +109,7 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form' ) || (i
}
}
CourseArchiver::clean_backup_dir();
} elseif (isset($_POST['import_option']) && $_POST['import_option'] == 'select_items') {
if ($_POST['backup_type'] == 'server') {
$filename = $_POST['backup_server'];
@ -129,7 +134,7 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form' ) || (i
$backups = CourseArchiver::get_available_backups($is_platformAdmin ?null:$user['user_id']);
$backups_available = count($backups) > 0;
$form = new FormValidator('import_backup_form', 'post', 'import_backup.php', '', 'multipart/form-data');
$form = new FormValidator('import_backup_form', 'post', api_get_path(WEB_CODE_PATH).'coursecopy/import_backup.php?'.api_get_cidreq(), '', 'multipart/form-data');
$form->addElement('header', get_lang('SelectBackupFile'));
$renderer = $form->defaultRenderer();
$renderer->setElementTemplate('<div>{element}</div> ');
@ -175,10 +180,15 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form' ) || (i
$form->add_progress_bar();
// When progress bar appears we have to hide the title "Select backup file".
$form->updateAttributes(array('onsubmit' => str_replace('javascript: ', 'javascript: page_title = getElementById(\'page_title\'); if (page_title) { setTimeout(\'page_title.style.display = \\\'none\\\';\', 2000); } ', $form->getAttribute('onsubmit'))));
$form->updateAttributes(array(
'onsubmit' => str_replace(
'javascript: ',
'javascript: page_title = getElementById(\'page_title\'); if (page_title) { setTimeout(\'page_title.style.display = \\\'none\\\';\', 2000); } ',
$form->getAttribute('onsubmit')
)
));
$form->display();
}
/* FOOTER */
Display::display_footer();
Loading…
Cancel
Save