]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-8209 - Force admin/index.php to redirect to upgrade settings screen
authorpoltawski <poltawski>
Wed, 18 Apr 2007 09:39:49 +0000 (09:39 +0000)
committerpoltawski <poltawski>
Wed, 18 Apr 2007 09:39:49 +0000 (09:39 +0000)
when some admin settings are not set.

admin/index.php
lib/adminlib.php

index 7bde7e4716721d3e1e035f8484fd80e1fdeebfec..c0c39b44935e69bd2bf555b7193529d151837072 100644 (file)
         }
     }
 
+    $adminroot = admin_get_root();
+
+/// Check if there are any new admin settings which have still yet to be set
+    if( any_new_admin_settings( $adminroot ) ){
+        redirect('upgradesettings.php');
+    }
+
 /// Everything should now be set up, and the user is an admin
 
 /// Print default admin page with notifications.
 
-    $adminroot = admin_get_root();
     admin_externalpage_setup('adminnotifications', $adminroot);
     admin_externalpage_print_header($adminroot);
 
index a14b873e83839b7781a42c47f9dc95ceadf184aa..fd0be41112f417d3ca8e2fe3ffdabc277796bcd0 100644 (file)
@@ -2823,4 +2823,35 @@ function upgrade_language_pack($lang='') {
     return false;
 }
 
+/**
+ * Based on find_new_settings{@link ()}  in upgradesettings.php
+ * Looks to find any admin settings that have not been initialized. Returns 1 if it finds any.
+ *
+ * @param string &$node The node at which to start searching. 
+ * @return int Returns 1 if any settings haven't been initialised, 0 if they all have
+ */
+function any_new_admin_settings(&$node) {
+
+    if (is_a($node, 'admin_category')) {
+        $entries = array_keys($node->children);
+        foreach ($entries as $entry) {
+            if( any_new_admin_settings($node->children[$entry]) ){
+                return 1;
+            }
+        }
+    }
+
+    if (is_a($node, 'admin_settingpage')) {
+        foreach ($node->settings as $setting) {
+            if ($setting->get_setting() === NULL) {
+                return 1;
+            }
+        }
+    }
+
+
+    return 0;
+
+}
+
 ?>