Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Change creation of restorelog file location to protected backupdata f…

…older.

Reassign style and language links
  • Loading branch information...
commit eb87ac71c555e83826eb8712ea7a489cde940784 1 parent 57bdc37
thompson697 authored
View
3  .cvsignore
@@ -0,0 +1,3 @@
+Copy of .project
+config.php
+.project
View
40 backup/restorelib.php
@@ -2201,12 +2201,10 @@ function restore_create_events($restore,$xml_file) {
//Get admin->id for later use
$admin = get_admin();
$adminid = $admin->id;
-
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ //First, we check the course_id backup data folder exists
+ $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
-
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
//Now, if we have anything in events, we have to restore that
//events
if ($events) {
@@ -5441,7 +5439,7 @@ function restore_execute(&$restore,$info,$course_header,&$errorstr) {
}
if ($status = restore_open_html($restore,$course_header)){
- echo "<li>Creating the Restorelog.html in the course Files folder</li>";
+ echo "<li>Creating the Restorelog.html in the course backup folder</li>";
}
} else {
@@ -5942,16 +5940,27 @@ function restore_open_html($restore,$course_header) {
$status = true;
//Open file for writing
- //First, we check the "course_id" folder exists and create it as necessary in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ //First, we check the course_id backup data folder exists and create it as necessary in CFG->dataroot
+ if (!$dest_dir = make_upload_directory("$restore->course_id/backupdata")) { // Backup folder
+ error("Could not create backupdata folder. The site administrator needs to fix the file permissions");
+ }
$status = check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+ //Add the stylesheet
+ $stylesheetshtml = '';
+ foreach ($CFG->stylesheets as $stylesheet) {
+ $stylesheetshtml .= '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'" />'."\n";
+ }
+ ///Accessibility: added the 'lang' attribute to $direction, used in theme <html> tag.
+ $language = str_replace('_utf8','',$CFG->lang);
+ $languagehtml = '';
+ $languagehtml .= ' lang="'.$language.'" xml:lang="'.$language.'"';
//Write the header in the new logging file
fwrite ($restorelog_file,"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"");
fwrite ($restorelog_file," \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> ");
- fwrite ($restorelog_file,"<html dir=\"ltr\" lang=\"en\" xml:lang=\"en\">");
- fwrite ($restorelog_file,"<head><link rel=\"stylesheet\" type=\"text/css\" href=\"http://at4737.vledev.open.ac.uk/moodle/theme/standard/styles.php\" />");
+ fwrite ($restorelog_file,"<html dir=\"ltr\".$languagehtml.");
+ fwrite ($restorelog_file,"<head>");
+ fwrite ($restorelog_file,$stylesheetshtml);
fwrite ($restorelog_file,"<title>".$course_header->course_shortname." Restored </title>");
fwrite ($restorelog_file,"</head><body><br><h1>The following changes were made during the Restoration of this Course.</h1><br><br>");
fwrite ($restorelog_file,"The Course ShortName is now - ".$course_header->course_shortname." The FullName is now - ".$course_header->course_fullname."<br><br>");
@@ -5976,11 +5985,10 @@ function restore_close_html($restore) {
$status = true;
//Open file for writing
- //First, check that "course_id" folder exists
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ //First, check that course_id/backupdata folder exists in CFG->dataroot
+ $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
$status = check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
//Write the footer to close the logging file
fwrite ($restorelog_file,"<br>This file was written to directly by each modules restore process.");
fwrite ($restorelog_file,"<br><br>Log complete.</body></html>");
View
7 mod/assignment/restorelib.php
@@ -34,11 +34,10 @@ function assignment_restore_mods($mod,$restore) {
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, we check to "course_id" exists and create is as necessary in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ //First, check the course_id backup folder exists in CFG->dataroot
+ $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
View
9 mod/chat/restorelib.php
@@ -33,12 +33,11 @@ function chat_restore_mods($mod,$restore) {
if ($data) {
//Now get completed xmlized object
- $info = $data->info;
- //First, we check to "course_id" exists and create is as necessary in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ $info = $data->info;
+ //First, check the course_id backup folder exists in CFG->dataroot
+ $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
View
7 mod/choice/restorelib.php
@@ -39,11 +39,10 @@ function choice_restore_mods($mod,$restore) {
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, we check to "course_id" exists and create is as necessary in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ //First, check the course_id backup folder exists in CFG->dataroot
+ $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
View
7 mod/data/restorelib.php
@@ -47,11 +47,10 @@ function data_restore_mods($mod,$restore) {
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, we check to "course_id" exists and create is as necessary in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ //First, check the course_id backup folder exists in CFG->dataroot
+ $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
View
7 mod/exercise/restorelib.php
@@ -49,11 +49,10 @@ function exercise_restore_mods($mod,$restore) {
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, we check to "course_id" exists and create is as necessary in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ //First, check the course_id backup folder exists in CFG->dataroot
+ $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
View
15 mod/forum/restorelib.php
@@ -44,11 +44,10 @@ function forum_restore_mods($mod,$restore) {
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, we check to "course_id" exists and create is as necessary in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ //First, check the course_id backup folder exists in CFG->dataroot
+ $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
@@ -271,12 +270,10 @@ function forum_discussions_restore_mods($forum_id,$info,$restore) {
if (!empty($info['MOD']['#']['DISCUSSIONS']['0']['#']['DISCUSSION'])) {
$discussions = $info['MOD']['#']['DISCUSSIONS']['0']['#']['DISCUSSION'];
}
-
- //First, we check that "course_id" folder exists and create is as necessary in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ //First, check the course_id backup folder exists in CFG->dataroot
+ $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
//Iterate over discussions
for($i = 0; $i < sizeof($discussions); $i++) {
$dis_info = $discussions[$i];
View
7 mod/glossary/restorelib.php
@@ -41,11 +41,10 @@ function glossary_restore_mods($mod,$restore) {
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ //First, check the course_id backup folder exists in CFG->dataroot
+ $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
View
4 mod/hotpot/index.php
@@ -252,8 +252,8 @@
// so this operation could be done after getting the $totals from the attempts table
}
$totals = get_records_sql("SELECT $fields FROM $tables WHERE $select GROUP BY a.hotpot");
-
- if (ihas_capability('mod/hotpot:grade', get_context_instance(CONTEXT_SYSTEM, SITEID)) && empty($usejoin)) {
+//remove i here ihas_capability
+ if (has_capability('mod/hotpot:grade', get_context_instance(CONTEXT_SYSTEM, SITEID)) && empty($usejoin)) {
foreach ($hotpots as $hotpot) {
$totals[$hotpot->id]->detailcount = 0;
if ($ids = get_records('hotpot_attempts', 'hotpot', $hotpot->id)) {
View
4 mod/hotpot/restorelib.php
@@ -110,8 +110,8 @@ function hotpot_restore_mods($mod, $restore) {
// if necessary, adjust HotPot date/time fields and write to restorelog
if (!empty($restore->course_startdateoffset)) {
- // check course_directory exists
- $course_dir = "$CFG->dataroot/$restore->course_id";
+ // check course backup data directory exists
+ $course_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($course_dir, true);
// open $restorelog and start output for this HotPot
View
14 mod/journal/restorelib.php
@@ -34,11 +34,10 @@ function journal_restore_mods($mod,$restore) {
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ //First, check the course_id backup folder exists in CFG->dataroot
+ $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
@@ -104,11 +103,10 @@ function journal_entries_restore_mods($old_journal_id, $new_journal_id,$info,$re
//Get the entries array
$entries = $info['MOD']['#']['ENTRIES']['0']['#']['ENTRY'];
- //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ //First, check the course_id backup folder exists in CFG->dataroot
+ $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
//Iterate over entries
for($i = 0; $i < sizeof($entries); $i++) {
$entry_info = $entries[$i];
View
7 mod/lesson/restorelib.php
@@ -51,11 +51,10 @@ function lesson_restore_mods($mod,$restore) {
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ //First, check the course_id backup folder exists in CFG->dataroot
+ $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
View
7 mod/quiz/restorelib.php
@@ -54,11 +54,10 @@ function quiz_restore_mods($mod,$restore) {
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ //First, check the course_id backup folder exists in CFG->dataroot
+ $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
View
7 mod/quiz/restorelibpre15.php
@@ -1226,11 +1226,10 @@ function quiz_restore_pre15_mods($mod,$restore) {
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ //First, check the course_id backup folder exists in CFG->dataroot
+ $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
View
14 mod/wiki/restorelib.php
@@ -34,11 +34,10 @@ function wiki_restore_mods($mod,$restore) {
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ //First, check the course_id backup folder exists in CFG->dataroot
+ $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
@@ -103,11 +102,10 @@ function wiki_entries_restore_mods($old_wiki_id,$new_wiki_id,$info,$restore) {
//Get the entries array
$entries = $info['MOD']['#']['ENTRIES']['0']['#']['ENTRY'];
- //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ //First, check the course_id backup folder exists in CFG->dataroot
+ $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
//Iterate over entries
for($i = 0; $i < sizeof($entries); $i++) {
$ent_info = $entries[$i];
View
14 mod/workshop/restorelib.php
@@ -48,11 +48,10 @@ function workshop_restore_mods($mod,$restore) {
if ($data) {
//Now get completed xmlized object
$info = $data->info;
- //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ //First, check the course_id backup folder exists in CFG->dataroot
+ $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
@@ -352,11 +351,10 @@ function workshop_submissions_restore_mods($old_workshop_id, $new_workshop_id,$i
//Get the submissions array
$submissions = $info['MOD']['#']['SUBMISSIONS']['0']['#']['SUBMISSION'];
- //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot
- $dest_dir = $CFG->dataroot."/".$restore->course_id;
+ //First, we check the course_id backup folder exists in CFG->dataroot
+ $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
- $file = $dest_dir."/restorelog.html";
- $restorelog_file = fopen($file,"a");
+ $restorelog_file = fopen("$dest_dir/restorelog.html","a");
//Iterate over submissions
for($i = 0; $i < sizeof($submissions); $i++) {
$sub_info = $submissions[$i];

0 comments on commit eb87ac7

Please sign in to comment.
Something went wrong with that request. Please try again.