mirror of
https://github.com/moodle/moodle.git
synced 2025-02-02 06:10:08 +01:00
a2c7397c42
Restore sections and mod implemented. Restore users (all, course and none) implemented
100 lines
2.7 KiB
HTML
100 lines
2.7 KiB
HTML
<?PHP //$Id$
|
|
//This page receives the required info and executes the restore
|
|
//with the parameters suplied. Whe finished, delete temporary
|
|
//data from backup_tables and temp directory
|
|
|
|
//Get objects from session
|
|
if ($SESSION) {
|
|
$info = $SESSION->info;
|
|
$course_header = $SESSION->course_header;
|
|
$restore = $SESSION->restore;
|
|
}
|
|
|
|
//Check login
|
|
require_login();
|
|
|
|
//Check admin
|
|
if (!isadmin()) {
|
|
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
|
}
|
|
|
|
//Check site
|
|
if (!$site = get_site()) {
|
|
error("Site not found!");
|
|
}
|
|
|
|
//Start the main table
|
|
echo "<table cellpadding=5>";
|
|
echo "<tr><td>";
|
|
|
|
//Start the main ul
|
|
echo "<ul>";
|
|
|
|
//Init status
|
|
$status = true;
|
|
|
|
//Localtion of the xml file
|
|
$xml_file = $CFG->dataroot."/temp/backup/".$restore->backup_unique_code."/moodle.xml";
|
|
|
|
//If we've selected to restore into new course
|
|
//create it (course)
|
|
//Saving conversion id variables into backup_tables
|
|
if ($restore->restoreto ==1) {
|
|
echo "<li>Creating new course";
|
|
$status = restore_create_new_course($restore,&$course_header);
|
|
//Print course fullname and shortname and category
|
|
if ($status) {
|
|
echo "<ul>";
|
|
echo "<li>".$course_header->course_fullname." (".$course_header->course_shortname.")";
|
|
echo "<li>".get_string("category").": ".$course_header->category->name;
|
|
echo "</ul>";
|
|
//Put the destination course_id
|
|
$restore->course_id = $course_header->course_id;
|
|
}
|
|
} else {
|
|
$course = get_record("course","id",$restore->course_id);
|
|
if ($course) {
|
|
echo "<li>Using existing course";
|
|
echo "<ul>";
|
|
echo "<li>From: ".$course_header->course_fullname." (".$course_header->course_shortname.")";
|
|
echo "<li>To: ".$course->fullname." (".$course->shortname.")";
|
|
echo "</ul>";
|
|
}
|
|
}
|
|
|
|
//Now create the course_sections and their associated course_modules
|
|
if (($restore->restoreto ==1) and ($status)) {
|
|
echo "<li>Creating sections";
|
|
$status = restore_create_sections($restore,$xml_file);
|
|
}
|
|
|
|
//Now create users as needed
|
|
if ($status and ($restore->users == 0 or $restore->users == 1)) {
|
|
echo "<li>Creating users";
|
|
$status = restore_create_users($restore,$xml_file);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Now, if all is OK, adjust the instance field in course_modules !!
|
|
|
|
//Now if all is OK, update course modinfo field !!
|
|
|
|
//End the main ul
|
|
echo "</ul>";
|
|
|
|
|
|
//End the main table
|
|
echo "</tr></td>";
|
|
echo "</table>";
|
|
|
|
if (!$status) {
|
|
error ("An error has ocurred");
|
|
}
|
|
|
|
?>
|