Permalink
Browse files

Removed $moodle_home and $mods_home references.

Also removed direct references to $backup_version and $backup_release

backup.php now accepts teachers of their own course
  • Loading branch information...
moodler
moodler committed Aug 1, 2003
1 parent 10dcde4 commit 9c1ae5ae32308f39a87694324c4aa4c0298b38b1
View
@@ -3,29 +3,22 @@
//Define some globals for all the script
//MUST CHANGE WITH FINAL BACKUP LOCATION !! WITHOUT TRAILING SLASH !!
//ALL RELATIVE FROM THE LOCATION OF THE backup.php SCRIPT !!!
$moodle_home = "..";
$mods_home = "../mod";
//END MUST CHANGE
//Units used
require_once ("$moodle_home/config.php");
require_once ("$moodle_home/version.php");
require_once ("../config.php");
require_once ("lib.php");
require_once ("backuplib.php");
//Optional variables
optional_variable($id); // course id
//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");
if (!empty($id)) {
if (!isteacher($id)) {
error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
}
} else {
if (!isadmin()) {
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
}
}
//Check site
@@ -46,7 +39,7 @@
//If no course has been selected or cancel button pressed
if (!$id or $cancel) {
print_header("$site->shortname: $strcoursebackup", $site->fullname,
"<A HREF=\"$moodle_home/$CFG->admin/index.php\">$stradministration</A> -> $strcoursebackup");
"<A HREF=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</A> -> $strcoursebackup");
if ($courses = get_courses()) {
print_heading(get_string("choosecourse"));
@@ -57,7 +50,7 @@
print_simple_box_end();
} else {
print_heading(get_string("nocoursesyet"));
print_continue("$moodle_home/$CFG->admin/index.php");
print_continue("$CFG->wwwroot/$CFG->admin/index.php");
}
print_footer();
exit;
@@ -67,10 +60,17 @@
if (! $course = get_record("course", "id", $id)) {
error("Course ID was incorrect (can't find it)");
}
//Print header
print_header("$site->shortname: $strcoursebackup", $site->fullname,
"<A HREF=\"$moodle_home/$CFG->admin/index.php\">$stradministration</A> ->
<A HREF=\"backup.php\">$strcoursebackup</A> -> $course->fullname ($course->shortname)");
if (isadmin()) {
print_header("$site->shortname: $strcoursebackup", $site->fullname,
"<a href=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</a> ->
<a href=\"backup.php\">$strcoursebackup</a> -> $course->fullname ($course->shortname)");
} else {
print_header("$site->shortname: $strcoursebackup", $site->fullname,
"<a href=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</a> ->
<a href=\"backup.php\">$strcoursebackup</a> -> $course->fullname ($course->shortname)");
}
//Print form
print_heading("$strcoursebackup: $course->fullname ($course->shortname)");
View
@@ -20,7 +20,7 @@
if ($allmods = get_records("modules") ) {
foreach ($allmods as $mod) {
$modname = $mod->name;
$modfile = "$mods_home/$modname/backuplib.php";
$modfile = "$CFG->dirroot/mod/$modname/backuplib.php";
$modbackup = $modname."_backup_mods";
$modcheckbackup = $modname."_check_backup_mods";
if (file_exists($modfile)) {
View
@@ -20,7 +20,7 @@
if ($allmods = get_records("modules") ) {
foreach ($allmods as $mod) {
$modname = $mod->name;
$modfile = "$mods_home/$modname/backuplib.php";
$modfile = "$CFG->dirroot/mod/$modname/backuplib.php";
$modbackup = $modname."_backup_mods";
$modcheckbackup = $modname."_check_backup_mods";
if (file_exists($modfile)) {
@@ -90,10 +90,10 @@
$preferences->backup_unique_code = $backup_unique_code;
//Another Info
$preferences->moodle_version = $version;
$preferences->moodle_release = $release;
$preferences->backup_version = $backup_version;
$preferences->backup_release = $backup_release;
$preferences->moodle_version = $CFG->version;
$preferences->moodle_release = $CFG->release;
$preferences->backup_version = $CFG->backup_version;
$preferences->backup_release = $CFG->backup_release;
if ($count == 0) {
notice("No backupable modules are installed!");
@@ -249,7 +249,7 @@
//Now, zip all the backup directory contents
if ($status) {
echo "<li>".get_string("zippingbackup");
$status = backup_zip ($preferences,$moodle_home);
$status = backup_zip ($preferences);
}
//Now, copy the zip file to course directory
@@ -279,6 +279,6 @@
//Print final message
print_simple_box(get_string("backupfinished"),"CENTER");
print_continue($moodle_home."/files/index.php?id=".$preferences->backup_course."&wdir=/".get_string("backupdir"));
print_continue("$CFG->wwwroot/files/index.php?id=".$preferences->backup_course."&wdir=/".get_string("backupdir"));
?>
View
@@ -20,7 +20,7 @@
if ($allmods = get_records("modules") ) {
foreach ($allmods as $mod) {
$modname = $mod->name;
$modfile = "$mods_home/$modname/backuplib.php";
$modfile = "$CFG->dirroot/mod/$modname/backuplib.php";
$modbackup = $modname."_backup_mods";
$modcheckbackup = $modname."_check_backup_mods";
if (file_exists($modfile)) {
View
@@ -845,7 +845,7 @@ function backup_copy_course_files ($preferences) {
//The zipped file is created in the backup directory and named with
//the "oficial" name of the backup
//It uses "pclzip" if available or system "zip" (unix only)
function backup_zip ($preferences,$moodle_home) {
function backup_zip ($preferences) {
global $CFG;
@@ -869,7 +869,7 @@ function backup_zip ($preferences,$moodle_home) {
//Include into array
$files[] = $basedir."/".$file;
}
include_once($moodle_home."/lib/pclzip/pclzip.lib.php");
include_once("$CFG->dirroot/lib/pclzip/pclzip.lib.php");
$archive = new PclZip("$basedir/$name");
if (($list = $archive->create($files,PCLZIP_OPT_REMOVE_PATH,$basedir)) == 0) {
error($archive->errorInfo(true));
View
@@ -3,14 +3,10 @@
//Define some globals for all the script
$moodle_home = "..";
$mods_home = "../mod";
//Units used
require_once ("$moodle_home/config.php");
require_once ("$moodle_home/version.php");
require_once ("$moodle_home/lib/xmlize.php");
require_once ("$moodle_home/course/lib.php");
require_once ("../config.php");
require_once ("../lib/xmlize.php");
require_once ("../course/lib.php");
require_once ("lib.php");
require_once ("restorelib.php");
@@ -49,27 +45,27 @@
//If no file has been selected from the FileManager, inform and end
if (!$file) {
print_header("$site->shortname: $strcourserestore", $site->fullname,
"<A HREF=\"$moodle_home/$CFG->admin/index.php\">$stradministration</A> -> $strcourserestore");
"<A HREF=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</A> -> $strcourserestore");
print_heading(get_string("nofilesselected"));
print_continue("$moodle_home/$CFG->admin/index.php");
print_continue("$CFG->wwwroot/$CFG->admin/index.php");
print_footer();
exit;
}
//If cancel has been selected, inform and end
if ($cancel) {
print_header("$site->shortname: $strcourserestore", $site->fullname,
"<A HREF=\"$moodle_home/$CFG->admin/index.php\">$stradministration</A> -> $strcourserestore");
"<A HREF=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</A> -> $strcourserestore");
print_heading(get_string("restorecancelled"));
print_continue("$moodle_home/$CFG->admin/index.php");
print_continue("$CFG->wwwroot/$CFG->admin/index.php");
print_footer();
exit;
}
//We are here, so me have a file.
//Print header
print_header("$site->shortname: $strcourserestore", $site->fullname,
"<A HREF=\"$moodle_home/$CFG->admin/index.php\">$stradministration</A> ->
"<A HREF=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</A> ->
$strcourserestore -> ".basename($file));
//Print form
print_heading("$strcourserestore: ".basename($file));
@@ -122,7 +122,7 @@
print_simple_box_end();
} else {
print_heading(get_string("nocoursesyet"));
print_continue("$moodle_home/$CFG->admin/index.php");
print_continue("$CFG->wwwroot/$CFG->admin/index.php");
}
//Checks everything and execute restore
} else if ((($restore->restoreto == 0) and ($restore->course_id != 0)) or ($restore->restoreto == 1)) {
@@ -28,7 +28,7 @@
if ($allmods = get_records("modules") ) {
foreach ($allmods as $mod) {
$modname = $mod->name;
$modfile = "$mods_home/$modname/restorelib.php";
$modfile = "$CFG->dirroot/mod/$modname/restorelib.php";
//If file exists and we have selected to restore that type of module
if ((file_exists($modfile)) and ($restore->mods[$modname]->restore)) {
include_once($modfile);
@@ -236,6 +236,6 @@
//Print final message
print_simple_box(get_string("restorefinished"),"CENTER");
print_continue($moodle_home."/course/view.php?id=".$restore->course_id);
print_continue("$CFG->wwwroot/course/view.php?id=".$restore->course_id);
?>
View
@@ -36,7 +36,7 @@
if ($allmods = get_records("modules") ) {
foreach ($allmods as $mod) {
$modname = $mod->name;
$modfile = "$mods_home/$modname/restorelib.php";
$modfile = "$CFG->dirroot/mod/$modname/restorelib.php";
$modrestore = $modname."_restore_mods";
if (file_exists($modfile)) {
include_once($modfile);
@@ -68,7 +68,7 @@
//Now unzip the file
if ($status) {
echo "<li>".get_string("unzippingbackup");
$status = restore_unzip ($CFG->dataroot."/temp/backup/".$backup_unique_code."/".basename($file),$moodle_home);
$status = restore_unzip ($CFG->dataroot."/temp/backup/".$backup_unique_code."/".basename($file));
}
//Now check for the moodle.xml file
View
@@ -3,14 +3,14 @@
//This function unzips a zip file in the same directory that it is
//It automatically uses pclzip or command line unzip
function restore_unzip ($file,$moodle_home) {
function restore_unzip ($file) {
global $CFG;
$status = true;
if (empty($CFG->unzip)) { // Use built-in php-based unzip function
include_once($moodle_home."/lib/pclzip/pclzip.lib.php");
include_once("$CFG->wwwroot/lib/pclzip/pclzip.lib.php");
$archive = new PclZip($file);
if (!$list = $archive->extract(dirname($file))) {
$status = false;

0 comments on commit 9c1ae5a

Please sign in to comment.