From: stronk7 Date: Mon, 10 Sep 2007 17:13:12 +0000 (+0000) Subject: Allow the upgrade_plugins() function to autodetect if the header X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=15999a935158f6e70f3422ad5cde7267f4318efc;p=moodle.git Allow the upgrade_plugins() function to autodetect if the header has been printed, so it runs in "embedded" mode. Useful to run submodule installation/upgrade in the same page than the parent. MDL-11183 --- diff --git a/lib/adminlib.php b/lib/adminlib.php index d0c876b52c..f3f3047593 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -21,6 +21,9 @@ function upgrade_plugins($type, $dir, $return) { global $CFG, $db; +/// Let's know if the header has been printed, so the funcion is being called embedded in an outer page + $embedded = defined('HEADER_PRINTED'); + $plugs = get_list_of_plugins($dir); $updated_plugins = false; $strpluginsetup = get_string('pluginsetup'); @@ -59,7 +62,7 @@ function upgrade_plugins($type, $dir, $return) { $info->pluginversion = $plugin->version; $info->currentmoodle = $CFG->version; $info->requiremoodle = $plugin->requires; - if (!$updated_plugins) { + if (!$updated_plugins && !$embedded) { print_header($strpluginsetup, $strpluginsetup, build_navigation(array(array('name' => $strpluginsetup, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript(), false, ' ', ' '); @@ -82,7 +85,7 @@ function upgrade_plugins($type, $dir, $return) { if ($CFG->$pluginversion == $plugin->version) { // do nothing } else if ($CFG->$pluginversion < $plugin->version) { - if (!$updated_plugins) { + if (!$updated_plugins && !$embedded) { print_header($strpluginsetup, $strpluginsetup, build_navigation(array(array('name' => $strpluginsetup, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript(), false, ' ', ' '); @@ -181,7 +184,7 @@ function upgrade_plugins($type, $dir, $return) { upgrade_log_finish(); - if ($updated_plugins) { + if ($updated_plugins && !$embedded) { print_continue($return); print_footer('none'); die;