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
This commit is contained in:
moodler 2003-08-01 14:34:11 +00:00
parent 10dcde409b
commit 9c1ae5ae32
11 changed files with 47 additions and 51 deletions

View File

@ -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 File

@ -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 File

@ -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 File

@ -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 File

@ -845,7 +845,7 @@
//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 @@
//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 File

@ -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,9 +45,9 @@
//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;
}
@ -59,9 +55,9 @@
//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;
}
@ -69,7 +65,7 @@
//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));

View 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)) {

View File

@ -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 File

@ -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);

View File

@ -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 File

@ -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;