From 2c4483e5fb8043e13c7ab3c718d75d88e4bea1f1 Mon Sep 17 00:00:00 2001 From: martin Date: Sat, 27 Jul 2002 06:08:29 +0000 Subject: [PATCH] New upgrading procedure, uses module functions to handle all version changes --- admin/index.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/admin/index.php b/admin/index.php index 887b8003846..4f821e66b5d 100644 --- a/admin/index.php +++ b/admin/index.php @@ -50,7 +50,20 @@ if ($currmodule->version == $module->version) { // do nothing } else if ($currmodule->version < $module->version) { - notify("$module->name module needs upgrading"); // XXX do the upgrade here + notify("$module->name module needs upgrading"); + $upgrade_function = $module->name."_upgrade"; + if (function_exists($upgrade_function)) { + if ($upgrade_function($currmodule->version, $module)) { + // OK so far, now update the modules record + $module->id = $currmodule->id; + if (! update_record("modules", $module)) { + error("Could not update $module->name record in modules table!"); + } + notify("$module->name module was successfully upgraded"); + } else { + notify("Upgrading $module->name from $currmodule->version to $module->version FAILED!"); + } + } $updated_modules = true; } else { error("Version mismatch: $module->name can't downgrade $currmodule->version -> $module->version !"); @@ -67,7 +80,7 @@ } else { error("$module->name module could not be added to the module list!"); } - } else { + } else { error("$module->name tables could NOT be set up successfully!"); } } @@ -101,7 +114,7 @@ echo "
  • Edit a user's account"; echo "
  • Assign teachers to courses"; echo "
  • Delete a course"; - echo "
  • View Logs"; + echo "
  • id\">Site Logs"; echo ""; print_footer();