]> git.mjollnir.org Git - moodle.git/commitdiff
No need for forcetables hack any more. Moodle can now detect whether
authormoodler <moodler>
Tue, 24 Dec 2002 05:39:45 +0000 (05:39 +0000)
committermoodler <moodler>
Tue, 24 Dec 2002 05:39:45 +0000 (05:39 +0000)
it has already been installed in the current database (by looking
for all the main tables) and do the right thing.  It doesn't matter now
if there are other tables in the database or not.

admin/forcetables.php [deleted file]
admin/index.php

diff --git a/admin/forcetables.php b/admin/forcetables.php
deleted file mode 100644 (file)
index 1406382..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?PHP // $Id$
-
-    require("../config.php");
-
-/// Normally this file is never used.
-///
-/// It can be useful to jump-start a new moodle installation when 
-/// it is being installed into a database that already contains
-/// some tables.   
-/// 
-/// For this case you would call this script directly
-///
-/// Warning: this method ASSUMES that all existing tables with 
-/// have different names to any Moodle tables, so make sure 
-/// there aren't any Moodle-named tables in your database before
-/// using this script.   See lib/db/mysql.sql and mod/*/db/mysql.sql
-
-    if ($CFG->version) { // To avoid this being used on a working site.
-        echo "No need to use this";
-
-    } else {
-
-        $strdatabasesetup    = get_string("databasesetup");
-        $strdatabasesuccess  = get_string("databasesuccess");
-
-        print_header($strdatabasesetup, $strdatabasesetup, $strdatabasesetup);
-        if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) {
-            $db->debug = true;
-            if (modify_database("$CFG->libdir/db/$CFG->dbtype.sql")) {
-                $db->debug = false;
-                notify($strdatabasesuccess);
-            } else {
-                $db->debug = false;
-                error("Error: Main databases NOT set up successfully");
-            }
-        } else {
-            error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle.  
-                   See the lib/db directory.");
-        }
-        print_continue("index.php");
-    }
-
index 4163934700b2b8ca27c220070ccf26589b5c5014..d8f203e787fb6b7242fed388edb6acc035119853 100644 (file)
         error("Moodle has not been configured yet.  You need to to edit config.php first.");
     }
 
-/// Check databases and modules and install as needed.
-    if (! $db->Metatables() ) { 
+/// Check if the main tables have been installed yet or not.
+
+    if (! $tables = $db->Metatables() ) {    // No tables yet at all.
+        $maintables = false;
+
+    } else {                                 // Check for missing main tables
+        $maintables = true;
+        $mtables = array("config", "course", "course_categories", "course_modules", 
+                         "course_sections", "log", "log_display", "modules", 
+                         "user", "user_admins", "user_students", "user_teachers");
+        foreach ($mtables as $mtable) {
+            if (!in_array($CFG->prefix.$mtable, $tables)) { 
+                $maintables = false;
+                break;
+            }
+        }
+    }
 
+    if (! $maintables) {
         if (!$agreelicence) {
             $strlicense = get_string("license");
             print_header($strlicense, $strlicense, $strlicense);