MDL-23109 backup - define some original course bits for easier access from UI
authorEloy Lafuente <stronk7@moodle.org>
Wed, 21 Jul 2010 00:42:55 +0000 (00:42 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Wed, 21 Jul 2010 00:42:55 +0000 (00:42 +0000)
backup/backup.class.php
backup/moodle2/backup_stepslib.php
backup/util/dbops/backup_controller_dbops.class.php
backup/util/helper/backup_general_helper.class.php
backup/util/helper/restore_prechecks_helper.class.php

index d854368..2905c82 100644 (file)
@@ -106,7 +106,7 @@ abstract class backup implements checksumable {
     const OPERATION_RESTORE ='restore';// We are performing one restore
 
     // Version (to keep CFG->backup_version (and release) updated automatically)
-    const VERSION = 2010071800;
+    const VERSION = 2010072000;
     const RELEASE = '2.0 Preview 5';
 }
 
index 7950a4b..994546c 100644 (file)
@@ -1202,6 +1202,10 @@ class backup_main_structure_step extends backup_structure_step {
         $info['original_wwwroot']=$CFG->wwwroot;
         $info['original_site_identifier_hash'] = md5(get_site_identifier());
         $info['original_course_id'] = $this->get_courseid();
+        $originalcourseinfo = backup_controller_dbops::backup_get_original_course_info($this->get_courseid());
+        $info['original_course_fullname']  = $originalcourseinfo->fullname;
+        $info['original_course_shortname'] = $originalcourseinfo->shortname;
+        $info['original_course_startdate'] = $originalcourseinfo->startdate;
         $info['original_course_contextid'] = get_context_instance(CONTEXT_COURSE, $this->get_courseid())->id;
         $info['original_system_contextid'] = get_context_instance(CONTEXT_SYSTEM)->id;
 
@@ -1215,7 +1219,9 @@ class backup_main_structure_step extends backup_structure_step {
         $information = new backup_nested_element('information', null, array(
             'name', 'moodle_version', 'moodle_release', 'backup_version',
             'backup_release', 'backup_date', 'mnet_remoteusers', 'original_wwwroot',
-            'original_site_identifier_hash', 'original_course_id', 'original_course_contextid', 'original_system_contextid'));
+            'original_site_identifier_hash', 'original_course_id',
+            'original_course_fullname', 'original_course_shortname', 'original_course_startdate',
+            'original_course_contextid', 'original_system_contextid'));
 
         $details = new backup_nested_element('details');
 
index 82523e1..b2c7754 100644 (file)
@@ -370,9 +370,19 @@ abstract class backup_controller_dbops extends backup_dbops {
         return (int)(bool)$count;
     }
 
+    /**
+     * Given the courseid, return some course related information we want to transport
+     *
+     * @param int $course the id of the course this backup belongs to
+     */
+    public static function backup_get_original_course_info($courseid) {
+        global $DB;
+        return $DB->get_record('course', array('id' => $courseid), 'fullname, shortname, startdate');
+    }
+
     /**
      * Sets the controller settings default values from the backup config.
-     * 
+     *
      * @param backup_controller $controller
      */
     public static function apply_general_config_defaults(backup_controller $controller) {
index 5cab2fe..99db287 100644 (file)
@@ -140,6 +140,9 @@ abstract class backup_general_helper extends backup_helper {
         $info->original_wwwroot         = $infoarr['original_wwwroot'];
         $info->original_site_identifier_hash = $infoarr['original_site_identifier_hash'];
         $info->original_course_id       = $infoarr['original_course_id'];
+        $info->original_course_fullname = $infoarr['original_course_fullname'];
+        $info->original_course_shortname= $infoarr['original_course_shortname'];
+        $info->original_course_startdate= $infoarr['original_course_startdate'];
         $info->original_course_contextid= $infoarr['original_course_contextid'];
         $info->original_system_contextid= $infoarr['original_system_contextid'];
         $info->type   =  $infoarr['details']['detail'][0]['type'];
index 81689b0..f1090c5 100644 (file)
@@ -63,7 +63,7 @@ abstract class restore_prechecks_helper {
         restore_controller_dbops::create_restore_temp_tables($controller->get_restoreid());
 
         // Check we are restoring one backup >= $min20version (very first ok ever)
-        $min20version = 2010071800;
+        $min20version = 2010072000;
         if ($controller->get_info()->backup_version < $min20version) {
             $message = new stdclass();
             $message->backup = $controller->get_info()->backup_version;