From: moodler Date: Fri, 1 Aug 2003 14:34:11 +0000 (+0000) Subject: Removed $moodle_home and $mods_home references. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9c1ae5ae32308f39a87694324c4aa4c0298b38b1;p=moodle.git 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 --- diff --git a/backup/backup.php b/backup/backup.php index eb51689617..767c7c12ad 100644 --- a/backup/backup.php +++ b/backup/backup.php @@ -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, - "admin/index.php\">$stradministration -> $strcoursebackup"); + "wwwroot/$CFG->admin/index.php\">$stradministration -> $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, - "admin/index.php\">$stradministration -> - $strcoursebackup -> $course->fullname ($course->shortname)"); + if (isadmin()) { + print_header("$site->shortname: $strcoursebackup", $site->fullname, + "wwwroot/$CFG->admin/index.php\">$stradministration -> + $strcoursebackup -> $course->fullname ($course->shortname)"); + } else { + print_header("$site->shortname: $strcoursebackup", $site->fullname, + "wwwroot/$CFG->admin/index.php\">$stradministration -> + $strcoursebackup -> $course->fullname ($course->shortname)"); + } //Print form print_heading("$strcoursebackup: $course->fullname ($course->shortname)"); diff --git a/backup/backup_check.html b/backup/backup_check.html index 6c9ecec569..8c75523286 100644 --- a/backup/backup_check.html +++ b/backup/backup_check.html @@ -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)) { diff --git a/backup/backup_execute.html b/backup/backup_execute.html index 4981feba8a..7394e0304b 100644 --- a/backup/backup_execute.html +++ b/backup/backup_execute.html @@ -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 "
  • ".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")); ?> diff --git a/backup/backup_form.html b/backup/backup_form.html index a79caee36f..fe20b0033b 100644 --- a/backup/backup_form.html +++ b/backup/backup_form.html @@ -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)) { diff --git a/backup/backuplib.php b/backup/backuplib.php index e176c204aa..e91094dcda 100644 --- a/backup/backuplib.php +++ b/backup/backuplib.php @@ -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)); diff --git a/backup/restore.php b/backup/restore.php index 9cc6b61bcc..f261950e13 100644 --- a/backup/restore.php +++ b/backup/restore.php @@ -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, - "admin/index.php\">$stradministration -> $strcourserestore"); + "wwwroot/$CFG->admin/index.php\">$stradministration -> $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, - "admin/index.php\">$stradministration -> $strcourserestore"); + "wwwroot/$CFG->admin/index.php\">$stradministration -> $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, - "admin/index.php\">$stradministration -> + "wwwroot/$CFG->admin/index.php\">$stradministration -> $strcourserestore -> ".basename($file)); //Print form print_heading("$strcourserestore: ".basename($file)); diff --git a/backup/restore_check.html b/backup/restore_check.html index c20e1118ac..f0e0c19f6e 100644 --- a/backup/restore_check.html +++ b/backup/restore_check.html @@ -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)) { diff --git a/backup/restore_execute.html b/backup/restore_execute.html index 727819aea6..7d4b7e220b 100644 --- a/backup/restore_execute.html +++ b/backup/restore_execute.html @@ -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); ?> diff --git a/backup/restore_form.html b/backup/restore_form.html index f11c26fa12..22df920769 100644 --- a/backup/restore_form.html +++ b/backup/restore_form.html @@ -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); diff --git a/backup/restore_precheck.html b/backup/restore_precheck.html index 78a9f08847..d036944d06 100644 --- a/backup/restore_precheck.html +++ b/backup/restore_precheck.html @@ -68,7 +68,7 @@ //Now unzip the file if ($status) { echo "
  • ".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 diff --git a/backup/restorelib.php b/backup/restorelib.php index 20c45a80b2..8d6557c98c 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -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;