]> git.mjollnir.org Git - moodle.git/commitdiff
Now, to restore course category do this:
authorstronk7 <stronk7>
Tue, 23 Sep 2003 16:40:44 +0000 (16:40 +0000)
committerstronk7 <stronk7>
Tue, 23 Sep 2003 16:40:44 +0000 (16:40 +0000)
- Check if (category_id, category_name) exists.
- Check if (category_name) exists.
- Check if category_id = 1 exists.
- Create a new, initially invisible category withe the info in backup-file.

This solves a issue when restoring to a new course and category_id 1
had been removed !!

backup/restorelib.php

index 2590a5b22bf14e7927a2665a718987db25647c33..9a4564aa2c58d1dc25c78ef3cb6b04c0cc740cea 100644 (file)
         if (!$category) {
             $category = get_record("course_categories","id","1");
         }
+        //If category 1 doesn'exists, lets create the course category (get it from backup file)
+        if (!$category) {
+            $ins_category->name = addslashes($course_header->category->name);
+            $ins_category->parent = 0;
+            $ins_category->sortorder = 0;
+            $ins_category->coursecount = 0;
+            $ins_category->visible = 0;            //To avoid interferences with the rest of the site
+            $ins_category->timemodified = time();
+            $newid = insert_record("course_categories",$ins_category);
+            $category->id = $newid;
+            $category->name = $course_header->category->name;
+        }
         //If exists, put new category id
         if ($category) {
             $course_header->category->id = $category->id;