MDL-13847 gradebook backup/restore fixes, xhtml strict fixes, other minor fixes; merged from MOODLE_19_STABLE
This commit is contained in:
+23
-19
@@ -124,7 +124,7 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
//Print option to select/deselect everything with 1 click.
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\">";
|
||||
echo '<b>'.get_string("include").":</b>";
|
||||
echo '<b>'.get_string("include")."</b>";
|
||||
echo "</td><td>";
|
||||
echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'backup_', true);\">". get_string("all")."</a>/";
|
||||
echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'backup_', false);\">". get_string("none")."</a>";
|
||||
@@ -195,7 +195,7 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
//Now print the Metacourse tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" colspan=\"2\"><b>";
|
||||
echo get_string ("metacourse").":";
|
||||
echo '<label for="menubackup_metacourse">'.get_string ("metacourse").'</label>';
|
||||
echo "</b></td><td colspan=\"2\">";
|
||||
$meta_options[0] = get_string("no");
|
||||
$meta_options[1] = get_string("yes");
|
||||
@@ -210,7 +210,7 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
//Now print the Users tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" colspan=\"2\"><b>";
|
||||
echo get_string("users").":";
|
||||
echo '<label for="menubackup_users">'.get_string ("users").'</label>';
|
||||
echo "</b></td><td colspan=\"2\">";
|
||||
$user_options[0] = get_string("all");
|
||||
$user_options[1] = get_string("course");
|
||||
@@ -226,7 +226,7 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
//Now print the Logs tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" colspan=\"2\"><b>";
|
||||
echo get_string("logs").":";
|
||||
echo '<label for="menubackup_logs">'.get_string ("logs").'</label>';
|
||||
echo "</b></td><td colspan=\"2\">";
|
||||
$log_options[0] = get_string("no");
|
||||
$log_options[1] = get_string("yes");
|
||||
@@ -241,7 +241,7 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
//Now print the User Files tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" colspan=\"2\"><b>";
|
||||
echo get_string ("userfiles").":";
|
||||
echo '<label for="menubackup_user_files">'.get_string ("userfiles").'</label>';
|
||||
echo "</b></td><td colspan=\"2\">";
|
||||
$user_file_options[0] = get_string("no");
|
||||
$user_file_options[1] = get_string("yes");
|
||||
@@ -251,10 +251,11 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
else {
|
||||
$hidden_options .= '<input type="hidden" name="backup_user_files" value="0" />';
|
||||
}
|
||||
|
||||
//Now print the Course Files tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" colspan=\"2\"><b>";
|
||||
echo get_string ("coursefiles").":";
|
||||
echo '<label for="menubackup_course_files">'.get_string ("coursefiles").'</label>';
|
||||
echo "</b></td><td colspan=\"2\">";
|
||||
$course_file_options[0] = get_string("no");
|
||||
$course_file_options[1] = get_string("yes");
|
||||
@@ -266,7 +267,7 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
//Now print the site Files tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" colspan=\"2\"><b>";
|
||||
echo get_string ("sitefilesused").":";
|
||||
echo '<label for="menubackup_site_files">'.get_string ("sitefilesused").'</label>';
|
||||
helpbutton('sitefilesused', get_string('sitefilesused'));
|
||||
echo "</b></td><td colspan=\"2\">";
|
||||
$course_file_options[0] = get_string("no");
|
||||
@@ -276,20 +277,24 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
}
|
||||
|
||||
// do you want grade histories to be backed up?
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" colspan=\"2\"><b>";
|
||||
echo get_string ('gradebookhistories', 'grades').":";
|
||||
echo "</b></td><td colspan=\"2\">";
|
||||
$gradebook_history_options[0] = get_string("no");
|
||||
$gradebook_history_options[1] = get_string("yes");
|
||||
choose_from_menu($gradebook_history_options, "backup_gradebook_history", $backup_gradebook_history, "");
|
||||
echo "</td></tr>";
|
||||
if (empty($CFG->disablegradehistory)) {
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" colspan=\"2\"><b>";
|
||||
echo '<label for="menubackup_gradebook_history">'.get_string ('gradebookhistories', 'grades').'</label>';
|
||||
echo "</b></td><td colspan=\"2\">";
|
||||
$gradebook_history_options[0] = get_string("no");
|
||||
$gradebook_history_options[1] = get_string("yes");
|
||||
choose_from_menu($gradebook_history_options, "backup_gradebook_history", $backup_gradebook_history, "");
|
||||
echo "</td></tr>";
|
||||
} else {
|
||||
$hidden_options .= '<input type="hidden" name="backup_gradebook_history" value="0" />';
|
||||
}
|
||||
|
||||
if (empty($to) && $course->id == SITEID) {
|
||||
//If we are in a SITEID backup print the Messages tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" colspan=\"2\"><b>";
|
||||
echo get_string ('messages','message').":";
|
||||
echo '<label for="menubackup_messages">'.get_string ('messages', 'message').'</label>';
|
||||
echo "</b></td><td colspan=\"2\">";
|
||||
$mess_options[0] = get_string("no");
|
||||
$mess_options[1] = get_string("yes");
|
||||
@@ -308,7 +313,7 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" valign=\"top\" colspan=\"2\"><b>";
|
||||
echo get_string("backuproleassignments").":";
|
||||
echo get_string("backuproleassignments");
|
||||
echo "</b></td><td colspan=\"2\">";
|
||||
$roles = get_records('role', '', '', 'sortorder');
|
||||
foreach ($roles as $role) {
|
||||
@@ -330,12 +335,11 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
|
||||
?>
|
||||
</table>
|
||||
<div style="text-align:center;margin-left:auto;margin-right:auto">
|
||||
<?php
|
||||
/// Print captured hidden options, now that we have closed the table
|
||||
echo $hidden_options;
|
||||
?>
|
||||
|
||||
<div style="text-align:center;margin-left:auto;margin-right:auto">
|
||||
<input type="hidden" name="id" value="<?php p($id) ?>" />
|
||||
<input type="hidden" name="to" value="<?php p($to) ?>" />
|
||||
<input type="hidden" name="backup_unique_code" value="<?php p($backup_unique_code); ?>" />
|
||||
|
||||
+77
-99
@@ -585,12 +585,18 @@
|
||||
} else {
|
||||
fwrite ($bf,full_tag("COURSEFILES",3,false,"false"));
|
||||
}
|
||||
//The course files
|
||||
//The site files
|
||||
if ($preferences->backup_site_files == 1) {
|
||||
fwrite ($bf,full_tag("SITEFILES",3,false,"true"));
|
||||
} else {
|
||||
fwrite ($bf,full_tag("SITEFILES",3,false,"false"));
|
||||
}
|
||||
//The gradebook histories
|
||||
if ($preferences->backup_gradebook_history == 1) {
|
||||
fwrite ($bf,full_tag("GRADEBOOKHISTORIES",3,false,"true"));
|
||||
} else {
|
||||
fwrite ($bf,full_tag("GRADEBOOKHISTORIES",3,false,"false"));
|
||||
}
|
||||
//The messages in backup
|
||||
if ($preferences->backup_messages == 1 && $preferences->backup_course == SITEID) {
|
||||
fwrite ($bf,full_tag("MESSAGES",3,false,"true"));
|
||||
@@ -1129,6 +1135,7 @@
|
||||
fwrite ($bf,full_tag("GROUPMODE",6,false,$course_module[$tok]->groupmode));
|
||||
fwrite ($bf,full_tag("GROUPINGID",6,false,$course_module[$tok]->groupingid));
|
||||
fwrite ($bf,full_tag("GROUPMEMBERSONLY",6,false,$course_module[$tok]->groupmembersonly));
|
||||
fwrite ($bf,full_tag("IDNUMBER",6,false,$course_module[$tok]->idnumber));
|
||||
// get all the role_capabilities overrides in this mod
|
||||
write_role_overrides_xml($bf, $context, 6);
|
||||
/// write role_assign code here
|
||||
@@ -1411,54 +1418,54 @@
|
||||
}
|
||||
|
||||
//Backup gradebook info
|
||||
function backup_gradebook_info($bf,$preferences) {
|
||||
|
||||
function backup_gradebook_info($bf, $preferences) {
|
||||
global $CFG;
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
|
||||
//first make sure items are properly sorted and everything is ok
|
||||
grade_category::fetch_course_tree($preferences->backup_course, true);
|
||||
grade_regrade_final_grades($preferences->backup_course);
|
||||
|
||||
$status = true;
|
||||
|
||||
// see if ALL grade items of type mod of this course are being backed up
|
||||
// if not, we do not need to backup grade category and associated grade items/grades
|
||||
$backupall = true;
|
||||
|
||||
if ($grade_items = get_records_sql("SELECT * FROM {$CFG->prefix}grade_items
|
||||
WHERE courseid = $preferences->backup_course
|
||||
AND itemtype != 'course'
|
||||
ORDER BY sortorder ASC")) {
|
||||
if ($grade_items = get_records_sql("SELECT *
|
||||
FROM {$CFG->prefix}grade_items
|
||||
WHERE courseid = $preferences->backup_course
|
||||
AND itemtype = 'mod'")) {
|
||||
foreach ($grade_items as $grade_item) {
|
||||
|
||||
// do not restore if this grade_item is a mod, and
|
||||
if ($grade_item->itemtype == 'mod') {
|
||||
|
||||
// get module information
|
||||
// if no user data selected, we skip this grade_item
|
||||
if (!backup_userdata_selected($preferences,$grade_item->itemmodule,$grade_item->iteminstance)) {
|
||||
//print_object($grade_item);
|
||||
$backupall = false;
|
||||
break;
|
||||
}
|
||||
// get module information
|
||||
// if no user data selected, we do not backup categories
|
||||
if (!backup_userdata_selected($preferences,$grade_item->itemmodule,$grade_item->iteminstance)) {
|
||||
$backupall = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
unset($grade_items); //free memory
|
||||
}
|
||||
|
||||
//Gradebook header
|
||||
fwrite ($bf,start_tag("GRADEBOOK",2,true));
|
||||
|
||||
$status = backup_gradebook_outcomes_info($bf, $preferences);
|
||||
$status = backup_gradebook_grade_letters_info($bf,$preferences);
|
||||
|
||||
// Now backup grade_item (inside grade_category)
|
||||
if ($backupall) {
|
||||
$status = backup_gradebook_category_info($bf,$preferences);
|
||||
}
|
||||
|
||||
$status = backup_gradebook_item_info($bf,$preferences, $backupall);
|
||||
$status = backup_gradebook_grade_letters_info($bf,$preferences);
|
||||
$status = backup_gradebook_outcomes_info($bf, $preferences);
|
||||
$status = backup_gradebook_outcomes_courses_info($bf, $preferences);
|
||||
|
||||
// backup gradebook histories
|
||||
if ($preferences->backup_gradebook_history) {
|
||||
$status = backup_gradebook_categories_history_info($bf, $preferences);
|
||||
$status = backup_gradebook_grades_history_info($bf, $preferences);
|
||||
$status = backup_gradebook_items_history_info($bf, $preferences);
|
||||
$status = backup_gradebook_outcomes_history($bf, $preferences);
|
||||
$status = backup_gradebook_categories_history_info($bf, $preferences);
|
||||
$status = backup_gradebook_items_history_info($bf, $preferences);
|
||||
$status = backup_gradebook_grades_history_info($bf, $preferences);
|
||||
}
|
||||
|
||||
//Gradebook footer
|
||||
@@ -1466,17 +1473,20 @@
|
||||
return $status;
|
||||
}
|
||||
|
||||
function backup_gradebook_category_info($bf,$preferences) {
|
||||
function backup_gradebook_category_info($bf, $preferences) {
|
||||
global $CFG;
|
||||
$status = true;
|
||||
|
||||
// getting grade categories, but make sure parents come before children
|
||||
// because when we do restore, we need to recover the parents first
|
||||
// we do this by getting the lowest depth first
|
||||
$grade_categories = get_records_sql("SELECT * FROM {$CFG->prefix}grade_categories
|
||||
WHERE courseid = $preferences->backup_course
|
||||
AND depth > 1
|
||||
ORDER BY depth ASC");
|
||||
// get grade categories in proper order - specified in category grade items
|
||||
$course_item = grade_item::fetch_course_item($preferences->backup_course);
|
||||
$grade_categories = get_records_sql("SELECT gc.*, gi.sortorder
|
||||
FROM {$CFG->prefix}grade_categories gc
|
||||
JOIN {$CFG->prefix}grade_items gi
|
||||
ON (gi.iteminstance = gc.id)
|
||||
WHERE gc.courseid = $preferences->backup_course
|
||||
AND (gi.itemtype='course' OR gi.itemtype='category')
|
||||
ORDER BY gi.sortorder ASC");
|
||||
|
||||
if ($grade_categories) {
|
||||
//Begin grade_categories tag
|
||||
fwrite ($bf,start_tag("GRADE_CATEGORIES",3,true));
|
||||
@@ -1510,33 +1520,32 @@
|
||||
}
|
||||
|
||||
//Backup gradebook_item (called from backup_gradebook_info
|
||||
function backup_gradebook_item_info($bf,$preferences, $backupall) {
|
||||
|
||||
function backup_gradebook_item_info($bf, $preferences, $backupall) {
|
||||
global $CFG;
|
||||
require_once($CFG->libdir . '/gradelib.php');
|
||||
|
||||
$status = true;
|
||||
// get all the grade_items, ordered by sort order since upon restoring, it is not always
|
||||
// possible to use the same sort order. We could at least preserve the sortorder by restoring
|
||||
// grade_items in the original sortorder
|
||||
if ($grade_items = get_records_sql("SELECT * FROM {$CFG->prefix}grade_items
|
||||
WHERE courseid = $preferences->backup_course
|
||||
ORDER BY sortorder ASC")) {
|
||||
if ($grade_items = get_records_sql("SELECT *
|
||||
FROM {$CFG->prefix}grade_items
|
||||
WHERE courseid = $preferences->backup_course
|
||||
ORDER BY sortorder ASC")) {
|
||||
|
||||
//Begin grade_items tag
|
||||
fwrite ($bf,start_tag("GRADE_ITEMS",3,true));
|
||||
//Iterate for each item
|
||||
foreach ($grade_items as $grade_item) {
|
||||
//Iterate over each item
|
||||
foreach ($grade_items as $item) {
|
||||
// Instantiate a grade_item object, to access its methods
|
||||
$grade_item = grade_object::fetch_helper('grade_items', 'grade_item', $grade_item);
|
||||
$grade_item = new grade_item($item, false);
|
||||
|
||||
// do not restore if this grade_item is a mod, and
|
||||
if ($grade_item->itemtype == 'mod') {
|
||||
// this still needs to be included, though grades can be ignored
|
||||
|
||||
//MDL-12463 - exclude grade_items of instances not chosen for backup
|
||||
if (empty($preferences->mods[$grade_item->itemmodule]->instances[$grade_item->iteminstance]->backup)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if ($grade_item->itemtype == 'category') {
|
||||
// if not all grade items are being backed up
|
||||
// we ignore this type of grade_item and grades associated
|
||||
@@ -1601,28 +1610,23 @@
|
||||
global $CFG;
|
||||
$status = true;
|
||||
|
||||
// getting grade categories, but make sure parents come before children
|
||||
// because when we do restore, we need to recover the parents first
|
||||
// we do this by getting the lowest depth first
|
||||
$context = get_context_instance(CONTEXT_COURSE, $preferences->backup_course);
|
||||
$grade_letters = get_records_sql("SELECT *
|
||||
FROM {$CFG->prefix}grade_letters
|
||||
WHERE contextid = $context->id");
|
||||
FROM {$CFG->prefix}grade_letters
|
||||
WHERE contextid = $context->id");
|
||||
if ($grade_letters) {
|
||||
//Begin grade_categories tag
|
||||
//Begin grade_l tag
|
||||
fwrite ($bf,start_tag("GRADE_LETTERS",3,true));
|
||||
//Iterate for each category
|
||||
//Iterate for each letter
|
||||
foreach ($grade_letters as $grade_letter) {
|
||||
//Begin grade_category
|
||||
//Begin grade_letter
|
||||
fwrite ($bf,start_tag("GRADE_LETTER",4,true));
|
||||
//Output individual fields
|
||||
fwrite ($bf,full_tag("ID",5,false,$grade_letter->id));
|
||||
|
||||
// not keeping path and depth because they can be derived
|
||||
fwrite ($bf,full_tag("LOWERBOUNDARY",5,false,$grade_letter->lowerboundary));
|
||||
fwrite ($bf,full_tag("LETTER",5,false,$grade_letter->letter));
|
||||
|
||||
//End grade_category
|
||||
//End grade_letter
|
||||
fwrite ($bf,end_tag("GRADE_LETTER",4,true));
|
||||
}
|
||||
//End grade_categories tag
|
||||
@@ -1632,16 +1636,16 @@
|
||||
return $status;
|
||||
}
|
||||
|
||||
function backup_gradebook_outcomes_info($bf,$preferences) {
|
||||
function backup_gradebook_outcomes_info($bf, $preferences) {
|
||||
|
||||
global $CFG;
|
||||
$status = true;
|
||||
// only back up courses already in the grade_outcomes_courses table
|
||||
$grade_outcomes = get_records_sql('SELECT go.*
|
||||
FROM '.$CFG->prefix.'grade_outcomes_courses goc,
|
||||
'.$CFG->prefix.'grade_outcomes go
|
||||
WHERE goc.courseid = '.$preferences->backup_course.'
|
||||
AND goc.outcomeid = go.id');
|
||||
$grade_outcomes = get_records_sql("SELECT go.*
|
||||
FROM {$CFG->prefix}grade_outcomes go
|
||||
JOIN {$CFG->prefix}grade_outcomes_courses goc
|
||||
ON (goc.outcomeid = go.id)
|
||||
WHERE goc.courseid = $preferences->backup_course");
|
||||
|
||||
if (!empty($grade_outcomes)) {
|
||||
//Begin grade_outcomes tag
|
||||
@@ -1671,35 +1675,6 @@
|
||||
return $status;
|
||||
}
|
||||
|
||||
// outcomes assigned to this course
|
||||
function backup_gradebook_outcomes_courses_info($bf,$preferences) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
// get all global outcomes (used in this course)
|
||||
// and course specific outcomes
|
||||
// we don't need to backup all the outcomes in this case
|
||||
if ($outcomes_courses = get_records('grade_outcomes_courses', 'courseid', $preferences->backup_course)) {
|
||||
//Begin grade_outcomes tag
|
||||
fwrite ($bf,start_tag("GRADE_OUTCOMES_COURSES",3,true));
|
||||
//Iterate for each outcome
|
||||
foreach ($outcomes_courses as $outcomes_course) {
|
||||
//Begin grade_outcome
|
||||
fwrite ($bf,start_tag("GRADE_OUTCOMES_COURSE",4,true));
|
||||
//Output individual fields
|
||||
fwrite ($bf,full_tag("ID",5,false,$outcomes_course->id));
|
||||
fwrite ($bf,full_tag("OUTCOMEID",5,false,$outcomes_course->outcomeid));
|
||||
|
||||
//End grade_outcome
|
||||
fwrite ($bf,end_tag("GRADE_OUTCOMES_COURSE",4,true));
|
||||
}
|
||||
//End grade_outcomes tag
|
||||
$status = fwrite ($bf,end_tag("GRADE_OUTCOMES_COURSES",3,true));
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
function backup_gradebook_grades_info($bf,$preferences, $itemid) {
|
||||
|
||||
global $CFG;
|
||||
@@ -1780,10 +1755,11 @@
|
||||
$status = true;
|
||||
|
||||
// find all grade categories history
|
||||
if ($chs = get_records_sql("SELECT ggh.* FROM {$CFG->prefix}grade_grades_history ggh,
|
||||
{$CFG->prefix}grade_items gi
|
||||
WHERE gi.courseid = $preferences->backup_course
|
||||
AND ggh.itemid = gi.id")) {
|
||||
if ($chs = get_records_sql("SELECT ggh.*
|
||||
FROM {$CFG->prefix}grade_grades_history ggh
|
||||
JOIN {$CFG->prefix}grade_items gi
|
||||
ON gi.id = ggh.itemid
|
||||
WHERE gi.courseid = $preferences->backup_course")) {
|
||||
fwrite ($bf,start_tag("GRADE_GRADES_HISTORIES",5,true));
|
||||
foreach ($chs as $ch) {
|
||||
/// Grades are only sent to backup if the user is one target user
|
||||
@@ -1856,8 +1832,8 @@
|
||||
fwrite ($bf,full_tag("PLUSFACTOR",7,false,$ch->plusfactor));
|
||||
fwrite ($bf,full_tag("AGGREGATIONCOEF",7,false,$ch->aggregationcoef));
|
||||
fwrite ($bf,full_tag("SORTORDER",7,false,$ch->sortorder));
|
||||
fwrite ($bf,full_tag("DISPLAY",7,false,$ch->display));
|
||||
fwrite ($bf,full_tag("DECIMALS",7,false,$ch->decimals));
|
||||
//fwrite ($bf,full_tag("DISPLAY",7,false,$ch->display));
|
||||
//fwrite ($bf,full_tag("DECIMALS",7,false,$ch->decimals));
|
||||
fwrite ($bf,full_tag("HIDDEN",7,false,$ch->hidden));
|
||||
fwrite ($bf,full_tag("LOCKED",7,false,$ch->locked));
|
||||
fwrite ($bf,full_tag("LOCKTIME",7,false,$ch->locktime));
|
||||
@@ -1908,8 +1884,8 @@
|
||||
|
||||
//Get scales (common and course scales)
|
||||
$scales = get_records_sql("SELECT id, courseid, userid, name, scale, description, timemodified
|
||||
FROM {$CFG->prefix}scale
|
||||
WHERE courseid = '0' or courseid = $preferences->backup_course");
|
||||
FROM {$CFG->prefix}scale
|
||||
WHERE courseid = 0 OR courseid = $preferences->backup_course");
|
||||
|
||||
//Copy only used scales to $backupscales. They will be in backup (unused no). See Bug 1223.
|
||||
$backupscales = array();
|
||||
@@ -2278,6 +2254,7 @@
|
||||
foreach ($userlist as $userid => $userinfo) {
|
||||
//Look for dir like username in backup_ids
|
||||
$data = count_records("backup_ids","backup_code",$preferences->backup_unique_code, "table_name","user", "old_id",$userid);
|
||||
|
||||
//If exists, copy it
|
||||
if ($data) {
|
||||
$parts = explode('/', $userinfo['userfolder']);
|
||||
@@ -2290,7 +2267,7 @@
|
||||
// Create group dir first
|
||||
$status = check_dir_exists("$CFG->dataroot/temp/backup/$preferences->backup_unique_code/user_files/". $group, true);
|
||||
}
|
||||
|
||||
|
||||
$status = $status && backup_copy_file($userinfo['basedir'] . '/' . $userinfo['userfolder'],
|
||||
"$CFG->dataroot/temp/backup/$preferences->backup_unique_code/user_files/{$userinfo['userfolder']}");
|
||||
}
|
||||
@@ -2399,7 +2376,8 @@
|
||||
//check for dir structure and create recursively
|
||||
$file = $fileobj->path;
|
||||
$status = $status && check_dir_exists(dirname($CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/site_files/".$file), true, true);
|
||||
$status = $status && backup_copy_file($rootdir."/".$file, $CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/site_files/".$file);
|
||||
$status = $status && backup_copy_file($rootdir."/".$file,
|
||||
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/site_files/".$file);
|
||||
}
|
||||
}
|
||||
return $status;
|
||||
|
||||
+15
-7
@@ -553,11 +553,16 @@
|
||||
}
|
||||
} else {
|
||||
//Only if status (record exists)
|
||||
if ($status) {
|
||||
////First strip slashes
|
||||
$temp = stripslashes($status->info);
|
||||
//Now unserialize
|
||||
$status->info = unserialize($temp);
|
||||
if (!empty($status->info)) {
|
||||
if ($status->info === 'needed') {
|
||||
// TODO: ugly hack - fix before 1.9.1
|
||||
debugging('Incorrect string "needed" in $status->info, please fix the code (table:'.$table.'; old_id:'.$old_id.').', DEBUG_DEVELOPER);
|
||||
} else {
|
||||
////First strip slashes
|
||||
$temp = stripslashes($status->info);
|
||||
//Now unserialize
|
||||
$status->info = unserialize($temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,12 +571,15 @@
|
||||
|
||||
//This function is used to add slashes (and decode from UTF-8 if needed)
|
||||
//It's used intensivelly when restoring modules and saving them in db
|
||||
function backup_todb ($data) {
|
||||
function backup_todb ($data, $addslashes=true) {
|
||||
// MDL-10770
|
||||
if ($data === '$@NULL@$') {
|
||||
return null;
|
||||
} else {
|
||||
return restore_decode_absolute_links(addslashes($data));
|
||||
if ($addslashes) {
|
||||
$data = addslashes($data);
|
||||
}
|
||||
return restore_decode_absolute_links($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -72,32 +72,32 @@
|
||||
}
|
||||
foreach ($instances as $instance) {
|
||||
$var = 'restore_'.$modname.'_instance_'.$instance->id;
|
||||
$$var = optional_param($var,0);
|
||||
$$var = optional_param($var,0,PARAM_INT);
|
||||
$var = 'restore_user_info_'.$modname.'_instance_'.$instance->id;
|
||||
$$var = optional_param($var,0);
|
||||
$$var = optional_param($var,0,PARAM_INT);
|
||||
}
|
||||
}
|
||||
}
|
||||
//restoreto
|
||||
$restore_restoreto = required_param('restore_restoreto');
|
||||
$restore_restoreto = required_param('restore_restoreto', PARAM_INT);
|
||||
//restore_metacourse
|
||||
$restore_metacourse = required_param('restore_metacourse');
|
||||
$restore_metacourse = required_param('restore_metacourse', PARAM_INT);
|
||||
//restore_users
|
||||
$restore_users = required_param('restore_users');
|
||||
$restore_users = required_param('restore_users', PARAM_INT);
|
||||
|
||||
$restore_groups = required_param('restore_groups');
|
||||
$restore_groups = required_param('restore_groups', PARAM_INT);
|
||||
//restore_logs
|
||||
$restore_logs = required_param('restore_logs');
|
||||
$restore_logs = required_param('restore_logs', PARAM_INT);
|
||||
//restore_user_files
|
||||
$restore_user_files = required_param('restore_user_files');
|
||||
$restore_user_files = required_param('restore_user_files', PARAM_INT);
|
||||
//restore_course_files
|
||||
$restore_course_files = required_param('restore_course_files');
|
||||
$restore_course_files = required_param('restore_course_files', PARAM_INT);
|
||||
//restore_site_files
|
||||
$restore_site_files = required_param('restore_site_files');
|
||||
$restore_site_files = required_param('restore_site_files', PARAM_INT);
|
||||
//restore_gradebook_history
|
||||
$restore_gradebook_history = required_param('restore_gradebook_history');
|
||||
$restore_gradebook_history = required_param('restore_gradebook_history', PARAM_INT);
|
||||
//restore_messages
|
||||
$restore_messages = required_param('restore_messages');
|
||||
$restore_messages = required_param('restore_messages', PARAM_INT);
|
||||
|
||||
//Check we've selected a course to restore to
|
||||
$course_id = optional_param('course_id', 0, PARAM_INT);
|
||||
|
||||
+73
-50
@@ -29,7 +29,7 @@
|
||||
error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
||||
}
|
||||
} else {
|
||||
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
|
||||
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
||||
}
|
||||
}
|
||||
@@ -185,7 +185,8 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
//Print the full tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\"><b>";
|
||||
echo get_string("restoreto").":</b>";
|
||||
echo '<label for="menurestore_restoreto">'.get_string ('restoreto').'</label>';
|
||||
echo "</b>";
|
||||
echo "</td><td colspan=\"3\">";
|
||||
|
||||
|
||||
@@ -229,6 +230,9 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
$restore_restoreto_options[2] = get_string("newcourse");
|
||||
}
|
||||
|
||||
/// Acummulator for hidden options and proper XHTML output
|
||||
$hidden_options = '';
|
||||
|
||||
choose_from_menu($restore_restoreto_options, "restore_restoreto", $restore_restoreto, "");
|
||||
echo "</td></tr>";
|
||||
if (user_can_create_courses()) { //display these fields conditionally
|
||||
@@ -236,8 +240,8 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
// find the list of cates user can edit
|
||||
echo "<tr valign=\"top\" >";
|
||||
echo "<td align=\"right\">";
|
||||
print_string('category');
|
||||
echo " :</td>";
|
||||
echo '<label for="menurestore_restorecatto">'.get_string ('category').'</label>';
|
||||
echo "</td>";
|
||||
echo "<td>";
|
||||
choose_from_menu(get_creatable_categories(), "restore_restorecatto", $course_header->category->id, "");
|
||||
echo "</td>";
|
||||
@@ -245,25 +249,25 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
|
||||
echo "<tr valign=\"top\" >";
|
||||
echo "<td align=\"right\">";
|
||||
print_string("shortname");
|
||||
echo " :</td>";
|
||||
echo "<td><input type=\"text\" name=\"shortname\" maxlength=\"100\" size=\"20\" value=\"$form1->shortname\" alt=\"".get_string("shortname")."\" />" ;
|
||||
echo '<label for="shortnamefield">'.get_string ('shortname').'</label>';
|
||||
echo "</td>";
|
||||
echo "<td><input type=\"text\" id=\"shortnamefield\" name=\"shortname\" maxlength=\"100\" size=\"20\" value=\"$form1->shortname\" alt=\"".get_string("shortname")."\" />" ;
|
||||
helpbutton("courseshortname", get_string("shortname")) ;
|
||||
if (isset($err["shortname"])) formerr($err["shortname"]);
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
echo "<tr valign=\"top\" >";
|
||||
echo "<td align=\"right\">";
|
||||
print_string("fullname");
|
||||
echo " :</td>";
|
||||
echo "<td><input type=\"text\" name=\"fullname\" maxlength=\"254\" size=\"50\" value=\"$form1->fullname\" alt=\" ".get_string("fullname")."\" />" ;
|
||||
echo '<label for="fullnamefield">'.get_string ('fullname').'</label>';
|
||||
echo "</td>";
|
||||
echo "<td><input type=\"text\" id=\"fullnamefield\" name=\"fullname\" maxlength=\"254\" size=\"50\" value=\"$form1->fullname\" alt=\" ".get_string("fullname")."\" />" ;
|
||||
helpbutton("coursefullname", get_string("fullname")) ;
|
||||
if (isset($err["fullname"])) formerr($err["fullname"]);
|
||||
echo"</td></tr>";
|
||||
echo "<tr valign=\"top\"> ";
|
||||
echo "<td align=\"right\"> ";
|
||||
print_string("startdate");
|
||||
echo ":</td><td>";
|
||||
echo "</td><td>";
|
||||
/// Show the roll dates option only if the backup course has a start date
|
||||
/// (some formats like main page, social..., haven't it and rolling dates
|
||||
/// from 0 produces crazy dates. MDL-10125
|
||||
@@ -285,7 +289,7 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
//Print option to select/deselect everything with 1 click.
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\">";
|
||||
echo '<b>'.get_string("include").":</b>";
|
||||
echo '<b>'.get_string("include")."</b>";
|
||||
echo "</td><td>";
|
||||
echo "<a href=\"javascript:void(0);\" onclick=\"selectItemInCheckboxByName('form1', 'restore_', true);\">".
|
||||
get_string("all")."</a>/";
|
||||
@@ -386,25 +390,27 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
//Now print the Metacourse tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" colspan=\"2\"><b>";
|
||||
echo get_string("metacourse").":";
|
||||
echo '<label for="menurestore_metacourse">'.get_string ("metacourse").'</label>';
|
||||
echo "</b></td><td colspan=\"2\">";
|
||||
//If metacourse are in the backup file, show menu, else fixed to no
|
||||
if ($info->backup_metacourse == "true") {
|
||||
$metacourse_options = array();
|
||||
$metacourse_options[0] = get_string("no");
|
||||
$metacourse_options[1] = get_string("yes");
|
||||
choose_from_menu($metacourse_options, "restore_metacourse", $restore_metacourse, "");
|
||||
} else {
|
||||
echo get_string("no");
|
||||
echo "<input type=\"hidden\" name=\"restore_metacourse\" value=\"0\" />";
|
||||
echo "<input type=\"hidden\" id=\"menurestore_metacourse\" name=\"restore_metacourse\" value=\"0\" />";
|
||||
}
|
||||
echo "</td></tr>";
|
||||
//Now print the Users tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" colspan=\"2\"><b>";
|
||||
echo get_string("users").":";
|
||||
echo '<label for="menurestore_users">'.get_string ("users").'</label>';
|
||||
echo "</b></td><td colspan=\"2\">";
|
||||
//If some user is present in the backup file
|
||||
if ($info->backup_users == "all" or $info->backup_users == "course") {
|
||||
$user_options = array();
|
||||
//If all users are in the backup file
|
||||
if ($info->backup_users == "all") {
|
||||
$user_options[0] = get_string("all");
|
||||
@@ -414,7 +420,7 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
choose_from_menu($user_options, "restore_users", $restore_users, "");
|
||||
} else {
|
||||
echo get_string("none");
|
||||
echo "<input type=\"hidden\" name=\"restore_users\" value=\"2\" />";
|
||||
echo "<input type=\"hidden\" id=\"menurestore_users\" name=\"restore_users\" value=\"2\" />";
|
||||
|
||||
}
|
||||
echo "</td></tr>";
|
||||
@@ -445,50 +451,53 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
//Now print the Logs tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" colspan=\"2\"><b>";
|
||||
echo get_string("logs").":";
|
||||
echo '<label for="menurestore_logs">'.get_string ("logs").'</label>';
|
||||
echo "</b></td><td colspan=\"2\">";
|
||||
//If logs are in the backup file, show menu, else fixed to no
|
||||
if ($info->backup_logs == "true") {
|
||||
$log_options = array();
|
||||
$log_options[0] = get_string("no");
|
||||
$log_options[1] = get_string("yes");
|
||||
choose_from_menu($log_options, "restore_logs", $restore_logs, "");
|
||||
} else {
|
||||
echo get_string("no");
|
||||
echo "<input type=\"hidden\" name=\"restore_logs\" value=\"0\" />";
|
||||
echo "<input type=\"hidden\" id=\"menurestore_logs\" name=\"restore_logs\" value=\"0\" />";
|
||||
}
|
||||
echo "</td></tr>";
|
||||
|
||||
//Now print the User Files tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" colspan=\"2\"><b>";
|
||||
echo get_string ("userfiles").":";
|
||||
echo '<label for="menurestore_user_files">'.get_string ("userfiles").'</label>';
|
||||
echo "</b></td><td colspan=\"2\">";
|
||||
//If user files are in the backup file, show menu, else fixed to no
|
||||
if ($info->backup_user_files == "true") {
|
||||
$user_file_options = array();
|
||||
$user_file_options[0] = get_string("no");
|
||||
$user_file_options[1] = get_string("yes");
|
||||
choose_from_menu($user_file_options, "restore_user_files", $restore_user_files, "");
|
||||
} else {
|
||||
echo get_string("no");
|
||||
echo "<input type=\"hidden\" name=\"restore_user_files\" value=\"0\" />";
|
||||
echo "<input type=\"hidden\" id=\"menurestore_user_files\" name=\"restore_user_files\" value=\"0\" />";
|
||||
}
|
||||
echo "</td></tr>";
|
||||
|
||||
//Now print the Course Files tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" colspan=\"2\"><b>";
|
||||
echo get_string ("coursefiles").":";
|
||||
echo '<label for="menurestore_course_files">'.get_string ("coursefiles").'</label>';
|
||||
echo "</b></td><td colspan=\"2\">";
|
||||
echo "<input type=\"hidden\" name=\"backup_unique_code\" value=\"$backup_unique_code\" />";
|
||||
echo "<input type=\"hidden\" name=\"file\" value=\"$file\" />";
|
||||
//If course files are in the backup file, show menu, else fixed to no
|
||||
if ($info->backup_course_files == "true") {
|
||||
$course_file_options = array();
|
||||
$course_file_options[0] = get_string("no");
|
||||
$course_file_options[1] = get_string("yes");
|
||||
choose_from_menu($course_file_options, "restore_course_files", $restore_course_files, "");
|
||||
} else {
|
||||
echo get_string("no");
|
||||
echo "<input type=\"hidden\" name=\"restore_course_files\" value=\"0\" />";
|
||||
echo "<input type=\"hidden\" id=\"menurestore_course_files\" name=\"restore_course_files\" value=\"0\" />";
|
||||
}
|
||||
echo "</td></tr>";
|
||||
|
||||
@@ -496,54 +505,63 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||
//Now print the Site Files tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" colspan=\"2\"><b>";
|
||||
echo get_string ("sitefiles").":";
|
||||
echo '<label for="menurestore_site_files">'.get_string ("sitefiles").'</label>';
|
||||
echo "</b></td><td colspan=\"2\">";
|
||||
//If site files are in the backup file, show menu, else fixed to no
|
||||
if (isset($info->backup_site_files) && $info->backup_site_files == "true") {
|
||||
$site_file_options = array();
|
||||
$site_file_options[0] = get_string("no");
|
||||
$site_file_options[1] = get_string("yes");
|
||||
choose_from_menu($site_file_options, "restore_site_files", $restore_site_files, "");
|
||||
} else {
|
||||
echo get_string("no");
|
||||
echo "<input type=\"hidden\" name=\"restore_site_files\" value=\"0\" />";
|
||||
echo "<input type=\"hidden\" id=\"menurestore_site_files\" name=\"restore_site_files\" value=\"0\" />";
|
||||
}
|
||||
echo "</td></tr>";
|
||||
|
||||
// do you want grade histories to be restored?
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" colspan=\"2\"><b>";
|
||||
echo get_string ('gradebookhistories', 'grades').":";
|
||||
echo "</b></td><td colspan=\"2\">";
|
||||
$gradebook_history_options[0] = get_string("no");
|
||||
$gradebook_history_options[1] = get_string("yes");
|
||||
choose_from_menu($gradebook_history_options, "restore_gradebook_history", $restore_gradebook_history, "");
|
||||
echo "</td></tr>";
|
||||
if (empty($CFG->disablegradehistory)) {
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" colspan=\"2\"><b>";
|
||||
echo '<label for="menurestore_gradebook_history">'.get_string ('gradebookhistories', 'grades').'</label>';
|
||||
echo "</b></td><td colspan=\"2\">";
|
||||
if (isset($info->gradebook_histories) && $info->gradebook_histories == "true") {
|
||||
$gradebook_history_options = array();
|
||||
$gradebook_history_options[0] = get_string("no");
|
||||
$gradebook_history_options[1] = get_string("yes");
|
||||
choose_from_menu($gradebook_history_options, "restore_gradebook_history", $restore_gradebook_history, "");
|
||||
} else {
|
||||
echo get_string("no");
|
||||
echo "<input type=\"hidden\" id=\"menurestore_gradebook_history\" name=\"restore_gradebook_history\" value=\"0\" />";
|
||||
}
|
||||
echo "</td></tr>";
|
||||
} else {
|
||||
$hidden_options .= '<input type="hidden" name="restore_gradebook_history" value="0" />';
|
||||
}
|
||||
|
||||
//Now print the Messages tr
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" colspan=\"2\"><b>";
|
||||
|
||||
//This tr is slighty different. Everything becomes hidden if
|
||||
//we haven't messages is the backup, to avoid confusions to users.
|
||||
//If messages are in the backup file, show menu, else fixed to no and show nothing
|
||||
if ($info->backup_messages == "true") {
|
||||
echo get_string ('messages','message').":";
|
||||
if (isset($info->backup_messages) && $info->backup_messages == "true") {
|
||||
echo "<tr>";
|
||||
echo "<td align=\"right\" colspan=\"2\"><b>";
|
||||
echo '<label for="menurestore_messages">'.get_string ('messages', 'messages').'</label>';
|
||||
echo "</b></td><td colspan=\"2\">";
|
||||
$message_options = array();
|
||||
$message_options[0] = get_string("no");
|
||||
$message_options[1] = get_string("yes");
|
||||
choose_from_menu($message_options, "restore_messages", $restore_messages, "");
|
||||
echo "</td></tr>";
|
||||
} else {
|
||||
echo " </b></td><td colspan=\"2\">";
|
||||
echo "<input type=\"hidden\" name=\"restore_messages\" value=\"0\" />";
|
||||
$hidden_options .= '<input type="hidden" name="restore_messages" value="0" />';
|
||||
}
|
||||
echo "</td></tr>";
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
||||
<hr/>
|
||||
<hr />
|
||||
<?php
|
||||
|
||||
print_heading(get_string('rolemappings'));
|
||||
@@ -564,24 +582,25 @@ if ($info->backup_moodle_version < 2006092801) {
|
||||
|
||||
/// Editting teacher
|
||||
echo ('<tr><td align="right">');
|
||||
print_string('defaultcourseteacher');
|
||||
echo '<label for="menudefaultteacheredit">'.get_string ('defaultcourseteacher').'</label>';
|
||||
echo ('</td><td algin="left">');
|
||||
|
||||
// get the first teacheredit legacy
|
||||
$roles = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW, get_context_instance(CONTEXT_SYSTEM, SITEID));
|
||||
$roles = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW, get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$editteacher = array_shift($roles);
|
||||
$editteacher = reset($roles);
|
||||
choose_from_menu ($siterolesarray, "defaultteacheredit", $editteacher->id, 'new role', '', '0');
|
||||
echo ('</td></tr>');
|
||||
|
||||
/// Non-editting teacher
|
||||
echo ('<tr><td align="right">');
|
||||
echo '<label for="menudefaultteacher">'.get_string ('noneditingteacher').'</label>';
|
||||
print_string('noneditingteacher');
|
||||
echo ('</td><td algin="left">');
|
||||
|
||||
// get the first teacheredit legacy
|
||||
$roles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW, get_context_instance(CONTEXT_SYSTEM, SITEID));
|
||||
$teacher = array_shift($roles);
|
||||
$roles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW, get_context_instance(CONTEXT_SYSTEM));
|
||||
$teacher = reset($roles);
|
||||
|
||||
choose_from_menu ($siterolesarray, "defaultteacher", $teacher->id, 'new role', '', '0');
|
||||
echo ('</td></tr>');
|
||||
@@ -589,11 +608,11 @@ if ($info->backup_moodle_version < 2006092801) {
|
||||
|
||||
/// Student
|
||||
echo ('<tr><td align="right">');
|
||||
print_string('defaultcoursestudent');
|
||||
echo '<label for="menudefaultstudent">'.get_string ('defaultcoursestudent').'</label>';
|
||||
echo ('</td><td algin="left">');
|
||||
|
||||
// get the first teacheredit legacy
|
||||
$roles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW, get_context_instance(CONTEXT_SYSTEM, SITEID));
|
||||
$roles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW, get_context_instance(CONTEXT_SYSTEM));
|
||||
$studentrole = array_shift($roles);
|
||||
|
||||
choose_from_menu ($siterolesarray, "defaultstudent", $studentrole->id, 'new role', '', '0');
|
||||
@@ -613,7 +632,7 @@ if ($info->backup_moodle_version < 2006092801) {
|
||||
$mappableroles = $siteroleschoicearray;
|
||||
|
||||
echo ('<tr><td align="right">');
|
||||
echo $role->name." (".($role->shortname).")";
|
||||
echo '<label for="menuroles_'.$roleid.'">'.$role->name." (".($role->shortname).")".'</label>';
|
||||
echo ('</td><td align="left">');
|
||||
|
||||
/// first, we see if any exact role definition is found
|
||||
@@ -647,6 +666,10 @@ echo ('</table>'); // end of role mappings table
|
||||
?>
|
||||
<br />
|
||||
<div style="text-align:center">
|
||||
<?php
|
||||
/// Print captured hidden options, now that we have closed the table
|
||||
echo $hidden_options;
|
||||
?>
|
||||
<input type="hidden" name="id" value="<?php p($id) ?>" />
|
||||
<input type="hidden" name="launch" value="check" />
|
||||
<input type="hidden" name="fromform" value="1" />
|
||||
|
||||
+1102
-889
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user