From 61e1af73fff94b8e1f685a387a8852e896b1279a Mon Sep 17 00:00:00 2001 From: mjollnir_ Date: Mon, 31 Jan 2005 04:26:22 +0000 Subject: [PATCH] Apparently I forgot to commit this new file when committing the import course content stuff. Here it is! --- course/import.php | 101 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 course/import.php diff --git a/course/import.php b/course/import.php new file mode 100644 index 0000000000..cd38aee227 --- /dev/null +++ b/course/import.php @@ -0,0 +1,101 @@ +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(); +?> \ No newline at end of file -- 2.39.5