* @package dokeos.backup
* ==============================================================================
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
// name of the language file that needs to be included
$language_file = array('coursebackup','admin');
include ('../inc/global.inc.php');
include_once(api_get_path(LIBRARY_PATH) . 'fileManage.lib.php');
require_once ('classes/CourseBuilder.class.php');
require_once ('classes/CourseRestorer.class.php');
require_once ('classes/CourseSelectForm.class.php');
if (!api_is_allowed_to_edit())
{
api_not_allowed(true);
}
//remove memory and time limits as much as possible as this might be a long process...
if(function_exists('ini_set'))
{
ini_set('memory_limit','256M');
ini_set('max_execution_time',1800);
}
$nameTools = get_lang('CopyCourse');
$interbreadcrumb[] = array ("url" => "../course_info/maintenance.php", "name" => get_lang('Maintenance'));
Display::display_header($nameTools);
//api_display_tool_title($nameTools);
/*
==============================================================================
MAIN CODE
==============================================================================
*/
// If a CourseSelectForm is posted or we should copy all resources, then copy them
if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (isset ($_POST['copy_option']) && $_POST['copy_option'] == 'full_copy'))
{
if (isset ($_POST['action']) && $_POST['action'] == 'course_select_form')
{
$course = CourseSelectForm :: get_posted_course();
}
else
{
$cb = new CourseBuilder();
$course = $cb->build();
}
$cr = new CourseRestorer($course);
$cr->set_file_option($_POST['same_file_name_option']);
$cr->restore($_POST['destination_course']);
Display::display_normal_message(get_lang('CopyFinished'));
}
// Else, if a CourseSelectForm is requested, show it
elseif (isset ($_POST['copy_option']) && $_POST['copy_option'] == 'select_items')
{
Display::display_normal_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz'));
$cb = new CourseBuilder();
$course = $cb->build();
//echo get_lang('SelectItemsToCopy');
//echo '
';
$hidden_fields['same_file_name_option'] = $_POST['same_file_name_option'];
$hidden_fields['destination_course'] = $_POST['destination_course'];
CourseSelectForm :: display_form($course, $hidden_fields);
}
// Else, show the default page
else
{
$table_c = Database :: get_main_table(TABLE_MAIN_COURSE);
$table_cu = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$user_info = api_get_user_info();
$course_info = api_get_course_info();
$sql = 'SELECT * FROM '.$table_c.' c, '.$table_cu.' cu WHERE cu.course_code = c.code';
if( ! api_is_platform_admin())
{
$sql .= ' AND cu.status=1 ';
}
$sql .= ' AND target_course_code IS NULL AND cu.user_id = '.$user_info['user_id'].' AND c.code != '."'".$course_info['sysCode']."'".' ';
$res = api_sql_query($sql,__FILE__,__LINE__);
if( mysql_num_rows($res) == 0)
{
Display::display_normal_message(get_lang('NoDestinationCoursesAvailable'));
}
else
{
?>