id); if ($from = get_record("course","id",$fromcourse)) { if (!empty($filename) && file_exists($CFG->dataroot.'/'.$filename) && !empty($SESSION->import_preferences)) { $restore = backup_to_restore_array($SESSION->import_preferences); $restore->restoreto = 1; $restore->course_id=$id; $restore->importing=1; // magic variable so we know that we're importing rather than just restoring. $SESSION->restore = $restore; redirect($CFG->wwwroot.'/backup/restore.php?file='.$filename.'&id='.$fromcourse.'&to='.$id); } else { redirect($CFG->wwwroot.'/backup/backup.php?id='.$from->id.'&to='.$course->id); } } $strimport = get_string("importdata"); print_header("$course->fullname: $strimport", "$course->fullname: $strimport", "$course->shortname"); $taught_courses = get_my_courses($USER->id,"visible DESC,sortorder ASC",0,1); $cat_courses = get_courses($course->category); print_heading(get_string("importdatafrom")); $options = array(); foreach ($taught_courses as $tcourse) { if ($tcourse->id != $course->id && $tcourse->id != $site->id){ $options[$tcourse->id] = $tcourse->fullname; } } $fm = '
'; $submit = '
'; if (count($options) > 0) { $table->data[] = array($fm.''.get_string('coursestaught').'', choose_from_menu($options,"fromcourse","","choose","","0",true), $submit); } unset($options); $options = array(); foreach ($cat_courses as $ccourse) { if ($ccourse->id != $course->id && $ccourse->id != $site->id){ $options[$ccourse->id] = $ccourse->fullname; } } $cat = get_record("course_categories","id",$course->category); if (count($options) > 0) { $table->data[] = array($fm.''.get_string('coursescategory').' ('.$cat->name .')', choose_from_menu($options,"fromcourse","","choose","","0",true), $submit); } $table->data[] = array($fm.''.get_string('searchcourses').'', '', ''); if (!empty($fromcoursesearch)) { $totalcount = 0; $courses = get_courses_search(explode(" ",$fromcoursesearch),"fullname ASC",$page,50,$totalcount); if (is_array($courses) and count($courses) > 0) { $table->data[] = array(''.get_string('searchresults').'','',''); foreach ($courses as $scourse) { if ($course->id != $scourse->id) { $table->data[] = array('',$scourse->fullname, '' .get_string('usethiscourse')); } } } else { $table->data[] = array('',get_string('noresults'),''); } } print_table($table); print_footer(); ?>