]> git.mjollnir.org Git - moodle.git/commitdiff
Removed $moodle_home and $mods_home references.
authormoodler <moodler>
Fri, 1 Aug 2003 14:34:11 +0000 (14:34 +0000)
committermoodler <moodler>
Fri, 1 Aug 2003 14:34:11 +0000 (14:34 +0000)
Also removed direct references to $backup_version and $backup_release

backup.php now accepts teachers of their own course

backup/backup.php
backup/backup_check.html
backup/backup_execute.html
backup/backup_form.html
backup/backuplib.php
backup/restore.php
backup/restore_check.html
backup/restore_execute.html
backup/restore_form.html
backup/restore_precheck.html
backup/restorelib.php

index eb516896175f0477cfd7c55fb3f90cfa05febcb7..767c7c12ad5fd6559e2974f49279dddf9dca2f2c 100644 (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;
     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)");
index 6c9ecec569143a4ec963671f096d26b45761faa4..8c7552328679efffa3991c46023857f2e91a2fc3 100644 (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)) {
index 4981feba8aac5c17000836d527b5797d2547053a..7394e0304bd519a5dccab301cf70eb6f9c89255e 100644 (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)) {
     $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!");
     //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
 
     //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"));    
 
 ?>
index a79caee36f55fd7d80e3a72b9c23c7e255c6e103..fe20b0033bdacdf22d8fe348b1d0cb084147aebf 100644 (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)) {
index e176c204aa575a6338c7fb6f1ffafeeb282412bd..e91094dcdad1996b0bda0f1be9e751f1d16be77a 100644 (file)
     //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;
 
                 //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));
index 9cc6b61bcc05c981ea8a9f37dc9e9e90d200c2fc..f261950e134449ac3a0f291420147effa2acb36d 100644 (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));
index c20e1118acc90b0f2926c7f10e60bd21d1532a43..f0e0c19f6eb28f66d65e4e1e59c8c746dcda254d 100644 (file)
             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)) {
index 727819aea6c73f9f691bcd85e44477582740a777..7d4b7e220b7dd4c9333f59bf568aa2cb68f88159 100644 (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);
 
     //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);
 
 ?>
index f11c26fa123a0957257ace12c8b87526d94012a5..22df9207692efbe10459d3d733046b4eeb6df5f1 100644 (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);
index 78a9f0884750215ce22ce9da334533743e72e8c7..d036944d063160154edf60a1fc1a17c021351cb9 100644 (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
index 20c45a80b2949cb85f2a9058d02ab8a26e173755..8d6557c98ce29ecd25895de56169eb047343babb 100644 (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;