From d210e12e85ce10fa76d43abcaa88d03314764ec8 Mon Sep 17 00:00:00 2001 From: moodler Date: Mon, 6 Nov 2006 12:51:27 +0000 Subject: [PATCH] Merged MDL-7351 from stable --- admin/index.php | 8 ++++++++ lib/adminlib.php | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/admin/index.php b/admin/index.php index de37e4aab1..09fff39e4d 100644 --- a/admin/index.php +++ b/admin/index.php @@ -229,8 +229,11 @@ } if (empty($confirmupgrade)) { + + print_header($strdatabasechecking, $stradministration, $strdatabasechecking, "", "", false, " ", " "); + notice_yesno(get_string('upgradesure', 'admin', $a->newversion), 'index.php?confirmupgrade=yes', 'index.php'); exit; @@ -238,10 +241,15 @@ $strdatabasesuccess = get_string("databasesuccess"); print_header($strdatabasechecking, $stradministration, $strdatabasechecking, "", $linktoscrolltoerrors, false, " ", " "); + /// return to original debugging level $CFG->debug = $origdebug; error_reporting($CFG->debug); upgrade_log_start(); + + /// Upgrade current language pack if we can + upgrade_language_pack(); + print_heading($strdatabasechecking); $db->debug=true; /// Launch the old main upgrade (if exists) diff --git a/lib/adminlib.php b/lib/adminlib.php index 9a7cbebc91..4737463634 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -2570,4 +2570,39 @@ function format_admin_setting($name, $title='', $form='', $description='') { "\n\n"; } +/* + * Try to upgrade the given language pack (or current language) + * If it doesn't work, fail silently and return false + */ +function upgrade_language_pack($lang='') { + global $CFG; + + if (empty($lang)) { + $lang = current_language(); + } + + if ($lang == 'en_utf8') { + return true; // Nothing to do + } + + notify(get_string('langimport', 'admin').': '.$lang.' ... ', 'notifysuccess'); + + @mkdir ($CFG->dataroot.'/temp/'); //make it in case it's a fresh install, it might not be there + @mkdir ($CFG->dataroot.'/lang/'); + + require_once($CFG->libdir.'/componentlib.class.php'); + + if ($cd = new component_installer('http://download.moodle.org', 'lang16', $lang.'.zip', 'languages.md5', 'lang')) { + $status = $cd->install(); //returns ERROR | UPTODATE | INSTALLED + + if ($status == INSTALLED) { + debugging('Downloading successful: '.$lang); + @unlink($CFG->dataroot.'/cache/languages'); + return true; + } + } + + return false; +} + ?> -- 2.39.5