1
0
mirror of https://github.com/moodle/moodle.git synced 2025-03-21 16:10:15 +01:00

Now metacourse in supported in manual and scheduled backups. It can be configured

in both backups. Please check if the used structure and exported data has sense!
This commit is contained in:
stronk7 2005-02-04 14:33:51 +00:00
parent 7544920d2b
commit 572248937e
7 changed files with 137 additions and 5 deletions

@ -36,10 +36,10 @@ Now I show the specific detailed status of every item in the process:
mimic it.
22. TODO: Review the wiki module fully (if possible, try to make binary
uploaded contents to work).
23. TODO: Add support for metacourses in backup and restore. Show a new option
23. PROG: Add support for metacourses in backup and restore. Show a new option
to decide what to do (ignore, process).
24. DONE: Take out THEME from backup directory.
25. TODO: Add support for forum_read table in backup and restore.
26. TODO: chat_users->course and chat_users->lang.
26. DONE: chat_users->course and chat_users->lang. No changes required!
Eloy (stronk7)
23-01-2004

@ -58,6 +58,10 @@
}
//Check other parameters
if (!isset($backup_metacourse)) {
$backup_metacourse = 1;
}
if (!isset($backup_users)) {
$backup_users = 1;
}
@ -215,10 +219,13 @@
}
}
//Write metacourse hidden field
echo "<input type=\"hidden\" name=\"backup_metacourse\" value=\"".$backup_metacourse."\">";
if (empty($to)) {
//Line
echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
//Now print the Users tr
echo "<tr>";
echo "<td colspan=\"2\"><p><b>";

@ -66,6 +66,11 @@
}
//Check other parameters
if (!isset($backup_metacourse)) {
$backup_metacourse = 1;
}
$preferences->backup_metacourse = $backup_metacourse;
if (!isset($backup_users)) {
$backup_users = 1;
}
@ -175,6 +180,13 @@
notify("An error occurred while backing up course start");
}
}
//Metacourse information
if ($status && $preferences->backup_metacourse) {
echo "<li>".get_string("metacourse");
if (!$status = backup_course_metacourse($backup_file,$preferences)) {
notify("An error occurred while backing up metacourse info");
}
}
echo "<li>".get_string("blocks");
//Blocks information
if ($status) {

@ -57,6 +57,10 @@
}
//Check other parameters
if (!isset($backup_metacourse)) {
$backup_metacourse = 1;
}
if (!isset($backup_users)) {
$backup_users = 1;
}
@ -113,6 +117,21 @@
//Line
echo "<tr><td colspan=\"2\"><hr noshade size=\"1\"></td></tr>";
if (empty($to)) {
//Now print the Metacourse tr
echo "<tr>";
echo "<td align=\"right\"><P><B>";
echo get_string ("metacourse").":";
echo "</td><td>";
$meta_options[0] = get_string("no");
$meta_options[1] = get_string("yes");
choose_from_menu($meta_options, "backup_metacourse", $backup_metacourse, "");
echo "</td></tr>";
}
else {
echo '<input type="hidden" name="backup_metacourse" value="0" />';
}
if (empty($to)) {
//Now print the Users tr
echo "<tr>";

@ -307,6 +307,9 @@ function schedule_backup_course_configure($course,$starttime = 0) {
if (!isset($backup_config->backup_sche_withuserdata)) {
$backup_config->backup_sche_withuserdata = 1;
}
if (!isset($backup_config->backup_sche_metacourse)) {
$backup_config->backup_sche_metacourse = 1;
}
if (!isset($backup_config->backup_sche_users)) {
$backup_config->backup_sche_users = 1;
}
@ -381,6 +384,7 @@ function schedule_backup_course_configure($course,$starttime = 0) {
//Convert other parameters
if ($status) {
$preferences->backup_metacourse = $backup_config->backup_sche_metacourse;
$preferences->backup_users = $backup_config->backup_sche_users;
$preferences->backup_logs = $backup_config->backup_sche_logs;
$preferences->backup_user_files = $backup_config->backup_sche_userfiles;
@ -558,6 +562,12 @@ function schedule_backup_course_execute($preferences,$starttime = 0) {
$status = backup_course_start($backup_file,$preferences);
}
//Metacourse information
if ($status && $preferences->backup_metacourse) {
schedule_backup_log($starttime,$preferences->backup_course," metacourse info");
$status = backup_course_metacourse($backup_file,$preferences);
}
//Block info
if ($status) {
schedule_backup_log($starttime,$preferences->backup_course," blocks info");

@ -495,6 +495,12 @@
//Print the end
fwrite ($bf,end_tag("MOD",3,true));
}
//The metacourse in backup
if ($preferences->backup_metacourse == 1) {
fwrite ($bf,full_tag("METACOURSE",3,false,"true"));
} else {
fwrite ($bf,full_tag("METACOURSE",3,false,"false"));
}
//The user in backup
if ($preferences->backup_users == 1) {
fwrite ($bf,full_tag("USERS",3,false,"course"));
@ -586,7 +592,14 @@
fwrite ($bf,full_tag("VISIBLE",3,false,$course->visible));
fwrite ($bf,full_tag("HIDDENSECTIONS",3,false,$course->hiddensections));
fwrite ($bf,full_tag("TIMECREATED",3,false,$course->timecreated));
$status = fwrite ($bf,full_tag("TIMEMODIFIED",3,false,$course->timemodified));
fwrite ($bf,full_tag("TIMEMODIFIED",3,false,$course->timemodified));
//If not selected, force metacourse to 0
if (!$preferences->backup_metacourse) {
$status = fwrite ($bf,full_tag("METACOURSE",3,false,'0'));
//else, export the field as is in DB
} else {
$status = fwrite ($bf,full_tag("METACOURSE",3,false,$course->metacourse));
}
//Print header end
fwrite ($bf,end_tag("HEADER",2,true));
} else {
@ -606,7 +619,66 @@
}
//Prints course's sections info (table block_instance)
//Prints course's metacourse info (table course_meta)
function backup_course_metacourse ($bf,$preferences) {
global $CFG;
$status = true;
//Get info from meta
$parents = get_records_sql ("SELECT m.*, c.idnumber, c.shortname
FROM {$CFG->prefix}course_meta m,
{$CFG->prefix}course c
WHERE m.child_course = '$preferences->backup_course' AND
m.parent_course = c.id");
$childs = get_records_sql ("SELECT m.*, c.idnumber, c.shortname
FROM {$CFG->prefix}course_meta m,
{$CFG->prefix}course c
WHERE m.parent_course = '$preferences->backup_course' AND
m.child_course = c.id");
if ($parents || $childs) {
//metacourse open tag
fwrite ($bf,start_tag("METACOURSE",2,true));
if ($parents) {
fwrite($bf, start_tag("PARENTS",3,true));
//Iterate over every parent
foreach ($parents as $parent) {
//Begin parent
fwrite ($bf,start_tag("PARENT",4,true));
fwrite ($bf,full_tag("ID",5,false,$parent->parent_course));
fwrite ($bf,full_tag("IDNUMBER",5,false,$parent->idnumber));
fwrite ($bf,full_tag("SHORTNAME",5,false,$parent->shortname));
//End parent
fwrite ($bf,end_tag("PARENT",4,true));
}
fwrite ($bf,end_tag("PARENTS",3,true));
}
if ($childs) {
fwrite($bf, start_tag("CHILDS",3,true));
//Iterate over every child
foreach ($childs as $child) {
//Begin parent
fwrite ($bf,start_tag("CHILD",4,true));
fwrite ($bf,full_tag("ID",5,false,$child->child_course));
fwrite ($bf,full_tag("IDNUMBER",5,false,$child->idnumber));
fwrite ($bf,full_tag("SHORTNAME",5,false,$child->shortname));
//End parent
fwrite ($bf,end_tag("CHILD",4,true));
}
fwrite ($bf,end_tag("CHILDS",3,true));
}
//metacourse close tag
$status = fwrite ($bf,end_tag("METACOURSE",3,true));
}
return $status;
}
//Prints course's blocks info (table block_instance)
function backup_course_blocks ($bf,$preferences) {
global $CFG;

@ -20,6 +20,9 @@
if (!isset($backup_config->backup_sche_withuserdata)) {
$backup_config->backup_sche_withuserdata = 1;
}
if (!isset($backup_config->backup_sche_metacourse)) {
$backup_config->backup_sche_metacourse = 1;
}
if (!isset($backup_config->backup_sche_users)) {
$backup_config->backup_sche_users = 1;
}
@ -98,6 +101,15 @@
<?php print_string("backupincludemoduleshelp") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p><?php print_string("metacourse") ?>:</td>
<td>
<?php choose_from_menu($yesno_array, "backup_sche_metacourse", $backup_config->backup_sche_metacourse, "") ?>
</td>
<td>
<?php print_string("backupmetacoursehelp") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p><?php print_string("users") ?>:</td>
<td>