]> git.mjollnir.org Git - moodle.git/commitdiff
Merged MDL-7351 from stable
authormoodler <moodler>
Mon, 6 Nov 2006 12:51:27 +0000 (12:51 +0000)
committermoodler <moodler>
Mon, 6 Nov 2006 12:51:27 +0000 (12:51 +0000)
admin/index.php
lib/adminlib.php

index de37e4aab1ce038e9bc9bd1007b37273979632eb..09fff39e4d0885208ab09d2673f58f33c5518fba 100644 (file)
             }
 
             if (empty($confirmupgrade)) {
+
+
                 print_header($strdatabasechecking, $stradministration, $strdatabasechecking,
                         "", "", false, "&nbsp;", "&nbsp;");
+
                 notice_yesno(get_string('upgradesure', 'admin', $a->newversion), 'index.php?confirmupgrade=yes', 'index.php');
                 exit;
 
                 $strdatabasesuccess  = get_string("databasesuccess");
                 print_header($strdatabasechecking, $stradministration, $strdatabasechecking,
                         "", $linktoscrolltoerrors, false, "&nbsp;", "&nbsp;");
+
             /// 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)
index 9a7cbebc91079ed7186c08507174a92c8fb57b44..473746363450e6e3e76d3104908850907aec1094 100644 (file)
@@ -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;
+}
+
 ?>