| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // preliminary page to find a course to import data from & interface with the backup/restore functionality 2 3 require_once('../../../config.php'); 4 require_once ('../../lib.php'); 5 require_once($CFG->dirroot.'/backup/restorelib.php'); 6 7 $id = required_param('id', PARAM_INT); // course id to import TO 8 $fromcourse = optional_param('fromcourse', 0, PARAM_INT); 9 $fromcoursesearch = optional_param('fromcoursesearch', '', PARAM_RAW); 10 $page = optional_param('page', 0, PARAM_INT); 11 $filename = optional_param('filename', 0, PARAM_PATH); 12 13 $strimportactivities = get_string('importactivities'); 14 15 if (! ($course = get_record("course", "id", $id)) ) { 16 error("That's an invalid course id"); 17 } 18 19 if (!$site = get_site()){ 20 error("Couldn't get site course"); 21 } 22 23 require_login($course->id); 24 $tocontext = get_context_instance(CONTEXT_COURSE, $id); 25 if ($fromcourse) { 26 $fromcontext = get_context_instance(CONTEXT_COURSE, $fromcourse); 27 } 28 $syscontext = get_context_instance(CONTEXT_SYSTEM); 29 30 if (!has_capability('moodle/course:manageactivities', $tocontext)) { 31 error("You need do not have the required permissions to import activities to this course"); 32 } 33 34 // if we're not a course creator , we can only import from our own courses. 35 if (has_capability('moodle/course:create', $syscontext)) { 36 $creator = true; 37 } 38 39 if ($from = get_record('course', 'id', $fromcourse)) { 40 if (!has_capability('moodle/course:manageactivities', $fromcontext)) { 41 error("You need to have the required permissions in the course you are importing data from, as well"); 42 } 43 if (!empty($filename) && file_exists($CFG->dataroot.'/'.$filename) && !empty($SESSION->import_preferences)) { 44 $restore = backup_to_restore_array($SESSION->import_preferences); 45 $restore->restoreto = 1; 46 $restore->course_id = $id; 47 $restore->importing = 1; // magic variable so we know that we're importing rather than just restoring. 48 49 $SESSION->restore = $restore; 50 redirect($CFG->wwwroot.'/backup/restore.php?file='.$filename.'&id='.$fromcourse.'&to='.$id); 51 } 52 else { 53 redirect($CFG->wwwroot.'/backup/backup.php?id='.$from->id.'&to='.$course->id); 54 } 55 } 56 57 $navlinks = array(); 58 $navlinks[] = array('name' => $course->shortname, 59 'link' => "$CFG->wwwroot/course/view.php?id=$course->id", 60 'type' => 'misc'); 61 $navlinks[] = array('name' => get_string('import'), 62 'link' => "$CFG->wwwroot/course/import.php?id=$course->id", 63 'type' => 'misc'); 64 $navlinks[] = array('name' => $strimportactivities, 'link' => null, 'type' => 'misc'); 65 $navigation = build_navigation($navlinks); 66 67 print_header("$course->shortname: $strimportactivities", $course->fullname, $navigation); 68 require_once ('mod.php'); 69 70 print_footer(); 71 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |