]> git.mjollnir.org Git - moodle.git/commitdiff
added prune() to admin tree class to prevent errors in applying of backup defaults
authorskodak <skodak>
Sat, 2 Sep 2006 19:30:54 +0000 (19:30 +0000)
committerskodak <skodak>
Sat, 2 Sep 2006 19:30:54 +0000 (19:30 +0000)
admin/index.php
lib/adminlib.php

index 4daa3d6d03038d6ac546acffef68e9dfa9cd6835..a458a9a88e9f523a7a4a1db9713a0903ee8a8ed9 100644 (file)
             // Write default settings unconditionally (i.e. even if a setting is already set, overwrite it)
             // (this should only have any effect during initial install).
             $adminroot = admin_get_root();
+            $adminroot->prune('backups'); // backup settings table not created yet
             apply_default_settings($adminroot);
 
             /// This is used to handle any settings that must exist in $CFG but which do not exist in
index e7803527c78fb5e57fbd9e5bf6491a19fce13804..f7c4514bf8222e2e7c43ac83529f798b067314d6 100644 (file)
@@ -738,7 +738,18 @@ class part_of_admin_tree {
         trigger_error('Admin class does not implement method <strong>locate()</strong>', E_USER_WARNING); 
         return; 
     }
-    
+
+    /**
+     * Removes named part_of_admin_tree.
+     *
+     * @param string $name The internal name of the part_of_admin_tree we want to remove.
+     * @return boolean success.
+     */
+    function prune($name) {
+        trigger_error('Admin class does not implement method <strong>prune()</strong>', E_USER_WARNING); 
+        return;
+    } 
+
     /**
      * Verifies current user's access to this part_of_admin_tree.
      *
@@ -901,6 +912,31 @@ class admin_category extends parentable_part_of_admin_tree {
         return $return;
     }
 
+    /**
+     * Removes part_of_admin_tree object with internal name $name.
+     *
+     * @param string $name The internal name of the object we want to remove.
+     * @return boolean success
+     */
+    function prune($name) {
+
+        if ($this->name == $name) {
+            return false;  //can not remove itself
+        }
+
+        foreach($this->children as $precedence => $child) {
+            if ($child->name == $name) {
+                // found it!
+                unset($this->children[$precedence]); 
+                return true;
+            }
+            if ($this->children[$precedence]->prune($name)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     /**
      * Adds a part_of_admin_tree to a child or grandchild (or great-grandchild, and so forth) of this object.
      *
@@ -1033,7 +1069,11 @@ class admin_externalpage extends part_of_admin_tree {
         $return = ($this->name == $name ? $this : NULL);
         return $return;
     }
-    
+
+    function prune($name) {
+        return false;
+    }
+
     /**
      * Determines if the current user has access to this external page based on $this->role.
      *
@@ -1093,7 +1133,11 @@ class admin_settingpage extends part_of_admin_tree {
         $return = ($this->name == $name ? $this : NULL);
         return $return;
     }
-    
+
+    function prune($name) {
+        return false;
+    }
+
     // see admin_externalpage
     function admin_settingpage($name, $visiblename, $role = 'moodle/legacy:admin') {
         global $CFG;
@@ -1427,11 +1471,7 @@ class admin_setting_courselist_frontpage extends admin_setting_configselect {
         if (count_records("course") > FRONTPAGECOURSELIMIT) {
             unset($choices[FRONTPAGECOURSELIST]);
         }
-        if ($loggedin) {
-            $defaults = FRONTPAGECOURSELIST.',,,';
-        } else {
-            $defaults = FRONTPAGECATEGORYCOMBO.',,,';
-        }
+        $defaults = FRONTPAGECOURSELIST.',,,';
         parent::admin_setting_configselect($name, $visiblename, $description, $defaults, $choices);
     }