Skip to content

Commit

Permalink
Merged MDL-7351 from stable
Browse files Browse the repository at this point in the history
  • Loading branch information
moodler committed Nov 6, 2006
1 parent ae79dad commit d210e12
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
8 changes: 8 additions & 0 deletions admin/index.php
Expand Up @@ -229,19 +229,27 @@
}

if (empty($confirmupgrade)) {


print_header($strdatabasechecking, $stradministration, $strdatabasechecking,
"", "", false, " ", " ");

notice_yesno(get_string('upgradesure', 'admin', $a->newversion), 'index.php?confirmupgrade=yes', 'index.php');
exit;

} else {
$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)
Expand Down
35 changes: 35 additions & 0 deletions lib/adminlib.php
Expand Up @@ -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;
}

?>

0 comments on commit d210e12

Please sign in to comment.