Skip to content

Commit

Permalink
Change creation of restorelog file location to protected backupdata f…
Browse files Browse the repository at this point in the history
…older.

Reassign style and language links
  • Loading branch information
thompson697 committed Oct 4, 2006
1 parent 57bdc37 commit eb87ac7
Show file tree
Hide file tree
Showing 17 changed files with 83 additions and 90 deletions.
3 changes: 3 additions & 0 deletions .cvsignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Copy of .project
config.php
.project
40 changes: 24 additions & 16 deletions backup/restorelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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>");
Expand All @@ -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>");
Expand Down
7 changes: 3 additions & 4 deletions mod/assignment/restorelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions mod/chat/restorelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions mod/choice/restorelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions mod/data/restorelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions mod/exercise/restorelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 6 additions & 9 deletions mod/forum/restorelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand Down
7 changes: 3 additions & 4 deletions mod/glossary/restorelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mod/hotpot/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 2 additions & 2 deletions mod/hotpot/restorelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 6 additions & 8 deletions mod/journal/restorelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand Down
7 changes: 3 additions & 4 deletions mod/lesson/restorelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions mod/quiz/restorelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions mod/quiz/restorelibpre15.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit eb87ac7

Please sign in to comment.